From 1d348e98e3745ef98bf9fa36119ead6294c6c80b Mon Sep 17 00:00:00 2001 From: Mytchel Hammond Date: Fri, 24 Jul 2015 17:58:18 +1200 Subject: [PATCH 01/16] added note about the low precedence of shell to config.def.h --- config.def.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config.def.h b/config.def.h index e246e3c..2616dea 100644 --- a/config.def.h +++ b/config.def.h @@ -7,6 +7,15 @@ */ static char font[] = "Liberation Mono:pixelsize=12:antialias=false:autohint=false"; static int borderpx = 2; + +/* + * What program is execed by st depends of these precedence rules: + * 1: program passed with -e + * 2: utmp option + * 3: SHELL environment variable + * 4: value of shell in /etc/passwd + * 5: value of shell in config.h + */ static char shell[] = "/bin/sh"; static char *utmp = NULL; static char stty_args[] = "stty raw -echo -iexten echonl"; -- 2.20.1 From 4a193b96862c8ed7147048592aa4a898b3c05b5b Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Fri, 24 Jul 2015 11:52:17 +0200 Subject: [PATCH 02/16] Fix type for write(2) return variable. A little fix in xwrite(). >From 3727d2e3344b57128ab51c7839795204f1f839ff Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Fri, 24 Jul 2015 11:40:46 +0200 Subject: [PATCH] Fix type for write(2) return variable. The allocated lengh of s fits into an integer so we can safely use ssize_t here. --- st.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/st.c b/st.c index b604f0e..f53378c 100644 --- a/st.c +++ b/st.c @@ -560,7 +560,8 @@ static int frclen = 0; ssize_t xwrite(int fd, const char *s, size_t len) { - size_t aux = len, r; + size_t aux = len; + ssize_t r; while (len > 0) { r = write(fd, s, len); -- 2.20.1 From b5e29cce5246f30dc671cbb9486af704bc8cd2fc Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Fri, 24 Jul 2015 18:24:10 +0200 Subject: [PATCH 03/16] Add -T, as recommended by Dmitrij D. Czarkoff --- st.1 | 7 +++++++ st.c | 1 + 2 files changed, 8 insertions(+) diff --git a/st.1 b/st.1 index 9548c1a..82e228a 100644 --- a/st.1 +++ b/st.1 @@ -15,6 +15,8 @@ st \- simple terminal .IR file ] .RB [ \-t .IR title ] +.RB [ \-T +.IR title ] .RB [ \-l .IR line ] .RB [ \-w @@ -37,6 +39,8 @@ st \- simple terminal .IR file ] .RB [ \-t .IR title ] +.RB [ \-T +.IR title ] .RB [ \-l .IR line ] .RB [ \-w @@ -79,6 +83,9 @@ standard output. .BI \-t " title" defines the window title (default 'st'). .TP +.BI \-T " title" +defines the window title (default 'st'). +.TP .BI \-w " windowid" embeds st within the window identified by .I windowid diff --git a/st.c b/st.c index f53378c..c384977 100644 --- a/st.c +++ b/st.c @@ -4302,6 +4302,7 @@ main(int argc, char *argv[]) opt_line = EARGF(usage()); break; case 't': + case 'T': opt_title = EARGF(usage()); break; case 'w': -- 2.20.1 From dc33d1d66e89ee974cc6d7cfa2efb693ce67aa86 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Fri, 24 Jul 2015 18:25:33 +0200 Subject: [PATCH 04/16] Adding -T to the usage too. --- st.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index c384977..0db3d58 100644 --- a/st.c +++ b/st.c @@ -4259,9 +4259,11 @@ usage(void) { die("%s " VERSION " (c) 2010-2015 st engineers\n" "usage: st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]\n" - " [-i] [-t title] [-w windowid] [-e command ...] [command ...]\n" + " [-i] [-t title] [-T title] [-w windowid] [-e command ...]" + " [command ...]\n" " st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]\n" - " [-i] [-t title] [-w windowid] [-l line] [stty_args ...]\n", + " [-i] [-t title] [-T title] [-w windowid] [-l line]" + " [stty_args ...]\n", argv0); } -- 2.20.1 From ee5cad439b427fa974903a6f0bb2689d11119d89 Mon Sep 17 00:00:00 2001 From: Alex Kozadaev Date: Tue, 28 Jul 2015 10:30:14 +0100 Subject: [PATCH 05/16] Adding mouse colour/shape settings --- config.def.h | 8 ++++++++ st.c | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index 2616dea..930e468 100644 --- a/config.def.h +++ b/config.def.h @@ -105,6 +105,14 @@ static unsigned int defaultfg = 7; static unsigned int defaultbg = 0; static unsigned int defaultcs = 256; + +/* + * Default colour and shape of the mouse cursor + */ +static unsigned int mouseshape = XC_xterm; +static unsigned int mousefg = 7; +static unsigned int mousebg = 0; + /* * Colors used, when the specific fg == defaultfg. So in reverse mode this * will reverse too. Another logic would only make the simple feature too diff --git a/st.c b/st.c index 0db3d58..1df4fde 100644 --- a/st.c +++ b/st.c @@ -3411,6 +3411,7 @@ xinit(void) Cursor cursor; Window parent; pid_t thispid = getpid(); + XColor xmousefg, xmousebg; if (!(xw.dpy = XOpenDisplay(NULL))) die("Can't open display\n"); @@ -3483,11 +3484,22 @@ xinit(void) die("XCreateIC failed. Could not obtain input method.\n"); /* white cursor, black outline */ - cursor = XCreateFontCursor(xw.dpy, XC_xterm); + cursor = XCreateFontCursor(xw.dpy, mouseshape); XDefineCursor(xw.dpy, xw.win, cursor); - XRecolorCursor(xw.dpy, cursor, - &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff}, - &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000}); + + if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) { + xmousefg.red = 0xffff; + xmousefg.green = 0xffff; + xmousefg.blue = 0xffff; + } + + if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) { + xmousebg.red = 0x0000; + xmousebg.green = 0x0000; + xmousebg.blue = 0x0000; + } + + XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg); xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); -- 2.20.1 From 9984ad4ba730b043d064095dca42b490904e38f3 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Tue, 11 Aug 2015 17:47:12 +0200 Subject: [PATCH 06/16] st.info: replace the acsc entry from xterm to urxvt The current acsc entry, copied from xterm was not exposing capability to display arrows. --- st.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.info b/st.info index 2acd8b2..b70fefa 100644 --- a/st.info +++ b/st.info @@ -1,5 +1,5 @@ st| simpleterm, - acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, am, bce, bel=^G, -- 2.20.1 From 7e61f5e4c514a233250442263b62d887c9e5ca9c Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Mon, 17 Aug 2015 11:25:38 +0200 Subject: [PATCH 07/16] Do not mark as invalid UTF8 control codes wcwidth() returns -1 for all the non visible characters, but it doesn't necessarilly mean that they are incorrect. It only means that they are not printable. --- st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index 1df4fde..35a840b 100644 --- a/st.c +++ b/st.c @@ -2895,15 +2895,15 @@ tputc(Rune u) int width, len; Glyph *gp; + control = ISCONTROL(u); len = utf8encode(u, c); - if ((width = wcwidth(u)) == -1) { + if (!control && (width = wcwidth(u)) == -1) { memcpy(c, "\357\277\275", 4); /* UTF_INVALID */ width = 1; } if (IS_SET(MODE_PRINT)) tprinter(c, len); - control = ISCONTROL(u); /* * STR sequence must be checked before anything else -- 2.20.1 From 0d838b72437c6cac0d87366352939fdb86c2b697 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sun, 30 Aug 2015 11:28:35 +0200 Subject: [PATCH 08/16] Don't read if we chunked the input data. --- st.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/st.c b/st.c index 1df4fde..e76aaf3 100644 --- a/st.c +++ b/st.c @@ -1531,7 +1531,8 @@ ttywrite(const char *s, size_t n) * This means the buffer is getting full * again. Empty it. */ - ttyread(); + if (n < 256) + ttyread(); n -= r; s += r; } else { -- 2.20.1 From 9eeb4e1ea22b9ca53b885615b896cd5ed8dee04a Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Mon, 31 Aug 2015 15:26:21 +0200 Subject: [PATCH 09/16] Reordering and adding control codes. For completeness and documentation add all C1 control codes. --- st.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/st.c b/st.c index aaf868d..d49804b 100644 --- a/st.c +++ b/st.c @@ -2774,18 +2774,37 @@ tcontrolcode(uchar ascii) case '\023': /* XOFF (IGNORED) */ case 0177: /* DEL (IGNORED) */ return; + case 0x80: /* TODO: PAD */ + case 0x81: /* TODO: HOP */ + case 0x82: /* TODO: BPH */ + case 0x83: /* TODO: NBH */ case 0x84: /* TODO: IND */ break; case 0x85: /* NEL -- Next line */ tnewline(1); /* always go to first col */ break; + case 0x86: /* TODO: SSA */ + case 0x87: /* TODO: ESA */ + break; case 0x88: /* HTS -- Horizontal tab stop */ term.tabs[term.c.x] = 1; break; + case 0x89: /* TODO: HTJ */ + case 0x8a: /* TODO: VTS */ + case 0x8b: /* TODO: PLD */ + case 0x8c: /* TODO: PLU */ case 0x8d: /* TODO: RI */ case 0x8e: /* TODO: SS2 */ case 0x8f: /* TODO: SS3 */ + case 0x91: /* TODO: PU1 */ + case 0x92: /* TODO: PU2 */ + case 0x93: /* TODO: STS */ + case 0x94: /* TODO: CCH */ + case 0x95: /* TODO: MW */ + case 0x96: /* TODO: SPA */ + case 0x97: /* TODO: EPA */ case 0x98: /* TODO: SOS */ + case 0x99: /* TODO: SGCI */ break; case 0x9a: /* DECID -- Identify Terminal */ ttywrite(vtiden, sizeof(vtiden) - 1); @@ -2794,9 +2813,9 @@ tcontrolcode(uchar ascii) case 0x9c: /* TODO: ST */ break; case 0x90: /* DCS -- Device Control String */ - case 0x9f: /* APC -- Application Program Command */ - case 0x9e: /* PM -- Privacy Message */ case 0x9d: /* OSC -- Operating System Command */ + case 0x9e: /* PM -- Privacy Message */ + case 0x9f: /* APC -- Application Program Command */ tstrsequence(ascii); return; } -- 2.20.1 From 080a5ae4252c9c9a9d83b702d8478966ab79326e Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Mon, 7 Sep 2015 20:00:49 +0200 Subject: [PATCH 10/16] Fix the st manpage for -l line. --- st.1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/st.1 b/st.1 index 82e228a..b961b26 100644 --- a/st.1 +++ b/st.1 @@ -41,13 +41,11 @@ st \- simple terminal .IR title ] .RB [ \-T .IR title ] -.RB [ \-l -.IR line ] .RB [ \-w .IR windowid ] .RB [ \-v ] -.RB [ \-l -.IR line ] +.RB \-l +.IR line .RI [ stty_args ...] .SH DESCRIPTION .B st -- 2.20.1 From aa5d4c3b340d180eb0b375b3b4a923cf91ffb04a Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Mon, 7 Sep 2015 22:59:05 +0200 Subject: [PATCH 11/16] Making st.1 more descriptive about -l and fix -l in st.c. --- st.1 | 21 ++++++++++++++++++--- st.c | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/st.1 b/st.1 index b961b26..29e3163 100644 --- a/st.1 +++ b/st.1 @@ -89,9 +89,24 @@ embeds st within the window identified by .I windowid .TP .BI \-l " line" -use a tty line instead of a pseudo terminal. -When this flag is used -remaining arguments are used as flags for stty. +use a tty +.I line +instead of a pseudo terminal. +.I line +should be a (pseudo-)serial device (e.g. /dev/ttySO on Linux for serial port +0). +When this flag is given +remaining arguments are used as flags for +.BR stty(1). +By default st initializes the serial line to 8 bits, no parity, 1 stop bit +and a 38400 baud rate. The speed is set by appending it as last argument +(e.g. 'st -l 115200'). Arguments before the last one are +.BR stty(1) +flags. If you want to set odd parity on 115200 baud use for example 'st -l +parenb parodd 115200'. Set the number of bits by using for example 'st -l cs7 +115200'. See +.BR stty(1) +for more arguments and cases. .TP .B \-v prints version information to stderr, then exits. diff --git a/st.c b/st.c index d49804b..256f8f5 100644 --- a/st.c +++ b/st.c @@ -4294,7 +4294,7 @@ usage(void) " [-i] [-t title] [-T title] [-w windowid] [-e command ...]" " [command ...]\n" " st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]\n" - " [-i] [-t title] [-T title] [-w windowid] [-l line]" + " [-i] [-t title] [-T title] [-w windowid] -l line" " [stty_args ...]\n", argv0); } -- 2.20.1 From 473326f2e3115f4b745730be782b2eba63e0934c Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Tue, 8 Sep 2015 10:44:35 +0200 Subject: [PATCH 12/16] Set default values of stty according to the man page This configuration is basically 38400 8N1, without echo and in raw mode. Kernel will not process any of the characters sent by the user. --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 930e468..11a0c02 100644 --- a/config.def.h +++ b/config.def.h @@ -18,7 +18,7 @@ static int borderpx = 2; */ static char shell[] = "/bin/sh"; static char *utmp = NULL; -static char stty_args[] = "stty raw -echo -iexten echonl"; +static char stty_args[] = "stty raw pass8 nl -echo -iexten -cstopb 38400"; /* identification sequence returned in DA and DECID */ static char vtiden[] = "\033[?6c"; -- 2.20.1 From 1f087aa8b70fce67e7c43f689b5fb35667b5d84c Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Tue, 8 Sep 2015 12:10:11 +0200 Subject: [PATCH 13/16] Add key to send a break to the serial line --- config.def.h | 1 + st.1 | 3 +++ st.c | 9 +++++++++ 3 files changed, 13 insertions(+) diff --git a/config.def.h b/config.def.h index 11a0c02..7129fa1 100644 --- a/config.def.h +++ b/config.def.h @@ -134,6 +134,7 @@ static Mousekey mshortcuts[] = { static Shortcut shortcuts[] = { /* mask keysym function argument */ + { XK_NO_MOD, XK_Pause, sendbreak, {.i = 0} }, { ControlMask, XK_Print, toggleprinter, {.i = 0} }, { ShiftMask, XK_Print, printscreen, {.i = 0} }, { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, diff --git a/st.1 b/st.1 index 29e3163..f2f3f0e 100644 --- a/st.1 +++ b/st.1 @@ -122,6 +122,9 @@ and all the remaining arguments are used as a command even without it. .SH SHORTCUTS .TP +.B Pause +Send a break in the serial line +.TP .B Ctrl-Print Screen Toggle if st should print to the .I iofile. diff --git a/st.c b/st.c index 256f8f5..7804316 100644 --- a/st.c +++ b/st.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -333,6 +334,7 @@ static void xzoomreset(const Arg *); static void printsel(const Arg *); static void printscreen(const Arg *) ; static void toggleprinter(const Arg *); +static void sendbreak(const Arg *); /* Config.h for applying patches and the configuration. */ #include "config.h" @@ -2578,6 +2580,13 @@ strreset(void) memset(&strescseq, 0, sizeof(strescseq)); } +void +sendbreak(const Arg *arg) +{ + if (tcsendbreak(cmdfd, 0)) + perror("Error sending break"); +} + void tprinter(char *s, size_t len) { -- 2.20.1 From 3ba9c8fc3f547a5762b3d4a6a16cc794446d76a3 Mon Sep 17 00:00:00 2001 From: Jan Christoph Ebersbach Date: Tue, 8 Sep 2015 07:28:52 +0200 Subject: [PATCH 14/16] Expose cursor shape in config.def.h Signed-off-by: Christoph Lohmann <20h@r-36.net> --- config.def.h | 9 +++++++++ st.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 7129fa1..c7ce3b4 100644 --- a/config.def.h +++ b/config.def.h @@ -105,6 +105,15 @@ static unsigned int defaultfg = 7; static unsigned int defaultbg = 0; static unsigned int defaultcs = 256; +/* + * Default shape of cursor + * 2: Block + * 4: Underline + * 6: IBeam + */ + +static unsigned int cursorshape = 2; + /* * Default colour and shape of the mouse cursor diff --git a/st.c b/st.c index 7804316..530d7e4 100644 --- a/st.c +++ b/st.c @@ -4315,7 +4315,7 @@ main(int argc, char *argv[]) xw.l = xw.t = 0; xw.isfixed = False; - xw.cursor = 0; + xw.cursor = cursorshape; ARGBEGIN { case 'a': -- 2.20.1 From a1ed5071e54e4f8ce765c07d5415da7d8cedf618 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Tue, 8 Sep 2015 17:00:20 +0200 Subject: [PATCH 15/16] Change Pause to Break in shortcut for serial break --- config.def.h | 2 +- st.1 | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index c7ce3b4..52bf3a4 100644 --- a/config.def.h +++ b/config.def.h @@ -143,7 +143,7 @@ static Mousekey mshortcuts[] = { static Shortcut shortcuts[] = { /* mask keysym function argument */ - { XK_NO_MOD, XK_Pause, sendbreak, {.i = 0} }, + { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, { ControlMask, XK_Print, toggleprinter, {.i = 0} }, { ShiftMask, XK_Print, printscreen, {.i = 0} }, { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, diff --git a/st.1 b/st.1 index f2f3f0e..187a734 100644 --- a/st.1 +++ b/st.1 @@ -122,8 +122,10 @@ and all the remaining arguments are used as a command even without it. .SH SHORTCUTS .TP -.B Pause -Send a break in the serial line +.B Break +Send a break in the serial line. +Break key is obtained in PC keyboards +pressing at the same time control and pause. .TP .B Ctrl-Print Screen Toggle if st should print to the -- 2.20.1 From 5d2d9d540d84761cf11648ea42a6413001a5d7b9 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Thu, 10 Sep 2015 11:53:11 +0200 Subject: [PATCH 16/16] Fix copy of line with len = 0 When a line has no any character linelen is 0, so last = &term.line[y][MIN(lastx, linelen-1)] generated a pointer to the end of the previous line. The best thing we can do in this case is to add a newline, because we don't have a glyph to print (and consult its state of wrapping). --- st.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/st.c b/st.c index 530d7e4..bd8b815 100644 --- a/st.c +++ b/st.c @@ -1004,7 +1004,10 @@ getsel(void) /* append every set & selected glyph to the selection */ for (y = sel.nb.y; y <= sel.ne.y; y++) { - linelen = tlinelen(y); + if ((linelen = tlinelen(y)) == 0) { + *ptr++ = '\n'; + continue; + } if (sel.type == SEL_RECTANGULAR) { gp = &term.line[y][sel.nb.x]; -- 2.20.1