X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=d2261e22fe7bc9b0439386afc066e9533e34edbc;hb=02d2df5790d186f16e0e22becd8107a85f328c2f;hp=b37069c6934e69b3007a350b7d77f8147002ab3a;hpb=8f11e1cd034ff28ca47bb4955505db7fa8016ba8;p=st.git diff --git a/st.c b/st.c index b37069c..d2261e2 100644 --- a/st.c +++ b/st.c @@ -149,7 +149,7 @@ enum charset { enum escape_state { ESC_START = 1, ESC_CSI = 2, - ESC_STR = 4, /* DSC, OSC, PM, APC */ + ESC_STR = 4, /* DCS, OSC, PM, APC */ ESC_ALTCHARSET = 8, ESC_STR_END = 16, /* a final string was encountered */ ESC_TEST = 32, /* Enter in test mode */ @@ -452,7 +452,7 @@ static char utf8encodebyte(long, size_t); static size_t utf8len(char *); static size_t utf8validate(long *, size_t); -static ssize_t xwrite(int, char *, size_t); +static ssize_t xwrite(int, const char *, size_t); static void *xmalloc(size_t); static void *xrealloc(void *, size_t); static char *xstrdup(char *); @@ -518,7 +518,7 @@ static Fontcache frc[16]; static int frclen = 0; ssize_t -xwrite(int fd, char *s, size_t len) { +xwrite(int fd, const char *s, size_t len) { size_t aux = len; while(len > 0) { @@ -992,7 +992,7 @@ selnotify(XEvent *e) { } /* - * As seen in selcopy: + * As seen in getsel: * Line endings are inconsistent in the terminal and GUI world * copy and pasting. When receiving some selection data, * replace all '\n' with '\r'. @@ -1270,7 +1270,7 @@ ttyread(void) { void ttywrite(const char *s, size_t n) { - if(write(cmdfd, s, n) == -1) + if(xwrite(cmdfd, s, n) == -1) die("write error on tty: %s\n", strerror(errno)); } @@ -1781,7 +1781,6 @@ tsetmode(bool priv, bool set, int *args, int narg) { for(lim = args + narg; args < lim; ++args) { if(priv) { switch(*args) { - break; case 1: /* DECCKM -- Cursor key */ MODBIT(term.mode, set, MODE_APPCURSOR); break; @@ -2170,7 +2169,7 @@ strhandle(void) { case 'k': /* old title set compatibility */ xsettitle(strescseq.args[0]); return; - case 'P': /* DSC -- Device Control String */ + case 'P': /* DCS -- Device Control String */ case '_': /* APC -- Application Program Command */ case '^': /* PM -- Privacy Message */ return; @@ -2299,7 +2298,7 @@ techo(char *buf, int len) { for(; len > 0; buf++, len--) { char c = *buf; - if(c < 0x20 || c == 0177) { /* control code */ + if(BETWEEN(c, 0x00, 0x1f) || c == 0x7f) { /* control code */ if(c != '\n' && c != '\r' && c != '\t') { c ^= '\x40'; tputc("^", 1); @@ -2453,10 +2452,6 @@ tputc(char *c, int len) { csiparse(); csihandle(); } - } else if(term.esc & ESC_STR_END) { - term.esc = 0; - if(ascii == '\\') - strhandle(); } else if(term.esc & ESC_ALTCHARSET) { tdeftran(ascii); tselcs(); @@ -2546,7 +2541,9 @@ tputc(char *c, int len) { tcursor(CURSOR_LOAD); term.esc = 0; break; - case '\\': /* ST -- Stop */ + case '\\': /* ST -- String Terminator */ + if(term.esc & ESC_STR_END) + strhandle(); term.esc = 0; break; default: