Skip to content

Commit 49eb0a9

Browse files
committed
Add spacesearch and update scrollback patch
1 parent 940cdc4 commit 49eb0a9

File tree

2 files changed

+120
-33
lines changed

2 files changed

+120
-33
lines changed

patches/st-scrollback-20170104-c63a87c.diff patches/st-scrollback-20170329-149c0d3.diff

+98-33
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
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+
/*
114
diff --git a/st.c b/st.c
2-
index fbcd9e0..64bc208 100644
15+
index ae93ade..b74b9dc 100644
316
--- a/st.c
417
+++ 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 {
1519
/* function definitions used in config.h */
1620
static void clipcopy(const Arg *);
1721
static void clippaste(const Arg *);
@@ -20,7 +24,7 @@ index fbcd9e0..64bc208 100644
2024
static void numlock(const Arg *);
2125
static void selpaste(const Arg *);
2226
static void zoom(const Arg *);
23-
@@ -409,8 +417,8 @@ static void tputtab(int);
27+
@@ -174,8 +176,8 @@ static void tputtab(int);
2428
static void tputc(Rune);
2529
static void treset(void);
2630
static void tresize(int, int);
@@ -31,7 +35,7 @@ index fbcd9e0..64bc208 100644
3135
static void tsetattr(int *, int);
3236
static void tsetchar(Rune, Glyph *, int, int);
3337
static void tsetscroll(int, int);
34-
@@ -742,10 +750,10 @@ tlinelen(int y)
38+
@@ -448,10 +450,10 @@ tlinelen(int y)
3539
{
3640
int i = term.col;
3741

@@ -44,7 +48,7 @@ index fbcd9e0..64bc208 100644
4448
--i;
4549

4650
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)
4852
* Snap around if the word wraps around at the end or
4953
* beginning of a line.
5054
*/
@@ -53,7 +57,7 @@ index fbcd9e0..64bc208 100644
5357
prevdelim = ISDELIM(prevgp->u);
5458
for (;;) {
5559
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)
5761
yt = *y, xt = *x;
5862
else
5963
yt = newy, xt = newx;
@@ -70,7 +74,7 @@ index fbcd9e0..64bc208 100644
7074
delim = ISDELIM(gp->u);
7175
if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
7276
|| (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)
7478
*x = (direction < 0) ? 0 : term.col - 1;
7579
if (direction < 0) {
7680
for (; *y > 0; *y += direction) {
@@ -87,7 +91,7 @@ index fbcd9e0..64bc208 100644
8791
& ATTR_WRAP)) {
8892
break;
8993
}
90-
@@ -1023,13 +1031,13 @@ getsel(void)
94+
@@ -594,13 +596,13 @@ getsel(void)
9195
}
9296

9397
if (sel.type == SEL_RECTANGULAR) {
@@ -104,17 +108,17 @@ index fbcd9e0..64bc208 100644
104108
while (last >= gp && last->u == ' ')
105109
--last;
106110

107-
@@ -1513,6 +1521,9 @@ ttyread(void)
111+
@@ -844,6 +846,9 @@ ttyread(void)
108112
if (buflen > 0)
109113
memmove(buf, ptr, buflen);
110114

111-
+ if (term.scr > 0 && term.scr < histsize-1)
115+
+ if (term.scr > 0 && term.scr < HISTSIZE-1)
112116
+ term.scr++;
113117
+
114118
return ret;
115119
}
116120

117-
@@ -1522,6 +1533,9 @@ ttywrite(const char *s, size_t n)
121+
@@ -853,6 +858,9 @@ ttywrite(const char *s, size_t n)
118122
fd_set wfd, rfd;
119123
ssize_t r;
120124
size_t lim = 256;
@@ -124,7 +128,7 @@ index fbcd9e0..64bc208 100644
124128

