]> git.armaanb.net Git - st.git/commitdiff
Add support for scroll(1)
authorRoberto E. Vargas Caballero <k0ga@shike2.com>
Fri, 10 Apr 2020 20:06:32 +0000 (22:06 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sat, 11 Apr 2020 13:23:20 +0000 (15:23 +0200)
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.

config.def.h
st.1
st.c
st.h

index 546edda1a03d26447d62a15bc6c99a12872af427..dfcbda999eb362ff7d64a2bd14e42d7caebe8d2b 100644 (file)
@@ -11,13 +11,14 @@ static int borderpx = 2;
 /*
  * What program is execed by st depends of these precedence rules:
  * 1: program passed with -e
 /*
  * What program is execed by st depends of these precedence rules:
  * 1: program passed with -e
- * 2: utmp option
+ * 2: scroll and/or utmp
  * 3: SHELL environment variable
  * 4: value of shell in /etc/passwd
  * 5: value of shell in config.h
  */
 static char *shell = "/bin/sh";
 char *utmp = NULL;
  * 3: SHELL environment variable
  * 4: value of shell in /etc/passwd
  * 5: value of shell in config.h
  */
 static char *shell = "/bin/sh";
 char *utmp = NULL;
+char *scroll = NULL;
 char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
 
 /* identification sequence returned in DA and DECID */
 char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
 
 /* identification sequence returned in DA and DECID */
diff --git a/st.1 b/st.1
index e8d6059a9d531d24a6221d0d084c3474e1512687..39120b4848c1dd055724e0d8345c515d641ec7d4 100644 (file)
--- a/st.1
+++ b/st.1
@@ -170,7 +170,8 @@ See the LICENSE file for the terms of redistribution.
 .SH SEE ALSO
 .BR tabbed (1),
 .BR utmp (1),
 .SH SEE ALSO
 .BR tabbed (1),
 .BR utmp (1),
-.BR stty (1)
+.BR stty (1),
+.BR scroll (1)
 .SH BUGS
 See the TODO file in the distribution.
 
 .SH BUGS
 See the TODO file in the distribution.
 
diff --git a/st.c b/st.c
index 3e4841079a90ce76e83a9cbe361b7a46e71ff9a2..5f2352af2f10fc7e97d6d127f5d2e8244cb02722 100644 (file)
--- a/st.c
+++ b/st.c
@@ -664,7 +664,7 @@ die(const char *errstr, ...)
 void
 execsh(char *cmd, char **args)
 {
 void
 execsh(char *cmd, char **args)
 {
-       char *sh, *prog;
+       char *sh, *prog, *arg;
        const struct passwd *pw;
 
        errno = 0;
        const struct passwd *pw;
 
        errno = 0;
@@ -678,13 +678,17 @@ execsh(char *cmd, char **args)
        if ((sh = getenv("SHELL")) == NULL)
                sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd;
 
        if ((sh = getenv("SHELL")) == NULL)
                sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd;
 
-       if (args)
+       if (args) {
                prog = args[0];
                prog = args[0];
-       else if (utmp)
-               prog = utmp;
-       else
+               arg = NULL;
+       } else if (scroll || utmp) {
+               prog = scroll ? scroll : utmp;
+               arg = scroll ? utmp : NULL;
+       } else {
                prog = sh;
                prog = sh;
-       DEFAULT(args, ((char *[]) {prog, NULL}));
+               arg = NULL;
+       }
+       DEFAULT(args, ((char *[]) {prog, arg, NULL}));
 
        unsetenv("COLUMNS");
        unsetenv("LINES");
 
        unsetenv("COLUMNS");
        unsetenv("LINES");
diff --git a/st.h b/st.h
index a1928cae4b818f03d220adb015f70a2e424c610f..d978458425934fa1db8c5c03a62c917e244d8933 100644 (file)
--- a/st.h
+++ b/st.h
@@ -113,6 +113,7 @@ char *xstrdup(char *);
 
 /* config.h globals */
 extern char *utmp;
 
 /* config.h globals */
 extern char *utmp;
+extern char *scroll;
 extern char *stty_args;
 extern char *vtiden;
 extern wchar_t *worddelimiters;
 extern char *stty_args;
 extern char *vtiden;
 extern wchar_t *worddelimiters;