Skip to content

Commit 21e0d6e

Browse files
k0gaMSXhiltjo
authored andcommitted
Add support for scroll(1)
Scroll is a program that stores all the lines of its child and be used in st as a way of implementing scrollback. This solution is much better than implementing the scrollback in st itself because having a different program allows to use it in any other program without doing modifications to those programs.
1 parent 5703aa0 commit 21e0d6e

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

config.def.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ static int borderpx = 2;
1111
/*
1212
* What program is execed by st depends of these precedence rules:
1313
* 1: program passed with -e
14-
* 2: utmp option
14+
* 2: scroll and/or utmp
1515
* 3: SHELL environment variable
1616
* 4: value of shell in /etc/passwd
1717
* 5: value of shell in config.h
1818
*/
1919
static char *shell = "/bin/sh";
2020
char *utmp = NULL;
21+
char *scroll = NULL;
2122
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
2223

2324
/* identification sequence returned in DA and DECID */

st.1

+2-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ See the LICENSE file for the terms of redistribution.
170170
.SH SEE ALSO
171171
.BR tabbed (1),
172172
.BR utmp (1),
173-
.BR stty (1)
173+
.BR stty (1),
174+
.BR scroll (1)
174175
.SH BUGS
175176
See the TODO file in the distribution.
176177

st.c

+10-6
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ die(const char *errstr, ...)
664664
void
665665
execsh(char *cmd, char **args)
666666
{
667-
char *sh, *prog;
667+
char *sh, *prog, *arg;
668668
const struct passwd *pw;
669669

670670
errno = 0;
@@ -678,13 +678,17 @@ execsh(char *cmd, char **args)
678678
if ((sh = getenv("SHELL")) == NULL)
679679
sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd;
680680

681-
if (args)
681+
if (args) {
682682
prog = args[0];
683-
else if (utmp)
684-
prog = utmp;
685-
else
683+
arg = NULL;
684+
} else if (scroll || utmp) {
685+
prog = scroll ? scroll : utmp;
686+
arg = scroll ? utmp : NULL;
687+
} else {
686688
prog = sh;
687-
DEFAULT(args, ((char *[]) {prog, NULL}));
689+
arg = NULL;
690+
}
691+
DEFAULT(args, ((char *[]) {prog, arg, NULL}));
688692

689693
unsetenv("COLUMNS");
690694
unsetenv("LINES");

st.h

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ char *xstrdup(char *);
113113

114114
/* config.h globals */
115115
extern char *utmp;
116+
extern char *scroll;
116117
extern char *stty_args;
117118
extern char *vtiden;
118119
extern wchar_t *worddelimiters;

0 commit comments

Comments
 (0)