sites

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

st-externalpipe-eternal-ringbuffer-0.9.3.diff (1442B)


      1 diff -up a/st.c b/st.c
      2 --- a/st.c	2026-02-12 14:56:55.248311919 -0300
      3 +++ b/st.c	2026-02-12 14:36:36.827197795 -0300
      4 @@ -2513,21 +2513,21 @@ externalpipe(const Arg *arg)
      5          /* ignore sigpipe for now, in case child exists early */
      6          oldsigpipe = signal(SIGPIPE, SIG_IGN);
      7          newline = 0;
      8 -	for (n = 0; n < term.row; n++) {
      9 -		bp = term.line[n];
     10 -		lastpos = MIN(tlinelen(n) + 1, term.col) - 1;
     11 -                if (lastpos < 0)
     12 -                        break;
     13 -                end = &bp[lastpos + 1];
     14 -                for (; bp < end; ++bp)
     15 -                        if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
     16 -                                break;
     17 -		if ((newline = term.line[n][lastpos].mode & ATTR_WRAP))
     18 -                        continue;
     19 -                if (xwrite(to[1], "\n", 1) < 0)
     20 -                        break;
     21 -                newline = 0;
     22 -        }
     23 +	int histlen = term.screen[0].cur < term.screen[0].size
     24 +		? term.screen[0].cur
     25 +		: term.screen[0].size;
     26 +	int total = histlen + term.row;
     27 +	for (int n = -histlen; n < term.row; n++) {
     28 +		Line line = TLINE(n);
     29 +		int len = tlinelen(n);
     30 +		for (int i = 0; i < len; i++) {
     31 +			char buf[UTF_SIZ];
     32 +			if (xwrite(to[1], buf, utf8encode(line[i].u, buf)) < 0)
     33 +				break;
     34 +		}
     35 +		if (len > 0 && !(line[len - 1].mode & ATTR_WRAP))
     36 +			xwrite(to[1], "\n", 1);
     37 +	}
     38          if (newline)
     39                  (void)xwrite(to[1], "\n", 1);
     40          close(to[1]);