1 _________________________________________________________________ 2/ \ 3| yaze.ktt | 4| | 5| This key translation table was generated from sample.ktt by | 6| stripping all the experimental stuff from the end of that file. | 7| | 8| This file contains only about 30 active lines; the rest are | 9| comments which could be removed. There is no real benefit in | 10| doing so because the plethora of comments has no effect on | 11| performance. | 12\_________________________________________________________________/ 13 14;---------------------------------------------------------------------------- 15; 16; Notes on keyboard translation 17; ----------------------------- 18; 19; Modern keyboards typically generate scan codes which are interpreted 20; by an operating system and translated into something more traditional. 21; 22; In the environments which support yaze-ag, the operating system 23; translates the scan codes for keys such as Home, Page Up, Insert 24; and the arrow keys into multi-byte sequences which are not undersood 25; by CP/M. 26; 27; The primary purpose of the keyboard translation module in yaze-ag is 28; to apply a secondary translation, converting the multi-byte sequences 29; into something more useful to CP/M and its applications. 30; 31; However there is a secondary purpose which is almost as important as 32; the first, namely to prevent an untranslated multi-byte sequence from 33; being passed to CP/M in the first place. For example, on the 64-bit 34; ubuntu on which I am writing these notes, pressing the up arrow key 35; generates <esc>[A and F12 yields <esc>[24~ either of which could 36; make a mess of a CP/M text editor. 37; 38; The keyboard translation facility introduced in yaze-ag 2.3 allows 39; a user to specify a set of key translations and to pass just those 40; translated sequences to CP/M. 41; 42; In the absence of a defined translation, yaze-ag 2.3 still works as 43; always, except that no multi-byte sequences will get through. 44; 45; You may treat this document as a sample keyboard translation. Make 46; a copy called yaze.ktt and edit it to contain just the key defin- 47; itions that are useful to you. 48; 49;---------------------------------------------------------------------------- 50; 51; Format of the key translation file (yaze.ktt) 52; --------------------------------------------- 53; 54; Any line which does not start with an alphabetic character is considered 55; to be a comment. Leading and trailing spaces are ignored. 56; 57; The general format is: 58; 59; <key_description> = <character_sequence> 60; 61; When the key described on the left is pressed, the sequence of characters 62; listed on the right is sent to CP/M. 63; 64; Key description 65; --------------- 66; 67; The key description comprises a single character or a key name which 68; serves to identify the key. This key descriptor may be accompanied by 69; zero or more modifiers (control, alt, shift). The order is not relevant 70; and for key names case is ignored so that 71; 72; Ctrl Shift PageUp 73; 74; is the same as 75; 76; shift pgUp CTL 77; 78; Also, as seen in the foregoing example, some keys and modifiers have 79; multiple spellings. 80; 81; When using a single character key descriptor, case is preserved so that 82; 83; Alt e and Alt E 84; 85; are different, just as e and E are different. 86; 87; Note that the = character cannot be used as a single character key 88; descriptor. Althougy you can say 89; Alt / = ¨something¨ 90; you cannot say: 91; Alt = = "something" 92; but there is a way to express that via a key name: 93; Alt eq = "something" 94; or 95; alt equals = ¨something¨ 96; (eq and equals are synonyms). 97; 98; Keyboards other than US English can generate characters which do not fall 99; into the range 0x00 to 0x7F. In typical yaze-ag environments those keys 100; yield UTF-8 sequences. These are quite different from the ESC prefix 101; sequences for function keys and cursor keys but the keyboard translator 102; recognises UTF-8 sequences and converts them to the corresponding Unicode. 103; So to translate a non-ASCII character to something usable in CP/M, just 104; give the Unicode description 105; U+nnnn 106; where nnnn is the code point in hexadecimal notation. (It doesn't have to 107; be four digits long.) Shift codes are meaningless in a Unicode context and 108; they will be ignored. Examples: 109; 110; 1. u+20ac = "~" 111; 2. U+E9 = 02 112; 3. u+3a0 = "pi" 113; 4. ctrl U+03A0 = "pi" 114; 115; 1 translates a Euro symbol to a tilde. 116; 2 translates a lower case e with an acute accent to a ^B 117; 3 translates the upper case pi character to a string "pi" 118; 4 is the same as 3. The "ctrl" is ignored. 119; 120; Character sequences 121; ------------------ 122; 123; The character sequence sent to CP/M can be a string in "quote" 124; marks, a control character name, a two-digit hexadecimal number 125; or any combination thereof. Strings are sent as coded. Control 126; character names and hexadecimal numbers are not case-sensitive. 127; 128; F12 = "3dir" cr 129; 130; will send all five characters to CP/M when F12 is pressed. 131; 132; Further notes 133; ------------- 134; 135; Certain keys and combinations of keys may be intercepted by the host 136; operating system and not even passed into the translation engine. (SysRq 137; and PrtSc are two examples.) 138; 139; Some keyboard configurations distinguish between left and right Alt keys. 140; This may mean that one of the Alt keys does not work the way you expect. 141; It is probably not worth the trouble to try making the distinction in 142; this system, Just use the one that works. 143; 144; If your CP/M session locks up it is most likely because some program is in 145; a tight loop or (CP/M) memory has been scrambled. Under such conditions it 146; is useful to be able to interrupt CP/M no matter what it is doing. 147; 148; Given that you cannot use the SysRq key to send anything meaningful to 149; CP/M (because as mentioned above, SysReq is never seen by yaze-ag) choose a 150; different key to interrupt CP/M at any time. Pressing this key (or com- 151; bination) will exit to the "sys" monitor. 152 153; Examples might be: 154; ctl alt bs 155; ctl alt \ 156; but anything you fancy that shows up with the keytest program will be 157; satisfactory. 158; 159;----------------------------------------------------------------------- 160; 161; 00 NUL 01 SOH 02 STX 03 ETX 04 EOT 05 ENQ 06 ACK 07 BEL 162; ^@ ^A ^B ^C ^D ^E ^F ^G 163; 164; 08 BS 09 HT 0A LF 0B VT 0C FF 0D CR 0E SO 0F SI 165; ^H ^I ^J ^K ^L ^M ^N ^O 166; 167; 10 DLE 11 DC1 12 DC2 13 DC3 14 DC4 15 NAK 16 SYN 17 ETB 168; ^P ^Q ^R ^S ^T ^U ^V ^W 169; 170; 18 CAN 19 EM 1A SUB 1B ESC 1C FS 1D GS 1E RS 1F US 171; ^X ^Y ^Z ^[ ^\ ^] ^^ ^_ 172; 173; 7F DEL FF SRQ 174; 175;----------------------------------------------------------------------- 176; 177; A minimal set of key translations suitable for CP/M+ command editing 178; and basic WordStar use. 179; 180; Word processors and editors do their own keyboard input handling but 181; the CCP is just another application program (albeit a rather special 182; and important one) which gets input a line at a time calling BDOS 183; function 10. To any program which does line input via bdos(10) ZPM3 184; presents a history of such inputs to the user for possible recall and 185; editing. To the user entering commands to the CCP this means a history 186; of the past several commands. 187; 188; Unfortunately there are a few fundamental incompatibilities between 189; bdos(10) and the WordStar class of editors. There is a modified ZPM3 190; available which corrects these incompatibilities and this sample key 191; translation file assumes that the modified ZPM3 is in use. ZPM3 is 192; just Simeon Cran's BDOS clone; it is not sacrosanct and there is no 193; reason to refrain from fixing it. 194; 195;----------------------------------------------------------------------- 196; 197; In the descriptions which follow, WS means WordStar or similar editor 198; and CCP refers to any program which uses bdos(10) for line input. 199; Of course the CCP itself is one such program. 200; 201;----------------------------------------------------------------------- 202 203; Arrow keys 204; ---------- 205 206; Up arrow key is mapped to ^E (05 ENQ) 207; WS: Move cursor up one line. 208; CCP: Returns the previously entered line. Each successive Up keypress 209; steps one line further back in the history. 210Up = ^E 211 212; Down arrow is mapped to ^X (18 CAN) 213; WS: Move cursor down one line unless at end of file 214: CCP: Return the next line in the history unless already at the most 215; recent line. 216Down = ^X 217 218; Left arrow is mapped to ^S (13 DC3) 219; WS: Move cursor one character to the left. If at the beginning of a 220; line then wrap backwards to the end of the previous line. 221: CCP: Move cursor one character left unless at the beginning of the line. 222Left = ^S 223 224; Right arrow is mapped to ^D (06 ACK) 225; WS: Move cursor one character to the right. If at the end of a line 226; then wrap to the beginnng of the next. 227; CCP: Move cursor one character to the right unless already at the end 228; of the line. 229Right = ^D 230 231; Control + left arrow is mapped to ^A (01 SOH) 232; WS: Move cursor one word to the left, wrapping to previous line if 233; necessary. 234; CCP: Move cursor one word to the left, stopping at the beginning of 235; the line. 236Ctrl left = ^A 237 238; Control + right arrow is mapped to ^F (06 ACK) 239; WS: Move cursor one word to the right, wrapping to next line if 240; necessary. 241: CCP: Move cursor one word to the right, stopping at end of line. 242Ctrl right = ^F 243 244; Alt + up arrow is mapped to ^W (17 ETB) 245; WS: Scroll the screen up one line. Cursor remains fixed with respect 246; to the text unless it is at the bottom of the screen in which case 247; it remains at the bottom of the screen, effectively moving up one 248; line in the text. 249; CCP: Delete everything to the right of the cursor. 250ctrl Up = ^W 251 252; Alt + down arrow is mapped to ^Z (1A SUB) 253; WS: Scroll the screen up one line. Cursor remains fixed with respect 254; to the text unless it is at the top of the screen in which case it 255; remains at the top of the screen, effectively moving down one line 256; in the text. 257ctrl Down = ^Z 258 259: Dealing with the Home and End keys presented a bit of a challenge. First 260: we must decide what we expect that the Home and End keys should do. 261: 262: The weight of experience suggests that in most contexts (not limited to 263: CP/M) the End key should move the cursor to the end of the current line 264: and that the Home key should move the cursor to the beginning of the line. 265: This is common behaviour in text editors (UNIX, Windows) and in command 266: editing (Windows, linux [gnome]). 267: 268; Recall that the objective here is to construct a set of key translations 269; which are useful in two primary CP/M contexts: 270; 1. Text editors which follow the WordStar input model 271; 2. Line-at-a-time input via BDOS function 10 such as used by application 272; programs (such as the CCP) 273; The difficulties we face in this endeavour arise from the observation that 274; the control sequences needed to move the cursor to the end or beginning of 275; the current line in the BDOS(10) context are very different from those which 276; perform the same operation in the WordStar class of text editors. 277; 278; bdos(10) WordStar 279; Cursor to start of line ^B ^Q S 280; Cursor to end of line ^B ^Q D 281; 282; Presenting those sequenes in the wrong context may have nasty effects. ^B 283; in WordStar reformats the current paragraph. That is probably not what a 284; user would expect of Home or End. Similarly, in a bdos(10) context, ^Q S 285; and ^Q D are unlikely to do anything that could be expected of Home or End. 286; ^Q would be ignored and the S or D would be inserted into the text. 287; 288; It gets even more complex because some shift keys don't work as expected 289; when chorded with Home, End, Insert and Delete. 290; 291; In the hope of at least partially resolving these issues, we do not trans- 292; late the unshifted Home and End keys at all because it is too easy to forget 293; the consequences and press Home or End in an inappropriate context. It is 294; hoped that making the user choose the correct shift key will force him/her 295; to select the one which offers the desired effect. 296; bdos(10) Chord with Control 297; editors Chord with Alt 298; Using the shift key instead of control or alt is not an option but beyond 299; that there is no particular reason for choosing these pairings; it was an 300; arbitrary decision and anyone is free to change it. 301 302; Control Home 303; WS: Reformat a couple of paragraphs, possibly making a mess. 304; CCP: Move cursor to the beginning of the line. 305;Control Home = ^B ^B 306 307; Control End 308; WS: Reformat the current paragraph, a potentiall useful action so long 309; as the user knows what he/she is doing. 310; CCP: Move the cursor to the end of the input line. 311;control end = ^B 312 313; Interestingly, the effect of ^B in WordMaster, a precursor to WordStar, is 314; to move the cursor to the beginning of the line unless it is already there 315; in which case move it to the end. Quite similar to the bdos(10) operation. 316 317; Home 318; WS: Move cursor to the beginning of the current line 319; CCP: Inserts an S into the input line. 320Home = ^Q ^S 321 322; End 323; WS: Move cursor to the end of the current line 324; CCP: Inserts a D into the input line 325End = ^Q ^D 326 327: In one particular scenario, namely 64-bit cygwin, the untranslated byte 328: sequences generated by the Home and End keys are: 329: home <esc>[H 330: end <esc>[F 331: alt home <esc>[1;3H 332: alt end <esc>[1;3F 333: control home <esc>[1;5H 334: control end <esc>[1;5F 335 336 337; Page up is mapped to 12 DC2 ^R 338; WS: Display the previous page of text. 339; CCP: Ignore 340PgUp = DC2 341 342; Page down is mapped to ^C (03 ETX) 343; WS: Display the next page of text. 344; CCP: Do a warm boot if at start of line, otherwise do nothing. 345PgDn = ^C 346 347; Control PageUp and Control PageDown are set up for WordStar to move to 348; the beginning & the end of the document 349Ctl PageUp = ^Q ^R 350Ctl PageDown = ^Q ^C 351 352; Delete is mapped to ^G (07 BEL) 353; Works for bdos(10) calls and in WordStar-like applicatons to 354; delete the character at the cursor. 355Delete = bel 356 357; Control Delete is mapped to ^Y (19 EM) 358; WS: Delete line. (Also WordMaster) 359; CCP: Clear entire line 360ctl del = ^Y 361 362; Shift Insert is mapped to ^O (0F SI) 363; This is for WordMaster rather than WordStar and it toggles insert mode. 364; HOWEVER: Some xterm implementations deliver CR for Shift-Insert so 365; to cater for that we also map Alt-Insert to ^O even though that may 366; be hard to remember ... 367;Shift Ins = ^O 368;Alt Ins = ^O 369 370; Insert is mapped to ^V (16 SYN) 371; WS: Toggle insert mode 372; CCP: Clear line and delete from history 373Ins = ^V 374Alt Ins = ^N 375 376; The 5 key in the centre of the number pad is mapped to ^Q which 377; makes a convenient modifier for the surrounding keys when using 378; WordStar controls. 379NP5 = DC1 380 381; In many UNIX-like environments the backspace key generates DEL. 382; CP/M software normally expects a BS. (Note, here DEL refers to 383; a character, not the Del/Delete key so I use the Unicode point 384; to refer to it.) 385; 386; Some advice: Map keys by function, not by what is generated. For 387; example, in this case the key is labelled Backspace and CP/M wants 388; a BS so we make the keypress deliver a BS. To do that we translate 389; 7F to 08. 390;U+7F = bs 391 392; There may be an occasion where some CP/M program really wants to see 393; a DEL character. We've already made the Del(ete) key generate a ^G 394; which is what WordStar and BDOS(10) treat as meaning "delete the 395; character at the cursor" (a fine example of mapping keys by function) 396; so to satisfy this particular need we'll make Shift-Del generate DEL 397; and for uniformity with the Insert key treatment we'll do the same 398; with alt-del 399shift del = 7F 400alt del = 7F 401 402; Enable a fast interrupt when CP/M is locked, perhaps because it is 403; in a tight loop or memory is corrupt or a program accessed the BIOS 404; via the jump vector or for some other indeterminate reason. 405;alt | = SysRq 406 407F2 = "ws p:bootsys.z80" 408F7 = "i" cr 409