Gets the logical value of the key hit#include <smkeys.h>int sm_getkey(void);
sm_getkeygets and interprets keyboard input and returns its logical value. Panther returns normal characters unchanged; it interprets logical keys according to the current key translation file.
sm_getkeyis called by
sm_inputand is not usually called explicitly by the application program.
Logical keys include XMIT, EXIT, HELP, arrows, data modification keys like INS, user function keys PF1 - PF24, shifted function keys SPF1 - SPF24, and others. Defined values for all are in
smkeys.h. Some logical keys like LP and REFR are processed locally in
sm_getkeyand are not returned to the caller.
sm_getkeyto retrieve logical key values previously pushed back on the input stream by sm_ungetkey. Because all Panther input routines call
sm_getkey, you can use
sm_ungetkeyto generate any input sequence automatically.
sm_getkeyreads a key from the keyboard, it flushes the display first so the user sees a fully updated display before typing on. This is not the case for keys pushed back by sm_ungetkey; because input comes from the program, it is responsible for updating the display itself.
sm_getkeycan call a number of user-installed functions. For information on installing functions, refer to "Installing Functions" in Application Development Guide.
Like other Panther input functions,
sm_getkeychecks for externally established abort conditions on each iteration. If such a condition exists,
sm_getkeyreturns the ABORT key and returns to its caller immediately. Refer to sm_isabort.
Note that Panther control strings are not executed within this function, but at a higher level in Panther's runtime system—that is, by functions that call
The following outline shows how Panther processes
sm_getkey. This presentation omits key translation for the sake of clarity; for a description of that algorithm, refer to Chapter 6, "Key Translation File," in Configuration Guide.
- Step 1:
- If an abort condition exists, return the ABORT key.
- If playback is active and a key is available, take it directly to Step 2; otherwise read and translate input from the keyboard. When the keyboard is read and remains inactive, Panther calls the asynchronous functions, if any are installed.
- Step 2:
- Pass the key to the keychange function. If that function specifies to discard the key, repeat step 1; otherwise, if an abort condition exists, return the ABORT key.
- Step 3:
int query (text)
switch (key = sm_getkey())
sm_femsg(0, "%Mu So it's 'no'");