1
+ diff --git a/config.def.h b/config.def.h
2
+ index 877afab..3e9cda5 100644
3
+ --- a/config.def.h
4
+ +++ b/config.def.h
5
+ @@ -178,6 +178,8 @@ Shortcut shortcuts[] = {
6
+ { TERMMOD, XK_Y, selpaste, {.i = 0} },
7
+ { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
8
+ { TERMMOD, XK_I, iso14755, {.i = 0} },
9
+ + { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
10
+ + { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
11
+ };
12
+
13
+ /*
1
14
diff --git a/st.c b/st.c
2
- index fbcd9e0..64bc208 100644
15
+ index ae93ade..b74b9dc 100644
3
16
--- a/st.c
4
17
+++ b/st.c
5
- @@ -87,6 +88,8 @@ char *argv0;
6
- #define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
7
- #define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
8
- #define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL)
9
- + #define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - term.scr \
10
- + + histsize + 1) % histsize] : term.line[(y) - term.scr])
11
-
12
- /* constants */
13
- #define ISO14755CMD "dmenu -w %lu -p codepoint: </dev/null"
14
- @@ -334,6 +340,8 @@ typedef struct {
18
+ @@ -128,6 +128,8 @@ typedef struct {
15
19
/* function definitions used in config.h */
16
20
static void clipcopy(const Arg *);
17
21
static void clippaste(const Arg *);
@@ -20,7 +24,7 @@ index fbcd9e0..64bc208 100644
20
24
static void numlock(const Arg *);
21
25
static void selpaste(const Arg *);
22
26
static void zoom(const Arg *);
23
- @@ -409 ,8 +417 ,8 @@ static void tputtab(int);
27
+ @@ -174 ,8 +176 ,8 @@ static void tputtab(int);
24
28
static void tputc(Rune);
25
29
static void treset(void);
26
30
static void tresize(int, int);
@@ -31,7 +35,7 @@ index fbcd9e0..64bc208 100644
31
35
static void tsetattr(int *, int);
32
36
static void tsetchar(Rune, Glyph *, int, int);
33
37
static void tsetscroll(int, int);
34
- @@ -742 ,10 +750 ,10 @@ tlinelen(int y)
38
+ @@ -448 ,10 +450 ,10 @@ tlinelen(int y)
35
39
{
36
40
int i = term.col;
37
41
@@ -44,7 +48,7 @@ index fbcd9e0..64bc208 100644
44
48
--i;
45
49
46
50
return i;
47
- @@ -807 ,7 +815 ,7 @@ selsnap(int *x, int *y, int direction)
51
+ @@ -513 ,7 +515 ,7 @@ selsnap(int *x, int *y, int direction)
48
52
* Snap around if the word wraps around at the end or
49
53
* beginning of a line.
50
54
*/
@@ -53,7 +57,7 @@ index fbcd9e0..64bc208 100644
53
57
prevdelim = ISDELIM(prevgp->u);
54
58
for (;;) {
55
59
newx = *x + direction;
56
- @@ -822 ,14 +830 ,14 @@ selsnap(int *x, int *y, int direction)
60
+ @@ -528 ,14 +530 ,14 @@ selsnap(int *x, int *y, int direction)
57
61
yt = *y, xt = *x;
58
62
else
59
63
yt = newy, xt = newx;
@@ -70,7 +74,7 @@ index fbcd9e0..64bc208 100644
70
74
delim = ISDELIM(gp->u);
71
75
if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
72
76
|| (delim && gp->u != prevgp->u)))
73
- @@ -850 ,14 +858 ,14 @@ selsnap(int *x, int *y, int direction)
77
+ @@ -556 ,14 +558 ,14 @@ selsnap(int *x, int *y, int direction)
74
78
*x = (direction < 0) ? 0 : term.col - 1;
75
79
if (direction < 0) {
76
80
for (; *y > 0; *y += direction) {
@@ -87,7 +91,7 @@ index fbcd9e0..64bc208 100644
87
91
& ATTR_WRAP)) {
88
92
break;
89
93
}
90
- @@ -1023 ,13 +1031 ,13 @@ getsel(void)
94
+ @@ -594 ,13 +596 ,13 @@ getsel(void)
91
95
}
92
96
93
97
if (sel.type == SEL_RECTANGULAR) {
@@ -104,17 +108,17 @@ index fbcd9e0..64bc208 100644
104
108
while (last >= gp && last->u == ' ')
105
109
--last;
106
110
107
- @@ -1513 ,6 +1521 ,9 @@ ttyread(void)
111
+ @@ -844 ,6 +846 ,9 @@ ttyread(void)
108
112
if (buflen > 0)
109
113
memmove(buf, ptr, buflen);
110
114
111
- + if (term.scr > 0 && term.scr < histsize -1)
115
+ + if (term.scr > 0 && term.scr < HISTSIZE -1)
112
116
+ term.scr++;
113
117
+
114
118
return ret;
115
119
}
116
120
117
- @@ -1522 ,6 +1533 ,9 @@ ttywrite(const char *s, size_t n)
121
+ @@ -853 ,6 +858 ,9 @@ ttywrite(const char *s, size_t n)
118
122
fd_set wfd, rfd;
119
123
ssize_t r;
120
124
size_t lim = 256;
@@ -124,7 +128,7 @@ index fbcd9e0..64bc208 100644
124
128
125
129
/*
126
130
* Remember that we are using a pty, which might be a modem line.
127
- @@ -1724 ,13 +1738 ,53 @@ tswapscreen(void)
131
+ @@ -1055 ,13 +1063 ,53 @@ tswapscreen(void)
128
132
}
129
133
130
134
void
@@ -154,7 +158,7 @@ index fbcd9e0..64bc208 100644
154
158
+ if (n < 0)
155
159
+ n = term.row + n;
156
160
+
157
- + if (term.scr <= histsize - n) {
161
+ + if (term.scr <= HISTSIZE- n) {
158
162
+ term.scr += n;
159
163
+ selscroll(0, n);
160
164
+ tfulldirt();
@@ -170,7 +174,7 @@ index fbcd9e0..64bc208 100644
170
174
LIMIT(n, 0, term.bot-orig+1);
171
175
172
176
+ if (copyhist) {
173
- + term.histi = (term.histi - 1 + histsize ) % histsize ;
177
+ + term.histi = (term.histi - 1 + HISTSIZE ) % HISTSIZE ;
174
178
+ temp = term.hist[term.histi];
175
179
+ term.hist[term.histi] = term.line[term.bot];
176
180
+ term.line[term.bot] = temp;
@@ -179,7 +183,7 @@ index fbcd9e0..64bc208 100644
179
183
tsetdirt(orig, term.bot-n);
180
184
tclearregion(0, term.bot-n+1, term.col-1, term.bot);
181
185
182
- @@ -1744 ,13 +1798 ,20 @@ tscrolldown(int orig, int n)
186
+ @@ -1075 ,13 +1123 ,20 @@ tscrolldown(int orig, int n)
183
187
}
184
188
185
189
void
@@ -192,7 +196,7 @@ index fbcd9e0..64bc208 100644
192
196
LIMIT(n, 0, term.bot-orig+1);
193
197
194
198
+ if (copyhist) {
195
- + term.histi = (term.histi + 1) % histsize ;
199
+ + term.histi = (term.histi + 1) % HISTSIZE ;
196
200
+ temp = term.hist[term.histi];
197
201
+ term.hist[term.histi] = term.line[orig];
198
202
+ term.line[orig] = temp;
@@ -201,7 +205,7 @@ index fbcd9e0..64bc208 100644
201
205
tclearregion(0, orig, term.col-1, orig+n-1);
202
206
tsetdirt(orig+n, term.bot);
203
207
204
- @@ -1799 ,7 +1860 ,7 @@ tnewline(int first_col)
208
+ @@ -1130 ,7 +1185 ,7 @@ tnewline(int first_col)
205
209
int y = term.c.y;
206
210
207
211
if (y == term.bot) {
@@ -210,7 +214,7 @@ index fbcd9e0..64bc208 100644
210
214
} else {
211
215
y++;
212
216
}
213
- @@ -1964 ,14 +2025 ,14 @@ void
217
+ @@ -1295 ,14 +1350 ,14 @@ void
214
218
tinsertblankline(int n)
215
219
{
216
220
if (BETWEEN(term.c.y, term.top, term.bot))
@@ -227,7 +231,7 @@ index fbcd9e0..64bc208 100644
227
231
}
228
232
229
233
int32_t
230
- @@ -2405 ,11 +2466 ,11 @@ csihandle(void)
234
+ @@ -1736 ,11 +1791 ,11 @@ csihandle(void)
231
235
break;
232
236
case 'S': /* SU -- Scroll <n> line up */
233
237
DEFAULT(csiescseq.arg[0], 1);
@@ -241,7 +245,7 @@ index fbcd9e0..64bc208 100644
241
245
break;
242
246
case 'L': /* IL -- Insert <n> blank lines */
243
247
DEFAULT(csiescseq.arg[0], 1);
244
- @@ -2945 ,7 +3006 ,7 @@ eschandle(uchar ascii)
248
+ @@ -2290 ,7 +2345 ,7 @@ eschandle(uchar ascii)
245
249
return 0;
246
250
case 'D': /* IND -- Linefeed */
247
251
if (term.c.y == term.bot) {
@@ -250,7 +254,7 @@ index fbcd9e0..64bc208 100644
250
254
} else {
251
255
tmoveto(term.c.x, term.c.y+1);
252
256
}
253
- @@ -2958 ,7 +3019 ,7 @@ eschandle(uchar ascii)
257
+ @@ -2303 ,7 +2358 ,7 @@ eschandle(uchar ascii)
254
258
break;
255
259
case 'M': /* RI -- Reverse index */
256
260
if (term.c.y == term.top) {
@@ -259,7 +263,7 @@ index fbcd9e0..64bc208 100644
259
263
} else {
260
264
tmoveto(term.c.x, term.c.y-1);
261
265
}
262
- @@ -3145 ,7 +3206 ,7 @@ check_control_code:
266
+ @@ -2490 ,7 +2545 ,7 @@ check_control_code:
263
267
void
264
268
tresize(int col, int row)
265
269
{
@@ -268,11 +272,11 @@ index fbcd9e0..64bc208 100644
268
272
int minrow = MIN(row, term.row);
269
273
int mincol = MIN(col, term.col);
270
274
int *bp;
271
- @@ -3185 ,6 +3246 ,14 @@ tresize(int col, int row)
275
+ @@ -2530 ,6 +2585 ,14 @@ tresize(int col, int row)
272
276
term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty));
273
277
term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs));
274
278
275
- + for (i = 0; i < histsize ; i++) {
279
+ + for (i = 0; i < HISTSIZE ; i++) {
276
280
+ term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph));
277
281
+ for (j = mincol; j < col; j++) {
278
282
+ term.hist[i][j] = term.c.attr;
@@ -283,3 +287,64 @@ index fbcd9e0..64bc208 100644
283
287
/* resize each row to new width, zero-pad if needed */
284
288
for (i = 0; i < minrow; i++) {
285
289
term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
290
+ diff --git a/st.h b/st.h
291
+ index 44d4938..2d9b028 100644
292
+ --- a/st.h
293
+ +++ b/st.h
294
+ @@ -2,6 +2,7 @@
295
+
296
+ /* Arbitrary sizes */
297
+ #define UTF_SIZ 4
298
+ + #define HISTSIZE 2000
299
+
300
+ /* macros */
301
+ #define MIN(a, b) ((a) < (b) ? (a) : (b))
302
+ @@ -20,6 +21,9 @@
303
+ #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
304
+ #define IS_TRUECOL(x) (1 << 24 & (x))
305
+
306
+ + #define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - term.scr \
307
+ + + HISTSIZE + 1) % HISTSIZE] : term.line[(y) - term.scr])
308
+ +
309
+ enum glyph_attribute {
310
+ ATTR_NULL = 0,
311
+ ATTR_BOLD = 1 << 0,
312
+ @@ -114,6 +118,9 @@ typedef struct {
313
+ int col; /* nb col */
314
+ Line *line; /* screen */
315
+ Line *alt; /* alternate screen */
316
+ + Line hist[HISTSIZE]; /* history buffer */
317
+ + int histi; /* history index */
318
+ + int scr; /* scroll back */
319
+ int *dirty; /* dirtyness of lines */
320
+ GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
321
+ TCursor c; /* cursor */
322
+ diff --git a/x.c b/x.c
323
+ index b7339e9..2ae8b17 100644
324
+ --- a/x.c
325
+ +++ b/x.c
326
+ @@ -1413,11 +1413,11 @@ drawregion(int x1, int y1, int x2, int y2)
327
+ term.dirty[y] = 0;
328
+
329
+ specs = term.specbuf;
330
+ - numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y);
331
+ + numspecs = xmakeglyphfontspecs(specs, &TLINE(y)[x1], x2 - x1, x1, y);
332
+
333
+ i = ox = 0;
334
+ for (x = x1; x < x2 && i < numspecs; x++) {
335
+ - new = term.line[y][x];
336
+ + new = TLINE(y)[x];
337
+ if (new.mode == ATTR_WDUMMY)
338
+ continue;
339
+ if (ena_sel && selected(x, y))
340
+ @@ -1437,7 +1437,9 @@ drawregion(int x1, int y1, int x2, int y2)
341
+ if (i > 0)
342
+ xdrawglyphfontspecs(specs, base, i, ox, y);
343
+ }
344
+ - xdrawcursor();
345
+ +
346
+ + if (term.scr == 0)
347
+ + xdrawcursor();
348
+ }
349
+
350
+ void
0 commit comments