Hello,

        Some new patches for st:

0001-Add-initialization-strings-in-terminfo.patch

Some new terminfo capabilities which help running reset.

0001-Add-write-I-O-to-file.patch

Add a theorical feature listed in st goals.

0001-Force-redisplay-of-all-lines-in-DECSCNM.patch

Add full redraw of the window in DECSCNM (reverse mode).

Best regards,
>From 36550dccb6776a67d25b8af3cbfa87407fb5364b Mon Sep 17 00:00:00 2001
From: "Roberto E. Vargas Caballero" <[email protected]>
Date: Mon, 3 Sep 2012 18:50:52 +0200
Subject: [PATCH] Add initialization strings in terminfo

When tput init is executed the list of task performed are (taken from
terminfo(5)):

              run the program
                     iprog

              output is1 is2

              set the margins using
                     mgc, smgl and smgr

              set tabs using
                     tbc and hts

              print the file
                     if

              and finally
                     output is3.

When reset is executed, a more stronger initialization process is performed,
so the terminal can return from an unknown state. rs1, rs2 and rs3 are used
in this case instead of
using is1, is2 and is3.

This patch makes is2 = rs2, resets insert mode and set normal keypad
mode. For rs1 it performs a full initilization using ^[c.
---
 st.info |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/st.info b/st.info
index e883319..20e3f57 100644
--- a/st.info
+++ b/st.info
@@ -46,6 +46,7 @@ st| simpleterm,
 	ind=^J,
 	indn=\E[%p1%dS,
 	invis=\E[8m,
+	is2=\E[4l\E>,
 	it#8,
 	kbs=\177,
 	kcub1=\E[D,
@@ -82,6 +83,8 @@ st| simpleterm,
 	op=\E[39;49m,
 	pairs#64,
 	rc=\E8,
+        rs1=\Ec,
+        rs2=\E[4l\E>,
 	rev=\E[7m,
 	ri=\EM,
 	rmacs=\E(B,
-- 
1.7.10.4

>From 91dbb5a8892b4b672722c9044316a0611683c777 Mon Sep 17 00:00:00 2001
From: "Roberto E. Vargas Caballero" <[email protected]>
Date: Mon, 3 Sep 2012 18:47:54 +0200
Subject: [PATCH] Add write I/O to file

This is a theorical feature listed in http://st.suckless.org/goals. All the
input/output of the terminal will be written to a file, which can be very
useful for debugging, and also allow interconnect st to other process
through named pipes.
---
 st.1 |    6 ++++++
 st.c |   14 +++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/st.1 b/st.1
index b6c119f..931b481 100644
--- a/st.1
+++ b/st.1
@@ -10,6 +10,8 @@ st \- simple terminal
 .RB [ \-w 
 .IR windowid ]
 .RB [ \-v ]
+.RB [ \-f
+.IR file ]
 .RB [ \-e
 .IR command ...]
 .SH DESCRIPTION
@@ -30,6 +32,10 @@ embeds st within the window identified by
 .B \-v
 prints version information to stderr, then exits.
 .TP
+.BI \-f " file"
+writes all the I/O to
+.I file
+.TP
 .BI \-e " program " [ " arguments " "... ]"
 st executes
 .I program
diff --git a/st.c b/st.c
index bd230a3..fde0493 100644
--- a/st.c
+++ b/st.c
@@ -36,7 +36,7 @@
 
 #define USAGE \
 	"st " VERSION " (c) 2010-2012 st engineers\n" \
-	"usage: st [-t title] [-c class] [-w windowid] [-v] [-e command...]\n"
+	"usage: st [-t title] [-c class] [-w windowid] [-v] [-f file] [-e command...]\n"
 
 /* XEMBED messages */
 #define XEMBED_FOCUS_IN  4
@@ -342,7 +342,9 @@ static STREscape strescseq;
 static int cmdfd;
 static pid_t pid;
 static Selection sel;
+static FILE *fileio;
 static char **opt_cmd  = NULL;
+static char *opt_io    = NULL;
 static char *opt_title = NULL;
 static char *opt_embed = NULL;
 static char *opt_class = NULL;
@@ -776,6 +778,10 @@ ttynew(void) {
 		close(s);
 		cmdfd = m;
 		signal(SIGCHLD, sigchld);
+		if (opt_io && !(fileio = fopen(opt_io, "w"))) {
+			fprintf(stderr, "Error opening %s:%s",
+				opt_io, strerror(errno));
+		}
 	}
 }
 
@@ -1534,6 +1540,9 @@ tputtab(bool forward) {
 void
 tputc(char *c) {
 	char ascii = *c;
+
+	if (fileio)
+		putc(ascii, fileio);
 	if(term.esc & ESC_START) {
 		if(term.esc & ESC_CSI) {
 			csiescseq.buf[csiescseq.len++] = ascii;
@@ -2269,6 +2278,9 @@ main(int argc, char *argv[]) {
 		case 'w':
 			if(++i < argc) opt_embed = argv[i];
 			break;
+		case 'f':
+			if (++i < argc) opt_io = argv[i];
+			break;
 		case 'e':
 			/* eat every remaining arguments */
 			if(++i < argc) opt_cmd = &argv[i];
-- 
1.7.10.4

>From 7274e538601584d00617236193ad225e7b8e3f8d Mon Sep 17 00:00:00 2001
From: "Roberto E. Vargas Caballero" <[email protected]>
Date: Mon, 3 Sep 2012 19:01:53 +0200
Subject: [PATCH] Force redisplay of all lines in DECSCNM

When it is called DECSCNM all lines become dirty, because it is necessary
redraw all lines for getting the new colors. It is easy see the problem
running 'echo ^[[?5h'.

In order to get a correct flash when running tput flash is necessary wait
after DECSCNM, until the changes are displayed, because in other case the
switch between reverse on/reverse off will be too much fast and nothing will
happen.
---
 st.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/st.c b/st.c
index fde0493..193db5e 100644
--- a/st.c
+++ b/st.c
@@ -54,6 +54,7 @@
 
 #define SELECT_TIMEOUT (20*1000) /* 20 ms */
 #define DRAW_TIMEOUT  (20*1000) /* 20 ms */
+#define REDRAW_TIMEOUT (80*1000) /* 80 ms */
 
 #define SERRNO strerror(errno)
 #define MIN(a, b)  ((a) < (b) ? (a) : (b))
@@ -238,6 +239,7 @@ typedef struct {
 
 static void die(const char*, ...);
 static void draw(void);
+static void redraw(void);
 static void drawregion(int, int, int, int);
 static void execsh(void);
 static void sigchld(int);
@@ -1206,7 +1208,7 @@ tsetmode(bool priv, bool set, int *args, int narg) {
 				mode = term.mode;
 				MODBIT(term.mode,set, MODE_REVERSE);
 				if (mode != term.mode)
-					draw();
+					redraw();
 				break;
 			case 7:
 				MODBIT(term.mode, set, MODE_WRAP);
@@ -2030,6 +2032,14 @@ xdrawcursor(void) {
 }
 
 void
+redraw(void) {
+	struct timespec tv = {0, REDRAW_TIMEOUT * 1000};
+	tfulldirt();
+	draw();
+	nanosleep(&tv, NULL);
+}
+
+void
 draw() {
 	drawregion(0, 0, term.col, term.row);
 	xcopy();
-- 
1.7.10.4

Reply via email to