! LIST_KEYS.TPU - List all defined keys ! ! Edit History ! ! Which When Who What ! ! X00-01 16-May-85 JLB Created ! X00-02 28-May-85 JLB Clean-up illegal key-name notation ! X00-03 19-Sep-85 JLB KEY is now a key-word ! ! The list keys command attempts to exhaustively look-up all the possible ! key names and lists those which have comments associated with them. ! In order to do this it uses internal knowledge of the structure of ! key names. It is not guaranteed to work from on release of TPU to ! another. It will even list the definitions of key names which can ! never be entered from the keyboard. ! ! The function is based on the following presumed keyname layout: ! ! +---+---+---+---+---+---+---+---+ ! | | | | | ! ! +---+---+ +-------+---+---+ ! ^ ^ ^ ^ ! | | | | ! | | | +---- Byte 0 - Low byte ! | | +------------ Byte 1 - Index ! | +---------------------------Nibble 6 - Type ! +-------------------------------Nibble 7 - Always = 4 ! ! There are 8 types: printing, keypad key, function key, and control key, ! and shifted (gold-key) versions of each. There are 256 possible keys of ! each type. For printing keys (not shifted printing keys) the low byte ! (byte 0) is equal to the index (byte 1). For all others the low byte ! is always zero. For all types byte 2 is always zero, and the top byte ! is always equal to 64 + the type. ! ! Clearly, some of these combinations can never actually occur (printing ! keys can't have an index less than 32, for instance). However, TPU ! allows these values to be passed to define_key. LIST KEYS will list ! these keys using a notation containing the index of the key in angle ! brackets. Thus a printing key with an index of 3 (CTRL/C regarded as ! a printing character!) is represented as "<3>" and a control key ! with an index of 65 ("A" viewed as a control key) is "<65>". Finally, ! an escape sequence with a value of 155 (representing the illegal ! escape sequence ESC/CSI) is listed as ESC/<155>. ! ! There is also the possibility of non-LK201 function keys. The highest ! legal index for a function key is 34 which coresponds to F20. A ! function key with an index of 50 would be listed as "CSI 50 ~" which ! is the escape sequence it sends.. ! ! LIST KEYS looks up all 256 keys of each type, according to the ! description and lists each one for which there is a comment stored. ! procedure eve_list_keys ! List all defined keys local key_type, key_index, the_key, key_comment; eve_buffer("LIST KEYS"); erase(current_buffer); copy_text('Key Function'); split_line; split_line; key_type := 0; loop exitif (key_type = 8); key_index := 0; loop exitif (key_index = 256); the_key := ((64+key_type) * 16777216) + (key_index * 256); if (key_type = 0) then the_key := the_key + key_index; endif; key_comment := lookup_key(the_key, comment); edit(key_comment, trim_leading, off); if (key_comment <> '') then copy_text(fao("!20AS !AS", user$key_name(the_key), key_comment)); split_line; endif; key_index := key_index + 1; endloop; key_type := key_type + 1; endloop; eve_top; endprocedure procedure eve_describe_key local the_key, description; message("press Key to Describe: "); the_key := read_key; description := lookup_key(the_key, COMMENT); if (description <> "") then message(fao("Key (!AS) is: !AS", user$key_name(the_key), description)); else MESSAGE(fao("Key (!AS) has no function...", user$key_name(the_key))); endif; endprocedure; procedure user$key_type ( the_key ) ! Get the type of a key local key_type; key_type := ((( the_key * 16 ) / 16 ) / 16777216 ); case key_type from 0 to 7 [0]: return printing; [1]: return keypad; [2]: return function; [3]: return control; [4]: return shift_printing; [5]: return shift_keypad; [6]: return shift_function; [7]: return shift_control; endcase; endprocedure !+ ! The key index will be on of the following values. ! printing or shift_printing -> the character ! control or shift_control -> the character ! keypad or shift_keypad -> the terminator from the escape sequence ! function or shift_Function -> the number generated by the function key ! ! procedure user$key_index ( the_key ) ! Get the index of a key local temp; return (the_key - ((the_key/65536) * 65536 )) / 256; endprocedure ! ! The following routine attempts to turn a key-name key-word into ! reasonable printable string. ! procedure user$key_name (the_key) ! Make key_name printable local key_type, key_index, is_shift; key_type := user$key_type(the_key); key_index := user$key_index(the_key); case key_type from printing to shift_control [shift_printing, shift_function, shift_keypad, shift_control]: is_shift := 'SHIFT/'; [printing, function, keypad, control]: is_shift := ''; endcase; case key_Type from printing to shift_control [printing, shift_printing]: if (key_index = 32) then return(is_shift+'SPACE'); endif; if (((key_index > 32) and (key_index < 127)) or (key_index >= 160)) then return(is_shift+ascii(key_index)); else return(is_shift+'<' + str(key_index) + '>'); endif; [control, shift_control]: if (key_index = 127) then return(is_shift+'DELETE'); endif; if (key_index < 32) then return(is_shift+'CTRL/' + ascii(key_index + 64)); else return(is_shift+'<' + str(key_index)+'>'); endif; [function, shift_function]: case key_index from 1 to 41 [1]: return(is_shift+'FIND'); [2]: return(is_shift+'INSERT HERE'); [3]: return(is_shift+'REMOVE'); [4]: return(is_shift+'SELECT'); [5]: return(is_shift+'PREV SCREEN'); [6]: return(is_shift+'NEXT SCREEN'); [17,18,19,20,21]: return(is_shift+'F' + str(key_index - 11)); [23,24,25,26]: return(is_shift+'F' + str(key_index - 12)); [28]: return(is_shift+'HELP'); [29]: return(is_shift+'DO'); [31,32,33,34]: return(is_shift+'F' + str(key_index - 14)); [35]: return(is_shift+'M1 DOWN'); [36]: return(is_shift+'M1 UP'); [37]: return(is_shift+'M2 DOWN'); [38]: return(is_shift+'M2 UP'); [39]: return(is_shift+'M3 DOWN'); [40]: return(is_shift+'M3 UP'); [41]: return(is_shift+'DRAG'); [inrange,outrange]: return(is_shift+'CSI ' + str(key_index) + ' ~'); endcase; [keypad, shift_keypad]: case key_index from 'P' to 'S' [inrange]: return(is_shift+'PF' + ascii(key_index-31)); endcase; case key_index from 'A' to 'D' ['A']: return(is_shift+'UP ARROW'); ['B']: return(is_shift+'DOWN ARROW'); ['C']: return(is_shift+'RIGHT ARROW'); ['D']: return(is_shift+'LEFT ARROW'); endcase; case key_index from 'l' to 'n' ['l']: return(is_shift+'KP COMMA'); ['m']: return(is_shift+'KP MINUS'); ['n']: return(is_shift+'KP PERIOD'); endcase; case key_index from 'p' to 'y' [inrange]: return(is_shift+'KP' + ascii(key_index-64)); endcase; if (key_index = 77) then return(is_shift+'ENTER'); endif; if ((key_index <= 32) or ((key_index >= 127) and (key_index < 160))) then return(is_shift+'ESC/<' + str(key_index)+'>'); endif; return(is_shift+'ESC/' + ascii(key_index)); [outrange]: return ('Unknown key type'); endcase; endprocedure