リビジョン | 690b0b36e8e779645d804d0aa9ce1760ce8ca9fc (tree) |
---|---|
日時 | 2019-11-15 19:43:20 |
作者 | IWAMOTO Kouichi <sue@iwmt...> |
コミッター | IWAMOTO Kouichi |
support DCS/OSC control string.
@@ -18,6 +18,7 @@ typedef unsigned long cell; | ||
18 | 18 | #define TRUE 1 |
19 | 19 | #define FALSE 0 |
20 | 20 | |
21 | +#define BEL '\007' | |
21 | 22 | #define ESC '\033' |
22 | 23 | #define SO '\016' |
23 | 24 | #define SI '\017' |
@@ -74,6 +75,7 @@ void clearscr(); | ||
74 | 75 | void sepline(); |
75 | 76 | void flush(); |
76 | 77 | void flushline(); |
78 | +int cstring(); | |
77 | 79 | |
78 | 80 | int |
79 | 81 | main(ac, av) |
@@ -415,6 +417,11 @@ FILE *fp; | ||
415 | 417 | if (csi(fp) == EOF) |
416 | 418 | goto done; |
417 | 419 | break; |
420 | + case 'P': /* DCS */ | |
421 | + case ']': /* OSC */ | |
422 | + if (cstring(fp) == EOF) | |
423 | + goto done; | |
424 | + break; | |
418 | 425 | default: |
419 | 426 | /* do nothing */ |
420 | 427 | break; |
@@ -864,3 +871,34 @@ int n; | ||
864 | 871 | printf("\033[m"); |
865 | 872 | putchar('\n'); |
866 | 873 | } |
874 | + | |
875 | +int | |
876 | +cstring(fp) | |
877 | +FILE *fp; | |
878 | +{ | |
879 | + int c, esc = FALSE; | |
880 | + | |
881 | + c = getc(fp); | |
882 | + if (c == EOF) | |
883 | + return EOF; | |
884 | + | |
885 | + for (;;) { | |
886 | + if (c == ESC) { | |
887 | + esc = TRUE; | |
888 | + } | |
889 | + else if (c == BEL) { | |
890 | + break; | |
891 | + } | |
892 | + else if (esc) { | |
893 | + if (c == '\\') { | |
894 | + break; | |
895 | + } | |
896 | + esc = FALSE; | |
897 | + } | |
898 | + c = getc(fp); | |
899 | + if (c == EOF) | |
900 | + return EOF; | |
901 | + } | |
902 | + | |
903 | + return 0; | |
904 | +} |