miller@cs.rochester.edu (03/01/91)
Hi, I'm trying to get a couple of UNIX-type programs up under the MPW shell. Nothing *too* bizzare, but I can't seem to get much working... in particular I need to do raw i/o to the console, and send control information as well (e.g. clear to end of line, move cursor, etc.). Similar to the CONSOLE library in THINK C, or the CURSES package in unix. But I'm stuck. Not only isn't there any console control defined in the C or MPW manuals (if there is, please point me to it!), but something simple like main (){ setbuf(stdin, NULL); setbuf(stdout, NULL); while (getchar() != NULL){ putchar('x'); } } compiled and linked to be a tool, I'd expect on running it that every char I type would cause an x to be printed, but actually the input is echoed and nothing is printed until I do command-ret. when I get a single 'x'. Is there any way to get unbuffered, no echo, no editing input from the worksheet? (or stdin whatever it turns out to be?) Is there any way to control the worksheet from a tool, e.g. clearing the screen, getting the size of the screen, etc. I'd like to get this tool up (for personal use) asap, rather than have to learn how to do everything via mac windows and a large port... Thanks for any help, (probably a mailed response would be best; I can summarize) <<I'm trying to do this in MPW because I prefer working in it than THINK, but if worst comes to worst, I suppose I can get the tool up over there>>. Regards, Brad Miller miller@cs.rochester.edu
ksand@Apple.COM (Kent Sandvik) (03/02/91)
In article <1991Mar1.030623.9398@cs.rochester.edu> miller@cs.rochester.edu writes: >Hi, > >I'm trying to get a couple of UNIX-type programs up under the MPW >shell. Nothing *too* bizzare, but I can't seem to get much working... >in particular I need to do raw i/o to the console, and send control >information as well (e.g. clear to end of line, move cursor, etc.). >Similar to the CONSOLE library in THINK C, or the CURSES package in >unix. > >But I'm stuck. Not only isn't there any console control defined in >the C or MPW manuals (if there is, please point me to it!), but something >simple like > >main (){ > setbuf(stdin, NULL); > setbuf(stdout, NULL); > while (getchar() != NULL){ > putchar('x'); > } >} > >compiled and linked to be a tool, I'd expect on running it that every >char I type would cause an x to be printed, but actually the input is echoed >and nothing is printed until I do command-ret. when I get a single 'x'. The standard I/O is buffered by default, so you don't get anything before you do a fflush (e.g. fflush(stdio); ). MPW 3.2 will contain a library of standard I/O routines which makes it possible to fast hack simple standalone binaries (not MPW tools) which use standard I/O procedures. It's called SIOW. Last time I checked the beta releases it even had default code for printing and clipboard support. As for a ported curses library to MPW, I don't know of any. I do know that the curses libraries have been ported to the Think-C environment, as part of the nethack port. John V{tte or someone else should know the story behind that one. Kent 'Skonk' Sandvik -- Kent Sandvik, Apple Computer Inc, Developer Technical Support NET:ksand@apple.com, AppleLink: KSAND DISCLAIMER: Private mumbo-jumbo Zippy++ says: "C++ was given to mankind, so that we might learn patience"
Louis.Pecora@f421.n109.z1.fidonet.org (Louis Pecora) (03/05/91)
The ret key does not enter data, as in the usual console I/O. The enter key or cmd-ret does this. Nice to here about the new I/O support. It took them long enough. I always wonder why this simple support was never there. It's not hard to do and it adds another market (UNIX or other console users who want to develop on the Mac and port to other platforms.) --- Lou Pecora -- Louis Pecora, Louis.Pecora@f421.n109.z1.fidonet.org via The Black Cat's Shack's FidoNet<->Usenet Gateway blkcat.fidonet.org and Fidonet 1:109/401
d88-jwa@byse.nada.kth.se (Jon W{tte) (03/05/91)
>>Similar to the CONSOLE library in THINK C, or the CURSES package in >>unix. In article <49788@apple.Apple.COM> ksand@Apple.COM (Kent Sandvik) writes: >As for a ported curses library to MPW, I don't know of any. I do know >that the curses libraries have been ported to the Think-C environment, >as part of the nethack port. John V{tte or someone else should know >the story behind that one. Hi, Kent ! No, curses hasn't been ported to the mac. Johnny Lee (who did the basic nethack port and still is very much in the development team) did a port of (emulation of) Termcap for an ANSI terminal. The source is available at appl.com (or is that just the binary ?) or in the comp.sources.games archives. h+@nada.kth.se Jon W{tte "The IM-IV file manager chapter documents zillions of calls, all of which seem to do almost the same thing and none of which seem to do what I want them to do." -- Juri Munkki in comp.sys.mac.programmer