aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2010-08-29 20:12:44 +0200
committerAurélien Aptel <aurelien.aptel@gmail.com>2010-08-29 20:12:44 +0200
commit5258d6054599e456c260984b8619500d0b4b75b7 (patch)
tree05a51ae2342dab7f5adc4d935f29ca7ac5f4a116
parentb4f623f9109cc38a87469c6430d5e780e9a01989 (diff)
downloadst-5258d6054599e456c260984b8619500d0b4b75b7.tar.gz
st-5258d6054599e456c260984b8619500d0b4b75b7.zip
fixed optimized drawing routine and factored some code.
-rw-r--r--st.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/st.c b/st.c
index 5f206fd..5c7d855 100644
--- a/st.c
+++ b/st.c
@@ -46,8 +46,8 @@
46 46
47/* Attribute, Cursor, Character state, Terminal mode, Screen draw mode */ 47/* Attribute, Cursor, Character state, Terminal mode, Screen draw mode */
48enum { ATTR_NULL=0 , ATTR_REVERSE=1 , ATTR_UNDERLINE=2, ATTR_BOLD=4, ATTR_GFX=8 }; 48enum { ATTR_NULL=0 , ATTR_REVERSE=1 , ATTR_UNDERLINE=2, ATTR_BOLD=4, ATTR_GFX=8 };
49enum { CURSOR_UP, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT, CURSOR_HIDE, CURSOR_DRAW, 49enum { CURSOR_UP, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT, CURSOR_HIDE = 1,
50 CURSOR_SAVE, CURSOR_LOAD }; 50 CURSOR_DRAW = 0, CURSOR_SAVE, CURSOR_LOAD };
51enum { GLYPH_SET=1, GLYPH_DIRTY=2 }; 51enum { GLYPH_SET=1, GLYPH_DIRTY=2 };
52enum { MODE_WRAP=1, MODE_INSERT=2, MODE_APPKEYPAD=4 }; 52enum { MODE_WRAP=1, MODE_INSERT=2, MODE_APPKEYPAD=4 };
53enum { ESC_START=1, ESC_CSI=2, ESC_OSC=4, ESC_TITLE=8, ESC_ALTCHARSET=16 }; 53enum { ESC_START=1, ESC_CSI=2, ESC_OSC=4, ESC_TITLE=8, ESC_ALTCHARSET=16 };
@@ -711,7 +711,7 @@ csihandle(void) {
711 case 12: /* att610 -- Stop blinking cursor (IGNORED) */ 711 case 12: /* att610 -- Stop blinking cursor (IGNORED) */
712 break; 712 break;
713 case 25: 713 case 25:
714 term.c.hide = 1; 714 term.c.hide = CURSOR_HIDE;
715 break; 715 break;
716 case 1048: /* XXX: no alt. screen to erase/save */ 716 case 1048: /* XXX: no alt. screen to erase/save */
717 case 1049: 717 case 1049:
@@ -760,7 +760,7 @@ csihandle(void) {
760 case 12: /* att610 -- Start blinking cursor (IGNORED) */ 760 case 12: /* att610 -- Start blinking cursor (IGNORED) */
761 break; 761 break;
762 case 25: 762 case 25:
763 term.c.hide = 0; 763 term.c.hide = CURSOR_DRAW;
764 break; 764 break;
765 case 1048: 765 case 1048:
766 case 1049: /* XXX: no alt. screen to erase/save */ 766 case 1049: /* XXX: no alt. screen to erase/save */
@@ -1166,8 +1166,7 @@ draw(int dummy) {
1166 if(term.line[y][x].state & GLYPH_SET) 1166 if(term.line[y][x].state & GLYPH_SET)
1167 xdrawc(x, y, term.line[y][x]); 1167 xdrawc(x, y, term.line[y][x]);
1168 1168
1169 if(!term.c.hide) 1169 xcursor(term.c.hide);
1170 xcursor(CURSOR_DRAW);
1171 XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER); 1170 XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER);
1172 XFlush(xw.dis); 1171 XFlush(xw.dis);
1173} 1172}
@@ -1187,19 +1186,23 @@ draw(int redraw_all) {
1187 i = ox = 0; 1186 i = ox = 0;
1188 for(x = 0; x < term.col; x++) { 1187 for(x = 0; x < term.col; x++) {
1189 new = term.line[y][x]; 1188 new = term.line[y][x];
1190 if(!ATTRCMP(base, new) && i < DRAW_BUF_SIZ) 1189 if(i > 0 && (!(new.state & GLYPH_SET) || ATTRCMP(base, new) ||
1191 buf[i++] = new.c; 1190 i >= DRAW_BUF_SIZ)) {
1192 else {
1193 xdraws(buf, base, ox, y, i); 1191 xdraws(buf, base, ox, y, i);
1194 buf[0] = new.c; 1192 i = 0;
1195 i = 1; 1193 }
1196 ox = x; 1194 if(new.state & GLYPH_SET) {
1197 base = new; 1195 if(i == 0) {
1196 ox = x;
1197 base = new;
1198 }
1199 buf[i++] = new.c;
1198 } 1200 }
1199 } 1201 }
1200 xdraws(buf, base, ox, y, i); 1202 if(i > 0)
1203 xdraws(buf, base, ox, y, i);
1201 } 1204 }
1202 xcursor(term.c.hide ? CURSOR_HIDE : CURSOR_DRAW); 1205 xcursor(term.c.hide);
1203 XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER); 1206 XCopyArea(xw.dis, xw.buf, xw.win, dc.gc, 0, 0, xw.bufw, xw.bufh, BORDER, BORDER);
1204 XFlush(xw.dis); 1207 XFlush(xw.dis);
1205} 1208}