On Jun 10, 2011, at 9:56 PM, William Squires wrote: > 1st question: > In regular C, you have the <stdio.h> functions for reading/writing to stdio; > printf(), scanf(), etc... > In C++, you have cin/cout and the overridden '>>' and '<<' operators. > What does ObjC have (besides NSLog() anyway) that C/C++ doesn't? > I'm guessing... zilch. You have to use the standard C libraries, right? Or > is there an OO way of reading/writing to stdio (and stderr) from a console > app? Or use ObjC++...
NSFileHandle has the class methods: • + fileHandleWithStandardError • + fileHandleWithStandardInput • + fileHandleWithStandardOutput • + fileHandleWithNullDevice However, NSFileHandle does not have many of the line-oriented or format-oriented mechanisms provided by the C or C++ standard libraries. So, it is often more convenient to use those. Objective-C was built on top of C precisely so that you have access to C language and library features, so there's nothing wrong with using them. > 2nd question: > Can a console app control the text 'cursor' in Terminal.app's window solely > through stdio? (i.e. are there control codes that clear the screen, locate > the cursor at some x,y location, set the text color/brightness (I know the > man page reader can, at the very least, change the text brightness), position > the cursor at the beginning/end of a line, etc...) Or do apps like vim, > emacs, pico, etc... use custom machine-language calls to the darwin core to > do this? > If it helps, under Terminal.app's Prefs | Text, I have "Use bold fonts", > "Allow blinking text" and "Display ANSI colors" all checked, and under Prefs > | Window I have window size set for 80x24 with unlimited scrollback, and > under Prefs | Advanced, I have "Declare terminal as:" set to xterm-color, > "Paste newlines as carriage returns" and "Scroll to bottom on input" checked. You're looking for the "curses" library (or, to be more specific, "ncurses" nowadays). http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ncurses.3x.html Regards, Ken _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com