sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 8c62c77d4e6601ebb5a671df138cb9b05d222507
parent ae8088b3e37b58f3e530f69a1e359ee2c386da49
Author: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date:   Tue, 28 Jul 2015 10:52:18 +0200

Cleanup st scrollback patch

- Remove double xrealloc.
- Adopt style to new st style.
- Adopt to current st master.
- Remove unrelated style fixes.

Diffstat:
Mst.suckless.org/patches/st-scrollback.diff | 57++++++++++++++++++++++++++++-----------------------------
1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/st.suckless.org/patches/st-scrollback.diff b/st.suckless.org/patches/st-scrollback.diff @@ -1,5 +1,5 @@ diff --git a/config.def.h b/config.def.h -index e246e3c..ffabf3d 100644 +index 2616dea..f5215b2 100644 --- a/config.def.h +++ b/config.def.h @@ -7,6 +7,7 @@ @@ -7,10 +7,10 @@ index e246e3c..ffabf3d 100644 static char font[] = "Liberation Mono:pixelsize=12:antialias=false:autohint=false"; static int borderpx = 2; +static int histsize = 2000; - static char shell[] = "/bin/sh"; - static char *utmp = NULL; - static char stty_args[] = "stty raw -echo -iexten echonl"; -@@ -128,6 +129,8 @@ static Shortcut shortcuts[] = { + + /* + * What program is execed by st depends of these precedence rules: +@@ -137,6 +138,8 @@ static Shortcut shortcuts[] = { { MODKEY|ShiftMask, XK_C, clipcopy, {.i = 0} }, { MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} }, { MODKEY, XK_Num_Lock, numlock, {.i = 0} }, @@ -20,7 +20,7 @@ index e246e3c..ffabf3d 100644 /* diff --git a/st.c b/st.c -index 64e2cec..9cc71c3 100644 +index 0db3d58..59b671e 100644 --- a/st.c +++ b/st.c @@ -84,6 +84,8 @@ char *argv0; @@ -32,18 +32,16 @@ index 64e2cec..9cc71c3 100644 enum glyph_attribute { -@@ -232,7 +234,10 @@ typedef struct { +@@ -232,6 +234,9 @@ typedef struct { int col; /* nb col */ Line *line; /* screen */ Line *alt; /* alternate screen */ -- int *dirty; /* dirtyness of lines */ + Line *hist; /* history buffer */ + int histi; /* history index */ + int scr; /* scroll back */ -+ int *dirty; /* dirtyness of lines */ + int *dirty; /* dirtyness of lines */ XftGlyphFontSpec *specbuf; /* font spec buffer used for rendering */ TCursor c; /* cursor */ - int top; /* top scroll limit */ @@ -325,6 +330,8 @@ typedef struct { /* function definitions used in config.h */ static void clipcopy(const Arg *); @@ -64,7 +62,7 @@ index 64e2cec..9cc71c3 100644 static void tsetattr(int *, int); static void tsetchar(Rune, Glyph *, int, int); static void tsetscroll(int, int); -@@ -726,10 +733,10 @@ tlinelen(int y) +@@ -727,10 +734,10 @@ tlinelen(int y) { int i = term.col; @@ -77,7 +75,7 @@ index 64e2cec..9cc71c3 100644 --i; return i; -@@ -791,7 +798,7 @@ selsnap(int *x, int *y, int direction) +@@ -792,7 +799,7 @@ selsnap(int *x, int *y, int direction) * Snap around if the word wraps around at the end or * beginning of a line. */ @@ -86,7 +84,7 @@ index 64e2cec..9cc71c3 100644 prevdelim = ISDELIM(prevgp->u); for (;;) { newx = *x + direction; -@@ -806,14 +813,14 @@ selsnap(int *x, int *y, int direction) +@@ -807,14 +814,14 @@ selsnap(int *x, int *y, int direction) yt = *y, xt = *x; else yt = newy, xt = newx; @@ -103,7 +101,7 @@ index 64e2cec..9cc71c3 100644 delim = ISDELIM(gp->u); if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim || (delim && gp->u != prevgp->u))) -@@ -834,14 +841,14 @@ selsnap(int *x, int *y, int direction) +@@ -835,14 +842,14 @@ selsnap(int *x, int *y, int direction) *x = (direction < 0) ? 0 : term.col - 1; if (direction < 0) { for (; *y > 0; *y += direction) { @@ -120,7 +118,7 @@ index 64e2cec..9cc71c3 100644 & ATTR_WRAP)) { break; } -@@ -1004,13 +1011,13 @@ getsel(void) +@@ -1005,13 +1012,13 @@ getsel(void) linelen = tlinelen(y); if (sel.type == SEL_RECTANGULAR) { @@ -156,12 +154,13 @@ index 64e2cec..9cc71c3 100644 /* * Remember that we are using a pty, which might be a modem line. -@@ -1682,13 +1694,51 @@ tswapscreen(void) +@@ -1682,13 +1694,53 @@ tswapscreen(void) } void -tscrolldown(int orig, int n) -+kscrolldown(const Arg* a) { ++kscrolldown(const Arg* a) ++{ + int n = a->i; + + if (n < 0) @@ -178,7 +177,8 @@ index 64e2cec..9cc71c3 100644 +} + +void -+kscrollup(const Arg* a) { ++kscrollup(const Arg* a) ++{ + int n = a->i; + + if (n < 0) @@ -209,7 +209,7 @@ index 64e2cec..9cc71c3 100644 tsetdirt(orig, term.bot-n); tclearregion(0, term.bot-n+1, term.col-1, term.bot); -@@ -1702,13 +1752,20 @@ tscrolldown(int orig, int n) +@@ -1702,13 +1754,20 @@ tscrolldown(int orig, int n) } void @@ -231,7 +231,7 @@ index 64e2cec..9cc71c3 100644 tclearregion(0, orig, term.col-1, orig+n-1); tsetdirt(orig+n, term.bot); -@@ -1757,7 +1814,7 @@ tnewline(int first_col) +@@ -1757,7 +1816,7 @@ tnewline(int first_col) int y = term.c.y; if (y == term.bot) { @@ -240,7 +240,7 @@ index 64e2cec..9cc71c3 100644 } else { y++; } -@@ -1922,14 +1979,14 @@ void +@@ -1922,14 +1981,14 @@ void tinsertblankline(int n) { if (BETWEEN(term.c.y, term.top, term.bot)) @@ -257,7 +257,7 @@ index 64e2cec..9cc71c3 100644 } int32_t -@@ -2363,11 +2420,11 @@ csihandle(void) +@@ -2363,11 +2422,11 @@ csihandle(void) break; case 'S': /* SU -- Scroll <n> line up */ DEFAULT(csiescseq.arg[0], 1); @@ -271,7 +271,7 @@ index 64e2cec..9cc71c3 100644 break; case 'L': /* IL -- Insert <n> blank lines */ DEFAULT(csiescseq.arg[0], 1); -@@ -2837,7 +2894,7 @@ eschandle(uchar ascii) +@@ -2837,7 +2896,7 @@ eschandle(uchar ascii) return 0; case 'D': /* IND -- Linefeed */ if (term.c.y == term.bot) { @@ -280,7 +280,7 @@ index 64e2cec..9cc71c3 100644 } else { tmoveto(term.c.x, term.c.y+1); } -@@ -2850,7 +2907,7 @@ eschandle(uchar ascii) +@@ -2850,7 +2909,7 @@ eschandle(uchar ascii) break; case 'M': /* RI -- Reverse index */ if (term.c.y == term.top) { @@ -289,7 +289,7 @@ index 64e2cec..9cc71c3 100644 } else { tmoveto(term.c.x, term.c.y-1); } -@@ -3013,7 +3070,7 @@ tputc(Rune u) +@@ -3013,7 +3072,7 @@ tputc(Rune u) void tresize(int col, int row) { @@ -298,12 +298,11 @@ index 64e2cec..9cc71c3 100644 int minrow = MIN(row, term.row); int mincol = MIN(col, term.col); int *bp; -@@ -3050,9 +3107,19 @@ tresize(int col, int row) +@@ -3050,9 +3109,18 @@ tresize(int col, int row) /* resize to new height */ term.line = xrealloc(term.line, row * sizeof(Line)); term.alt = xrealloc(term.alt, row * sizeof(Line)); + term.hist = xrealloc(term.hist, histsize * sizeof(Line)); -+ term.hist = xrealloc(term.hist, histsize * sizeof(Line)); term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty)); term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs)); @@ -318,7 +317,7 @@ index 64e2cec..9cc71c3 100644 /* resize each row to new width, zero-pad if needed */ for (i = 0; i < minrow; i++) { term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph)); -@@ -3912,11 +3979,11 @@ drawregion(int x1, int y1, int x2, int y2) +@@ -3912,11 +3980,11 @@ drawregion(int x1, int y1, int x2, int y2) term.dirty[y] = 0; specs = term.specbuf; @@ -332,7 +331,7 @@ index 64e2cec..9cc71c3 100644 if (new.mode == ATTR_WDUMMY) continue; if (ena_sel && selected(x, y)) -@@ -3936,7 +4003,8 @@ drawregion(int x1, int y1, int x2, int y2) +@@ -3936,7 +4004,8 @@ drawregion(int x1, int y1, int x2, int y2) if (i > 0) xdrawglyphfontspecs(specs, base, i, ox, y); }