From eeae9b0ceef9e2fec4cb4f1132748c302e5ac702 Mon Sep 17 00:00:00 2001 From: Maurice Quennet Date: Sat, 21 Sep 2013 23:33:56 +0200 Subject: [PATCH 01/16] Fix core in multi-line selection on OpenBSD OpenBSD 5.3 amd64 release version with the most current st version from git, crash and dump core when selecting multiple lines whith the cursor. This happens, because on line 964 of st.c (gp-1)->mode is accessed, although gp is still pointing at the beginning of the array term.line[y] (see line 939 for initialization of gp). --- st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.c b/st.c index df58e9e..c3a04c5 100644 --- a/st.c +++ b/st.c @@ -962,7 +962,7 @@ selcopy(void) { * st. * FIXME: Fix the computer world. */ - if(y < sel.ne.y && !((gp-1)->mode & ATTR_WRAP)) + if(y < sel.ne.y && x > 0 && !((gp-1)->mode & ATTR_WRAP)) *ptr++ = '\n'; /* -- 2.20.1 From 2b1bc8087f232a7b0ba4c7233e76be7abae25a88 Mon Sep 17 00:00:00 2001 From: Mihail Zenkov Date: Tue, 1 Oct 2013 20:01:15 +0200 Subject: [PATCH 02/16] Add DSR cursor position sequence --- st.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/st.c b/st.c index c3a04c5..05e285c 100644 --- a/st.c +++ b/st.c @@ -2067,6 +2067,13 @@ csihandle(void) { case 'm': /* SGR -- Terminal attribute (color) */ tsetattr(csiescseq.arg, csiescseq.narg); break; + case 'n': /* DSR – Device Status Report (cursor position) */ + if (csiescseq.arg[0] == 6) { + char buf[40]; + int len = snprintf(buf, sizeof(buf),"\033[%i;%iR", term.c.y+1, term.c.x+1); + ttywrite(buf, len); + break; + } case 'r': /* DECSTBM -- Set Scrolling Region */ if(csiescseq.priv) { goto unknown; -- 2.20.1 From 62ab938965f2673e029ae2e2a4244788e673bd70 Mon Sep 17 00:00:00 2001 From: Mihail Zenkov Date: Tue, 1 Oct 2013 20:02:24 +0200 Subject: [PATCH 03/16] Fix save/restore cursor st was assuming that save/restore cursor position was independent of the screen that was shown in each moment, but it is not true, because each screen has a different save/restore buffer. This patch fixes it. --- st.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/st.c b/st.c index 05e285c..12fcc90 100644 --- a/st.c +++ b/st.c @@ -1342,13 +1342,14 @@ tfulldirt(void) { void tcursor(int mode) { - static TCursor c; + static TCursor c[2]; + bool alt = IS_SET(MODE_ALTSCREEN); if(mode == CURSOR_SAVE) { - c = term.c; + c[alt] = term.c; } else if(mode == CURSOR_LOAD) { - term.c = c; - tmoveto(c.x, c.y); + term.c = c[alt]; + tmoveto(c[alt].x, c[alt].y); } } @@ -1854,12 +1855,12 @@ tsetmode(bool priv, bool set, int *args, int narg) { case 1034: MODBIT(term.mode, set, MODE_8BIT); break; - case 1049: /* = 1047 and 1048 */ - case 47: + case 1049: /* swap screen & set/restore cursor as xterm */ + tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD); + case 47: /* swap screen */ case 1047: if (!allowaltscreen) break; - alt = IS_SET(MODE_ALTSCREEN); if(alt) { tclearregion(0, 0, term.col-1, -- 2.20.1 From c5c2365ab7c7ac2671b6e7d31cc9b0d41636393c Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Wed, 2 Oct 2013 21:06:50 +0200 Subject: [PATCH 04/16] People, learn to keep to styles. Thanks. --- st.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index 12fcc90..84f9abb 100644 --- a/st.c +++ b/st.c @@ -1920,6 +1920,9 @@ tsetmode(bool priv, bool set, int *args, int narg) { void csihandle(void) { + char buf[40]; + int len; + switch(csiescseq.mode) { default: unknown: @@ -2070,8 +2073,8 @@ csihandle(void) { break; case 'n': /* DSR – Device Status Report (cursor position) */ if (csiescseq.arg[0] == 6) { - char buf[40]; - int len = snprintf(buf, sizeof(buf),"\033[%i;%iR", term.c.y+1, term.c.x+1); + len = snprintf(buf, sizeof(buf),"\033[%i;%iR", + term.c.y+1, term.c.x+1); ttywrite(buf, len); break; } -- 2.20.1 From 7a4eefe87cb7661c8a77286d05b6c3afb467f806 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Tue, 1 Oct 2013 21:23:11 +0200 Subject: [PATCH 05/16] Add support for multiple charset definitions vt100 has support for two defined charset, G0 and G1. Each charset can be defined, but in each moment is selected only one of both charset. This is usually used selecting a national charset in G0 and graphic charset in G1, so you can switch between graphic charset and text charset without losing the national charset already defined. st hasn't support for national charsets, because it is an utf8 based terminal emulator, but it has support for graphic charset because it is heavily used, but it only supports G0, without understanding G1 selection sequences, which causes some programs in some moments can print some garbage in the screen. This patch adds a fake support for multiple charset definitions, where we only support graphic charset and us-ascii charset, but we allow more of one charset definition. This patch allow define G0 until G3 charsets, but only accepts select G0 or G1, and it accepts some national charset definitions but all of them are mapped to us-ascii. --- st.c | 82 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/st.c b/st.c index 84f9abb..77ea0c8 100644 --- a/st.c +++ b/st.c @@ -137,6 +137,16 @@ enum term_mode { |MODE_MOUSEMANY, }; +enum charset { + CS_GRAPHIC0, + CS_GRAPHIC1, + CS_UK, + CS_USA, + CS_MULTI, + CS_GER, + CS_FIN +}; + enum escape_state { ESC_START = 1, ESC_CSI = 2, @@ -216,6 +226,9 @@ typedef struct { int bot; /* bottom scroll limit */ int mode; /* terminal mode flags */ int esc; /* escape state flags */ + char trantbl[4]; /* charset table translation */ + int charset; /* current charset */ + int icharset; /* selected charset for sequence */ bool numlock; /* lock numbers in keyboard */ bool *tabs; } Term; @@ -367,6 +380,8 @@ static void tsetmode(bool, bool, int *, int); static void tfulldirt(void); static void techo(char *, int); static long tdefcolor(int *, int *, int); +static void tselcs(void); +static void tdeftran(char); static inline bool match(uint, uint); static void ttynew(void); static void ttyread(void); @@ -1369,6 +1384,8 @@ treset(void) { term.top = 0; term.bot = term.row - 1; term.mode = MODE_WRAP; + memset(term.trantbl, sizeof(term.trantbl), CS_USA); + term.charset = 0; tclearregion(0, 0, term.col-1, term.row-1); tmoveto(0, 0); @@ -2259,6 +2276,33 @@ techo(char *buf, int len) { tputc(buf, len); } +void +tdeftran(char ascii) { + char c, (*bp)[2]; + static char tbl[][2] = { + {'0', CS_GRAPHIC0}, {'1', CS_GRAPHIC1}, {'A', CS_UK}, + {'B', CS_USA}, {'<', CS_MULTI}, {'K', CS_GER}, + {'5', CS_FIN}, {'C', CS_FIN}, + {0, 0} + }; + + for (bp = &tbl[0]; (c = (*bp)[0]) && c != ascii; ++bp) + /* nothing */; + + if (c == 0) + fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii); + else + term.trantbl[term.icharset] = (*bp)[1]; +} + +void +tselcs(void) { + if (term.trantbl[term.charset] == CS_GRAPHIC0) + term.c.attr.mode |= ATTR_GFX; + else + term.c.attr.mode &= ~ATTR_GFX; +} + void tputc(char *c, int len) { uchar ascii = *c; @@ -2351,13 +2395,12 @@ tputc(char *c, int len) { term.esc = ESC_START; return; case '\016': /* SO */ + term.charset = 0; + tselcs(); + return; case '\017': /* SI */ - /* - * Different charsets are hard to handle. Applications - * should use the right alt charset escapes for the - * only reason they still exist: line drawing. The - * rest is incompatible history st should not support. - */ + term.charset = 1; + tselcs(); return; case '\032': /* SUB */ case '\030': /* CAN */ @@ -2385,22 +2428,8 @@ tputc(char *c, int len) { if(ascii == '\\') strhandle(); } else if(term.esc & ESC_ALTCHARSET) { - switch(ascii) { - case '0': /* Line drawing set */ - term.c.attr.mode |= ATTR_GFX; - break; - case 'B': /* USASCII */ - term.c.attr.mode &= ~ATTR_GFX; - break; - case 'A': /* UK (IGNORED) */ - case '<': /* multinational charset (IGNORED) */ - case '5': /* Finnish (IGNORED) */ - case 'C': /* Finnish (IGNORED) */ - case 'K': /* German (IGNORED) */ - break; - default: - fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii); - } + tdeftran(ascii); + tselcs(); term.esc = 0; } else if(term.esc & ESC_TEST) { if(ascii == '8') { /* DEC screen alignment test. */ @@ -2431,13 +2460,12 @@ tputc(char *c, int len) { term.esc |= ESC_STR; break; case '(': /* set primary charset G0 */ + case ')': /* set secondary charset G1 */ + case '*': /* set tertiary charset G2 */ + case '+': /* set quaternary charset G3 */ + term.icharset = ascii - '('; term.esc |= ESC_ALTCHARSET; break; - case ')': /* set secondary charset G1 (IGNORED) */ - case '*': /* set tertiary charset G2 (IGNORED) */ - case '+': /* set quaternary charset G3 (IGNORED) */ - term.esc = 0; - break; case 'D': /* IND -- Linefeed */ if(term.c.y == term.bot) { tscrollup(term.top, 1); -- 2.20.1 From 02ae3ce6fdc178ca6eb9b10b6447bb56a6513a27 Mon Sep 17 00:00:00 2001 From: Mark Edgar Date: Sat, 5 Oct 2013 11:45:17 +0200 Subject: [PATCH 06/16] Simplify Mod1 logic in kpress(), eliminating locals and a memcpy. --- st.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/st.c b/st.c index 77ea0c8..331509f 100644 --- a/st.c +++ b/st.c @@ -3563,8 +3563,8 @@ void kpress(XEvent *ev) { XKeyEvent *e = &ev->xkey; KeySym ksym; - char xstr[31], buf[32], *customkey, *cp = buf; - int len, ret; + char buf[32], *customkey; + int len; long c; Status status; Shortcut *bp; @@ -3572,7 +3572,7 @@ kpress(XEvent *ev) { if(IS_SET(MODE_KBDLOCK)) return; - len = XmbLookupString(xw.xic, e, xstr, sizeof(xstr), &ksym, &status); + len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status); e->state &= ~Mod2Mask; /* 1. shortcuts */ for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { @@ -3586,26 +3586,23 @@ kpress(XEvent *ev) { if((customkey = kmap(ksym, e->state))) { len = strlen(customkey); memcpy(buf, customkey, len); - /* 3. hardcoded (overrides X lookup) */ + /* 3. composed string from input method */ } else { if(len == 0) return; if(len == 1 && e->state & Mod1Mask) { if(IS_SET(MODE_8BIT)) { - if(*xstr < 0177) { - c = *xstr | 0x80; - ret = utf8encode(&c, cp); - cp += ret; - len = 0; + if(*buf < 0177) { + c = *buf | 0x80; + len = utf8encode(&c, buf); } } else { - *cp++ = '\033'; + buf[1] = buf[0]; + buf[0] = '\033'; + len = 2; } } - - memcpy(cp, xstr, len); - len = cp - buf + len; } ttywrite(buf, len); -- 2.20.1 From 939e149544e4da958c333f3b6d00991d459c2e34 Mon Sep 17 00:00:00 2001 From: Mark Edgar Date: Sat, 5 Oct 2013 11:45:44 +0200 Subject: [PATCH 07/16] Avoid buffer overrun in kpress() and remove limit on shortcut strings. --- st.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/st.c b/st.c index 331509f..16bf68b 100644 --- a/st.c +++ b/st.c @@ -264,7 +264,7 @@ typedef struct { typedef struct { KeySym k; uint mask; - char s[ESC_BUF_SIZ]; + char *s; /* three valued logic variables: 0 indifferent, 1 on, -1 off */ signed char appkey; /* application keypad */ signed char appcursor; /* application cursor */ @@ -3585,26 +3585,27 @@ kpress(XEvent *ev) { /* 2. custom keys from config.h */ if((customkey = kmap(ksym, e->state))) { len = strlen(customkey); - memcpy(buf, customkey, len); - /* 3. composed string from input method */ - } else { - if(len == 0) - return; + ttywrite(customkey, len); + if(IS_SET(MODE_ECHO)) + techo(customkey, len); + return; + } - if(len == 1 && e->state & Mod1Mask) { - if(IS_SET(MODE_8BIT)) { - if(*buf < 0177) { - c = *buf | 0x80; - len = utf8encode(&c, buf); - } - } else { - buf[1] = buf[0]; - buf[0] = '\033'; - len = 2; + /* 3. composed string from input method */ + if(len == 0) + return; + if(len == 1 && e->state & Mod1Mask) { + if(IS_SET(MODE_8BIT)) { + if(*buf < 0177) { + c = *buf | 0x80; + len = utf8encode(&c, buf); } + } else { + buf[1] = buf[0]; + buf[0] = '\033'; + len = 2; } } - ttywrite(buf, len); if(IS_SET(MODE_ECHO)) techo(buf, len); -- 2.20.1 From 8e577322a3a55abf2f8226218ec87a7eec7fc3b1 Mon Sep 17 00:00:00 2001 From: Mark Edgar Date: Sat, 5 Oct 2013 11:49:35 +0200 Subject: [PATCH 08/16] New ttysend() function calls ttywrite() and techo(). Honor MODE_ECHO when pasting in selnotify(). --- st.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/st.c b/st.c index 16bf68b..9df6707 100644 --- a/st.c +++ b/st.c @@ -386,6 +386,7 @@ static inline bool match(uint, uint); static void ttynew(void); static void ttyread(void); static void ttyresize(void); +static void ttysend(char *, size_t); static void ttywrite(const char *, size_t); static void xdraws(char *, Glyph, int, int, int, int); @@ -893,9 +894,7 @@ bpress(XEvent *e) { for(mk = mshortcuts; mk < mshortcuts + LEN(mshortcuts); mk++) { if(e->xbutton.button == mk->b && match(mk->mask, e->xbutton.state)) { - ttywrite(mk->s, strlen(mk->s)); - if(IS_SET(MODE_ECHO)) - techo(mk->s, strlen(mk->s)); + ttysend(mk->s, strlen(mk->s)); return; } } @@ -1031,7 +1030,7 @@ selnotify(XEvent *e) { if(IS_SET(MODE_BRCKTPASTE)) ttywrite("\033[200~", 6); - ttywrite((const char *)data, nitems * format / 8); + ttysend((char *)data, nitems * format / 8); if(IS_SET(MODE_BRCKTPASTE)) ttywrite("\033[201~", 6); XFree(data); @@ -1299,6 +1298,13 @@ ttywrite(const char *s, size_t n) { die("write error on tty: %s\n", SERRNO); } +void +ttysend(char *s, size_t n) { + ttywrite(s, n); + if(IS_SET(MODE_ECHO)) + techo(s, n); +} + void ttyresize(void) { struct winsize w; @@ -3584,10 +3590,7 @@ kpress(XEvent *ev) { /* 2. custom keys from config.h */ if((customkey = kmap(ksym, e->state))) { - len = strlen(customkey); - ttywrite(customkey, len); - if(IS_SET(MODE_ECHO)) - techo(customkey, len); + ttysend(customkey, strlen(customkey)); return; } @@ -3606,9 +3609,7 @@ kpress(XEvent *ev) { len = 2; } } - ttywrite(buf, len); - if(IS_SET(MODE_ECHO)) - techo(buf, len); + ttysend(buf, len); } -- 2.20.1 From 0f6942cdf6f8220f1ecd06e4b398e95c43833d44 Mon Sep 17 00:00:00 2001 From: Mark Edgar Date: Sun, 6 Oct 2013 12:19:12 +0200 Subject: [PATCH 09/16] Avoid buffer overrun in bpress() Use correct type for Mousekey.b (XButtonEvent.button). --- st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index 9df6707..50b58a7 100644 --- a/st.c +++ b/st.c @@ -256,9 +256,9 @@ typedef struct { } XWindow; typedef struct { - int b; + uint b; uint mask; - char s[ESC_BUF_SIZ]; + char *s; } Mousekey; typedef struct { -- 2.20.1 From 297c886b72f4e9093973aaa14b66d392f6196634 Mon Sep 17 00:00:00 2001 From: Mark Edgar Date: Sun, 22 Sep 2013 00:07:49 +0200 Subject: [PATCH 10/16] Ignore numlock (Mod2Mask) for button events too. Conflicts: config.def.h st.c --- config.def.h | 6 +++--- st.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index def6c9e..2a7e098 100644 --- a/config.def.h +++ b/config.def.h @@ -146,10 +146,10 @@ static Shortcut shortcuts[] = { static KeySym mappedkeys[] = { -1 }; /* - * Which bits of the state should be ignored. By default the state bit for the - * keyboard layout (XK_SWITCH_MOD) is ignored. + * State bits to ignore when matching key or button events. By default, + * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored. */ -uint ignoremod = XK_SWITCH_MOD; +static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; /* key, mask, output, keypad, cursor, crlf */ static Key key[] = { diff --git a/st.c b/st.c index 50b58a7..12e1e1f 100644 --- a/st.c +++ b/st.c @@ -3579,7 +3579,6 @@ kpress(XEvent *ev) { return; len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status); - e->state &= ~Mod2Mask; /* 1. shortcuts */ for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { if(ksym == bp->keysym && match(bp->mod, e->state)) { -- 2.20.1 From 489982d4b8442af25a380f8c22be542055cda81f Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 19 Jun 2013 21:24:01 +0100 Subject: [PATCH 11/16] Fixed lock up when system time jumps backwards Signed-off-by: Christoph Lohmann <20h@r-36.net> --- st.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index 50b58a7..d0a6218 100644 --- a/st.c +++ b/st.c @@ -3687,6 +3687,8 @@ run(void) { gettimeofday(&last, NULL); for(xev = actionfps;;) { + long deltatime; + FD_ZERO(&rfd); FD_SET(cmdfd, &rfd); FD_SET(xfd, &rfd); @@ -3720,8 +3722,9 @@ run(void) { gettimeofday(&lastblink, NULL); dodraw = 1; } - if(TIMEDIFF(now, last) \ - > (xev? (1000/xfps) : (1000/actionfps))) { + deltatime = TIMEDIFF(now, last); + if(deltatime > (xev? (1000/xfps) : (1000/actionfps)) + || deltatime < 0) { dodraw = 1; last = now; } -- 2.20.1 From 1fa27b93f9a78ee78a35a5449bb8c4d0c3ef0f1b Mon Sep 17 00:00:00 2001 From: Mark Edgar Date: Sat, 19 Oct 2013 14:56:40 +0200 Subject: [PATCH 12/16] Simplify logic in match(). --- st.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/st.c b/st.c index 8cfa2f7..da2ce3f 100644 --- a/st.c +++ b/st.c @@ -3501,15 +3501,7 @@ focus(XEvent *ev) { static inline bool match(uint mask, uint state) { - state &= ~ignoremod; - - if(mask == XK_NO_MOD && state) - return false; - if(mask != XK_ANY_MOD && mask != XK_NO_MOD && !state) - return false; - if(mask == XK_ANY_MOD) - return true; - return state == mask; + return mask == XK_ANY_MOD || mask == (state & ~ignoremod); } void -- 2.20.1 From 7263820759aa914b27ab3097613bdf22432ed736 Mon Sep 17 00:00:00 2001 From: Mark Edgar Date: Sat, 19 Oct 2013 15:13:13 +0200 Subject: [PATCH 13/16] Simplify logic in kmap(). --- st.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/st.c b/st.c index da2ce3f..fda7044 100644 --- a/st.c +++ b/st.c @@ -3531,25 +3531,16 @@ kmap(KeySym k, uint state) { if(!match(kp->mask, state)) continue; - if(kp->appkey > 0) { - if(!IS_SET(MODE_APPKEYPAD)) - continue; - if(term.numlock && kp->appkey == 2) - continue; - } else if(kp->appkey < 0 && IS_SET(MODE_APPKEYPAD)) { + if(IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0) + continue; + if(term.numlock && kp->appkey == 2) continue; - } - if((kp->appcursor < 0 && IS_SET(MODE_APPCURSOR)) || - (kp->appcursor > 0 - && !IS_SET(MODE_APPCURSOR))) { + if(IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0) continue; - } - if((kp->crlf < 0 && IS_SET(MODE_CRLF)) || - (kp->crlf > 0 && !IS_SET(MODE_CRLF))) { + if(IS_SET(MODE_CRLF) ? kp->crlf < 0 : kp->crlf > 0) continue; - } return kp->s; } -- 2.20.1 From 4435e0ee6791136e641d58ce6cf00f8665fe3065 Mon Sep 17 00:00:00 2001 From: "Carlos J. Torres" Date: Fri, 22 Nov 2013 10:45:48 -0500 Subject: [PATCH 14/16] add _NET_WM_NAME --- st.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/st.c b/st.c index fda7044..ee8dc94 100644 --- a/st.c +++ b/st.c @@ -239,7 +239,7 @@ typedef struct { Colourmap cmap; Window win; Drawable buf; - Atom xembed, wmdeletewin; + Atom xembed, wmdeletewin, netwmname; XIM xim; XIC xic; Draw draw; @@ -3023,6 +3023,7 @@ xinit(void) { xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); + xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False); XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1); xresettitle(); @@ -3355,6 +3356,7 @@ xsettitle(char *p) { Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, &prop); XSetWMName(xw.dpy, xw.win, &prop); + XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname); XFree(prop.value); } -- 2.20.1 From 1fe0a5f39a8755da4cd16e92f2ea00676d9ee3ca Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sun, 24 Nov 2013 10:20:45 +0100 Subject: [PATCH 15/16] Use int instead of long for color This patch replaces long by int32_t. It saves some memory on 64bit systems. --- st.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/st.c b/st.c index ee8dc94..fb084b1 100644 --- a/st.c +++ b/st.c @@ -180,8 +180,8 @@ typedef unsigned short ushort; typedef struct { char c[UTF_SIZ]; /* character code */ ushort mode; /* attribute flags */ - ulong fg; /* foreground */ - ulong bg; /* background */ + uint32_t fg; /* foreground */ + uint32_t bg; /* background */ } Glyph; typedef Glyph *Line; @@ -379,7 +379,7 @@ static void tsetdirtattr(int); static void tsetmode(bool, bool, int *, int); static void tfulldirt(void); static void techo(char *, int); -static long tdefcolor(int *, int *, int); +static uint32_t tdefcolor(int *, int *, int); static void tselcs(void); static void tdeftran(char); static inline bool match(uint, uint); @@ -1666,9 +1666,9 @@ tdeleteline(int n) { tscrollup(term.c.y, n); } -long +uint32_t tdefcolor(int *attr, int *npar, int l) { - long idx = -1; + int32_t idx = -1; uint r, g, b; switch (attr[*npar + 1]) { @@ -1717,7 +1717,7 @@ tdefcolor(int *attr, int *npar, int l) { void tsetattr(int *attr, int l) { int i; - long idx; + int32_t idx; for(i = 0; i < l; i++) { switch(attr[i]) { -- 2.20.1 From 53474391bcf2122921d27356a70e6da3c78d058e Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Mon, 25 Nov 2013 14:09:53 +0100 Subject: [PATCH 16/16] Fix stupid bug in tdefcolor returning -1 in unsigned function k0ga misktook applying patch of others. Sorry guys!!!! --- st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index fb084b1..8f1b8d8 100644 --- a/st.c +++ b/st.c @@ -379,7 +379,7 @@ static void tsetdirtattr(int); static void tsetmode(bool, bool, int *, int); static void tfulldirt(void); static void techo(char *, int); -static uint32_t tdefcolor(int *, int *, int); +static int32_t tdefcolor(int *, int *, int); static void tselcs(void); static void tdeftran(char); static inline bool match(uint, uint); @@ -1666,7 +1666,7 @@ tdeleteline(int n) { tscrollup(term.c.y, n); } -uint32_t +int32_t tdefcolor(int *attr, int *npar, int l) { int32_t idx = -1; uint r, g, b; -- 2.20.1