From 1b6c6535c10172facb350f4b8fef442f7f8ddc5a Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 23 Feb 2013 21:17:25 +0100 Subject: [PATCH 01/16] Replace parse_int with atoi(). --- st.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/st.c b/st.c index c25f24c..c6a840d 100644 --- a/st.c +++ b/st.c @@ -302,7 +302,6 @@ static void execsh(void); static void sigchld(int); static void run(void); -static inline int parse_int(char *); static void csidump(void); static void csihandle(void); static void csiparse(void); @@ -941,7 +940,7 @@ brelease(XEvent *e) { void bmotion(XEvent *e) { - int oldey, oldex; + int oldey, oldex, oldsby, oldsey; if(IS_SET(MODE_MOUSE)) { mousereport(e); @@ -953,10 +952,12 @@ bmotion(XEvent *e) { oldey = sel.ey; oldex = sel.ex; + oldsby = sel.b.y; + oldsey = sel.e.y; getbuttoninfo(e); if(oldey != sel.ey || oldex != sel.ex) { - tsetdirt(sel.b.y, sel.e.y); + tsetdirt(MIN(sel.b.y, oldsby), MAX(sel.e.y, oldsey)); } } @@ -1857,22 +1858,6 @@ csireset(void) { memset(&csiescseq, 0, sizeof(csiescseq)); } -inline int -parse_int(char *s) { - int x = 0; - char c; - while(isdigit(c = *s)) { - if((INT_MAX - c + '0') / 10 >= x) { - x = x * 10 + c - '0'; - } else - return -1; - s++; - } - if(*s != '\0') - return -1; - return x; -} - void strhandle(void) { char *p = NULL; @@ -1887,7 +1872,7 @@ strhandle(void) { switch(strescseq.type) { case ']': /* OSC -- Operating System Command */ - switch(i = parse_int(strescseq.args[0])) { + switch(i = atoi(strescseq.args[0])) { case 0: case 1: case 2: @@ -1903,10 +1888,10 @@ strhandle(void) { p = strescseq.args[2]; /* fall through */ case 104: /* color reset, here p = NULL */ - j = (narg > 1) ? parse_int(strescseq.args[1]) : -1; - if (!xsetcolorname(j, p)) + j = (narg > 1) ? atoi(strescseq.args[1]) : -1; + if (!xsetcolorname(j, p)) { fprintf(stderr, "erresc: invalid color %s\n", p); - else { + } else { redraw(0); /* TODO if defaultbg color is changed, borders are dirty */ } break; -- 2.20.1 From efaf1c2a94ed9193c04c3a67f374d31f988b0e9a Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 23 Feb 2013 21:20:21 +0100 Subject: [PATCH 02/16] Add umlaut support for title change. Thanks Alexander Sedov ! --- TODO | 1 - st.c | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 2f42720..67615f8 100644 --- a/TODO +++ b/TODO @@ -18,7 +18,6 @@ bugs * fix shift up/down (shift selection in emacs) * fix selection paste for xatom STRING -* fix umlaut handling in settitle * fix rows and column definition in fixed geometry * fix -e handling * remove DEC test sequence when appropriate diff --git a/st.c b/st.c index c6a840d..6117c92 100644 --- a/st.c +++ b/st.c @@ -1861,12 +1861,9 @@ csireset(void) { void strhandle(void) { char *p = NULL; - int i, j; - int narg; + int i, j, narg; + XTextProperty prop; - /* - * TODO: make this being useful in case of color palette change. - */ strparse(); narg = strescseq.narg; @@ -1876,11 +1873,12 @@ strhandle(void) { case 0: case 1: case 2: - /* - * TODO: Handle special chars in string, like umlauts. - */ - if(narg > 1) - XStoreName(xw.dpy, xw.win, strescseq.args[2]); + if(narg > 1) { + p += 2; + Xutf8TextListToTextProperty(xw.dpy, &p, 1, + XUTF8StringStyle, &prop); + XSetWMName(xw.dpy, xw.win, &prop); + } break; case 4: /* color set */ if(narg < 3) @@ -1902,7 +1900,10 @@ strhandle(void) { } break; case 'k': /* old title set compatibility */ - XStoreName(xw.dpy, xw.win, strescseq.buf); + p += 1; + Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, + &prop); + XSetWMName(xw.dpy, xw.win, &prop); break; case 'P': /* DSC -- Device Control String */ case '_': /* APC -- Application Program Command */ -- 2.20.1 From e40d8da194cb02b400b09d2c8642f701c5c16821 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 23 Feb 2013 21:44:06 +0100 Subject: [PATCH 03/16] Removing dbe and introducing umlauts to titles. Thanks Alexander Sedov for the title patch! --- st.c | 92 ++++++++++++++++++++++++++---------------------------------- 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/st.c b/st.c index 6117c92..2ebb15b 100644 --- a/st.c +++ b/st.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -351,6 +350,7 @@ static void xloadcols(void); static int xsetcolorname(int, const char *); static int xloadfont(Font *, FcPattern *); static void xloadfonts(char *, int); +static void xsettitle(char *); static void xresettitle(void); static void xseturgency(int); static void xsetsel(char*); @@ -423,8 +423,6 @@ static char *opt_embed = NULL; static char *opt_class = NULL; static char *opt_font = NULL; -bool usedbe = False; - static char *usedfont = NULL; static int usedfontsize = 0; @@ -1862,7 +1860,6 @@ void strhandle(void) { char *p = NULL; int i, j, narg; - XTextProperty prop; strparse(); narg = strescseq.narg; @@ -1873,12 +1870,8 @@ strhandle(void) { case 0: case 1: case 2: - if(narg > 1) { - p += 2; - Xutf8TextListToTextProperty(xw.dpy, &p, 1, - XUTF8StringStyle, &prop); - XSetWMName(xw.dpy, xw.win, &prop); - } + if(narg > 1) + xsettitle(strescseq.args[1]); break; case 4: /* color set */ if(narg < 3) @@ -1890,7 +1883,11 @@ strhandle(void) { if (!xsetcolorname(j, p)) { fprintf(stderr, "erresc: invalid color %s\n", p); } else { - redraw(0); /* TODO if defaultbg color is changed, borders are dirty */ + /* + * TODO if defaultbg color is changed, borders + * are dirty + */ + redraw(0); } break; default: @@ -1900,10 +1897,7 @@ strhandle(void) { } break; case 'k': /* old title set compatibility */ - p += 1; - Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, - &prop); - XSetWMName(xw.dpy, xw.win, &prop); + xsettitle(strescseq.args[0]); break; case 'P': /* DSC -- Device Control String */ case '_': /* APC -- Application Program Command */ @@ -2338,13 +2332,11 @@ xresize(int col, int row) { xw.tw = MAX(1, col * xw.cw); xw.th = MAX(1, row * xw.ch); - if(!usedbe) { - XFreePixmap(xw.dpy, xw.buf); - xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, - DefaultDepth(xw.dpy, xw.scr)); - XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel); - XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); - } + XFreePixmap(xw.dpy, xw.buf); + xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, + DefaultDepth(xw.dpy, xw.scr)); + XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel); + XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); XftDrawChange(xw.draw, xw.buf); } @@ -2606,7 +2598,7 @@ xinit(void) { XGCValues gcvalues; Cursor cursor; Window parent; - int sw, sh, major, minor; + int sw, sh; if(!(xw.dpy = XOpenDisplay(NULL))) die("Can't open display\n"); @@ -2661,26 +2653,14 @@ xinit(void) { | CWColormap, &attrs); - /* double buffering */ - /* - if(XdbeQueryExtension(xw.dpy, &major, &minor)) { - xw.buf = XdbeAllocateBackBufferName(xw.dpy, xw.win, - XdbeBackground); - usedbe = True; - } else { - */ - memset(&gcvalues, 0, sizeof(gcvalues)); - gcvalues.graphics_exposures = False; - dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, - &gcvalues); - xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, - DefaultDepth(xw.dpy, xw.scr)); - XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); - XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); - //xw.buf = xw.win; - /* - } - */ + memset(&gcvalues, 0, sizeof(gcvalues)); + gcvalues.graphics_exposures = False; + dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, + &gcvalues); + xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, + DefaultDepth(xw.dpy, xw.scr)); + XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); + XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); /* Xft rendering context */ xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); @@ -2971,9 +2951,19 @@ xdrawcursor(void) { } } + +void +xsettitle(char *p) { + XTextProperty prop; + + Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, + &prop); + XSetWMName(xw.dpy, xw.win, &prop); +} + void xresettitle(void) { - XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st"); + xsettitle(opt_title ? opt_title : "st"); } void @@ -2991,16 +2981,12 @@ redraw(int timeout) { void draw(void) { - XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}}; - drawregion(0, 0, term.col, term.row); - if(usedbe) { - XdbeSwapBuffers(xw.dpy, swpinfo, 1); - } else { - XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w, - xw.h, 0, 0); - XSetForeground(xw.dpy, dc.gc, dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg].pixel); - } + XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w, + xw.h, 0, 0); + XSetForeground(xw.dpy, dc.gc, + dc.col[IS_SET(MODE_REVERSE)? + defaultfg : defaultbg].pixel); } void -- 2.20.1 From be7c6d7fb09ff50127332060d771b94a3bc8e44c Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 23 Feb 2013 21:50:13 +0100 Subject: [PATCH 04/16] Add insert for the primary clipboard to MOD + Shift + Ins. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Thanks Mantas Mikulėnas for the patch! --- config.def.h | 1 + st.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index a31a235..34884c0 100644 --- a/config.def.h +++ b/config.def.h @@ -70,6 +70,7 @@ static Shortcut shortcuts[] = { { MODKEY|ShiftMask, XK_Prior, xzoom, {.i = +1} }, { MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} }, + { MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} }, { MODKEY, XK_Num_Lock, numlock, {.i = 0} }, }; diff --git a/st.c b/st.c index 2ebb15b..afa6813 100644 --- a/st.c +++ b/st.c @@ -266,9 +266,10 @@ typedef struct { } Shortcut; /* function definitions used in config.h */ -static void xzoom(const Arg *); -static void selpaste(const Arg *); +static void clippaste(const Arg *); static void numlock(const Arg *); +static void selpaste(const Arg *); +static void xzoom(const Arg *); /* Config.h for applying patches and the configuration. */ #include "config.h" @@ -830,7 +831,17 @@ selpaste(const Arg *dummy) { xw.win, CurrentTime); } -void selclear(XEvent *e) { +void +clippaste(const Arg *dummy) { + Atom clipboard; + + clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); + XConvertSelection(xw.dpy, clipboard, sel.xtarget, XA_PRIMARY, + xw.win, CurrentTime); +} + +void +selclear(XEvent *e) { if(sel.bx == -1) return; sel.bx = -1; -- 2.20.1 From 37863356b00cd41c24e10243121649473b98824f Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Mon, 25 Feb 2013 13:23:56 +0100 Subject: [PATCH 05/16] Using strtol with overflow checking. --- st.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/st.c b/st.c index afa6813..23c4caf 100644 --- a/st.c +++ b/st.c @@ -1296,17 +1296,22 @@ tnewline(int first_col) { void csiparse(void) { /* int noarg = 1; */ - char *p = csiescseq.buf; + char *p = csiescseq.buf, *np; + long int v; csiescseq.narg = 0; if(*p == '?') csiescseq.priv = 1, p++; while(p < csiescseq.buf+csiescseq.len) { - while(isdigit(*p)) { - csiescseq.arg[csiescseq.narg] *= 10; - csiescseq.arg[csiescseq.narg] += *p++ - '0'/*, noarg = 0 */; - } + np = NULL; + v = strtol(p, &np, 10); + if(v == LONG_MAX || v == LONG_MIN) + v = -1; + csiescseq.arg[csiescseq.narg] = v; + if(np != NULL) + p = np; + if(*p == ';' && csiescseq.narg+1 < ESC_ARG_SIZ) { csiescseq.narg++, p++; } else { @@ -2116,7 +2121,8 @@ tputc(char *c, int len) { if(BETWEEN(ascii, 0x40, 0x7E) || csiescseq.len >= ESC_BUF_SIZ) { term.esc = 0; - csiparse(), csihandle(); + csiparse(); + csihandle(); } } else if(term.esc & ESC_STR_END) { term.esc = 0; -- 2.20.1 From 7cb0d95509d1b2837e4fa7d131f497800b20d22c Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Mon, 25 Feb 2013 13:36:40 +0100 Subject: [PATCH 06/16] Using strtok_r for the string parsing. --- st.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/st.c b/st.c index 23c4caf..7ddce0c 100644 --- a/st.c +++ b/st.c @@ -1300,8 +1300,10 @@ csiparse(void) { long int v; csiescseq.narg = 0; - if(*p == '?') - csiescseq.priv = 1, p++; + if(*p == '?') { + csiescseq.priv = 1; + p++; + } while(p < csiescseq.buf+csiescseq.len) { np = NULL; @@ -1928,23 +1930,17 @@ strhandle(void) { void strparse(void) { - /* - * TODO: Implement parsing like for CSI when required. - * Format: ESC type cmd ';' arg0 [';' argn] ESC \ - */ - int narg = 0; - char *start = strescseq.buf, *end = start + strescseq.len; - strescseq.args[0] = start; - while(start < end && narg < LEN(strescseq.args)) { - start = memchr(start, ';', end - start); - if(!start) - break; - *start++ = '\0'; - if(start < end) { - strescseq.args[++narg] = start; - } + char *p = strescseq.buf, *np, *sp; + + strescseq.narg = 0; + np = strtok_r(strescseq.buf, ";", &sp); + while(p < strescseq.buf+strescseq.len && np != NULL) { + strescseq.args[strescseq.narg++] = p; + + np = strtok_r(NULL, ";", &sp); + if(np != NULL) + p = np; } - strescseq.narg = narg + 1; } void -- 2.20.1 From 7d32471efffa825f52d24930b5ee617105f9c83e Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 26 Feb 2013 18:19:44 +0100 Subject: [PATCH 07/16] Fixing bugs in the strtol and strtok_r replacements. Thanks "Roberto E. Vargas Caballero" for the comments! --- st.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/st.c b/st.c index 7ddce0c..9f5793c 100644 --- a/st.c +++ b/st.c @@ -1306,23 +1306,18 @@ csiparse(void) { } while(p < csiescseq.buf+csiescseq.len) { - np = NULL; v = strtol(p, &np, 10); + if(np == p) + break; if(v == LONG_MAX || v == LONG_MIN) v = -1; - csiescseq.arg[csiescseq.narg] = v; - if(np != NULL) - p = np; - - if(*p == ';' && csiescseq.narg+1 < ESC_ARG_SIZ) { - csiescseq.narg++, p++; - } else { - csiescseq.mode = *p; - csiescseq.narg++; - - return; - } + csiescseq.arg[csiescseq.narg++] = v; + p = np; + if(*p != ';' || csiescseq.narg == ESC_ARG_SIZ) + break; + p++; } + csiescseq.mode = *p; } /* for absolute user moves, when decom is set */ @@ -1930,16 +1925,13 @@ strhandle(void) { void strparse(void) { - char *p = strescseq.buf, *np, *sp; + char *p = strescseq.buf, *sp; - strescseq.narg = 0; - np = strtok_r(strescseq.buf, ";", &sp); - while(p < strescseq.buf+strescseq.len && np != NULL) { + strescseq.buf[strescseq.len] = '\0'; + for(p = strtok_r(p, ";", &sp); p; p = strtok_r(NULL, ";", &sp)) { + if(strescseq.narg == STR_ARG_SIZ) + return; strescseq.args[strescseq.narg++] = p; - - np = strtok_r(NULL, ";", &sp); - if(np != NULL) - p = np; } } @@ -1951,7 +1943,9 @@ strdump(void) { printf("ESC%c", strescseq.type); for(i = 0; i < strescseq.len; i++) { c = strescseq.buf[i] & 0xff; - if(isprint(c)) { + if(c == '\0') { + return; + } else if(isprint(c)) { putchar(c); } else if(c == '\n') { printf("(\\n)"); @@ -2039,7 +2033,7 @@ tputc(char *c, int len) { strhandle(); break; default: - if(strescseq.len + len < sizeof(strescseq.buf)) { + if(strescseq.len + len < sizeof(strescseq.buf) - 1) { memmove(&strescseq.buf[strescseq.len], c, len); strescseq.len += len; } else { -- 2.20.1 From 1aa26b4ecd68e6071d36e9103aa9c21711bbf6ea Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 26 Feb 2013 19:07:23 +0100 Subject: [PATCH 08/16] Fixing a bug while parsing empty arguments in csiparse. --- st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index 9f5793c..83fdc6d 100644 --- a/st.c +++ b/st.c @@ -1295,7 +1295,6 @@ tnewline(int first_col) { void csiparse(void) { - /* int noarg = 1; */ char *p = csiescseq.buf, *np; long int v; @@ -1306,9 +1305,10 @@ csiparse(void) { } while(p < csiescseq.buf+csiescseq.len) { + np = NULL; v = strtol(p, &np, 10); if(np == p) - break; + v = 0; if(v == LONG_MAX || v == LONG_MIN) v = -1; csiescseq.arg[csiescseq.narg++] = v; -- 2.20.1 From 1c1621da699adae49a4344b145f856dacb57270c Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 26 Feb 2013 19:08:51 +0100 Subject: [PATCH 09/16] Changing the way how paste is handled, just for the nano people. --- st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.c b/st.c index 83fdc6d..8b5ba64 100644 --- a/st.c +++ b/st.c @@ -796,7 +796,7 @@ selcopy(void) { } /* \n at the end of every selected line except for the last one */ if(is_selected && y < sel.e.y) - *ptr++ = '\n'; + *ptr++ = '\r'; } *ptr = 0; } -- 2.20.1 From c6b89f23e7546c30dea42a3c49f99682c5818190 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 26 Feb 2013 21:43:40 +0100 Subject: [PATCH 10/16] Using strsep and fixing null termination in csiparse. Thanks for the hint from Alexander Sedov ! --- config.mk | 2 +- st.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config.mk b/config.mk index ecc5c83..abf25c1 100644 --- a/config.mk +++ b/config.mk @@ -19,7 +19,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil -lXext -lXft \ $(shell pkg-config --libs freetype2) # flags -CPPFLAGS = -DVERSION=\"${VERSION}\" +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_XOPEN_SOURCE=600 CFLAGS += -g -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} LDFLAGS += -g ${LIBS} diff --git a/st.c b/st.c index 8b5ba64..fc9ed70 100644 --- a/st.c +++ b/st.c @@ -1,5 +1,4 @@ /* See LICENSE for licence details. */ -#define _XOPEN_SOURCE 600 #include #include #include @@ -1304,6 +1303,7 @@ csiparse(void) { p++; } + csiescseq.buf[csiescseq.len] = '\0'; while(p < csiescseq.buf+csiescseq.len) { np = NULL; v = strtol(p, &np, 10); @@ -1925,14 +1925,12 @@ strhandle(void) { void strparse(void) { - char *p = strescseq.buf, *sp; + char *p = strescseq.buf; + strescseq.narg = 0; strescseq.buf[strescseq.len] = '\0'; - for(p = strtok_r(p, ";", &sp); p; p = strtok_r(NULL, ";", &sp)) { - if(strescseq.narg == STR_ARG_SIZ) - return; - strescseq.args[strescseq.narg++] = p; - } + while(p && strescseq.narg < STR_ARG_SIZ) + strescseq.args[strescseq.narg++] = strsep(&p, ";"); } void @@ -2109,7 +2107,8 @@ tputc(char *c, int len) { if(term.esc & ESC_CSI) { csiescseq.buf[csiescseq.len++] = ascii; if(BETWEEN(ascii, 0x40, 0x7E) - || csiescseq.len >= ESC_BUF_SIZ) { + || csiescseq.len >= \ + sizeof(csiescseq.buf)-1) { term.esc = 0; csiparse(); csihandle(); -- 2.20.1 From 82494f248d778e1195a9eabfac916ce08c52b6da Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 5 Mar 2013 22:12:11 +0100 Subject: [PATCH 11/16] Making st compile on OS X. --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index abf25c1..4d10df4 100644 --- a/config.mk +++ b/config.mk @@ -20,7 +20,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil -lXext -lXft \ # flags CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_XOPEN_SOURCE=600 -CFLAGS += -g -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} +CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS} LDFLAGS += -g ${LIBS} # compiler and linker -- 2.20.1 From 55adf0aad1d5acf0b9a00e2a9f834cef8b61b3b3 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sun, 10 Mar 2013 21:16:51 +0100 Subject: [PATCH 12/16] Pange seems to use ascent + descent instead of height. Thanks Bobby Powers for noticing this! --- st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.c b/st.c index fc9ed70..0923cec 100644 --- a/st.c +++ b/st.c @@ -2493,7 +2493,7 @@ xloadfont(Font *f, FcPattern *pattern) { f->lbearing = 0; f->rbearing = f->match->max_advance_width; - f->height = f->match->height; + f->height = f->ascent + f->descent; f->width = f->lbearing + f->rbearing; return 0; -- 2.20.1 From 4b17dddb104bd2ac87dd6e334aafd325197c1407 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Wed, 20 Mar 2013 21:19:28 +0100 Subject: [PATCH 13/16] Making rectangular selection work again. People sending me patches against strange revisions and basing on their own revisions make me having to reapply them. Then such errors appear. Thanks Alexander Sedov for noticing this. --- st.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/st.c b/st.c index 0923cec..131cba8 100644 --- a/st.c +++ b/st.c @@ -649,13 +649,10 @@ selected(int x, int y) { if(sel.ey == y && sel.by == y) { bx = MIN(sel.bx, sel.ex); ex = MAX(sel.bx, sel.ex); + return BETWEEN(x, bx, ex); } - return ((sel.b.y < y && y < sel.e.y) - || (y == sel.e.y && x <= sel.e.x)) - || (y == sel.b.y && x >= sel.b.x - && (x <= sel.e.x || sel.b.y != sel.e.y)); switch(sel.type) { case SEL_REGULAR: return ((sel.b.y < y && y < sel.e.y) -- 2.20.1 From a1e3b94b374c269f9d379f40b67b8519a485b8a6 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Fri, 29 Mar 2013 18:39:01 +0100 Subject: [PATCH 14/16] Removing an undefined case. just do regular selections. --- st.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/st.c b/st.c index 131cba8..599685c 100644 --- a/st.c +++ b/st.c @@ -653,16 +653,14 @@ selected(int x, int y) { return BETWEEN(x, bx, ex); } - switch(sel.type) { - case SEL_REGULAR: - return ((sel.b.y < y && y < sel.e.y) - || (y == sel.e.y && x <= sel.e.x)) - || (y == sel.b.y && x >= sel.b.x - && (x <= sel.e.x || sel.b.y != sel.e.y)); - case SEL_RECTANGULAR: + if(sel.type == SEL_RECTANGULAR) { return ((sel.b.y <= y && y <= sel.e.y) && (sel.b.x <= x && x <= sel.e.x)); - }; + } + return ((sel.b.y < y && y < sel.e.y) + || (y == sel.e.y && x <= sel.e.x)) + || (y == sel.b.y && x >= sel.b.x + && (x <= sel.e.x || sel.b.y != sel.e.y)); } void @@ -1254,8 +1252,12 @@ selscroll(int orig, int n) { sel.bx = -1; return; } - switch(sel.type) { - case SEL_REGULAR: + if(sel.type == SEL_RECTANGULAR) { + if(sel.by < term.top) + sel.by = term.top; + if(sel.ey > term.bot) + sel.ey = term.bot; + } else { if(sel.by < term.top) { sel.by = term.top; sel.bx = 0; @@ -1264,14 +1266,7 @@ selscroll(int orig, int n) { sel.ey = term.bot; sel.ex = term.col; } - break; - case SEL_RECTANGULAR: - if(sel.by < term.top) - sel.by = term.top; - if(sel.ey > term.bot) - sel.ey = term.bot; - break; - }; + } sel.b.y = sel.by, sel.b.x = sel.bx; sel.e.y = sel.ey, sel.e.x = sel.ex; } -- 2.20.1 From f876810626773828747f48675a6d1f33dc163662 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Fri, 29 Mar 2013 18:43:32 +0100 Subject: [PATCH 15/16] Adding PgUp and PgDown + Ctrl to config.def.h Thanks stargrave@stargrave.org! --- config.def.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.def.h b/config.def.h index 34884c0..4114f4b 100644 --- a/config.def.h +++ b/config.def.h @@ -215,7 +215,9 @@ static Key key[] = { { XK_End, ShiftMask, "\033[K", -1, 0, 0}, { XK_End, ShiftMask, "\033[1;2F", +1, 0, 0}, { XK_End, XK_ANY_MOD, "\033[4~", 0, 0, 0}, + { XK_Prior, ControlMask, "\033[5;5~", 0, 0, 0}, { XK_Prior, XK_NO_MOD, "\033[5~", 0, 0, 0}, + { XK_Next, ControlMask, "\033[6;5~", 0, 0, 0}, { XK_Next, ShiftMask, "\033[6;2~", 0, 0, 0}, { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0}, { XK_F1, XK_NO_MOD, "\033OP" , 0, 0, 0}, -- 2.20.1 From adde5c6d9dec3a0ab4d78b9d6e70b970ffb33a05 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Fri, 29 Mar 2013 18:45:09 +0100 Subject: [PATCH 16/16] Adding PgUp + Ctrl. Thanks stargrave@stargrave.org! --- config.def.h | 1 + 1 file changed, 1 insertion(+) diff --git a/config.def.h b/config.def.h index 4114f4b..75abefb 100644 --- a/config.def.h +++ b/config.def.h @@ -216,6 +216,7 @@ static Key key[] = { { XK_End, ShiftMask, "\033[1;2F", +1, 0, 0}, { XK_End, XK_ANY_MOD, "\033[4~", 0, 0, 0}, { XK_Prior, ControlMask, "\033[5;5~", 0, 0, 0}, + { XK_Prior, ShiftMask, "\033[5;2~", 0, 0, 0}, { XK_Prior, XK_NO_MOD, "\033[5~", 0, 0, 0}, { XK_Next, ControlMask, "\033[6;5~", 0, 0, 0}, { XK_Next, ShiftMask, "\033[6;2~", 0, 0, 0}, -- 2.20.1