DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
ETI menus

Defining the key virtualization correspondence

To illustrate a key virtualization routine, consider ``Sample routine that translates keys into menu requests'', which shows the key virtualization routine get_request. Nearly all the values it returns are the ETI menu requests to be discussed in the sections below.

   	/* define application commands */
   

#define QUIT (MAX_COMMAND + 1)

/* Note that ^X represents the character control-X.

^Q - end menu processing

^N - move to next item ^P - move to previous item home key - move to first item home down - move to last item

left arrow - move left to item right arrow - move right to item down arrow - move down to item up arrow - move up to item

^U - scroll up a line ^D - scroll down a line ^B - scroll up a page ^F - scroll down a page

^X - clear pattern buffer ^H <BS> - delete character from pattern buffer ^A - request next pattern match ^Z - request previous pattern match

^T - toggle item */

static int get_request (w) /* virtual key mapping */ WINDOW * w; { int c = wgetch (w); /* read a character */

switch (c) { case 0x11: /* ^Q */ return QUIT;

case 0x0e: /* ^N */ return REQ_NEXT_ITEM; case 0x10: /* ^P */ return REQ_PREV_ITEM; case KEY_HOME: return REQ_FIRST_ITEM; case KEY_LL: return REQ_LAST_ITEM;

case KEY_LEFT: return REQ_LEFT_ITEM; case KEY_RIGHT: return REQ_RIGHT_ITEM; case KEY_UP: return REQ_UP_ITEM; case KEY_DOWN: return REQ_DOWN_ITEM;

case 0x15: /* ^U */ return REQ_SCR_ULINE; case 0x04: /* ^D */ return REQ_SCR_DLINE; case 0x06: /* ^F */ return REQ_SCR_DPAGE; case 0x02: /* ^B */ return REQ_SCR_UPAGE;

case 0x18: /* ^X */ return REQ_CLEAR_PATTERN; case 0x08: /* ^H */ return REQ_BACK_PATTERN; case 0x01: /* ^A */ return REQ_NEXT_MATCH; case 0x1a: /* ^Z */ return REQ_PREV_MATCH;

case 0x14: /* ^T */ return REQ_TOGGLE_ITEM; } return c; }

Sample routine that translates keys into menu requests

Note that because wgetch here automatically does a refresh before reading a character, you can omit explicit calls to wrefresh in applications that do character input.


Next topic: ETI menu requests
Previous topic: Menu driver processing

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004