Coding a Mac OS X terminal emulator? - cocoa

I'd like to create a terminal emulator for Mac OS X. The problem is: I have no idea where to start. Can I just use a whole bunch of NSTasks? Or do I have to read through tons of source code for programs like xterm, urxvt, etc?
I don't want a lot of customizability (= no config file parsing), nor complex features, and I'm only gonna use bash as the shell.
Thanks for answers!
-Mike

I'd check out Visor: http://code.google.com/p/blacktree-visor/ It's a Quake-style terminal that slides up and down from the edge of the screen.
iTerm (http://iterm.sourceforge.net/) would also be a good project to look at (perhaps even better than Visor).

As Dave said, iTerm is probably the best place to start.
As for others, xterm/urxvt might not be the easiest thing to read for this, since they'll be mapping between VT100 and Xlib, which is kind of low-level. An implementation that might be easier to read is VTE terminal, which GNOME uses, since it'll be mapping between VT100 and GLib/GTK+, which is probably a lot closer to what Mac OS X provides.
Good luck!

Related

What's the difference between iTerm2 and Terminal on Mac?

I have seen lots of programmers use iTerm2 instead the default Terminal on Mac. But, what's the difference between these two shell terminals on earth? For me, they are the same, I didn't see any difference except the different colors.
As of Lion's release, a lot of the features iTerm2 boasted for a while now are finally matched in Terminal. plus a more consistent full screen (Lion) support.
Check out this apple stackexchange question
https://apple.stackexchange.com/questions/25143/what-is-the-difference-between-iterm2-and-terminal
http://www.iterm2.com/#/section/features

Simple Ruby Editor?

This editor isn't intended for me. It's intended for teaching someone else Ruby. I largely use Emacs when writing Ruby. Does anyone know of an editor that
indents the current line correctly when you press tab,
can indent the whole file correctly (keyboard shortcut would be nice),
has syntax highlighting for Ruby,
other than that works kind of like Windows Notepad (maybe with a toolbar of icons),
has a built in terminal (not absolutely required),
has multiple editor tabs,
and works on Windows, Linux, or both?
Or anything somewhat close?
Edit:
I'm also going to add that I'd like to be available for free (legally for an indefinite period of time). Open source wouldn't hurt.
Check Notepad++
I don't think that jEdit has a built-in terminal, but I believe it does everything else you need. It's implemented in Java, so it should run on any platform for which a JVM exists, including Windows and Linux.
Since it's about teaching ruby RedCar and Diakonos are good choices. They have most of the features you mention and as a bonus both are written in Ruby.
If you are not a die hard fan of emacs, then there's always vim and its plugins for any programming language. Here's one for Ruby: rails.vim : Ruby on Rails: easy file navigation, enhanced syntax highlighting, and more
If you are new to vim, this cheat sheet should help you: vim graphical cheat sheet
I like gedit - it doesn't have a terminal, but should work fine for the other requirements. It can run on Windows with Cygwin.
For a full-blown IDE, Aptana Studio is great. It meets your requirements.
If your main goal is to teach then you could try using Hackety Hack. It is somewhat weak at times, but I found it fun and simple to use, but then again I already knew ruby pretty well.
For a beginner being able to run the programs easily is very important so you want something where irb and ruby can be run very simply. Aptana seems to be a pretty good IDE for this sort of thing, but I have never used it myself aside for web development.
Aside from those two I suggest Notepad++... Also the free KomodoEdit might be worth a look. Personally I say teach the other person emacs, but then again shrug

something similar to Emacs shell?

I'm looking for something similar to Emacs shell.
I want to be able to select text easily in my terminal, be able to manipulate the output.
Unfortunately, emacs is not always an option. I can't figure out how to make a few things (e.g autocompletion) work the way it does in gnome-terminal and it is a bit of a pain on remote system.
I would rather not spend the time fixing/configuring Emacs unless there is a cool piece of software out there doing something similar to gnome-terminal + let's me manipulate the output without touching the bloody mouse.
Thanks for your help,
-hbt
I'm not sure I completely understand the question, but if you're looking for terminal emulation inside of Emacs, there are at least four options bundled with Emacs 22+ that offer varying levels of xterm-like capability:
term
ansi-term
shell
eshell
eshell, IMO, is the most departed from the tradtional "xterm" experience, but also offers the most buffer-like experience, and it is cross-platform, which is a huge win.
I think shell might be the sweet spot for you if you're looking for term-like behavior, while retaining the editing capabilities.
Finally, term and ansi-term are very term-like, and will behave almost exactly like a xterm/konsole/gnome-shell session.
One other note: if you want scrollback access, copying, pasting, etc. and you don't have Emacs available, I highly recommend learning and using GNU Screen.
You should try the Emacs terminal emulator term(or its colored version ansi-term). There are other terminal emulators for Emacs around, but this is the most popular(and the only one bundled with the default installation).
Looks like you want to look into readline on bash (or if available on your favourite shell). A quick google gives a few links here (including a cheatsheet).
I was also looking for some kind of shell like emacs, with support to some feature like emacs buffers for example. That would be great.
I just found this one: Terminator
Have a look:
http://www.makeuseof.com/tag/5-applications-to-change-the-way-you-work-with-linux-terminal/

How can a Windows programmer be sufficiently productive on Mac OS X?

I've been using MacBook Pro for a few months at home, and I was wondering if there's a good book or guide that can help me be a better programmer on Mac. Maybe Mac-equivalent of Beginning Linux Programming. Note I am not looking for resource on how to program Mac application, instead I am looking for more general guide of using Mac for general development environment.
As a background, I am a Windows programmer by day. I've also done some Linux and BSD over the years, esp in school, like socket programming, graphics, make install type stuff. At home, I'll be doing Java, Scala, PHP, etc. on Mac.
So far, I've been using Eclipse, QuickSilver, and TextMate. VMWare Fusion, XCode and NetBeans are set up, but I don't use them. A DVI KVM switch is hooked up to real keyboard, trackball, and monitor. Recently stayed up till late fighting with MacPorts, and figured out I needed x86_64. The most struggle I had was configuring PHP. I don't know why they don't ship with MySQL and GD library. I eventually figured it out Googling around, and built the extensions from source. I have a feeling that I didn't get the memo and didn't read some basic guide on how to become a programmer on Mac, like how the whole architecture works. How can a Windows programmer be sufficiently productive on Mac OS X?
Related: Setting up a Mac for programmers
Edit: The specific type of application I want to develop doesn't really matter in my opinion. It could be Java, Scala, PHP as I mentioned or Cocoa, C++, or whatever.
What I am looking for is specific book, resource, advice on how to be more effective programmer on Mac, preferably something beyond "install XYZ".
Having converted from Windows to Mac OS X about five years ago, I often find myself thinking the same thing. I just cannot be productive on Windows (as much, I can be productive) as I can on Mac OS X.
To be honest, there are lots of small differences between Mac OS X and Windows. I find the biggest reason for people thinking like this (at it normally only applies to gamers and developers) is that they are trying to use the Mac like a Windows machine. You need to learn to accept that you have to use the command key, not the control key, etc.
It sounds like you are using a Mac because you have to as opposed to because you want to. It really is a much better platform than Windows once you get used to it.
I think a lot of Windows programmers come to Mac and don't try to learn it properly because they are complacent thinking they know it all because they have "used Windows all their life". I guess once you discover Spotlight, Expose, Mac OS X Keyboard shortcuts, etc. You will find your self being MUCH more productive that you ever were on Windows.... and its actually a fun OS to use.
Checkout some of the best Mac applications you can get here and here. You can also do a search for "top 100 mac apps".
Also, I noticed you were trying to setup some kind of web server directly into Mac OS X. It does ship with one, but if you are going to add MySQL and some other extensions I wouldn't go the MacPorts route. Get VMWare Fusion or VirtualBox (open source) and run the server in a VM. Much cleaner. I have a subversion/trac FreeBSD VM that handles my local version control.
I would like to add that if you don't presently use Xcode, you should definitely learn it and use it asap. It's a much nicer IDE to use than Visual Studio and it will make your life much easier.
Don't forget you have probably spent years on Windows help sites, you're going to a small degree need to do that with the Mac. Whenever you have a problem about using the Mac, ask a question on ServerFault. We are all more than eager to help you out.
Good luck.
You seem to want an overview of how Mac OS X works at a system level, more than recomenations about tools and so forth. If that's the case, I'd start with the (very basic) Mac OS X System Architecture Guide from Apple, then move on to Getting Started with Mac OS X, which should give you enough of an overview to get started.
It's not clear from your question what you intend to actually make with your programming time, but if you decide to persue Cocoa/OS X development, I recommend Cocoa Programming for Mac OS X by Aaron Hillegass.
I have a similar situation like yours. I use Windows for development and about a year back purchased a MBP for home (as I shifted to an office). I find it really difficult to get any real work done on my MBP. Somehow am used to the Windows environment with dual screens. But let that not stop you. A couple of software which I suggest you should get are:
Transmit - Good ftp client
MAMP - Runs a webserver nearly out-of-the-box. Good for basic development
Quicksilver - Helps in quick finding of applications
Spaces along with gestures (Configure your gestures to move from one screen to another, I use three fingers glide. its amazing)
Entourage - for email
Terminal - for ssh (putty alternative) (included)
Dreamweaver/BBedit/Textmate (all pretty decent. but i love editplus on windows. not a fan of IDE)
I assume your question is not about learning COCOA and more about being more effective using a MAC. Well, the above tools might help you.
Unfortunately, your question isn't very clear as to what you really want.
If you're looking to write anything cross-platform, it can be very helpful to have a virtual machine for testing. When in Linux, I've always used VirtualBox, and it works on OS X as well.
Also, as for choice of IDE, a lot of it comes down to your preference. Eclipse is nice because there's a plugin for almost everything for it. My experience with TextMate is limited, but my local Ruby Users Group swears by it.
Finally, a suggestion for not just Mac, but any platform really. Learn your hotkeys, set up new ones for things you commonly do, and use them frequently. Not having to take your hands off the keyboard to click a mouse through a few menus can really improve productivity. It may take a little time for them to grow on you, but once they become second nature, you'll wonder how you lived without them.
Basically, you can apply all your Linux/UNIX knowledge that you already have to the Mac. If you use the Terminal (/Applications/Utilities/Terminal.app) you can run all your favorite UNIX commands. Mac has a special command called "open" which is equivalent to the Windows "start" command (used to launch programs and files). You can also use "open -a" to open an application by name (e.g. "open -a Finder").
You might want to reconsider Xcode. Xcode opens more quickly than Eclipse and provides very good syntax highlighting, brace matching, block indenting, and more. Xcode doesn't have to be used as an IDE, you can also use it as a code editor, just like you are currently using TextMate.
For code editing (and everything else), try Aquamacs (http://www.aquamacs.org). It's a Cocoa-native build of Emacs, and it's brilliant for any programming task.

What are the preferred versions of Vim and Emacs on Mac OS X? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
For those of us that like to use the graphical version of Vim or Emacs, instead of the console version, which version do you recommend?
For Vim, there's Mac OS X Vim, MacVim, Vim-Cocoa.
For Emacs, CarbonEmacs, XEmacs, and Aquamacs.
Are there more? Which of these are ready for prime-time? If it's a tough call, what are the trade-offs? Are all of these still being maintained?
No discussion of Vim versus Emacs, if you don't mind, or comparisons with other editors.
MacVim works well and certainly looks more mature than Vim-Cocoa, moreover there is a Cocoa plugin architecture in the pipeline for MacVim (and someone is already working on a TextMate style file browser tray plugin which is a huge ++ IMHO).
There was also a Carbon version of Vim, but this didn't offer a great deal over the Terminal version. i.e. only allowed one window open, not very OSX in appearance...
Aquamacs is very usable and looks pretty good. Supports both traditional Mac OS style keyboard shortcuts (command-O, command-S) and the Control/Meta shortcuts for those raised on traditional Emacs. It is definitely more Mac-like than Carbon Emacs. It seems stable and fast, but I am not an Emacs guru so I don't stress it all that much when I use it. I can't speak to the extensiveness of the included elisp packages, either.
Someone syncs Carbon Emacs with the upstream tree quarterly I think. Aquamacs has a more irregular schedule, but it's seen some pretty major updates over the last year.
GNU Emacs for OSX can be found at emacsformacosx.com. In addition to the latest stable release, there are also pre-release test builds and nightly builds, and Atom feeds are provided for tracking all three release types.
I've tried Aquamacs and it's very usable and looks pretty good. Supports both traditional Mac OS style keyboard shortcuts (command-O, command-S) and the Control/Meta shortcuts for those raised on traditional Emacs. It is definitely more Mac-like than Carbon Emacs. It seems stable and fast, but I am not an Emacs guru so I don't stress it all that much when I use it. I can't speak to the extensiveness of the included ellipse packages, either.
Someone syncs Carbon Emacs with the upstream tree quarterly I think. Aquamacs has a more irregular schedule, but it's seen some pretty major updates over the last year.
I just download the Emacs source from the GNU site and build it myself. I don't like too many Mac-specific features, because I want Emacs behavior to be consistent on all the platforms I use.
I like the Nextstep-derived Emacs.app formerly at http://emacs-app.sourceforge.net/ now integrated in Emacs-23 CVS (as of August 2008).
Emacs.app feels more zippy than Aquamacs to me but its just bare CVS-Emacs and doesn't come with the same amount of stuff (you have to install your own AucTeX etc.).
Personally, I've been using fink to install xemacs. It requires X but I've been
using xemacs for so long that I need what it has.
Additionally, I have installed gnu emacs. It's nice because it is a completely
integrated mac os x application with a dock icon and everything. I find it useful
when dragging a file on top of the gnu emacs icon to open it.
Last, I should mention that mac os x uses the emacs keystrokes all over the place.
stuff like ^A for beginning of text, ^E for end of text, ^N next line, ^P previous
line, etc... These work in most text boxes throughout the OS.
I'm using MacVim on Mac OS X. It's very, very nice.
I get all my unixish/GNU support using Fink (which provides Debian-like package control) with the emacs22-carbon package which means I also get a clickable application. It does everything I expect it to do, and automagically starts using emacs extensions loaded with fink.
Good times.
Of the emacsen for Mac OS X, I have to say that after the console version of 22, CarbonEmacs is the most usable. Aquamacs just does too many non-standard, read unexpected, things with configuration. Aquamacs questions generally aren't answered in any sort of timely manner in #emacs on freenode for whatever that is worth. It seem to be held in disdain simply because it does such a terrible job of handling standard configuration options in .emacs.
Some time ago, I was searching for a text editor for my new Mac. Since this was some months ago, some points might have been corrected in the meantime.
I feel that Aquamacs is by far the best OSX-Emacs. However, it feels a bit too Mac-like in some areas. For example, it rather uses several windows instead of several buffers and the coloring schemes are not "normal" Emacs-style.
If you look for a more basic set, Carbon Emacs might do it as well, though you might want to add some additional packages to add PHP support or AucTeX.
Emacs.app feels broken in my opinion. It not even opens files using drag and drop.
I use the CarbonEmacs version on the Macports program. It installs all the dependencies with just one line:
sudo port install emacs
For anyone interested in Macports (www.macports.org)
I love CarbonEmacs because it sticks very close to the standard GNU Emacs distribution, while still fitting in nicely with the Mac desktop. To me, it "felt" like Emacs on my Ubuntu desktop even if it looked like a Mac application.
Emacs 22 has worked pretty well for me.
I prefer Vim built from the Subversion repository. I run it in the console where I don't need to use the mouse while editing.

Resources