[Info-vax] C Examples of Calling SMG$ Routines?
David Jones
osuvman50 at gmail.com
Sun Jun 27 18:14:16 EDT 2021
On Sunday, June 27, 2021 at 3:07:48 PM UTC-4, Zane H. Healy wrote:
> Stephen Hoffman <seao... at hoffmanlabs.invalid> wrote:
> > Alas, I don't see a C example of smg$read_keystroke anywhere, and the
> > eight-cubed source code example coverage doesn't include SMG.
> Thank you for the detailed writeup and list of links! Keith Halewood got me
> the basic answer I needed, and it looks like your examples should take me
> much further. The last link, with the example programs look especially
> useful!
I've found in practice you need to tread carefully when trying to use SMG$READ_KEYSTROKE
as a drop in replacement for another OS's 'getch' type functions. By 'keystroke', it means it's
going to try to recognize escape sequences from keyboard function keys and such (e.g.
SMG$K_TRM_UP for the up arrow).
My linenoise() library emulation I use for the SQLite port calls SMG$READ_KEYSTROKE in
some situations (input lines > terminal width), but it's not a simple example. To do cursor
navigation, I have to get the starting screen position, but if there something in the typeahead
buffer is confuses SMG, so I precede that call with a flush of the typeahead buffer, saving
the contents. The read_keypress() returns the saved typeahead characters before it starts
calling SMG$READ_KEYSTROKE.
More information about the Info-vax
mailing list