-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathterminfo-capabilities.scm
579 lines (565 loc) · 23.8 KB
/
terminfo-capabilities.scm
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
;;; -*- Mode: Scheme; scheme48-package: terminfo -*-
;;;
(define *capabilities* (make-hash-table))
;;; see tigetflag, tigetnum, tigetstr
(define (terminal:capability terminal name)
(let ((capability (hash-table-ref *capabilities* name)))
(when (or (null? terminal)
(not (terminal? terminal)))
(error "Invalid terminfo object"))
(when (null? capability)
(error "Capability does not exist:" name))
(let* ((accessor (car capability))
(index (cdr capability))
(table (accessor terminal)))
(if (>= index (vector-length table))
-1
(vector-ref table index)))))
(define-syntax capability-available?
(syntax-rules ()
((_ terminal name)
(let ((value (terminal:capability terminal 'name)))
(not (and (number? value) (negative? value)))))))
(define (*define-capability name type index)
(hash-table-set! *capabilities*
name
(cons type index)))
(define-syntax define-capability
(syntax-rules ()
((_ name type index)
(begin (*define-capability 'name (capability-type type) index)
(define name ((capability-accessor type) 'name))))))
(define-syntax capability-type
(syntax-rules (boolean integer string)
((capability-type boolean) terminal:booleans)
((capability-type integer) terminal:numbers)
((capability-type string) terminal:strings)))
(define-syntax capability-accessor
(syntax-rules (boolean integer string)
((capability-accessor boolean) boolean-capability-accessor)
((capability-accessor integer) integer-capability-accessor)
((capability-accessor string) string-capability-accessor)))
(define (find-terminal arguments)
(if (and (not (null? arguments))
(terminal? (last arguments)))
(values (last arguments)
(drop-right arguments 1))
(values *current-terminal* arguments)))
(define (boolean-capability-accessor name)
(lambda args
(let-values (((term args) (find-terminal args)))
(let ((value (terminal:capability term name)))
(if (and (number? value) (negative? value))
#f
value)))))
(define (integer-capability-accessor name)
(lambda args
(let-values (((term args) (find-terminal args)))
(let ((value (terminal:capability term name)))
(if (and (number? value) (negative? value))
0
value)))))
(define (string-capability-accessor name)
(lambda args
(let-values (((term args) (find-terminal args)))
(let ((value (terminal:capability term name)))
(if (and (number? value) (negative? value))
#f
(tparm value args))))))
(define-capability auto-left-margin boolean 0)
(define-capability auto-right-margin boolean 1)
(define-capability no-esc-ctlc boolean 2)
(define-capability ceol-standout-glitch boolean 3)
(define-capability eat-newline-glitch boolean 4)
(define-capability erase-overstrike boolean 5)
(define-capability generic-type boolean 6)
(define-capability hard-copy boolean 7)
(define-capability has-meta-key boolean 8)
(define-capability has-status-line boolean 9)
(define-capability insert-null-glitch boolean 10)
(define-capability memory-above boolean 11)
(define-capability memory-below boolean 12)
(define-capability move-insert-mode boolean 13)
(define-capability move-standout-mode boolean 14)
(define-capability over-strike boolean 15)
(define-capability status-line-esc-ok boolean 16)
(define-capability dest-tabs-magic-smso boolean 17)
(define-capability tilde-glitch boolean 18)
(define-capability transparent-underline boolean 19)
(define-capability xon-xoff boolean 20)
(define-capability needs-xon-xoff boolean 21)
(define-capability prtr-silent boolean 22)
(define-capability hard-cursor boolean 23)
(define-capability non-rev-rmcup boolean 24)
(define-capability no-pad-char boolean 25)
(define-capability non-dest-scroll-region boolean 26)
(define-capability can-change boolean 27)
(define-capability back-color-erase boolean 28)
(define-capability hue-lightness-saturation boolean 29)
(define-capability col-addr-glitch boolean 30)
(define-capability cr-cancels-micro-mode boolean 31)
(define-capability has-print-wheel boolean 32)
(define-capability row-addr-glitch boolean 33)
(define-capability semi-auto-right-margin boolean 34)
(define-capability cpi-changes-res boolean 35)
(define-capability lpi-changes-res boolean 36)
(define-capability backspaces-with-bs boolean 37)
(define-capability crt-no-scrolling boolean 38)
(define-capability no-correctly-working-cr boolean 39)
(define-capability gnu-has-meta-key boolean 40)
(define-capability linefeed-is-newline boolean 41)
(define-capability has-hardware-tabs boolean 42)
(define-capability return-does-clr-eol boolean 43)
(define-capability columns integer 0)
(define-capability init-tabs integer 1)
(define-capability lines integer 2)
(define-capability lines-of-memory integer 3)
(define-capability magic-cookie-glitch integer 4)
(define-capability padding-baud-rate integer 5)
(define-capability virtual-terminal integer 6)
(define-capability width-status-line integer 7)
(define-capability num-labels integer 8)
(define-capability label-height integer 9)
(define-capability label-width integer 10)
(define-capability max-attributes integer 11)
(define-capability maximum-windows integer 12)
(define-capability max-colors integer 13)
(define-capability max-pairs integer 14)
(define-capability no-color-video integer 15)
(define-capability buffer-capacity integer 16)
(define-capability dot-vert-spacing integer 17)
(define-capability dot-horz-spacing integer 18)
(define-capability max-micro-address integer 19)
(define-capability max-micro-jump integer 20)
(define-capability micro-col-size integer 21)
(define-capability micro-line-size integer 22)
(define-capability number-of-pins integer 23)
(define-capability output-res-char integer 24)
(define-capability output-res-line integer 25)
(define-capability output-res-horz-inch integer 26)
(define-capability output-res-vert-inch integer 27)
(define-capability print-rate integer 28)
(define-capability wide-char-size integer 29)
(define-capability buttons integer 30)
(define-capability bit-image-entwining integer 31)
(define-capability bit-image-type integer 32)
(define-capability magic-cookie-glitch-ul integer 33)
(define-capability carriage-return-delay integer 34)
(define-capability new-line-delay integer 35)
(define-capability backspace-delay integer 36)
(define-capability horizontal-tab-delay integer 37)
(define-capability number-of-function-keys integer 38)
(define-capability back-tab string 0)
(define-capability bell string 1)
(define-capability carriage-return string 2)
(define-capability change-scroll-region string 3)
(define-capability clear-all-tabs string 4)
(define-capability clear-screen string 5)
(define-capability clr-eol string 6)
(define-capability clr-eos string 7)
(define-capability column-address string 8)
(define-capability command-character string 9)
(define-capability cursor-address string 10)
(define-capability cursor-down string 11)
(define-capability cursor-home string 12)
(define-capability cursor-invisible string 13)
(define-capability cursor-left string 14)
(define-capability cursor-mem-address string 15)
(define-capability cursor-normal string 16)
(define-capability cursor-right string 17)
(define-capability cursor-to-ll string 18)
(define-capability cursor-up string 19)
(define-capability cursor-visible string 20)
(define-capability delete-character string 21)
(define-capability delete-line string 22)
(define-capability dis-status-line string 23)
(define-capability down-half-line string 24)
(define-capability enter-alt-charset-mode string 25)
(define-capability enter-blink-mode string 26)
(define-capability enter-bold-mode string 27)
(define-capability enter-ca-mode string 28)
(define-capability enter-delete-mode string 29)
(define-capability enter-dim-mode string 30)
(define-capability enter-insert-mode string 31)
(define-capability enter-secure-mode string 32)
(define-capability enter-protected-mode string 33)
(define-capability enter-reverse-mode string 34)
(define-capability enter-standout-mode string 35)
(define-capability enter-underline-mode string 36)
(define-capability erase-chars string 37)
(define-capability exit-alt-charset-mode string 38)
(define-capability exit-attribute-mode string 39)
(define-capability exit-ca-mode string 40)
(define-capability exit-delete-mode string 41)
(define-capability exit-insert-mode string 42)
(define-capability exit-standout-mode string 43)
(define-capability exit-underline-mode string 44)
(define-capability flash-screen string 45)
(define-capability form-feed string 46)
(define-capability from-status-line string 47)
(define-capability init-1string string 48)
(define-capability init-2string string 49)
(define-capability init-3string string 50)
(define-capability init-file string 51)
(define-capability insert-character string 52)
(define-capability insert-line string 53)
(define-capability insert-padding string 54)
(define-capability key-backspace string 55)
(define-capability key-catab string 56)
(define-capability key-clear string 57)
(define-capability key-ctab string 58)
(define-capability key-dc string 59)
(define-capability key-dl string 60)
(define-capability key-down string 61)
(define-capability key-eic string 62)
(define-capability key-eol string 63)
(define-capability key-eos string 64)
(define-capability key-f0 string 65)
(define-capability key-f1 string 66)
(define-capability key-f10 string 67)
(define-capability key-f2 string 68)
(define-capability key-f3 string 69)
(define-capability key-f4 string 70)
(define-capability key-f5 string 71)
(define-capability key-f6 string 72)
(define-capability key-f7 string 73)
(define-capability key-f8 string 74)
(define-capability key-f9 string 75)
(define-capability key-home string 76)
(define-capability key-ic string 77)
(define-capability key-il string 78)
(define-capability key-left string 79)
(define-capability key-ll string 80)
(define-capability key-npage string 81)
(define-capability key-ppage string 82)
(define-capability key-right string 83)
(define-capability key-sf string 84)
(define-capability key-sr string 85)
(define-capability key-stab string 86)
(define-capability key-up string 87)
(define-capability keypad-local string 88)
(define-capability keypad-xmit string 89)
(define-capability lab-f0 string 90)
(define-capability lab-f1 string 91)
(define-capability lab-f10 string 92)
(define-capability lab-f2 string 93)
(define-capability lab-f3 string 94)
(define-capability lab-f4 string 95)
(define-capability lab-f5 string 96)
(define-capability lab-f6 string 97)
(define-capability lab-f7 string 98)
(define-capability lab-f8 string 99)
(define-capability lab-f9 string 100)
(define-capability meta-off string 101)
(define-capability meta-on string 102)
(define-capability new-line string 103)
(define-capability pad-char string 104)
(define-capability parm-dch string 105)
(define-capability parm-delete-line string 106)
(define-capability parm-down-cursor string 107)
(define-capability parm-ich string 108)
(define-capability parm-index string 109)
(define-capability parm-insert-line string 110)
(define-capability parm-left-cursor string 111)
(define-capability parm-right-cursor string 112)
(define-capability parm-rindex string 113)
(define-capability parm-up-cursor string 114)
(define-capability pkey-key string 115)
(define-capability pkey-local string 116)
(define-capability pkey-xmit string 117)
(define-capability print-screen string 118)
(define-capability prtr-off string 119)
(define-capability prtr-on string 120)
(define-capability repeat-char string 121)
(define-capability reset-1string string 122)
(define-capability reset-2string string 123)
(define-capability reset-3string string 124)
(define-capability reset-file string 125)
(define-capability restore-cursor string 126)
(define-capability row-address string 127)
(define-capability save-cursor string 128)
(define-capability scroll-forward string 129)
(define-capability scroll-reverse string 130)
(define-capability set-attributes string 131)
(define-capability set-tab string 132)
(define-capability set-window string 133)
(define-capability tab string 134)
(define-capability to-status-line string 135)
(define-capability underline-char string 136)
(define-capability up-half-line string 137)
(define-capability init-prog string 138)
(define-capability key-a1 string 139)
(define-capability key-a3 string 140)
(define-capability key-b2 string 141)
(define-capability key-c1 string 142)
(define-capability key-c3 string 143)
(define-capability prtr-non string 144)
(define-capability char-padding string 145)
(define-capability acs-chars string 146)
(define-capability plab-norm string 147)
(define-capability key-btab string 148)
(define-capability enter-xon-mode string 149)
(define-capability exit-xon-mode string 150)
(define-capability enter-am-mode string 151)
(define-capability exit-am-mode string 152)
(define-capability xon-character string 153)
(define-capability xoff-character string 154)
(define-capability ena-acs string 155)
(define-capability label-on string 156)
(define-capability label-off string 157)
(define-capability key-beg string 158)
(define-capability key-cancel string 159)
(define-capability key-close string 160)
(define-capability key-command string 161)
(define-capability key-copy string 162)
(define-capability key-create string 163)
(define-capability key-end string 164)
(define-capability key-enter string 165)
(define-capability key-exit string 166)
(define-capability key-find string 167)
(define-capability key-help string 168)
(define-capability key-mark string 169)
(define-capability key-message string 170)
(define-capability key-move string 171)
(define-capability key-next string 172)
(define-capability key-open string 173)
(define-capability key-options string 174)
(define-capability key-previous string 175)
(define-capability key-print string 176)
(define-capability key-redo string 177)
(define-capability key-reference string 178)
(define-capability key-refresh string 179)
(define-capability key-replace string 180)
(define-capability key-restart string 181)
(define-capability key-resume string 182)
(define-capability key-save string 183)
(define-capability key-suspend string 184)
(define-capability key-undo string 185)
(define-capability key-sbeg string 186)
(define-capability key-scancel string 187)
(define-capability key-scommand string 188)
(define-capability key-scopy string 189)
(define-capability key-screate string 190)
(define-capability key-sdc string 191)
(define-capability key-sdl string 192)
(define-capability key-select string 193)
(define-capability key-send string 194)
(define-capability key-seol string 195)
(define-capability key-sexit string 196)
(define-capability key-sfind string 197)
(define-capability key-shelp string 198)
(define-capability key-shome string 199)
(define-capability key-sic string 200)
(define-capability key-sleft string 201)
(define-capability key-smessage string 202)
(define-capability key-smove string 203)
(define-capability key-snext string 204)
(define-capability key-soptions string 205)
(define-capability key-sprevious string 206)
(define-capability key-sprint string 207)
(define-capability key-sredo string 208)
(define-capability key-sreplace string 209)
(define-capability key-sright string 210)
(define-capability key-srsume string 211)
(define-capability key-ssave string 212)
(define-capability key-ssuspend string 213)
(define-capability key-sundo string 214)
(define-capability req-for-input string 215)
(define-capability key-f11 string 216)
(define-capability key-f12 string 217)
(define-capability key-f13 string 218)
(define-capability key-f14 string 219)
(define-capability key-f15 string 220)
(define-capability key-f16 string 221)
(define-capability key-f17 string 222)
(define-capability key-f18 string 223)
(define-capability key-f19 string 224)
(define-capability key-f20 string 225)
(define-capability key-f21 string 226)
(define-capability key-f22 string 227)
(define-capability key-f23 string 228)
(define-capability key-f24 string 229)
(define-capability key-f25 string 230)
(define-capability key-f26 string 231)
(define-capability key-f27 string 232)
(define-capability key-f28 string 233)
(define-capability key-f29 string 234)
(define-capability key-f30 string 235)
(define-capability key-f31 string 236)
(define-capability key-f32 string 237)
(define-capability key-f33 string 238)
(define-capability key-f34 string 239)
(define-capability key-f35 string 240)
(define-capability key-f36 string 241)
(define-capability key-f37 string 242)
(define-capability key-f38 string 243)
(define-capability key-f39 string 244)
(define-capability key-f40 string 245)
(define-capability key-f41 string 246)
(define-capability key-f42 string 247)
(define-capability key-f43 string 248)
(define-capability key-f44 string 249)
(define-capability key-f45 string 250)
(define-capability key-f46 string 251)
(define-capability key-f47 string 252)
(define-capability key-f48 string 253)
(define-capability key-f49 string 254)
(define-capability key-f50 string 255)
(define-capability key-f51 string 256)
(define-capability key-f52 string 257)
(define-capability key-f53 string 258)
(define-capability key-f54 string 259)
(define-capability key-f55 string 260)
(define-capability key-f56 string 261)
(define-capability key-f57 string 262)
(define-capability key-f58 string 263)
(define-capability key-f59 string 264)
(define-capability key-f60 string 265)
(define-capability key-f61 string 266)
(define-capability key-f62 string 267)
(define-capability key-f63 string 268)
(define-capability clr-bol string 269)
(define-capability clear-margins string 270)
(define-capability set-left-margin string 271)
(define-capability set-right-margin string 272)
(define-capability label-format string 273)
(define-capability set-clock string 274)
(define-capability display-clock string 275)
(define-capability remove-clock string 276)
(define-capability create-window string 277)
(define-capability goto-window string 278)
(define-capability hangup string 279)
(define-capability dial-phone string 280)
(define-capability quick-dial string 281)
(define-capability tone string 282)
(define-capability pulse string 283)
(define-capability flash-hook string 284)
(define-capability fixed-pause string 285)
(define-capability wait-tone string 286)
(define-capability user0 string 287)
(define-capability user1 string 288)
(define-capability user2 string 289)
(define-capability user3 string 290)
(define-capability user4 string 291)
(define-capability user5 string 292)
(define-capability user6 string 293)
(define-capability user7 string 294)
(define-capability user8 string 295)
(define-capability user9 string 296)
(define-capability orig-pair string 297)
(define-capability orig-colors string 298)
(define-capability initialize-color string 299)
(define-capability initialize-pair string 300)
(define-capability set-color-pair string 301)
(define-capability set-foreground string 302)
(define-capability set-background string 303)
(define-capability change-char-pitch string 304)
(define-capability change-line-pitch string 305)
(define-capability change-res-horz string 306)
(define-capability change-res-vert string 307)
(define-capability define-char string 308)
(define-capability enter-doublewide-mode string 309)
(define-capability enter-draft-quality string 310)
(define-capability enter-italics-mode string 311)
(define-capability enter-leftward-mode string 312)
(define-capability enter-micro-mode string 313)
(define-capability enter-near-letter-quality string 314)
(define-capability enter-normal-quality string 315)
(define-capability enter-shadow-mode string 316)
(define-capability enter-subscript-mode string 317)
(define-capability enter-superscript-mode string 318)
(define-capability enter-upward-mode string 319)
(define-capability exit-doublewide-mode string 320)
(define-capability exit-italics-mode string 321)
(define-capability exit-leftward-mode string 322)
(define-capability exit-micro-mode string 323)
(define-capability exit-shadow-mode string 324)
(define-capability exit-subscript-mode string 325)
(define-capability exit-superscript-mode string 326)
(define-capability exit-upward-mode string 327)
(define-capability micro-column-address string 328)
(define-capability micro-down string 329)
(define-capability micro-left string 330)
(define-capability micro-right string 331)
(define-capability micro-row-address string 332)
(define-capability micro-up string 333)
(define-capability order-of-pins string 334)
(define-capability parm-down-micro string 335)
(define-capability parm-left-micro string 336)
(define-capability parm-right-micro string 337)
(define-capability parm-up-micro string 338)
(define-capability select-char-set string 339)
(define-capability set-bottom-margin string 340)
(define-capability set-bottom-margin-parm string 341)
(define-capability set-left-margin-parm string 342)
(define-capability set-right-margin-parm string 343)
(define-capability set-top-margin string 344)
(define-capability set-top-margin-parm string 345)
(define-capability start-bit-image string 346)
(define-capability start-char-set-def string 347)
(define-capability stop-bit-image string 348)
(define-capability stop-char-set-def string 349)
(define-capability subscript-characters string 350)
(define-capability superscript-characters string 351)
(define-capability these-cause-cr string 352)
(define-capability zero-motion string 353)
(define-capability char-set-names string 354)
(define-capability key-mouse string 355)
(define-capability mouse-info string 356)
(define-capability req-mouse-pos string 357)
(define-capability get-mouse string 358)
(define-capability set-a-foreground string 359)
(define-capability set-a-background string 360)
(define-capability pkey-plab string 361)
(define-capability device-type string 362)
(define-capability code-set-init string 363)
(define-capability set0-des-seq string 364)
(define-capability set1-des-seq string 365)
(define-capability set2-des-seq string 366)
(define-capability set3-des-seq string 367)
(define-capability set-lr-margin string 368)
(define-capability set-tb-margin string 369)
(define-capability bit-image-repeat string 370)
(define-capability bit-image-newline string 371)
(define-capability bit-image-carriage-return string 372)
(define-capability color-names string 373)
(define-capability define-bit-image-region string 374)
(define-capability end-bit-image-region string 375)
(define-capability set-color-band string 376)
(define-capability set-page-length string 377)
(define-capability display-pc-char string 378)
(define-capability enter-pc-charset-mode string 379)
(define-capability exit-pc-charset-mode string 380)
(define-capability enter-scancode-mode string 381)
(define-capability exit-scancode-mode string 382)
(define-capability pc-term-options string 383)
(define-capability scancode-escape string 384)
(define-capability alt-scancode-esc string 385)
(define-capability enter-horizontal-hl-mode string 386)
(define-capability enter-left-hl-mode string 387)
(define-capability enter-low-hl-mode string 388)
(define-capability enter-right-hl-mode string 389)
(define-capability enter-top-hl-mode string 390)
(define-capability enter-vertical-hl-mode string 391)
(define-capability set-a-attributes string 392)
(define-capability set-pglen-inch string 393)
(define-capability termcap-init2 string 394)
(define-capability termcap-reset string 395)
(define-capability linefeed-if-not-lf string 396)
(define-capability backspace-if-not-bs string 397)
(define-capability other-non-function-keys string 398)
(define-capability arrow-key-map string 399)
(define-capability acs-ulcorner string 400)
(define-capability acs-llcorner string 401)
(define-capability acs-urcorner string 402)
(define-capability acs-lrcorner string 403)
(define-capability acs-ltee string 404)
(define-capability acs-rtee string 405)
(define-capability acs-btee string 406)
(define-capability acs-ttee string 407)
(define-capability acs-hline string 408)
(define-capability acs-vline string 409)
(define-capability acs-plus string 410)
(define-capability memory-lock string 411)
(define-capability memory-unlock string 412)
(define-capability box-chars-1 string 413)