[wiki] [sites] Cleanup st scrollback patch || Jochen Sprickerhof

From: <git_AT_suckless.org>
Date: Tue, 28 Jul 2015 10:54:29 +0200

commit 8c62c77d4e6601ebb5a671df138cb9b05d222507
Author: Jochen Sprickerhof <git_AT_jochen.sprickerhof.de>
Date: Tue Jul 28 10:52:18 2015 +0200

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

diff --git a/st.suckless.org/patches/st-scrollback.diff b/st.suckless.org/patches/st-scrollback.diff
index 07d222c..8babd37 100644
--- a/st.suckless.org/patches/st-scrollback.diff
+++ b/st.suckless.org/patches/st-scrollback.diff
_AT_@ -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
 _AT_@ -7,6 +7,7 @@
_AT_@ -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";
-_AT_@ -128,6 +129,8 @@ static Shortcut shortcuts[] = {
+
+ /*
+ * What program is execed by st depends of these precedence rules:
+_AT_@ -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} },
_AT_@ -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
 _AT_@ -84,6 +84,8 @@ char *argv0;
_AT_@ -32,18 +32,16 @@ index 64e2cec..9cc71c3 100644
  
  
  enum glyph_attribute {
-_AT_@ -232,7 +234,10 @@ typedef struct {
+_AT_@ -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 */
 _AT_@ -325,6 +330,8 @@ typedef struct {
  /* function definitions used in config.h */
  static void clipcopy(const Arg *);
_AT_@ -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);
-_AT_@ -726,10 +733,10 @@ tlinelen(int y)
+_AT_@ -727,10 +734,10 @@ tlinelen(int y)
  {
          int i = term.col;
  
_AT_@ -77,7 +75,7 @@ index 64e2cec..9cc71c3 100644
                  --i;
  
          return i;
-_AT_@ -791,7 +798,7 @@ selsnap(int *x, int *y, int direction)
+_AT_@ -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.
                   */
_AT_@ -86,7 +84,7 @@ index 64e2cec..9cc71c3 100644
                  prevdelim = ISDELIM(prevgp->u);
                  for (;;) {
                          newx = *x + direction;
-_AT_@ -806,14 +813,14 @@ selsnap(int *x, int *y, int direction)
+_AT_@ -807,14 +814,14 @@ selsnap(int *x, int *y, int direction)
                                          yt = *y, xt = *x;
                                  else
                                          yt = newy, xt = newx;
_AT_@ -103,7 +101,7 @@ index 64e2cec..9cc71c3 100644
                          delim = ISDELIM(gp->u);
                          if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
                                          || (delim && gp->u != prevgp->u)))
-_AT_@ -834,14 +841,14 @@ selsnap(int *x, int *y, int direction)
+_AT_@ -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) {
_AT_@ -120,7 +118,7 @@ index 64e2cec..9cc71c3 100644
                                                  & ATTR_WRAP)) {
                                          break;
                                  }
