aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--st.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/st.c b/st.c
index 33a1501..693739e 100644
--- a/st.c
+++ b/st.c
@@ -123,6 +123,7 @@ enum escape_state {
123 ESC_STR = 4, /* DSC, OSC, PM, APC */ 123 ESC_STR = 4, /* DSC, OSC, PM, APC */
124 ESC_ALTCHARSET = 8, 124 ESC_ALTCHARSET = 8,
125 ESC_STR_END = 16, /* a final string was encountered */ 125 ESC_STR_END = 16, /* a final string was encountered */
126 ESC_TEST = 32, /* Enter in test mode */
126}; 127};
127 128
128enum window_state { 129enum window_state {
@@ -289,7 +290,7 @@ static int tresize(int, int);
289static void tscrollup(int, int); 290static void tscrollup(int, int);
290static void tscrolldown(int, int); 291static void tscrolldown(int, int);
291static void tsetattr(int*, int); 292static void tsetattr(int*, int);
292static void tsetchar(char*); 293static void tsetchar(char *, Glyph *, int, int);
293static void tsetscroll(int, int); 294static void tsetscroll(int, int);
294static void tswapscreen(void); 295static void tswapscreen(void);
295static void tsetdirt(int, int); 296static void tsetdirt(int, int);
@@ -1182,7 +1183,7 @@ tmoveto(int x, int y) {
1182} 1183}
1183 1184
1184void 1185void
1185tsetchar(char *c) { 1186tsetchar(char *c, Glyph *attr, int x, int y) {
1186 static char *vt100_0[62] = { /* 0x41 - 0x7e */ 1187 static char *vt100_0[62] = { /* 0x41 - 0x7e */
1187 "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */ 1188 "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
1188 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */ 1189 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
@@ -1197,17 +1198,17 @@ tsetchar(char *c) {
1197 /* 1198 /*
1198 * The table is proudly stolen from rxvt. 1199 * The table is proudly stolen from rxvt.
1199 */ 1200 */
1200 if(term.c.attr.mode & ATTR_GFX) { 1201 if(attr->mode & ATTR_GFX) {
1201 if(c[0] >= 0x41 && c[0] <= 0x7e 1202 if(c[0] >= 0x41 && c[0] <= 0x7e
1202 && vt100_0[c[0] - 0x41]) { 1203 && vt100_0[c[0] - 0x41]) {
1203 c = vt100_0[c[0] - 0x41]; 1204 c = vt100_0[c[0] - 0x41];
1204 } 1205 }
1205 } 1206 }
1206 1207
1207 term.dirty[term.c.y] = 1; 1208 term.dirty[y] = 1;
1208 term.line[term.c.y][term.c.x] = term.c.attr; 1209 term.line[y][x] = *attr;
1209 memcpy(term.line[term.c.y][term.c.x].c, c, UTF_SIZ); 1210 memcpy(term.line[y][x].c, c, UTF_SIZ);
1210 term.line[term.c.y][term.c.x].state |= GLYPH_SET; 1211 term.line[y][x].state |= GLYPH_SET;
1211} 1212}
1212 1213
1213void 1214void
@@ -1893,11 +1894,25 @@ tputc(char *c, int len) {
1893 fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii); 1894 fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii);
1894 } 1895 }
1895 term.esc = 0; 1896 term.esc = 0;
1897 } else if(term.esc & ESC_TEST) {
1898 if(ascii == '8') { /* DEC screen alignment test. */
1899 char E[UTF_SIZ] = "E";
1900 int x, y;
1901
1902 for(x = 0; x < term.col; ++x) {
1903 for(y = 0; y < term.row; ++y)
1904 tsetchar(E, &term.c.attr, x, y);
1905 }
1906 }
1907 term.esc = 0;
1896 } else { 1908 } else {
1897 switch(ascii) { 1909 switch(ascii) {
1898 case '[': 1910 case '[':
1899 term.esc |= ESC_CSI; 1911 term.esc |= ESC_CSI;
1900 break; 1912 break;
1913 case '#':
1914 term.esc |= ESC_TEST;
1915 break;
1901 case 'P': /* DCS -- Device Control String */ 1916 case 'P': /* DCS -- Device Control String */
1902 case '_': /* APC -- Application Program Command */ 1917 case '_': /* APC -- Application Program Command */
1903 case '^': /* PM -- Privacy Message */ 1918 case '^': /* PM -- Privacy Message */
@@ -1988,7 +2003,7 @@ tputc(char *c, int len) {
1988 sel.bx = -1; 2003 sel.bx = -1;
1989 if(IS_SET(MODE_WRAP) && term.c.state & CURSOR_WRAPNEXT) 2004 if(IS_SET(MODE_WRAP) && term.c.state & CURSOR_WRAPNEXT)
1990 tnewline(1); /* always go to first col */ 2005 tnewline(1); /* always go to first col */
1991 tsetchar(c); 2006 tsetchar(c, &term.c.attr, term.c.x, term.c.y);
1992 if(term.c.x+1 < term.col) 2007 if(term.c.x+1 < term.col)
1993 tmoveto(term.c.x+1, term.c.y); 2008 tmoveto(term.c.x+1, term.c.y);
1994 else 2009 else