-
Notifications
You must be signed in to change notification settings - Fork 1
/
TerminalParser_Linux.m
1449 lines (1310 loc) · 28.4 KB
/
TerminalParser_Linux.m
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
/*
copyright 2002, 2003 Alexander Malmberg <[email protected]>
This file is a part of Terminal.app. Terminal.app is free software; you
can redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation; version 2
of the License. See COPYING or main.m for more information.
*/
/*
lots borrowed from linux/drivers/char/console.c, GNU GPL:ed
*/
/*
* linux/drivers/char/console.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
#include <Foundation/NSString.h>
#include <Foundation/NSDebug.h>
#include <AppKit/NSGraphics.h>
#include <netinet/in.h>
/* TODO */
#include "TerminalViewPrefs.h"
#include <AppKit/NSEvent.h>
#include "TerminalParser_Linux.h"
#include "TerminalParser_LinuxPrefs.h"
#include "charmaps.h"
#define set_translate(charset,foo) _set_translate(charset)
static const unichar *_set_translate(int charset)
{
if (charset<0 || charset>=4)
return translate_maps[0];
return translate_maps[charset];
}
@interface TerminalParser_Linux (private)
#define csi_J(foo,vpar) [self _csi_J: vpar]
#define csi_K(foo,vpar) [self _csi_K: vpar]
#define csi_L(foo,vpar) [self _csi_L: vpar]
#define csi_M(foo,vpar) [self _csi_M: vpar]
#define csi_P(foo,vpar) [self _csi_P: vpar]
#define csi_X(foo,vpar) [self _csi_X: vpar]
#define csi_at(foo,vpar) [self _csi_at: vpar]
#define csi_m(foo) [self _csi_m]
-(void) _csi_J: (int)vpar;
-(void) _csi_K: (int)vpar;
-(void) _csi_L: (unsigned int)vpar;
-(void) _csi_M: (unsigned int)vpar;
-(void) _csi_P: (unsigned int)vpar;
-(void) _csi_X: (int)vpar;
-(void) _csi_at: (unsigned int)vpar;
-(void) _csi_m;
-(void) _default_attr;
-(void) _update_attr;
@end
#define SCREEN(x,y) ((x)+(y)*width)
@implementation TerminalParser_Linux
#define gotoxy(foo,new_x,new_y) do { \
int min_y, max_y; \
\
if (new_x < 0) \
x = 0; \
else \
if (new_x >= width) \
x = width - 1; \
else \
x = new_x; \
if (decom) { \
min_y = top; \
max_y = bottom; \
} else { \
min_y = 0; \
max_y = height; \
} \
if (new_y < min_y) \
y = min_y; \
else if (new_y >= max_y) \
y = max_y - 1; \
else \
y = new_y; \
[ts ts_goto: x:y]; \
} while (0)
#define gotoxay(foo,nx,ny) gotoxy(foo,nx,decom?top+ny:ny)
#define save_cur(foo) do { \
saved_x = x; \
saved_y = y; \
s_intensity = intensity; \
s_underline = underline; \
s_blink = blink; \
s_reverse = reverse; \
s_charset = charset; \
s_color = color; \
saved_G0 = G0_charset; \
saved_G1 = G1_charset; \
} while (0)
#define restore_cur(foo) do { \
gotoxy(currcons,saved_x,saved_y); \
intensity = s_intensity; \
underline = s_underline; \
blink = s_blink; \
reverse = s_reverse; \
charset = s_charset; \
color = s_color; \
G0_charset = saved_G0; \
G1_charset = saved_G1; \
translate = set_translate(charset ? G1_charset : G0_charset,currcons); \
} while (0)
-(void) _reset_terminal
{
top = 0;
bottom = height;
vc_state = ESnormal;
ques = 0;
translate = set_translate(LAT1_MAP,currcons);
G0_charset = LAT1_MAP;
G1_charset = GRAF_MAP;
charset = 0;
// report_mouse = 0;
utf = 0;
utf_count = 0;
disp_ctrl = 0;
toggle_meta = 0;
decscnm = 0;
decom = 0;
decawm = 1;
deccm = 1;
decim = 0;
#if 0
set_kbd(decarm);
clr_kbd(decckm);
clr_kbd(kbdapplic);
clr_kbd(lnm);
kbd_table[currcons].lockstate = 0;
kbd_table[currcons].slockstate = 0;
kbd_table[currcons].ledmode = LED_SHOW_FLAGS;
kbd_table[currcons].ledflagstate = kbd_table[currcons].default_ledflagstate;
set_leds();
cursor_type = CUR_DEFAULT;
complement_mask = s_complement_mask;
#endif
[self _default_attr];
[self _update_attr];
tab_stop[0]= 0x01010100;
tab_stop[1]=tab_stop[2]=tab_stop[3]=tab_stop[4]=
tab_stop[5]=tab_stop[6]=tab_stop[7]=0x01010101;
gotoxy(currcons,0,0);
save_cur(currcons);
[self _csi_J: 2];
}
-(void) _csi_J: (int) vpar
{
unsigned int count;
int start;
switch (vpar) {
case 0: /* erase from cursor to end of display */
count = width*height-(x+y*width);
start = SCREEN(x,y);
break;
case 1: /* erase from start to cursor */
count = x+y*width+1;
start = SCREEN(0,0);
break;
case 2: /* erase whole display */
count = width*height;
start = SCREEN(0,0);
break;
default:
return;
}
[ts ts_putChar: video_erase_char count: count offset: start];
}
-(void) _csi_K: (int)vpar
{
unsigned int count;
int start;
switch (vpar) {
case 0: /* erase from cursor to end of line */
count = width-x;
start = SCREEN(x,y);
break;
case 1: /* erase from start of line to cursor */
count = x+1;
start = SCREEN(0,y);
break;
case 2: /* erase whole line */
count = width;
start = SCREEN(0,y);
break;
default:
return;
}
[ts ts_putChar: video_erase_char count: count offset: start];
}
-(void) _csi_X: (int)vpar /* erase the following vpar positions */
{ /* not vt100? */
int count;
if (!vpar)
vpar++;
count = (vpar > width-x) ? (width-x) : vpar;
[ts ts_putChar: video_erase_char count: count offset: SCREEN(x,y)];
}
-(void) _default_attr
{
intensity = 1;
underline = 0;
reverse = 0;
blink = 0;
color = def_color;
}
-(void) _update_attr
{
video_erase_char.color=color;
video_erase_char.attr=(intensity)|(underline<<2)|(reverse<<3)|(blink<<4);
}
static unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7,
8,12,10,14, 9,13,11,15 };
-(void) _csi_m
{
int i;
for (i=0;i<=npar;i++)
switch (par[i]) {
case 0: /* all attributes off */
[self _default_attr];
break;
case 1:
intensity = 2;
break;
case 2:
intensity = 0;
break;
case 4:
underline = 1;
break;
case 5:
blink = 1;
break;
case 7:
reverse = 1;
break;
case 10: /* ANSI X3.64-1979 (SCO-ish?)
* Select primary font, don't display
* control chars if defined, don't set
* bit 8 on output.
*/
translate = set_translate(charset == 0
? G0_charset
: G1_charset,currcons);
disp_ctrl = 0;
toggle_meta = 0;
break;
case 11: /* ANSI X3.64-1979 (SCO-ish?)
* Select first alternate font, lets
* chars < 32 be displayed as ROM chars.
*/
translate = set_translate(IBMPC_MAP,currcons);
disp_ctrl = 1;
toggle_meta = 0;
break;
case 12: /* ANSI X3.64-1979 (SCO-ish?)
* Select second alternate font, toggle
* high bit before displaying as ROM char.
*/
translate = set_translate(IBMPC_MAP,currcons);
disp_ctrl = 1;
toggle_meta = 1;
break;
case 21:
case 22:
intensity = 1;
break;
case 24:
underline = 0;
break;
case 25:
blink = 0;
break;
case 27:
reverse = 0;
break;
case 38: /* ANSI X3.64-1979 (SCO-ish?)
* Enables underscore, white foreground
* with white underscore (Linux - use
* default foreground).
*/
color = (def_color & 0x0f) | background;
underline = 1;
break;
case 39: /* ANSI X3.64-1979 (SCO-ish?)
* Disable underline option.
* Reset colour to default? It did this
* before...
*/
color = (def_color & 0x0f) | background;
underline = 0;
break;
case 49:
color = (def_color & 0xf0) | foreground;
break;
default:
if (par[i] >= 30 && par[i] <= 37)
color = color_table[par[i]-30]
| background;
else if (par[i] >= 40 && par[i] <= 47)
color = (color_table[par[i]-40]<<4)
| foreground;
break;
}
[self _update_attr];
}
#define scrup(foo,t,b,nr,indirect_scroll) do { \
int scrup_nr=nr; \
\
if (t+scrup_nr >= b) \
scrup_nr = b - t - 1; \
if (b > height || t >= b || scrup_nr < 1) \
return; \
[ts ts_scrollUp: t:b rows: scrup_nr save: indirect_scroll]; \
[ts ts_putChar: video_erase_char count: width*scrup_nr offset: width*(b-scrup_nr)]; \
} while (0)
#define scrdown(foo,t,b,nr) do { \
unsigned int step; \
int scrdown_nr=nr; \
\
if (t+scrdown_nr >= b) \
scrdown_nr = b - t - 1; \
if (b > height || t >= b || scrdown_nr < 1) \
return; \
step = width * scrdown_nr; \
[ts ts_scrollDown: t:b rows: scrdown_nr]; \
[ts ts_putChar: video_erase_char count: step offset: t*width]; \
} while (0)
#define insert_char(foo,nr) do { \
[ts ts_shiftRow: y at: x delta: nr]; \
[ts ts_putChar: video_erase_char count: nr at: x:y]; \
} while (0)
#define delete_char(foo,nr) do { \
[ts ts_shiftRow: y at: x+nr delta: -nr]; \
[ts ts_putChar: video_erase_char count: nr at: width-nr:y]; \
} while (0)
-(void) _csi_at: (unsigned int)nr
{
if (nr > width - x)
nr = width - x;
else if (!nr)
nr = 1;
insert_char(currcons, nr);
}
-(void) _csi_L: (unsigned int)nr
{
if (nr > height - y)
nr = height - y;
else if (!nr)
nr = 1;
scrdown(foo,y,bottom,nr);
}
-(void) _csi_P: (unsigned int)nr
{
if (nr > width - x)
nr = width - x;
else if (!nr)
nr = 1;
delete_char(currcons, nr);
}
-(void) _csi_M: (unsigned int)nr
{
if (nr > height - y)
nr = height - y;
else if (!nr)
nr=1;
scrup(foo,y,bottom,nr,NO);
}
#define set_kbd(foo)
#define clr_kbd(foo)
#define set_mode(foo,on_off) [self _set_mode: on_off]
-(void) _set_mode: (int) on_off
{
int i;
for (i=0; i<=npar; i++)
if (ques) switch(par[i]) { /* DEC private modes set/reset */
case 1: /* Cursor keys send ^[Ox/^[[x */
if (on_off)
{
set_kbd(decckm);
}
else
{
clr_kbd(decckm);
}
break;
case 3: /* 80/132 mode switch unimplemented */
NSDebugLLog(@"term",@"ignore _set_mode 3");
#if 0
deccolm = on_off;
(void) vc_resize(height, deccolm ? 132 : 80);
/* this alone does not suffice; some user mode
utility has to change the hardware regs */
#endif
break;
case 5: /* Inverted screen on/off */
if (decscnm != on_off) {
decscnm = on_off;
[self _update_attr]; /* TODO? */
}
break;
case 6: /* Origin relative/absolute */
decom = on_off;
gotoxay(currcons,0,0);
break;
case 7: /* Autowrap on/off */
decawm = on_off;
break;
case 8: /* Autorepeat on/off */
NSDebugLLog(@"term",@"ignore _set_mode 8");
#if 0
if (on_off)
set_kbd(decarm);
else
clr_kbd(decarm);
#endif
break;
case 9:
NSDebugLLog(@"term",@"ignore _set_mode 9");
#if 0
report_mouse = on_off ? 1 : 0;
#endif
break;
case 25: /* Cursor on/off */
deccm = on_off;
break;
case 1000:
NSDebugLLog(@"term",@"ignore _set_mode 1000");
#if 0
report_mouse = on_off ? 2 : 0;
#endif
break;
} else switch(par[i]) { /* ANSI modes set/reset */
case 3: /* Monitor (display ctrls) */
disp_ctrl = on_off;
break;
case 4: /* Insert Mode on/off */
decim = on_off;
break;
case 20: /* Lf, Enter == CrLf/Lf */
NSDebugLLog(@"term",@"ignore _set_mode 20");
#if 0
if (on_off)
set_kbd(lnm);
else
clr_kbd(lnm);
#endif
break;
}
}
#define setterm_command(foo) [self _setterm_command]
-(void) _setterm_command
{
NSDebugLLog(@"term",@"ignore _setterm_command %i\n",par[0]);
/* TODO: will need _update_attr */
switch(par[0]) {
#if 0
case 1: /* set color for underline mode */
if (can_do_color && par[1] < 16) {
ulcolor = color_table[par[1]];
if (underline)
update_attr(currcons);
}
break;
case 2: /* set color for half intensity mode */
if (can_do_color && par[1] < 16) {
halfcolor = color_table[par[1]];
if (intensity == 0)
update_attr(currcons);
}
break;
#endif
case 8: /* store colors as defaults */
def_color = color;
/* if (hi_font_mask == 0x100)
def_color >>= 1;*/
[self _default_attr];
[self _update_attr];
break;
#if 0
case 9: /* set blanking interval */
blankinterval = ((par[1] < 60) ? par[1] : 60) * 60 * HZ;
poke_blanked_console();
break;
case 10: /* set bell frequency in Hz */
if (npar >= 1)
bell_pitch = par[1];
else
bell_pitch = DEFAULT_BELL_PITCH;
break;
case 11: /* set bell duration in msec */
if (npar >= 1)
bell_duration = (par[1] < 2000) ?
par[1]*HZ/1000 : 0;
else
bell_duration = DEFAULT_BELL_DURATION;
break;
case 12: /* bring specified console to the front */
if (par[1] >= 1 && vc_cons_allocated(par[1]-1))
set_console(par[1] - 1);
break;
case 13: /* unblank the screen */
poke_blanked_console();
break;
case 14: /* set vesa powerdown interval */
vesa_off_interval = ((par[1] < 60) ? par[1] : 60) * 60 * HZ;
break;
#endif
}
}
-(void) processByte: (unsigned char)c
{
#define lf() do { \
if (y+1==bottom) \
{ \
scrup(foo,top,bottom,1,(top==0 && bottom==height)?YES:NO); \
} \
else if (y<height-1) \
{ \
y++; \
[ts ts_goto: x:y]; \
} \
} while (0)
#define ri() do { \
if (y==top) \
{ \
scrdown(foo,top,bottom,1); \
} \
else if (y>0) \
{ \
y--; \
[ts ts_goto: x:y]; \
} \
} while (0)
#define cr() do { x=0; [ts ts_goto: x:y]; } while (0)
#define cursor_report(foo,bar) do { \
char buf[40]; \
\
sprintf(buf, "\033[%d;%dR", y + (decom ? top+1 : 1), x+1); \
[ts ts_sendCString: buf]; \
} while (0)
#define status_report(foo) do { \
[ts ts_sendCString: "\033[0n"]; \
} while (0)
#define VT102ID "\033[?6c"
#define respond_ID(foo) do { [ts ts_sendCString: VT102ID]; } while (0)
switch (c)
{
case 0:
return;
case 7:
if (vc_state==EStitle_buf)
{
NSString *new_title;
title_buf[title_len]=0;
new_title=[NSString stringWithCString: title_buf];
[ts ts_setTitle: new_title type: title_type];
vc_state=ESnormal;
return;
}
NSBeep();
return;
case 8:
if (x>0)
{
x--;
[ts ts_goto: x:y];
}
return;
case 9:
while (x < width - 1) {
x++;
if (tab_stop[x >> 5] & (1 << (x & 31)))
break;
}
[ts ts_goto: x:y];
return;
case 10: case 11: case 12:
lf();
/* if (!is_kbd(lnm))*/
return;
case 13:
cr();
return;
case 14:
charset = 1;
translate = set_translate(G1_charset,currcons);
disp_ctrl = 1;
return;
case 15:
charset = 0;
translate = set_translate(G0_charset,currcons);
disp_ctrl = 0;
return;
case 24: case 26:
vc_state = ESnormal;
return;
case 27:
vc_state = ESesc;
return;
case 127:
// del(currcons);
return;
case 128+27:
vc_state = ESsquare;
return;
}
switch(vc_state) {
case ESesc:
vc_state = ESnormal;
switch (c) {
case '[':
vc_state = ESsquare;
return;
case ']':
vc_state = ESnonstd;
return;
case '%':
vc_state = ESpercent;
return;
case 'E':
cr();
lf();
return;
case 'M':
ri();
return;
case 'D':
lf();
return;
case 'H':
tab_stop[x >> 5] |= (1 << (x & 31));
return;
case 'Z':
respond_ID(foo);
return;
case '7':
save_cur(currcons);
return;
case '8':
restore_cur(currcons);
return;
case '(':
vc_state = ESsetG0;
return;
case ')':
vc_state = ESsetG1;
return;
case '#':
vc_state = EShash;
return;
case 'c':
[self _reset_terminal];
return;
case '>': /* Numeric keypad */
NSDebugLLog(@"term",@"ignore ESesc > keypad");
#if 0
clr_kbd(kbdapplic);
#endif
return;
case '=': /* Appl. keypad */
NSDebugLLog(@"term",@"ignore ESesc = keypad");
#if 0
set_kbd(kbdapplic);
#endif
return;
}
return;
case ESnonstd:
switch (c)
{
case '0':
case '1':
case '2':
vc_state=EStitle_semi;
title_type=c-'0';
return;
case 'P':
NSDebugLLog(@"term",@"ignore ESnonstd P");
#if 0
for (npar=0; npar<NPAR; npar++)
par[npar] = 0 ;
npar = 0 ;
#endif
vc_state = ESpalette;
return;
case 'R':
NSDebugLLog(@"term",@"ignore ESnonstd R");
#if 0
reset_palette(currcons);
#endif
vc_state = ESnormal;
}
vc_state = ESnormal;
return;
case EStitle_semi:
if (c==';')
{
vc_state=EStitle_buf;
title_len=0;
}
else
vc_state=ESnormal;
return;
case EStitle_buf:
if (title_len==TITLE_BUF_SIZE)
{
vc_state=ESnormal;
}
else
{
title_buf[title_len++]=c;
}
return;
case ESpalette:
NSDebugLLog(@"term",@"ignore palette sequence (2)");
#if 0
if ( (c>='0'&&c<='9') || (c>='A'&&c<='F') || (c>='a'&&c<='f') ) {
par[npar++] = (c>'9' ? (c&0xDF)-'A'+10 : c-'0') ;
if (npar==7) {
int i = par[0]*3, j = 1;
palette[i] = 16*par[j++];
palette[i++] += par[j++];
palette[i] = 16*par[j++];
palette[i++] += par[j++];
palette[i] = 16*par[j++];
palette[i] += par[j];
set_palette(currcons);
vc_state = ESnormal;
}
} else
#endif
vc_state = ESnormal;
return;
case ESsquare:
for(npar = 0 ; npar < NPAR ; npar++)
par[npar] = 0;
npar = 0;
vc_state = ESgetpars;
if (c == '[') { /* Function key */
vc_state=ESfunckey;
return;
}
ques = (c=='?');
if (ques)
return;
case ESgetpars:
if (c==';' && npar<NPAR-1) {
npar++;
return;
} else if (c>='0' && c<='9') {
par[npar] *= 10;
par[npar] += c-'0';
return;
} else vc_state=ESgotpars;
case ESgotpars:
vc_state = ESnormal;
switch(c) {
case 'h':
set_mode(currcons,1);
return;
case 'l':
set_mode(currcons,0);
return;
case 'c':
NSDebugLLog(@"term",@"ignore ESgotpars c");
#if 0
if (ques) {
if (par[0])
cursor_type = par[0] | (par[1]<<8) | (par[2]<<16);
else
cursor_type = CUR_DEFAULT;
return;
}
#endif
break;
case 'n':
if (!ques) {
if (par[0] == 5)
status_report(tty);
else if (par[0] == 6)
cursor_report(currcons,tty);
}
return;
}
if (ques) {
ques = 0;
return;
}
switch(c) {
case 'G': case '`':
if (par[0]) par[0]--;
gotoxy(currcons,par[0],y);
return;
case 'A':
if (!par[0]) par[0]++;
gotoxy(currcons,x,y-par[0]);
return;
case 'B': case 'e':
if (!par[0]) par[0]++;
gotoxy(currcons,x,y+par[0]);
return;
case 'C': case 'a':
if (!par[0]) par[0]++;
gotoxy(currcons,x+par[0],y);
return;
case 'D':
if (!par[0]) par[0]++;
gotoxy(currcons,x-par[0],y);
return;
case 'E':
if (!par[0]) par[0]++;
gotoxy(currcons,0,y+par[0]);
return;
case 'F':
if (!par[0]) par[0]++;
gotoxy(currcons,0,y-par[0]);
return;
case 'd':
if (par[0]) par[0]--;
gotoxay(currcons,x,par[0]);
return;
case 'H': case 'f':
if (par[0]) par[0]--;
if (par[1]) par[1]--;
gotoxay(currcons,par[1],par[0]);
return;
case 'J':
csi_J(currcons,par[0]);
return;
case 'K':
csi_K(currcons,par[0]);
return;
case 'L':
csi_L(currcons,par[0]);
return;
case 'M':
csi_M(currcons,par[0]);
return;
case 'P':
csi_P(currcons,par[0]);
return;
case 'c':
if (!par[0])
respond_ID(tty);
return;
case 'g':
if (!par[0])
tab_stop[x >> 5] &= ~(1 << (x & 31));
else if (par[0] == 3) {
tab_stop[0] =
tab_stop[1] =
tab_stop[2] =
tab_stop[3] =
tab_stop[4] = 0;
}
return;
case 'm':
csi_m(currcons);
return;
case 'q': /* DECLL - but only 3 leds */
/* map 0,1,2,3 to 0,1,2,4 */
NSDebugLLog(@"term",@"ignore ESgotpars q");
#if 0
if (par[0] < 4)
setledstate(kbd_table + currcons,
(par[0] < 3) ? par[0] : 4);
#endif
return;
case 'r':
if (!par[0])
par[0]++;
if (!par[1])
par[1] = height;
/* Minimum allowed region is 2 lines */
if (par[0] < par[1] &&
par[1] <= height) {
top=par[0]-1;
bottom=par[1];
gotoxay(currcons,0,0);
}
return;
case 's':
save_cur(currcons);
return;
case 'u':
restore_cur(currcons);
return;
case 'X':
csi_X(currcons, par[0]);
return;
case '@':
csi_at(currcons,par[0]);
return;
case ']': /* setterm functions */
setterm_command(currcons);
return;
}
return;
case ESpercent:
vc_state = ESnormal;
switch (c) {
case '@': /* defined in ISO 2022 */
utf = 0;
return;
case 'G': /* prelim official escape code */
case '8': /* retained for compatibility */
utf = 1;
return;
}
return;
case ESfunckey:
vc_state = ESnormal;
return;
case EShash:
vc_state = ESnormal;