-_AT_@ -1004,13 +1011,13 @@ getsel(void)
+_AT_@ -1005,13 +1012,13 @@ getsel(void)
                  linelen = tlinelen(y);
  
                  if (sel.type == SEL_RECTANGULAR) {
_AT_@ -156,12 +154,13 @@ index 64e2cec..9cc71c3 100644
  
          /*
           * Remember that we are using a pty, which might be a modem line.
-_AT_@ -1682,13 +1694,51 @@ tswapscreen(void)
+_AT_@ -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)
_AT_@ -178,7 +177,8 @@ index 64e2cec..9cc71c3 100644
 +}
 +
 +void
-+kscrollup(const Arg* a) {
++kscrollup(const Arg* a)
++{
 + int n = a->i;
 +
 + if (n < 0)
_AT_@ -209,7 +209,7 @@ index 64e2cec..9cc71c3 100644
          tsetdirt(orig, term.bot-n);
          tclearregion(0, term.bot-n+1, term.col-1, term.bot);
  
-_AT_@ -1702,13 +1752,20 @@ tscrolldown(int orig, int n)
+_AT_@ -1702,13 +1754,20 @@ tscrolldown(int orig, int n)
  }
  
  void
_AT_@ -231,7 +231,7 @@ index 64e2cec..9cc71c3 100644
          tclearregion(0, orig, term.col-1, orig+n-1);
          tsetdirt(orig+n, term.bot);
  
-_AT_@ -1757,7 +1814,7 @@ tnewline(int first_col)
+_AT_@ -1757,7 +1816,7 @@ tnewline(int first_col)
          int y = term.c.y;
  
          if (y == term.bot) {
_AT_@ -240,7 +240,7 @@ index 64e2cec..9cc71c3 100644
          } else {
                  y++;
          }
-_AT_@ -1922,14 +1979,14 @@ void
+_AT_@ -1922,14 +1981,14 @@ void
  tinsertblankline(int n)
  {
          if (BETWEEN(term.c.y, term.top, term.bot))
_AT_@ -257,7 +257,7 @@ index 64e2cec..9cc71c3 100644
  }
  
  int32_t
-_AT_@ -2363,11 +2420,11 @@ csihandle(void)
+_AT_@ -2363,11 +2422,11 @@ csihandle(void)
                  break;
          case 'S': /* SU -- Scroll <n> line up */
                  DEFAULT(csiescseq.arg[0], 1);
_AT_@ -271,7 +271,7 @@ index 64e2cec..9cc71c3 100644
                  break;
          case 'L': /* IL -- Insert <n> blank lines */
                  DEFAULT(csiescseq.arg[0], 1);
-_AT_@ -2837,7 +2894,7 @@ eschandle(uchar ascii)
+_AT_@ -2837,7 +2896,7 @@ eschandle(uchar ascii)
                  return 0;
          case 'D': /* IND -- Linefeed */
                  if (term.c.y == term.bot) {
_AT_@ -280,7 +280,7 @@ index 64e2cec..9cc71c3 100644
                  } else {
                          tmoveto(term.c.x, term.c.y+1);
                  }
-_AT_@ -2850,7 +2907,7 @@ eschandle(uchar ascii)
+_AT_@ -2850,7 +2909,7 @@ eschandle(uchar ascii)
                  break;
          case 'M': /* RI -- Reverse index */
                  if (term.c.y == term.top) {
_AT_@ -289,7 +289,7 @@ index 64e2cec..9cc71c3 100644
                  } else {
                          tmoveto(term.c.x, term.c.y-1);
                  }
-_AT_@ -3013,7 +3070,7 @@ tputc(Rune u)
+_AT_@ -3013,7 +3072,7 @@ tputc(Rune u)
  void
  tresize(int col, int row)
  {
_AT_@ -298,12 +298,11 @@ index 64e2cec..9cc71c3 100644
          int minrow = MIN(row, term.row);
          int mincol = MIN(col, term.col);
          int *bp;
-_AT_@ -3050,9 +3107,19 @@ tresize(int col, int row)
+_AT_@ -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));
  
_AT_@ -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));
-_AT_@ -3912,11 +3979,11 @@ drawregion(int x1, int y1, int x2, int y2)
+_AT_@ -3912,11 +3980,11 @@ drawregion(int x1, int y1, int x2, int y2)
                  term.dirty[y] = 0;
  
                  specs = term.specbuf;
_AT_@ -332,7 +331,7 @@ index 64e2cec..9cc71c3 100644
                          if (new.mode == ATTR_WDUMMY)
                                  continue;
                          if (ena_sel && selected(x, y))
-_AT_@ -3936,7 +4003,8 @@ drawregion(int x1, int y1, int x2, int y2)
+_AT_@ -3936,7 +4004,8 @@ drawregion(int x1, int y1, int x2, int y2)
                  if (i > 0)
                          xdrawglyphfontspecs(specs, base, i, ox, y);
          }
Received on Tue Jul 28 2015 - 10:54:29 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 28 2015 - 11:00:16 CEST