• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版690b0b36e8e779645d804d0aa9ce1760ce8ca9fc (tree)
时间2019-11-15 19:43:20
作者IWAMOTO Kouichi <sue@iwmt...>
CommiterIWAMOTO Kouichi

Log Message

support DCS/OSC control string.

更改概述

差异

--- 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+}