Hello,

        These patches fix some control codes problems.

Sincerely.
>From 2a346a24efb6a79d25dcfa1d0fb718267b8f6bac Mon Sep 17 00:00:00 2001
From: "Roberto E. Vargas Caballero" <k...@shike2.com>
Date: Mon, 24 Sep 2012 23:03:34 +0200
Subject: Ignore all control characters not handled

Taken from vt100 programmer manual:

	Control characters have values of \000 - \037, and \177. The control
	characters recognized by the VT100 are shown in Table 3-10. All
	other control codes cause no action to be taken.

We have to take attention when we are using alternate charset, because in
this cases they are not used as control characters.
---
 st.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/st.c b/st.c
index 009ccb4..e1cb4a8 100644
--- a/st.c
+++ b/st.c
@@ -1642,7 +1642,7 @@ tputtab(bool forward) {
 
 void
 tputc(char *c, int len) {
-	char ascii = *c;
+	uchar ascii = *c;
 
 	if(iofd != -1)
 		write(iofd, c, len);
@@ -1761,8 +1761,6 @@ tputc(char *c, int len) {
 		if(sel.bx != -1 && BETWEEN(term.c.y, sel.by, sel.ey))
 			sel.bx = -1;
 		switch(ascii) {
-		case '\0': /* padding character, do nothing */
-			break;
 		case '\t':
 			tputtab(1);
 			break;
@@ -1787,13 +1785,15 @@ tputc(char *c, int len) {
 			term.esc = ESC_START;
 			break;
 		default:
-			if(IS_SET(MODE_WRAP) && term.c.state & CURSOR_WRAPNEXT)
-				tnewline(1); /* always go to first col */
-			tsetchar(c);
-			if(term.c.x+1 < term.col)
-				tmoveto(term.c.x+1, term.c.y);
-			else
-				term.c.state |= CURSOR_WRAPNEXT;
+			if(ascii >= '\020' || term.c.attr.mode & ATTR_GFX) {
+				if(IS_SET(MODE_WRAP) && term.c.state & CURSOR_WRAPNEXT)
+					tnewline(1); /* always go to first col */
+				tsetchar(c);
+				if(term.c.x+1 < term.col)
+					tmoveto(term.c.x+1, term.c.y);
+				else
+					term.c.state |= CURSOR_WRAPNEXT;
+			}
 		}
 	}
 }
-- 
1.7.10.4

>From bc5103baed408f79c1f0ba119816faab2284fe47 Mon Sep 17 00:00:00 2001
From: "Roberto E. Vargas Caballero" <k...@shike2.com>
Date: Wed, 26 Sep 2012 20:41:28 +0200
Subject: Allow control characters inside escape sequences

Taken from vt100 manual programmer:

	Control characters (codes \0 to \37 inclusive) are specifically
	excluded from the control sequence syntax, but may be embedded
	within a control sequence. Embedded control characters are executed
	as soon as they are encountered by the VT100. The processing of the
	control sequence then continues with the next character received.
---
 st.c |   68 +++++++++++++++++++++++++++++++++---------------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/st.c b/st.c
index e1cb4a8..16c6b8f 100644
--- a/st.c
+++ b/st.c
@@ -1647,6 +1647,32 @@ tputc(char *c, int len) {
 	if(iofd != -1)
 		write(iofd, c, len);
 
+	switch(ascii) {
+	case '\t':
+		tputtab(1);
+		return;
+	case '\b':
+		tmoveto(term.c.x-1, term.c.y);
+		return;
+	case '\r':
+		tmoveto(0, term.c.y);
+		return;
+	case '\f':
+	case '\v':
+	case '\n':
+		/* go to first col if the mode is set */
+		tnewline(IS_SET(MODE_CRLF));
+		return;
+	case '\a':
+		if(!(xw.state & WIN_FOCUSED))
+			xseturgency(1);
+		return;
+	case '\033':
+		csireset();
+		term.esc = ESC_START;
+		return;
+	}
+
 	if(term.esc & ESC_START) {
 		if(term.esc & ESC_CSI) {
 			csiescseq.buf[csiescseq.len++] = ascii;
@@ -1760,40 +1786,14 @@ tputc(char *c, int len) {
 	} else {
 		if(sel.bx != -1 && BETWEEN(term.c.y, sel.by, sel.ey))
 			sel.bx = -1;
-		switch(ascii) {
-		case '\t':
-			tputtab(1);
-			break;
-		case '\b':
-			tmoveto(term.c.x-1, term.c.y);
-			break;
-		case '\r':
-			tmoveto(0, term.c.y);
-			break;
-		case '\f':
-		case '\v':
-		case '\n':
-			/* go to first col if the mode is set */
-			tnewline(IS_SET(MODE_CRLF));
-			break;
-		case '\a':
-			if(!(xw.state & WIN_FOCUSED))
-				xseturgency(1);
-			break;
-		case '\033':
-			csireset();
-			term.esc = ESC_START;
-			break;
-		default:
-			if(ascii >= '\020' || term.c.attr.mode & ATTR_GFX) {
-				if(IS_SET(MODE_WRAP) && term.c.state & CURSOR_WRAPNEXT)
-					tnewline(1); /* always go to first col */
-				tsetchar(c);
-				if(term.c.x+1 < term.col)
-					tmoveto(term.c.x+1, term.c.y);
-				else
-					term.c.state |= CURSOR_WRAPNEXT;
-			}
+		if(ascii >= '\020' || term.c.attr.mode & ATTR_GFX) {
+			if(IS_SET(MODE_WRAP) && term.c.state & CURSOR_WRAPNEXT)
+				tnewline(1); /* always go to first col */
+			tsetchar(c);
+			if(term.c.x+1 < term.col)
+				tmoveto(term.c.x+1, term.c.y);
+			else
+				term.c.state |= CURSOR_WRAPNEXT;
 		}
 	}
 }
-- 
1.7.10.4

Reply via email to