Re: [Hla-stdlib-talk] non-buffered 'stdin.getc' function
Brought to you by:
evenbit
From: <rh...@cs...> - 2008-02-17 05:07:16
|
> Just coded this real quick and haven't tested it, but this is close to > what a 'non-buffered' stdin.getc() function (for Windows) would look like: > > unit StdInput; > #include( "../include/stdinunit.hhf" ) > > procedure nb_getc; > @nodisplay; > > var > hStdIn :dword; > curMode :dword; > newMode :dword; > > begin nb_getc; > > w.GetStdHandle( STD_INPUT_HANDLE ); > mov( eax, hStdIn ); > > w.GetConsoleMode( hStdIn, curMode ); > mov( curMode, eax ); > and( #$F9, al ); > mov( eax, newMode ); > w.SetConsoleMode( hStdIn, newMode ); > > w.ReadFile( hStdIn, &InputBuffer, 1, InputIndex, 0 ); > > w.SetConsoleMode( hStdIn, curMode ); > mov( InputBuffer[ 0 ], al ); > ret(); > > end nb_getc; > > Nathan. > > end StdInput; > > Windows has always been the easy one. The real question is "can we get a version that works for Linux and FreeBSD? (and, ultimately, MacOSX, too). I'd love to have this function in the stdlib, but to date I've not seen a decent version that always works under the *NIX OSes. The moment I see one (and they *can* be written, I just have looked into it yet), this is definitely a routine to add to the stdlib. hLater, Randy Hyde |