1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
|
#include <HTUtils.h>
#include <LYUtils.h>
#include <LYKeymap.h>
#include <LYGlobalDefs.h>
#include <HTAccess.h>
#include <HTFormat.h>
#include <HTAlert.h>
#include <LYStrings.h> /* for USE_KEYMAP stuff - kw */
#include <LYLeaks.h>
#ifdef EXP_KEYBOARD_LAYOUT
#include <jcuken_kb.h>
#include <yawerty_kb.h>
#include <rot13_kb.h>
#endif
#ifdef EXP_KEYBOARD_LAYOUT
PUBLIC int current_layout = 0; /* Index into LYKbLayouts[] */
PUBLIC LYKeymap_t * LYKbLayouts[]={
kb_layout_rot13,
kb_layout_jcuken,
kb_layout_yawerty
};
PUBLIC char * LYKbLayoutNames[]={
"ROT13'd keyboard layout",
"JCUKEN Cyrillic, for AT 101-key kbd",
"YAWERTY Cyrillic, for DEC LK201 kbd",
(char *) 0
};
#endif /* EXP_KEYBOARD_LAYOUT */
PRIVATE CONST DocAddress keymap_anchor = {"LYNXKEYMAP", NULL, NULL,
NULL, FALSE, FALSE};
struct _HTStream
{
HTStreamClass * isa;
};
/* * * Tables mapping LynxKeyCodes to LynxActionCodes * * */
/*
* Lynxkeycodes include all single-byte keys as well as codes
* for function keys and some special purposes. See LYStrings.h.
* Extended lynxkeycode values can also contain flags for modifiers
* and other purposes, but here only the base values are mapped to
* lynxactioncodes. They are called `keystrokes' in lynx.cfg.
*
* Lynxactioncodes (confusingly, constants are named LYK_foo and
* typed as LYKeymapCode) specify key `functions', see LYKeymap.h.
*/
/* the character gets 1 added to it before lookup,
* so that EOF maps to 0
*/
LYKeymap_t keymap[KEYMAP_SIZE] = {
0,
/* EOF */
LYK_DO_NOTHING, LYK_HOME, LYK_PREV_PAGE, 0,
/* nul */ /* ^A */ /* ^B */ /* ^C */
LYK_ABORT, LYK_END, LYK_NEXT_PAGE, 0,
/* ^D */ /* ^E */ /* ^F */ /* ^G */
LYK_HISTORY, LYK_FASTFORW_LINK, LYK_ACTIVATE, LYK_COOKIE_JAR,
/* bs */ /* ht */ /* nl */ /* ^K */
#ifdef SH_EX /* 1998/10/02 (Fri) 08:48:44 */
LYK_CHG_KCODE, LYK_ACTIVATE, LYK_DOWN_TWO, 0,
/* ^L */ /* cr */ /* ^N */ /* ^O */
LYK_UP_TWO, LYK_CHG_CENTER, LYK_RELOAD, LYK_TO_CLIPBOARD,
/* ^P */ /* XON */ /* ^R */ /* ^S */
#else
LYK_REFRESH, LYK_ACTIVATE, LYK_DOWN_TWO, 0,
/* ^L */ /* cr */ /* ^N */ /* ^O */
LYK_UP_TWO, 0, LYK_RELOAD, 0,
/* ^P */ /* XON */ /* ^R */ /* XOFF */
#endif
LYK_TRACE_TOGGLE, 0, LYK_SWITCH_DTD, LYK_REFRESH,
/* ^T */ /* ^U */ /* ^V */ /* ^W */
0, 0, 0, 0,
/* ^X */ /* ^Y */ /* ^Z */ /* ESC */
0, 0, 0, 0,
/* ^\ */ /* ^] */ /* ^^ */ /* ^_ */
LYK_NEXT_PAGE, LYK_SHELL, LYK_SOFT_DQUOTES, LYK_TOOLBAR,
/* sp */ /* ! */ /* " */ /* # */
0, 0, 0, LYK_HISTORICAL,
/* $ */ /* % */ /* & */ /* ' */
LYK_UP_HALF, LYK_DOWN_HALF, LYK_IMAGE_TOGGLE, LYK_NEXT_PAGE,
/* ( */ /* ) */ /* * */ /* + */
#ifndef USE_EXTERNALS
LYK_NEXT_PAGE, LYK_PREV_PAGE, 0, LYK_WHEREIS,
/* , */ /* - */ /* . */ /* / */
#else
LYK_NEXT_PAGE, LYK_PREV_PAGE, LYK_EXTERN, LYK_WHEREIS,
/* , */ /* - */ /* . */ /* / */
#endif
LYK_F_LINK_NUM, LYK_1, LYK_2, LYK_3,
/* 0 */ /* 1 */ /* 2 */ /* 3 */
LYK_4, LYK_5, LYK_6, LYK_7,
/* 4 */ /* 5 */ /* 6 */ /* 7 */
LYK_8, LYK_9, 0, LYK_TRACE_LOG,
/* 8 */ /* 9 */ /* : */ /* ; */
LYK_UP_LINK, LYK_INFO, LYK_DOWN_LINK, LYK_HELP,
/* < */ /* = */ /* > */ /* ? */
LYK_RAW_TOGGLE, LYK_ADDRLIST, LYK_PREV_PAGE, LYK_COMMENT,
/* @ */ /* A */ /* B */ /* C */
LYK_DOWNLOAD, LYK_ELGOTO,
/* D */ /* E */
#if defined(DIRED_SUPPORT) || defined(VMS)
LYK_DIRED_MENU,
#else
0,
#endif /* DIRED_SUPPORT || VMS */
/* F */
LYK_ECGOTO,
/* G */
LYK_HELP, LYK_INDEX, LYK_JUMP, LYK_KEYMAP,
/* H */ /* I */ /* J */ /* K */
LYK_LIST, LYK_MAIN_MENU, LYK_NEXT, LYK_OPTIONS,
/* L */ /* M */ /* N */ /* O */
LYK_PRINT, LYK_ABORT, LYK_DEL_BOOKMARK, LYK_INDEX_SEARCH,
/* P */ /* Q */ /* R */ /* S */
LYK_TAG_LINK, LYK_PREV_DOC, LYK_VLINKS, 0,
/* T */ /* U */ /* V */ /* W */
LYK_NOCACHE, 0, LYK_INTERRUPT, LYK_INLINE_TOGGLE,
/* X */ /* Y */ /* Z */ /* [ */
LYK_SOURCE, LYK_HEAD, 0, LYK_CLEAR_AUTH,
/* \ */ /* ] */ /* ^ */ /* _ */
LYK_MINIMAL, LYK_ADD_BOOKMARK, LYK_PREV_PAGE, LYK_COMMENT,
/* ` */ /* a */ /* b */ /* c */
LYK_DOWNLOAD, LYK_EDIT,
/* d */ /* e */
#if defined(DIRED_SUPPORT) || defined(VMS)
LYK_DIRED_MENU,
#else
0,
#endif /* DIRED_SUPPORT || VMS */
/* f */
LYK_GOTO,
/* g */
LYK_HELP, LYK_INDEX, LYK_JUMP, LYK_KEYMAP,
/* h */ /* i */ /* j */ /* k */
LYK_LIST, LYK_MAIN_MENU, LYK_NEXT, LYK_OPTIONS,
/* l */ /* m */ /* n */ /* o */
LYK_PRINT, LYK_QUIT, LYK_DEL_BOOKMARK, LYK_INDEX_SEARCH,
/* p */ /* q */ /* r */ /* s */
LYK_TAG_LINK, LYK_PREV_DOC, LYK_VIEW_BOOKMARK, 0,
/* t */ /* u */ /* v */ /* w */
LYK_NOCACHE, 0, LYK_INTERRUPT, 0,
/* x */ /* y */ /* z */ /* { */
#if (defined(_WINDOWS) || defined(__DJGPP__))
LYK_PIPE, 0, 0, 0,
/* | */ /* } */ /* ~ */
#else
LYK_PIPE, 0, 0, LYK_HISTORY,
/* | */ /* } */ /* ~ */ /* del */
#endif /* _WINDOWS || __DJGPP__ */
/* 80..9F (illegal ISO-8859-1) 8-bit characters. */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* A0..FF (permissible ISO-8859-1) 8-bit characters. */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* 100..10F function key definitions in LYStrings.h */
LYK_PREV_LINK, LYK_NEXT_LINK, LYK_ACTIVATE, LYK_PREV_DOC,
/* UPARROW */ /* DNARROW */ /* RTARROW */ /* LTARROW */
LYK_NEXT_PAGE, LYK_PREV_PAGE, LYK_HOME, LYK_END,
/* PGDOWN */ /* PGUP */ /* HOME */ /* END */
#if (defined(_WINDOWS) || defined(__DJGPP__))
LYK_HELP, 0, 0, 0,
/* F1*/
#else
LYK_HELP, LYK_ACTIVATE, LYK_HOME, LYK_END,
/* F1*/ /* Do key */ /* Find key */ /* Select key */
#endif /* _WINDOWS || __DJGPP__ */
LYK_UP_TWO, LYK_DOWN_TWO, LYK_DO_NOTHING, LYK_FASTBACKW_LINK,
/* Insert key */ /* Remove key */ /* DO_NOTHING*/ /* Back tab */
/* 110..18F */
#if (defined(_WINDOWS) || defined(__DJGPP__)) && defined(USE_SLANG) && !defined(DJGPP_KEYHANDLER)
LYK_HISTORY, LYK_ACTIVATE, 0, 0,
/* Backspace */ /* Enter */
#else
0, 0, 0, 0,
#endif /* USE_SLANG &&(_WINDOWS || __DJGPP) && !DJGPP_KEYHANDLER */
0, 0, 0, 0,
0, LYK_DO_NOTHING, 0, 0,
/* 0x11d: MOUSE_KEY */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
#ifdef DJGPP_KEYHANDLER
0, LYK_ABORT, 0, 0,
/* ALT_X */
#else
0, 0, 0, 0,
#endif /* DJGPP_KEYHANDLER */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* 190..20F */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
#if (defined(_WINDOWS) || defined(__DJGPP__)) && !defined(USE_SLANG) /* PDCurses */
LYK_ABORT, 0, 0, 0,
/* ALT_X */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, LYK_WHEREIS, 0,
/* KP_SLASH */
0, 0, 0, LYK_IMAGE_TOGGLE,
/* KP_* */
LYK_PREV_PAGE, LYK_NEXT_PAGE, 0, 0,
/* KP_- */ /* KP_+ */
#else
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
#endif /* (_WINDOWS || __DJGPP__) && !USE_SLANG */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* 210..28F */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* 290...293 */
LYK_CHANGE_LINK, 0, 0, 0,
};
#if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE)
/*
* This table is used to override the standard keyboard assignments
* when lynx_edit_mode is in effect and keyboard overrides have been
* allowed at compile time.
*/
LYKeymap_t key_override[KEYMAP_SIZE] = {
0,
/* EOF */
0, 0, 0, 0,
/* nul */ /* ^A */ /* ^B */ /* ^C */
0, 0, 0, 0,
/* ^D */ /* ^E */ /* ^F */ /* ^G */
0, 0, 0, 0,
/* bs */ /* ht */ /* nl */ /* ^K */
0, 0, 0, 0,
/* ^L */ /* cr */ /* ^N */ /* ^O */
0, 0, 0, 0,
/* ^P */ /* XON */ /* ^R */ /* XOFF */
0, LYK_PREV_DOC, 0, 0,
/* ^T */ /* ^U */ /* ^V */ /* ^W */
0, 0, 0, 0,
/* ^X */ /* ^Y */ /* ^Z */ /* ESC */
0, 0, 0, 0,
/* ^\ */ /* ^] */ /* ^^ */ /* ^_ */
0, 0, 0, 0,
/* sp */ /* ! */ /* " */ /* # */
0, 0, 0, 0,
/* $ */ /* % */ /* & */ /* ' */
0, 0, 0, 0,
/* ( */ /* ) */ /* * */ /* + */
0, 0, LYK_TAG_LINK, 0,
/* , */ /* - */ /* . */ /* / */
0, 0, 0, 0,
/* 0 */ /* 1 */ /* 2 */ /* 3 */
0, 0, 0, 0,
/* 4 */ /* 5 */ /* 6 */ /* 7 */
0, 0, 0, 0,
/* 8 */ /* 9 */ /* : */ /* ; */
0, 0, 0, 0,
/* < */ /* = */ /* > */ /* ? */
0, 0, 0, LYK_CREATE,
/* @ */ /* A */ /* B */ /* C */
0, 0, LYK_DIRED_MENU, 0,
/* D */ /* E */ /* F */ /* G */
0, 0, 0, 0,
/* H */ /* I */ /* J */ /* K */
0, LYK_MODIFY, 0, 0,
/* L */ /* M */ /* N */ /* O */
0, 0, LYK_REMOVE, 0,
/* P */ /* Q */ /* R */ /* S */
LYK_TAG_LINK, LYK_UPLOAD, 0, 0,
/* T */ /* U */ /* V */ /* W */
0, 0, 0, 0,
/* X */ /* Y */ /* Z */ /* [ */
0, 0, 0, 0,
/* \ */ /* ] */ /* ^ */ /* _ */
0, 0, 0, LYK_CREATE,
/* ` */ /* a */ /* b */ /* c */
0, 0, LYK_DIRED_MENU, 0,
/* d */ /* e */ /* f */ /* g */
0, 0, 0, 0,
/* h */ /* i */ /* j */ /* k */
0, LYK_MODIFY, 0, 0,
/* l */ /* m */ /* n */ /* o */
0, 0, LYK_REMOVE, 0,
/* p */ /* q */ /* r */ /* s */
LYK_TAG_LINK, LYK_UPLOAD, 0, 0,
/* t */ /* u */ /* v */ /* w */
0, 0, 0, 0,
/* x */ /* y */ /* z */ /* { */
0, 0, 0, 0,
/* | */ /* } */ /* ~ */ /* del */
/* 80..9F (illegal ISO-8859-1) 8-bit characters. */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* A0..FF (permissible ISO-8859-1) 8-bit characters. */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* 100..10F function key definitions in LYStrings.h */
0, 0, 0, 0,
/* UPARROW */ /* DNARROW */ /* RTARROW */ /* LTARROW */
0, 0, 0, 0,
/* PGDOWN */ /* PGUP */ /* HOME */ /* END */
0, 0, 0, 0,
/* F1*/ /* Do key */ /* Find key */ /* Select key */
0, 0, LYK_DO_NOTHING, 0,
/* Insert key */ /* Remove key */ /* DO_NOTHING */ /* Back tab */
/* 110..18F */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* 190..20F */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* 210..28F */
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
/* 290...293 */
0, 0, 0, 0,
};
#endif /* DIRED_SUPPORT && OK_OVERRIDE */
struct rmap {
CONST char *name;
CONST char *doc;
};
/* The order of this array must match the LYKeymapCode enum in LYKeymap.h */
PRIVATE struct rmap revmap[] = {
{ "UNMAPPED", NULL },
{ "1", NULL },
{ "2", NULL },
{ "3", NULL },
{ "4", NULL },
{ "5", NULL },
{ "6", NULL },
{ "7", NULL },
{ "8", NULL },
{ "9", NULL },
{ "SOURCE", "toggle source/presentation for current document" },
{ "RELOAD", "reload the current document" },
{ "PIPE", "pipe the current document to an external command" },
{ "QUIT", "quit the browser" },
{ "ABORT", "quit the browser unconditionally" },
{ "NEXT_PAGE", "view the next page of the document" },
{ "PREV_PAGE", "view the previous page of the document" },
{ "UP_TWO", "go back two lines in the document" },
{ "DOWN_TWO", "go forward two lines in the document" },
{ "UP_HALF", "go back half a page in the document" },
{ "DOWN_HALF", "go forward half a page in the document" },
{ "REFRESH", "refresh the screen to clear garbled text" },
{ "HOME", "go to the beginning of the current document" },
{ "END", "go to the end of the current document" },
{ "PREV_LINK", "make the previous link current" },
{ "NEXT_LINK", "make the next link current" },
{ "LPOS_PREV_LINK", "make previous link current, same column for input" },
{ "LPOS_NEXT_LINK", "make next link current, same column for input" },
{ "FASTBACKW_LINK", "previous link or text area, only stops on links" },
{ "FASTFORW_LINK", "next link or text area, only stops on links" },
{ "UP_LINK", "move up the page to a previous link" },
{ "DOWN_LINK", "move down the page to another link" },
{ "RIGHT_LINK", "move right to another link" },
{ "LEFT_LINK", "move left to a previous link" },
{ "HISTORY", "display stack of currently-suspended documents" },
{ "PREV_DOC", "go back to the previous document" },
{ "ACTIVATE", "go to the document given by the current link" },
{ "MOUSE_SUBMIT", "follow current link, submit" }, /* not mapped */
{ "GOTO", "go to a document given as a URL" },
{ "ECGOTO", "edit the current document's URL and go to it" },
{ "HELP", "display help on using the browser" },
{ "DWIMHELP", "display help page that may depend on context" },
{ "INDEX", "display an index of potentially useful documents" },
{ "NOCACHE", "force submission of form or link with no-cache" },
{ "INTERRUPT", "interrupt network connection or transmission" },
{ "MAIN_MENU", "return to the first screen (home page)" },
{ "OPTIONS", "display and change option settings" },
{ "INDEX_SEARCH", "allow searching of an index" },
{ "WHEREIS", "search within the current document" },
{ "NEXT", "search for the next occurence" },
{ "COMMENT", "send a comment to the author of the current document" },
{ "EDIT", "edit the current document or a form's textarea" },
{ "INFO", "display information on the current document and link" },
{ "PRINT", "display choices for printing the current document" },
{ "ADD_BOOKMARK", "add to your personal bookmark list" },
{ "DEL_BOOKMARK", "delete from your personal bookmark list" },
{ "VIEW_BOOKMARK", "view your personal bookmark list" },
{ "VLINKS", "list links visited during the current Lynx session" },
{ "SHELL", "escape from the browser to the system" },
{ "DOWNLOAD", "download the current link to your computer" },
{ "TRACE_TOGGLE", "toggle tracing of browser operations" },
{ "TRACE_LOG", "view trace log if started in the current session" },
{ "IMAGE_TOGGLE", "toggle handling of all images as links" },
{ "INLINE_TOGGLE", "toggle pseudo-ALTs for inlines with no ALT string" },
{ "HEAD", "send a HEAD request for the current document or link" },
{ "DO_NOTHING", NULL },
{ "TOGGLE_HELP", "show other commands in the novice help menu" },
{ "JUMP", "go directly to a target document or action" },
{ "KEYMAP", "display the current key map" },
{ "LIST", "list the references (links) in the current document" },
{ "TOOLBAR", "go to Toolbar or Banner in the current document" },
{ "HISTORICAL", "toggle historical vs. valid/minimal comment parsing" },
{ "MINIMAL", "toggle minimal vs. valid comment parsing" },
{ "SOFT_DQUOTES", "toggle valid vs. soft double-quote parsing" },
{ "RAW_TOGGLE", "toggle raw 8-bit translations or CJK mode ON or OFF" },
{ "COOKIE_JAR", "examine the Cookie Jar" },
{ "F_LINK_NUM", "invoke the 'Follow link (or page) number:' prompt" },
{ "CLEAR_AUTH", "clear all authorization info for this session" },
{ "SWITCH_DTD", "switch between two ways of parsing HTML" },
{ "ELGOTO", "edit the current link's URL or ACTION and go to it" },
{ "CHANGE_LINK", "force reset of the current link on the page" },
{ "DWIMEDIT", "use external editor for context-dependent purpose" },
{ "EDITTEXTAREA", "use an external editor to edit a form's textarea" },
{ "GROWTEXTAREA", "add 5 new blank lines to the bottom of a textarea" },
{ "INSERTFILE", "insert file into a textarea (just above cursorline)" },
#ifdef EXP_ADDRLIST_PAGE
{ "ADDRLIST", "like LIST command, but always shows the links' URLs" },
#endif
#ifdef USE_EXTERNALS
{ "EXTERN", "run external program with url" },
#endif
#ifdef VMS
{ "DIRED_MENU", "invoke File/Directory Manager, if available" },
#else
#ifdef DIRED_SUPPORT
{ "DIRED_MENU", "display a full menu of file operations" },
{ "CREATE", "create a new file or directory" },
{ "REMOVE", "remove a file or directory" },
{ "MODIFY", "modify the name or location of a file or directory" },
{ "TAG_LINK", "tag a file or directory for later action" },
{ "UPLOAD", "upload from your computer to the current directory" },
{ "INSTALL", "install file or tagged files into a system area" },
#endif /* DIRED_SUPPORT */
#ifdef SH_EX /* 1999/01/01 (Fri) 01:18:12 */
{ "CHANGE_CENTER", "toggle center alignment in HTML TABLE" },
{ "TO_CLIPBOARD", "link's URL to Clip Board" },
{ "CHANGE_KCODE", "Change Kanji code" },
#endif
#endif /* VMS */
{ NULL, "" }
};
PRIVATE CONST char *funckey[] = {
"Up Arrow",
"Down Arrow",
"Right Arrow",
"Left Arrow",
"Page Down",
"Page Up",
"Home",
"End",
"F1",
"Do key",
"Find key",
"Select key",
"Insert key",
"Remove key",
"(DO_NOTHING)", /* should normally not appear in list */
"Back Tab",
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
"mouse pseudo key", /* normally not mapped to keymap[] action */
};
PRIVATE char *pretty ARGS1 (int, c)
{
static char buf[30];
if (c == '\t')
sprintf(buf, "<tab> ");
else if (c == '\r')
sprintf(buf, "<return> ");
else if (c == ' ')
sprintf(buf, "<space> ");
else if (c == '<')
sprintf(buf, "< ");
else if (c == '>')
sprintf(buf, "> ");
else if (c == 0177)
sprintf(buf, "<delete> ");
else if (c > ' ' && c <= 0377)
sprintf(buf, "%c", c);
else if (c < ' ')
sprintf(buf, "^%c", c|0100);
else if (c >= 0400 && (c - 0400) < (int) TABLESIZE(funckey)
&& funckey[c-0400])
sprintf(buf, "%s", funckey[c-0400]);
else if (c >= 0400)
sprintf(buf, "%#x", c);
else
return 0;
return buf;
}
PRIVATE char * format_binding ARGS2(
LYKeymap_t *, table,
int, i)
{
unsigned the_key = table[i];
char *buf = 0;
char *formatted;
if (the_key != 0
&& the_key < TABLESIZE(revmap)
&& revmap[the_key].name != 0
&& revmap[the_key].doc != 0
&& (formatted = pretty(i-1)) != 0) {
HTSprintf0(&buf, "%-11s %-13s %s\n", formatted,
revmap[the_key].name,
revmap[the_key].doc);
return buf;
}
return 0;
}
PRIVATE void print_binding ARGS2(HTStream *, target, int, i)
{
char *buf;
#if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE)
if (prev_lynx_edit_mode && !no_dired_support &&
(buf = format_binding(key_override, i)) != 0) {
(*target->isa->put_block)(target, buf, strlen(buf));
FREE(buf);
} else
#endif /* DIRED_SUPPORT && OK_OVERRIDE */
if ((buf = format_binding(keymap, i)) != 0) {
(*target->isa->put_block)(target, buf, strlen(buf));
FREE(buf);
}
}
/*
* Return lynxactioncode whose name is the string func.
* func must be present in the revmap table.
* returns -1 if not found. - kw
*/
PUBLIC int lacname_to_lac ARGS1(
CONST char *, func)
{
int i;
struct rmap *mp;
if (func == NULL || *func == '\0')
return (-1);
for (i = 0, mp = revmap; (*mp).name != NULL; mp++, i++) {
if (strcmp((*mp).name, func) == 0) {
return i;
}
}
return (-1);
}
/*
* Return lynxkeycode represented by string src.
* returns -1 if not valid.
* This is simpler than what map_string_to_keysym() does for
* USE_KEYMAP, but compatible with revmap() used for processing
* KEYMAP options in the configuration file. - kw
*/
PUBLIC int lkcstring_to_lkc ARGS1(
CONST char *, src)
{
int c = -1;
if (strlen(src) == 1)
c = *src;
else if (strlen(src) == 2 && *src == '^')
c = src[1] & 037;
else if (strlen(src) >= 2 && isdigit(*src)) {
if (sscanf(src, "%i", &c) != 1)
return (-1);
#ifdef USE_KEYMAPS
} else {
map_string_to_keysym((char *)src, &c);
#ifndef USE_SLANG
if (c >= 0) {
if ((c&LKC_MASK) > 255 && !(c & LKC_ISLKC))
return (-1); /* Don't accept untranslated curses KEY_* */
else
c &= ~LKC_ISLKC;
}
#endif
#endif
}
if (c < -1)
return (-1);
else
return c;
}
PRIVATE int LYLoadKeymap ARGS4 (
CONST char *, arg GCC_UNUSED,
HTParentAnchor *, anAnchor,
HTFormat, format_out,
HTStream*, sink)
{
HTFormat format_in = WWW_HTML;
HTStream *target;
char *buf = 0;
int i;
/*
* Set up the stream. - FM
*/
target = HTStreamStack(format_in, format_out, sink, anAnchor);
if (!target || target == NULL) {
HTSprintf0(&buf, CANNOT_CONVERT_I_TO_O,
HTAtom_name(format_in), HTAtom_name(format_out));
HTAlert(buf);
FREE(buf);
return(HT_NOT_LOADED);
}
anAnchor->no_cache = TRUE;
HTSprintf0(&buf, "<head>\n<title>%s</title>\n</head>\n<body>\n",
CURRENT_KEYMAP_TITLE);
(*target->isa->put_block)(target, buf, strlen(buf));
HTSprintf0(&buf, "<h1>%s (%s)%s<a href=\"%s%s\">%s</a></h1>\n",
LYNX_NAME, LYNX_VERSION,
HELP_ON_SEGMENT,
helpfilepath, CURRENT_KEYMAP_HELP, CURRENT_KEYMAP_TITLE);
(*target->isa->put_block)(target, buf, strlen(buf));
HTSprintf0(&buf, "<pre>\n");
(*target->isa->put_block)(target, buf, strlen(buf));
for (i = 'a'+1; i <= 'z'+1; i++) {
print_binding(target, i);
if (keymap[i - ' '] != keymap[i]) {
print_binding(target, i-' '); /* uppercase mapping is different */
}
}
for (i = 1; i < KEYMAP_SIZE; i++) {
/*
* LYK_PIPE not implemented yet.
*
* Don't show CHANGE_LINK if mouse not enabled.
*/
if ((i >= 0400 || i <= ' ' || !isalpha(i-1)) &&
strcmp(revmap[keymap[i]].name, "PIPE") &&
(LYUseMouse || strcmp(revmap[keymap[i]].name, "CHANGE_LINK"))) {
print_binding(target, i);
}
}
HTSprintf0(&buf,"</pre>\n</body>\n");
(*target->isa->put_block)(target, buf, strlen(buf));
(*target->isa->_free)(target);
FREE(buf);
return(HT_LOADED);
}
#ifdef GLOBALDEF_IS_MACRO
#define _LYKEYMAP_C_GLOBALDEF_1_INIT { "LYNXKEYMAP", LYLoadKeymap, 0}
GLOBALDEF (HTProtocol,LYLynxKeymap,_LYKEYMAP_C_GLOBALDEF_1_INIT);
#else
GLOBALDEF PUBLIC HTProtocol LYLynxKeymap = {"LYNXKEYMAP", LYLoadKeymap, 0};
#endif /* GLOBALDEF_IS_MACRO */
/*
* install func as the mapping for key.
* func must be present in the revmap table.
* returns TRUE if the mapping was made, FALSE if not.
*/
PUBLIC int remap ARGS2(
char *, key,
char *, func)
{
int i;
struct rmap *mp;
int c;
if (func == NULL)
return 0;
c = lkcstring_to_lkc(key);
if (c <= -1)
return 0;
else if (c >= 0) {
/* Remapping of key actions is supported only for basic
* lynxkeycodes, without modifiers etc.! If we get somehow
* called for an invalid lynxkeycode, fail or silently
* modifiers. - kw
*/
if (c & LKC_ISLAC)
return 0;
if ((c & LKC_MASK) != c)
c &= LKC_MASK;
}
if (c + 1 >= KEYMAP_SIZE)
return 0;
for (i = 0, mp = revmap; (*mp).name != NULL; mp++, i++) {
if (strcmp((*mp).name, func) == 0) {
keymap[c+1] = i;
return (c ? c : LAC_TO_LKC0(i));
}
}
return 0;
}
PUBLIC void set_vms_keys NOARGS
{
keymap[26+1] = LYK_ABORT; /* control-Z */
keymap['$'+1] = LYK_SHELL;
}
static LYKeymap_t saved_vi_keys[4];
static BOOLEAN did_vi_keys;
PUBLIC void set_vi_keys NOARGS
{
saved_vi_keys[0] = keymap['h'+1];
keymap['h'+1] = LYK_PREV_DOC;
saved_vi_keys[1] = keymap['j'+1];
keymap['j'+1] = LYK_NEXT_LINK;
saved_vi_keys[2] = keymap['k'+1];
keymap['k'+1] = LYK_PREV_LINK;
saved_vi_keys[3] = keymap['l'+1];
keymap['l'+1] = LYK_ACTIVATE;
did_vi_keys = TRUE;
}
PUBLIC void reset_vi_keys NOARGS
{
if (!did_vi_keys)
return;
keymap['h'+1] = saved_vi_keys[0];
keymap['j'+1] = saved_vi_keys[1];
keymap['k'+1] = saved_vi_keys[2];
keymap['l'+1] = saved_vi_keys[3];
did_vi_keys = FALSE;
}
static LYKeymap_t saved_emacs_keys[4];
static BOOLEAN did_emacs_keys;
PUBLIC void set_emacs_keys NOARGS
{
saved_emacs_keys[0] = keymap[2+1];
keymap[2+1] = LYK_PREV_DOC; /* ^B */
saved_emacs_keys[1] = keymap[14+1];
keymap[14+1] = LYK_NEXT_LINK; /* ^N */
saved_emacs_keys[2] = keymap[16+1];
keymap[16+1] = LYK_PREV_LINK; /* ^P */
saved_emacs_keys[3] = keymap[6+1];
keymap[6+1] = LYK_ACTIVATE; /* ^F */
did_emacs_keys = TRUE;
}
PUBLIC void reset_emacs_keys NOARGS
{
if (!did_emacs_keys)
return;
keymap[2+1] = saved_emacs_keys[0];
keymap[14+1] = saved_emacs_keys[1];
keymap[16+1] = saved_emacs_keys[2];
keymap[6+1] = saved_emacs_keys[3];
did_emacs_keys = FALSE;
}
static LYKeymap_t saved_number_keys[9];
static BOOLEAN did_number_keys;
PUBLIC void set_numbers_as_arrows NOARGS
{
/*
* Map numbers to functions as labeled on the
* IBM Enhanced keypad, and save their original
* mapping for reset_numbers_as_arrows(). - FM
*/
saved_number_keys[0] = keymap['4'+1];
keymap['4'+1] = LYK_PREV_DOC;
saved_number_keys[1] = keymap['2'+1];
keymap['2'+1] = LYK_NEXT_LINK;
saved_number_keys[2] = keymap['8'+1];
keymap['8'+1] = LYK_PREV_LINK;
saved_number_keys[3] = keymap['6'+1];
keymap['6'+1] = LYK_ACTIVATE;
saved_number_keys[4] = keymap['7'+1];
keymap['7'+1] = LYK_HOME;
saved_number_keys[5] = keymap['1'+1];
keymap['1'+1] = LYK_END;
saved_number_keys[6] = keymap['9'+1];
keymap['9'+1] = LYK_PREV_PAGE;
saved_number_keys[7] = keymap['3'+1];
keymap['3'+1] = LYK_NEXT_PAGE;
/*
* Disable the 5.
*/
saved_number_keys[8] = keymap['5'+1];
keymap['5'+1] = LYK_DO_NOTHING;
did_number_keys = TRUE;
}
PUBLIC void reset_numbers_as_arrows NOARGS
{
if (!did_number_keys)
return;
keymap['4'+1] = saved_number_keys[0];
keymap['2'+1] = saved_number_keys[1];
keymap['8'+1] = saved_number_keys[2];
keymap['6'+1] = saved_number_keys[3];
keymap['7'+1] = saved_number_keys[4];
keymap['1'+1] = saved_number_keys[5];
keymap['9'+1] = saved_number_keys[6];
keymap['3'+1] = saved_number_keys[7];
keymap['5'+1] = saved_number_keys[8];
did_number_keys = FALSE;
}
PUBLIC int lookup_keymap ARGS1(
int, func)
{
size_t i;
for (i = 1; i < KEYMAP_SIZE; i++) {
if (LYisNonAlnumKeyname(i, func)) {
return i;
}
}
return -1;
}
PUBLIC char *key_for_func ARGS1 (
int, func)
{
static char *buf;
int i;
char *formatted;
if ((i = LYReverseKeymap(func)) >= 0) {
formatted = pretty(i);
StrAllocCopy(buf, formatted != 0 ? formatted : "?");
} else if (buf == 0) {
StrAllocCopy(buf, "");
}
return buf;
}
/*
* This function returns TRUE if the ch is non-alphanumeric
* and maps to key_name (LYK_foo in the keymap[] array). - FM
*/
PUBLIC BOOL LYisNonAlnumKeyname ARGS2(
int, ch,
int, key_name)
{
if ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'z') ||
ch < 0 || ch >= KEYMAP_SIZE)
return (FALSE);
return(keymap[ch+1] == key_name);
}
/*
* This function returns the (int)ch mapped to the
* LYK_foo value passed to it as an argument. - FM
*/
PUBLIC int LYReverseKeymap ARGS1(
int, key_name)
{
int i;
for (i = 1; i < KEYMAP_SIZE; i++) {
if (keymap[i] == key_name) {
return(i - 1);
}
}
return(-1);
}
#ifdef EXP_KEYBOARD_LAYOUT
PUBLIC int LYSetKbLayout ARGS1(
char *, layout_id)
{
int i;
for (i = 0; i < (int) TABLESIZE(LYKbLayoutNames) - 1; i++) {
if (!strcmp(LYKbLayoutNames[i], layout_id)) {
current_layout = i;
return (-1);
}
}
return 0;
}
#endif
|