Hi, The patchset again with small differencies and a few additions.
Regards,
>From 15608429bf80283f2edaf8bed04fb71e986b0123 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" <robe...@clue.aero> Date: Sat, 11 Apr 2020 11:52:58 +0200 Subject: [PATCH 5/6] Update FAQ with the last odifications --- FAQ | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/FAQ b/FAQ index 78c769a..85534a4 100644 --- a/FAQ +++ b/FAQ @@ -17,10 +17,16 @@ you can manually run `tic -sx st.info`. ## How do I scroll back up? -Using a terminal multiplexer. +* Using a terminal multiplexer. + * `st -e tmux` using C-b [ + * `st -e screen` using C-a ESC +* Using the excellent tool of [scroll](https://git.suckless.org/scroll/). +* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/). -* `st -e tmux` using C-b [ -* `st -e screen` using C-a ESC +## I would like to have utmp and/or scroll functionality by default + +You can add the absolute patch of both programs in your config.h +file. You only have to modify the value of utmp and scroll variables. ## Why doesn't the Del key work in some programs? -- 2.26.0
>From 44029220555fc763b40e43f9617a2bc75ca6c534 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" <k...@shike2.com> Date: Fri, 10 Apr 2020 22:50:23 +0200 Subject: [PATCH 4/6] Add terminfo entries for backspace mode St used to use backspace as BS until the commit 230d0c8, but due to general lack of knowledge of lusers, we moved to the most common configuration in linux to avoid answering the same question 3 times per month. With the most common configuration we have a backspace that returns a DEL, and we have a Delete key that doesn't return a DEL character neither a BS. When dealing with devices connected using a serial line (or even with Plan9) it is more common Backspace as BS and Delete as DEL. For this reason, st is not always the best tool when you talk with a serial device. This patch adds new terminfo entries for Backspace as BS and Delete as DEL. A patch for confg.h is also added, to make easier switch between both configurations. --- st.info | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/st.info b/st.info index 78ffd30..1df490b 100644 --- a/st.info +++ b/st.info @@ -220,3 +220,13 @@ st-meta-256color| simpleterm with meta key and 256 colors, smm=\E[?1034h, rs2=\E[4l\E>\E[?1034h, is2=\E[4l\E>\E[?1034h, + +st-bs| simpleterm with backspace as backspace, + use=st, + kbs=\010, + kdch1=\177, + +st-bs-256color| simpleterm with backspace as backspace and 256colors, + use=st-256color, + kbs=\010, + kdch1=\177, -- 2.26.0
>From 580f81346cae3714b50f69d932249260578fe4b1 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" <robe...@clue.aero> Date: Sat, 11 Apr 2020 11:53:31 +0200 Subject: [PATCH 6/6] Remove LEGACY file This file had a function 8 years ago. it doesn't make sense anymore. --- LEGACY | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 LEGACY diff --git a/LEGACY b/LEGACY deleted file mode 100644 index bf28b1e..0000000 --- a/LEGACY +++ /dev/null @@ -1,17 +0,0 @@ -A STATEMENT ON LEGACY SUPPORT - -In the terminal world there is much cruft that comes from old and unsup??? -ported terminals that inherit incompatible modes and escape sequences -which noone is able to know, except when he/she comes from that time and -developed a graphical vt100 emulator at that time. - -One goal of st is to only support what is really needed. When you en??? -counter a sequence which you really need, implement it. But while you -are at it, do not add the other cruft you might encounter while sneek??? -ing at other terminal emulators. History has bloated them and there is -no real evidence that most of the sequences are used today. - - -Christoph Lohmann <2...@r-36.net> -2012-09-13T07:00:36.081271045+02:00 - -- 2.26.0
>From d18c3a8c9eb82b2d135f4feb44060e6adb29428e Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" <k...@shike2.com> Date: Fri, 10 Apr 2020 22:26:12 +0200 Subject: [PATCH 3/6] Fix style issue --- st.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/st.c b/st.c index 81973ee..2ecf8f3 100644 --- a/st.c +++ b/st.c @@ -366,7 +366,8 @@ static const char base64_digits[] = { char base64dec_getc(const char **src) { - while (**src && !isprint(**src)) (*src)++; + while (**src && !isprint(**src)) + (*src)++; return **src ? *((*src)++) : '='; /* emulate padding if string ends */ } -- 2.26.0
>From 6d02a2710b3ecdd1874c3a34c5d9fc2e19747c73 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" <k...@shike2.com> Date: Fri, 10 Apr 2020 22:25:46 +0200 Subject: [PATCH 2/6] ttyread: Test for EOF while reading tty When If a read operation returns 0 then it means that we arrived to the end of the file, and new reads will return 0 unless you do some other operation such as lseek(). This case happens with usb-232 adapters when they are unplugged. --- st.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/st.c b/st.c index 5f2352a..81973ee 100644 --- a/st.c +++ b/st.c @@ -823,17 +823,24 @@ ttyread(void) int ret; /* append read bytes to unprocessed bytes */ - if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) - die("couldn't read from shell: %s\n", strerror(errno)); - buflen += ret; + ret = read(cmdfd, buf+buflen, LEN(buf)-buflen); - written = twrite(buf, buflen, 0); - buflen -= written; - /* keep any uncomplete utf8 char for the next call */ - if (buflen > 0) - memmove(buf, buf + written, buflen); + switch (ret) { + case 0: + fputs("Found EOF in input\n", stderr); + exit(0); + case -1: + die("couldn't read from shell: %s\n", strerror(errno)); + default: + buflen += ret; + written = twrite(buf, buflen, 0); + buflen -= written; + /* keep any uncomplete utf8 char for the next call */ + if (buflen > 0) + memmove(buf, buf + written, buflen); + return ret; - return ret; + } } void -- 2.26.0
>From 05485fb70f5cd2e130d2d3fa82281dc37b4c68fb Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" <k...@shike2.com> Date: Fri, 10 Apr 2020 22:06:32 +0200 Subject: [PATCH 1/6] 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. Add scroll option --- config.def.h | 3 ++- st.1 | 3 ++- st.c | 16 ++++++++++------ st.h | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/config.def.h b/config.def.h index 546edda..dfcbda9 100644 --- a/config.def.h +++ b/config.def.h @@ -11,13 +11,14 @@ static int borderpx = 2; /* * 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; +char *scroll = NULL; 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 e8d6059..39120b4 100644 --- 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), -.BR stty (1) +.BR stty (1), +.BR scroll (1) .SH BUGS See the TODO file in the distribution. diff --git a/st.c b/st.c index 3e48410..5f2352a 100644 --- a/st.c +++ b/st.c @@ -664,7 +664,7 @@ die(const char *errstr, ...) void execsh(char *cmd, char **args) { - char *sh, *prog; + char *sh, *prog, *arg; 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 (args) + if (args) { 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; - DEFAULT(args, ((char *[]) {prog, NULL})); + arg = NULL; + } + DEFAULT(args, ((char *[]) {prog, arg, NULL})); unsetenv("COLUMNS"); unsetenv("LINES"); diff --git a/st.h b/st.h index a1928ca..d978458 100644 --- a/st.h +++ b/st.h @@ -113,6 +113,7 @@ char *xstrdup(char *); /* config.h globals */ extern char *utmp; +extern char *scroll; extern char *stty_args; extern char *vtiden; extern wchar_t *worddelimiters; -- 2.26.0