• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

修訂690b0b36e8e779645d804d0aa9ce1760ce8ca9fc (tree)
時間2019-11-15 19:43:20
作者IWAMOTO Kouichi <sue@iwmt...>
CommiterIWAMOTO Kouichi

Log Message

support DCS/OSC control string.

Change Summary

差異

--- a/termlog.c
+++ b/termlog.c
@@ -18,6 +18,7 @@ typedef unsigned long cell;
1818 #define TRUE 1
1919 #define FALSE 0
2020
21+#define BEL '\007'
2122 #define ESC '\033'
2223 #define SO '\016'
2324 #define SI '\017'
@@ -74,6 +75,7 @@ void clearscr();
7475 void sepline();
7576 void flush();
7677 void flushline();
78+int cstring();
7779
7880 int
7981 main(ac, av)
@@ -415,6 +417,11 @@ FILE *fp;
415417 if (csi(fp) == EOF)
416418 goto done;
417419 break;
420+ case 'P': /* DCS */
421+ case ']': /* OSC */
422+ if (cstring(fp) == EOF)
423+ goto done;
424+ break;
418425 default:
419426 /* do nothing */
420427 break;
@@ -864,3 +871,34 @@ int n;
864871 printf("\033[m");
865872 putchar('\n');
866873 }
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+}