diff options
author | Christoph Lohmann <20h@r-36.net> | 2013-01-20 14:54:35 +0100 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2013-01-20 14:54:35 +0100 |
commit | b78c5085f72d66de26468e2c07fb3c72d0afe63b (patch) | |
tree | af879715dc400a2c0ddf4320c9070a4fbaf4d546 | |
parent | b4b513c791e01e46399b460789b830ddfc7cb425 (diff) | |
download | st-patched-b78c5085f72d66de26468e2c07fb3c72d0afe63b.tar.bz2 st-patched-b78c5085f72d66de26468e2c07fb3c72d0afe63b.tar.xz st-patched-b78c5085f72d66de26468e2c07fb3c72d0afe63b.zip |
Implementing Back Color Erase (BCE).
-rw-r--r-- | st.c | 63 | ||||
-rw-r--r-- | st.info | 2 |
2 files changed, 40 insertions, 25 deletions
@@ -152,7 +152,7 @@ typedef struct { | |||
152 | uchar state; /* state flags */ | 152 | uchar state; /* state flags */ |
153 | } Glyph; | 153 | } Glyph; |
154 | 154 | ||
155 | typedef Glyph* Line; | 155 | typedef Glyph *Line; |
156 | 156 | ||
157 | typedef struct { | 157 | typedef struct { |
158 | Glyph attr; /* current char attributes */ | 158 | Glyph attr; /* current char attributes */ |
@@ -303,7 +303,7 @@ static void strhandle(void); | |||
303 | static void strparse(void); | 303 | static void strparse(void); |
304 | static void strreset(void); | 304 | static void strreset(void); |
305 | 305 | ||
306 | static void tclearregion(int, int, int, int); | 306 | static void tclearregion(int, int, int, int, int); |
307 | static void tcursor(int); | 307 | static void tcursor(int); |
308 | static void tdeletechar(int); | 308 | static void tdeletechar(int); |
309 | static void tdeleteline(int); | 309 | static void tdeleteline(int); |
@@ -1113,7 +1113,7 @@ treset(void) { | |||
1113 | term.bot = term.row - 1; | 1113 | term.bot = term.row - 1; |
1114 | term.mode = MODE_WRAP; | 1114 | term.mode = MODE_WRAP; |
1115 | 1115 | ||
1116 | tclearregion(0, 0, term.col-1, term.row-1); | 1116 | tclearregion(0, 0, term.col-1, term.row-1, 0); |
1117 | tmoveto(0, 0); | 1117 | tmoveto(0, 0); |
1118 | tcursor(CURSOR_SAVE); | 1118 | tcursor(CURSOR_SAVE); |
1119 | } | 1119 | } |
@@ -1157,7 +1157,7 @@ tscrolldown(int orig, int n) { | |||
1157 | 1157 | ||
1158 | LIMIT(n, 0, term.bot-orig+1); | 1158 | LIMIT(n, 0, term.bot-orig+1); |
1159 | 1159 | ||
1160 | tclearregion(0, term.bot-n+1, term.col-1, term.bot); | 1160 | tclearregion(0, term.bot-n+1, term.col-1, term.bot, 0); |
1161 | 1161 | ||
1162 | for(i = term.bot; i >= orig+n; i--) { | 1162 | for(i = term.bot; i >= orig+n; i--) { |
1163 | temp = term.line[i]; | 1163 | temp = term.line[i]; |
@@ -1177,7 +1177,7 @@ tscrollup(int orig, int n) { | |||
1177 | Line temp; | 1177 | Line temp; |
1178 | LIMIT(n, 0, term.bot-orig+1); | 1178 | LIMIT(n, 0, term.bot-orig+1); |
1179 | 1179 | ||
1180 | tclearregion(0, orig, term.col-1, orig+n-1); | 1180 | tclearregion(0, orig, term.col-1, orig+n-1, 0); |
1181 | 1181 | ||
1182 | for(i = orig; i <= term.bot-n; i++) { | 1182 | for(i = orig; i <= term.bot-n; i++) { |
1183 | temp = term.line[i]; | 1183 | temp = term.line[i]; |
@@ -1305,7 +1305,7 @@ tsetchar(char *c, Glyph *attr, int x, int y) { | |||
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | void | 1307 | void |
1308 | tclearregion(int x1, int y1, int x2, int y2) { | 1308 | tclearregion(int x1, int y1, int x2, int y2, int bce) { |
1309 | int x, y, temp; | 1309 | int x, y, temp; |
1310 | 1310 | ||
1311 | if(x1 > x2) | 1311 | if(x1 > x2) |
@@ -1320,8 +1320,15 @@ tclearregion(int x1, int y1, int x2, int y2) { | |||
1320 | 1320 | ||
1321 | for(y = y1; y <= y2; y++) { | 1321 | for(y = y1; y <= y2; y++) { |
1322 | term.dirty[y] = 1; | 1322 | term.dirty[y] = 1; |
1323 | for(x = x1; x <= x2; x++) | 1323 | for(x = x1; x <= x2; x++) { |
1324 | term.line[y][x].state = 0; | 1324 | if(bce) { |
1325 | term.line[y][x] = term.c.attr; | ||
1326 | memcpy(term.line[y][x].c, " ", 2); | ||
1327 | term.line[y][x].state |= GLYPH_SET; | ||
1328 | } else { | ||
1329 | term.line[y][x].state = 0; | ||
1330 | } | ||
1331 | } | ||
1325 | } | 1332 | } |
1326 | } | 1333 | } |
1327 | 1334 | ||
@@ -1334,13 +1341,13 @@ tdeletechar(int n) { | |||
1334 | term.dirty[term.c.y] = 1; | 1341 | term.dirty[term.c.y] = 1; |
1335 | 1342 | ||
1336 | if(src >= term.col) { | 1343 | if(src >= term.col) { |
1337 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); | 1344 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y, 0); |
1338 | return; | 1345 | return; |
1339 | } | 1346 | } |
1340 | 1347 | ||
1341 | memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], | 1348 | memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], |
1342 | size * sizeof(Glyph)); | 1349 | size * sizeof(Glyph)); |
1343 | tclearregion(term.col-n, term.c.y, term.col-1, term.c.y); | 1350 | tclearregion(term.col-n, term.c.y, term.col-1, term.c.y, 0); |
1344 | } | 1351 | } |
1345 | 1352 | ||
1346 | void | 1353 | void |
@@ -1352,13 +1359,13 @@ tinsertblank(int n) { | |||
1352 | term.dirty[term.c.y] = 1; | 1359 | term.dirty[term.c.y] = 1; |
1353 | 1360 | ||
1354 | if(dst >= term.col) { | 1361 | if(dst >= term.col) { |
1355 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); | 1362 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y, 0); |
1356 | return; | 1363 | return; |
1357 | } | 1364 | } |
1358 | 1365 | ||
1359 | memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], | 1366 | memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], |
1360 | size * sizeof(Glyph)); | 1367 | size * sizeof(Glyph)); |
1361 | tclearregion(src, term.c.y, dst - 1, term.c.y); | 1368 | tclearregion(src, term.c.y, dst - 1, term.c.y, 0); |
1362 | } | 1369 | } |
1363 | 1370 | ||
1364 | void | 1371 | void |
@@ -1542,8 +1549,10 @@ tsetmode(bool priv, bool set, int *args, int narg) { | |||
1542 | case 47: | 1549 | case 47: |
1543 | case 1047: { | 1550 | case 1047: { |
1544 | alt = IS_SET(MODE_ALTSCREEN); | 1551 | alt = IS_SET(MODE_ALTSCREEN); |
1545 | if(alt) | 1552 | if(alt) { |
1546 | tclearregion(0, 0, term.col-1, term.row-1); | 1553 | tclearregion(0, 0, term.col-1, |
1554 | term.row-1, 0); | ||
1555 | } | ||
1547 | if(set ^ alt) /* set is always 1 or 0 */ | 1556 | if(set ^ alt) /* set is always 1 or 0 */ |
1548 | tswapscreen(); | 1557 | tswapscreen(); |
1549 | if(*args != 1049) | 1558 | if(*args != 1049) |
@@ -1662,17 +1671,19 @@ csihandle(void) { | |||
1662 | sel.bx = -1; | 1671 | sel.bx = -1; |
1663 | switch(csiescseq.arg[0]) { | 1672 | switch(csiescseq.arg[0]) { |
1664 | case 0: /* below */ | 1673 | case 0: /* below */ |
1665 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); | 1674 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y, 1); |
1666 | if(term.c.y < term.row-1) | 1675 | if(term.c.y < term.row-1) { |
1667 | tclearregion(0, term.c.y+1, term.col-1, term.row-1); | 1676 | tclearregion(0, term.c.y+1, term.col-1, |
1677 | term.row-1, 1); | ||
1678 | } | ||
1668 | break; | 1679 | break; |
1669 | case 1: /* above */ | 1680 | case 1: /* above */ |
1670 | if(term.c.y > 1) | 1681 | if(term.c.y > 1) |
1671 | tclearregion(0, 0, term.col-1, term.c.y-1); | 1682 | tclearregion(0, 0, term.col-1, term.c.y-1, 1); |
1672 | tclearregion(0, term.c.y, term.c.x, term.c.y); | 1683 | tclearregion(0, term.c.y, term.c.x, term.c.y, 1); |
1673 | break; | 1684 | break; |
1674 | case 2: /* all */ | 1685 | case 2: /* all */ |
1675 | tclearregion(0, 0, term.col-1, term.row-1); | 1686 | tclearregion(0, 0, term.col-1, term.row-1, 1); |
1676 | break; | 1687 | break; |
1677 | default: | 1688 | default: |
1678 | goto unknown; | 1689 | goto unknown; |
@@ -1681,13 +1692,14 @@ csihandle(void) { | |||
1681 | case 'K': /* EL -- Clear line */ | 1692 | case 'K': /* EL -- Clear line */ |
1682 | switch(csiescseq.arg[0]) { | 1693 | switch(csiescseq.arg[0]) { |
1683 | case 0: /* right */ | 1694 | case 0: /* right */ |
1684 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); | 1695 | tclearregion(term.c.x, term.c.y, term.col-1, |
1696 | term.c.y, 1); | ||
1685 | break; | 1697 | break; |
1686 | case 1: /* left */ | 1698 | case 1: /* left */ |
1687 | tclearregion(0, term.c.y, term.c.x, term.c.y); | 1699 | tclearregion(0, term.c.y, term.c.x, term.c.y, 1); |
1688 | break; | 1700 | break; |
1689 | case 2: /* all */ | 1701 | case 2: /* all */ |
1690 | tclearregion(0, term.c.y, term.col-1, term.c.y); | 1702 | tclearregion(0, term.c.y, term.col-1, term.c.y, 1); |
1691 | break; | 1703 | break; |
1692 | } | 1704 | } |
1693 | break; | 1705 | break; |
@@ -1712,7 +1724,8 @@ csihandle(void) { | |||
1712 | break; | 1724 | break; |
1713 | case 'X': /* ECH -- Erase <n> char */ | 1725 | case 'X': /* ECH -- Erase <n> char */ |
1714 | DEFAULT(csiescseq.arg[0], 1); | 1726 | DEFAULT(csiescseq.arg[0], 1); |
1715 | tclearregion(term.c.x, term.c.y, term.c.x + csiescseq.arg[0], term.c.y); | 1727 | tclearregion(term.c.x, term.c.y, term.c.x + csiescseq.arg[0], |
1728 | term.c.y, 0); | ||
1716 | break; | 1729 | break; |
1717 | case 'P': /* DCH -- Delete <n> char */ | 1730 | case 'P': /* DCH -- Delete <n> char */ |
1718 | DEFAULT(csiescseq.arg[0], 1); | 1731 | DEFAULT(csiescseq.arg[0], 1); |
@@ -2505,6 +2518,7 @@ xinit(void) { | |||
2505 | xw.fy = 0; | 2518 | xw.fy = 0; |
2506 | } | 2519 | } |
2507 | 2520 | ||
2521 | /* Events */ | ||
2508 | attrs.background_pixel = dc.col[defaultbg].pixel; | 2522 | attrs.background_pixel = dc.col[defaultbg].pixel; |
2509 | attrs.border_pixel = dc.col[defaultbg].pixel; | 2523 | attrs.border_pixel = dc.col[defaultbg].pixel; |
2510 | attrs.bit_gravity = NorthWestGravity; | 2524 | attrs.bit_gravity = NorthWestGravity; |
@@ -2898,6 +2912,7 @@ drawregion(int x1, int y1, int x2, int y2) { | |||
2898 | ox = x; | 2912 | ox = x; |
2899 | base = new; | 2913 | base = new; |
2900 | } | 2914 | } |
2915 | |||
2901 | sl = utf8size(new.c); | 2916 | sl = utf8size(new.c); |
2902 | memcpy(buf+ib, new.c, sl); | 2917 | memcpy(buf+ib, new.c, sl); |
2903 | ib += sl; | 2918 | ib += sl; |
@@ -3,7 +3,7 @@ | |||
3 | st| simpleterm, | 3 | st| simpleterm, |
4 | acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, | 4 | acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, |
5 | am, | 5 | am, |
6 | # bce, | 6 | bce, |
7 | bel=^G, | 7 | bel=^G, |
8 | # blink=\E[5m, | 8 | # blink=\E[5m, |
9 | bold=\E[1m, | 9 | bold=\E[1m, |