st-externalpipe-eternal-0.8.3.diff - sites - public wiki contents of suckless.o… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
st-externalpipe-eternal-0.8.3.diff (2045B) | |
--- | |
1 From 2228468a6db1e648c69849860d30867c0e77650e Mon Sep 17 00:00:00 2001 | |
2 From: AtomToast <[email protected]> | |
3 Date: Wed, 29 Apr 2020 02:31:29 +0200 | |
4 Subject: [PATCH] apply Luke Smiths external pipe eternal patch | |
5 | |
6 Enables external pipe to work on the entire scrollback history. | |
7 | |
8 Source: https://github.com/LukeSmithxyz/st/commit/da13ef12463d1870caed94… | |
9 Made to work on semi-vanilla st. | |
10 | |
11 This patch requires both externalpipe and scrollback patch in order to w… | |
12 --- | |
13 st.c | 25 +++++++++++++++++++++---- | |
14 1 file changed, 21 insertions(+), 4 deletions(-) | |
15 | |
16 diff --git a/st.c b/st.c | |
17 index d4c88a2..2716f44 100644 | |
18 --- a/st.c | |
19 +++ b/st.c | |
20 @@ -46,6 +46,7 @@ | |
21 #define TLINE(y) ((y) < term.scr ? term.hist[((y) + term… | |
22 term.scr + HISTSIZE + 1) % HISTSIZE] : \ | |
23 term.line[(y) - term.scr]) | |
24 +#define TLINE_HIST(y) ((y) <= HISTSIZE-term.row+2 ? term.hist… | |
25 | |
26 enum term_mode { | |
27 MODE_WRAP = 1 << 0, | |
28 @@ -431,6 +432,20 @@ tlinelen(int y) | |
29 return i; | |
30 } | |
31 | |
32 +int | |
33 +tlinehistlen(int y) | |
34 +{ | |
35 + int i = term.col; | |
36 + | |
37 + if (TLINE_HIST(y)[i - 1].mode & ATTR_WRAP) | |
38 + return i; | |
39 + | |
40 + while (i > 0 && TLINE_HIST(y)[i - 1].u == ' ') | |
41 + --i; | |
42 + | |
43 + return i; | |
44 +} | |
45 + | |
46 void | |
47 selstart(int col, int row, int snap) | |
48 { | |
49 @@ -2025,16 +2040,18 @@ externalpipe(const Arg *arg) | |
50 /* ignore sigpipe for now, in case child exists early */ | |
51 oldsigpipe = signal(SIGPIPE, SIG_IGN); | |
52 newline = 0; | |
53 - for (n = 0; n < term.row; n++) { | |
54 - bp = term.line[n]; | |
55 - lastpos = MIN(tlinelen(n) + 1, term.col) - 1; | |
56 + for (n = 0; n <= HISTSIZE + 2; n++) { | |
57 + bp = TLINE_HIST(n); | |
58 + lastpos = MIN(tlinehistlen(n) + 1, term.col) - 1; | |
59 if (lastpos < 0) | |
60 break; | |
61 + if (lastpos == 0) | |
62 + continue; | |
63 end = &bp[lastpos + 1]; | |
64 for (; bp < end; ++bp) | |
65 if (xwrite(to[1], buf, utf8encode(bp->u, buf)) … | |
66 break; | |
67 - if ((newline = term.line[n][lastpos].mode & ATTR_WRAP)) | |
68 + if ((newline = TLINE_HIST(n)[lastpos].mode & ATTR_WRAP)) | |
69 continue; | |
70 if (xwrite(to[1], "\n", 1) < 0) | |
71 break; | |
72 -- | |
73 2.26.2 | |
74 |