125129
/*
126130
* 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)
128132
}
129133

130134
void
@@ -154,7 +158,7 @@ index fbcd9e0..64bc208 100644
154158
+ if (n < 0)
155159
+ n = term.row + n;
156160
+
157-
+ if (term.scr <= histsize - n) {
161+
+ if (term.scr <= HISTSIZE-n) {
158162
+ term.scr += n;
159163
+ selscroll(0, n);
160164
+ tfulldirt();
@@ -170,7 +174,7 @@ index fbcd9e0..64bc208 100644
170174
LIMIT(n, 0, term.bot-orig+1);
171175

172176
+ if (copyhist) {
173-
+ term.histi = (term.histi - 1 + histsize) % histsize;
177+
+ term.histi = (term.histi - 1 + HISTSIZE) % HISTSIZE;
174178
+ temp = term.hist[term.histi];
175179
+ term.hist[term.histi] = term.line[term.bot];
176180
+ term.line[term.bot] = temp;
@@ -179,7 +183,7 @@ index fbcd9e0..64bc208 100644
179183
tsetdirt(orig, term.bot-n);
180184
tclearregion(0, term.bot-n+1, term.col-1, term.bot);
181185

182-
@@ -1744,13 +1798,20 @@ tscrolldown(int orig, int n)
186+
@@ -1075,13 +1123,20 @@ tscrolldown(int orig, int n)
183187
}
184188

185189
void
@@ -192,7 +196,7 @@ index fbcd9e0..64bc208 100644
192196
LIMIT(n, 0, term.bot-orig+1);
193197

194198
+ if (copyhist) {
195-
+ term.histi = (term.histi + 1) % histsize;
199+
+ term.histi = (term.histi + 1) % HISTSIZE;
196200
+ temp = term.hist[term.histi];
197201
+ term.hist[term.histi] = term.line[orig];
198202
+ term.line[orig] = temp;
@@ -201,7 +205,7 @@ index fbcd9e0..64bc208 100644
201205
tclearregion(0, orig, term.col-1, orig+n-1);
202206
tsetdirt(orig+n, term.bot);
203207

204-
@@ -1799,7 +1860,7 @@ tnewline(int first_col)
208+
@@ -1130,7 +1185,7 @@ tnewline(int first_col)
205209
int y = term.c.y;
206210

207211
if (y == term.bot) {
@@ -210,7 +214,7 @@ index fbcd9e0..64bc208 100644
210214
} else {
211215
y++;
212216
}
213-
@@ -1964,14 +2025,14 @@ void
217+
@@ -1295,14 +1350,14 @@ void
214218
tinsertblankline(int n)
215219
{
216220
if (BETWEEN(term.c.y, term.top, term.bot))
@@ -227,7 +231,7 @@ index fbcd9e0..64bc208 100644
227231
}
228232

229233
int32_t
230-
@@ -2405,11 +2466,11 @@ csihandle(void)
234+
@@ -1736,11 +1791,11 @@ csihandle(void)
231235
break;
232236
case 'S': /* SU -- Scroll <n> line up */
233237
DEFAULT(csiescseq.arg[0], 1);
@@ -241,7 +245,7 @@ index fbcd9e0..64bc208 100644
241245
break;
242246
case 'L': /* IL -- Insert <n> blank lines */
243247
DEFAULT(csiescseq.arg[0], 1);
244-
@@ -2945,7 +3006,7 @@ eschandle(uchar ascii)
248+
@@ -2290,7 +2345,7 @@ eschandle(uchar ascii)
245249
return 0;
246250
case 'D': /* IND -- Linefeed */
247251
if (term.c.y == term.bot) {
@@ -250,7 +254,7 @@ index fbcd9e0..64bc208 100644
250254
} else {
251255
tmoveto(term.c.x, term.c.y+1);
252256
}
253-
@@ -2958,7 +3019,7 @@ eschandle(uchar ascii)
257+
@@ -2303,7 +2358,7 @@ eschandle(uchar ascii)
254258
break;
255259
case 'M': /* RI -- Reverse index */
256260
if (term.c.y == term.top) {
@@ -259,7 +263,7 @@ index fbcd9e0..64bc208 100644
259263
} else {
260264
tmoveto(term.c.x, term.c.y-1);
261265
}
262-
@@ -3145,7 +3206,7 @@ check_control_code:
266+
@@ -2490,7 +2545,7 @@ check_control_code:
263267
void
264268
tresize(int col, int row)
265269
{
@@ -268,11 +272,11 @@ index fbcd9e0..64bc208 100644
268272
int minrow = MIN(row, term.row);
269273
int mincol = MIN(col, term.col);
270274
int *bp;
271-
@@ -3185,6 +3246,14 @@ tresize(int col, int row)
275+
@@ -2530,6 +2585,14 @@ tresize(int col, int row)
272276
term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty));
273277
term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs));
274278

275-
+ for (i = 0; i < histsize; i++) {
279+
+ for (i = 0; i < HISTSIZE; i++) {
276280
+ term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph));
277281
+ for (j = mincol; j < col; j++) {
278282
+ term.hist[i][j] = term.c.attr;
@@ -283,3 +287,64 @@ index fbcd9e0..64bc208 100644
283287
/* resize each row to new width, zero-pad if needed */
284288
for (i = 0; i < minrow; i++) {
285289
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

patches/surf-0.6-spacesearch.diff

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/config.def.h b/config.def.h
2+
index a221c86..c3aef5e 100644
3+
--- a/config.def.h
4+
+++ b/config.def.h
5+
@@ -103,3 +103,4 @@ static Key keys[] = {
6+
{ ClkAny, 0, 9, navigate, { .i = +1 } },
7+
};
8+
9+
+static char *searchengine = "https://duckduckgo.com/?q=";
10+
diff --git a/surf.c b/surf.c
11+
index cebd469..a5c0030 100644
12+
--- a/surf.c
13+
+++ b/surf.c
14+
@@ -626,6 +626,8 @@ loaduri(Client *c, const Arg *arg) {
15+
rp = realpath(uri, NULL);
16+
u = g_strdup_printf("file://%s", rp);
17+
free(rp);
18+
+ } else if (*uri == ' ') {
19+
+ u = g_strdup_printf("%s%s", searchengine, uri+1);
20+
} else {
21+
u = g_strrstr(uri, "://") || g_str_has_prefix(uri, "about:") ? g_strdup(uri)
22+
: g_strdup_printf("http://%s", uri);

0 commit comments

Comments
 (0)