aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2013-04-14 18:30:10 +0200
committerChristoph Lohmann <20h@r-36.net>2013-04-14 18:30:10 +0200
commitc371fe58a36abbfbf684e62d6b4026173dbc79be (patch)
tree6c03cec664a437fd75955153fbcab1cea6947daa /st.c
parent44db38a5f8560564851683f80e1a649836e5885c (diff)
downloadst-c371fe58a36abbfbf684e62d6b4026173dbc79be.tar.gz
st-c371fe58a36abbfbf684e62d6b4026173dbc79be.zip
Enable BCE everywhere.
Diffstat (limited to 'st.c')
-rw-r--r--st.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/st.c b/st.c
index d7d70e7..7250da2 100644
--- a/st.c
+++ b/st.c
@@ -310,7 +310,7 @@ static void strhandle(void);
310static void strparse(void); 310static void strparse(void);
311static void strreset(void); 311static void strreset(void);
312 312
313static void tclearregion(int, int, int, int, int); 313static void tclearregion(int, int, int, int);
314static void tcursor(int); 314static void tcursor(int);
315static void tdeletechar(int); 315static void tdeletechar(int);
316static void tdeleteline(int); 316static void tdeleteline(int);
@@ -1187,7 +1187,7 @@ treset(void) {
1187 term.bot = term.row - 1; 1187 term.bot = term.row - 1;
1188 term.mode = MODE_WRAP; 1188 term.mode = MODE_WRAP;
1189 1189
1190 tclearregion(0, 0, term.col-1, term.row-1, 0); 1190 tclearregion(0, 0, term.col-1, term.row-1);
1191 tmoveto(0, 0); 1191 tmoveto(0, 0);
1192 tcursor(CURSOR_SAVE); 1192 tcursor(CURSOR_SAVE);
1193} 1193}
@@ -1231,7 +1231,7 @@ tscrolldown(int orig, int n) {
1231 1231
1232 LIMIT(n, 0, term.bot-orig+1); 1232 LIMIT(n, 0, term.bot-orig+1);
1233 1233
1234 tclearregion(0, term.bot-n+1, term.col-1, term.bot, 0); 1234 tclearregion(0, term.bot-n+1, term.col-1, term.bot);
1235 1235
1236 for(i = term.bot; i >= orig+n; i--) { 1236 for(i = term.bot; i >= orig+n; i--) {
1237 temp = term.line[i]; 1237 temp = term.line[i];
@@ -1251,7 +1251,7 @@ tscrollup(int orig, int n) {
1251 Line temp; 1251 Line temp;
1252 LIMIT(n, 0, term.bot-orig+1); 1252 LIMIT(n, 0, term.bot-orig+1);
1253 1253
1254 tclearregion(0, orig, term.col-1, orig+n-1, 0); 1254 tclearregion(0, orig, term.col-1, orig+n-1);
1255 1255
1256 for(i = orig; i <= term.bot-n; i++) { 1256 for(i = orig; i <= term.bot-n; i++) {
1257 temp = term.line[i]; 1257 temp = term.line[i];
@@ -1389,7 +1389,7 @@ tsetchar(char *c, Glyph *attr, int x, int y) {
1389} 1389}
1390 1390
1391void 1391void
1392tclearregion(int x1, int y1, int x2, int y2, int bce) { 1392tclearregion(int x1, int y1, int x2, int y2) {
1393 int x, y, temp; 1393 int x, y, temp;
1394 1394
1395 if(x1 > x2) 1395 if(x1 > x2)
@@ -1405,13 +1405,9 @@ tclearregion(int x1, int y1, int x2, int y2, int bce) {
1405 for(y = y1; y <= y2; y++) { 1405 for(y = y1; y <= y2; y++) {
1406 term.dirty[y] = 1; 1406 term.dirty[y] = 1;
1407 for(x = x1; x <= x2; x++) { 1407 for(x = x1; x <= x2; x++) {
1408 if(bce) { 1408 term.line[y][x] = term.c.attr;
1409 term.line[y][x] = term.c.attr; 1409 memcpy(term.line[y][x].c, " ", 2);
1410 memcpy(term.line[y][x].c, " ", 2); 1410 term.line[y][x].state |= GLYPH_SET;
1411 term.line[y][x].state |= GLYPH_SET;
1412 } else {
1413 term.line[y][x].state = 0;
1414 }
1415 } 1411 }
1416 } 1412 }
1417} 1413}
@@ -1425,13 +1421,13 @@ tdeletechar(int n) {
1425 term.dirty[term.c.y] = 1; 1421 term.dirty[term.c.y] = 1;
1426 1422
1427 if(src >= term.col) { 1423 if(src >= term.col) {
1428 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y, 0); 1424 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
1429 return; 1425 return;
1430 } 1426 }
1431 1427
1432 memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], 1428 memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src],
1433 size * sizeof(Glyph)); 1429 size * sizeof(Glyph));
1434 tclearregion(term.col-n, term.c.y, term.col-1, term.c.y, 0); 1430 tclearregion(term.col-n, term.c.y, term.col-1, term.c.y);
1435} 1431}
1436 1432
1437void 1433void
@@ -1443,13 +1439,13 @@ tinsertblank(int n) {
1443 term.dirty[term.c.y] = 1; 1439 term.dirty[term.c.y] = 1;
1444 1440
1445 if(dst >= term.col) { 1441 if(dst >= term.col) {
1446 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y, 0); 1442 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
1447 return; 1443 return;
1448 } 1444 }
1449 1445
1450 memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], 1446 memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src],
1451 size * sizeof(Glyph)); 1447 size * sizeof(Glyph));
1452 tclearregion(src, term.c.y, dst - 1, term.c.y, 0); 1448 tclearregion(src, term.c.y, dst - 1, term.c.y);
1453} 1449}
1454 1450
1455void 1451void
@@ -1475,8 +1471,9 @@ tsetattr(int *attr, int l) {
1475 for(i = 0; i < l; i++) { 1471 for(i = 0; i < l; i++) {
1476 switch(attr[i]) { 1472 switch(attr[i]) {
1477 case 0: 1473 case 0:
1478 term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE | ATTR_BOLD \ 1474 term.c.attr.mode &= ~(ATTR_REVERSE | ATTR_UNDERLINE \
1479 | ATTR_ITALIC | ATTR_BLINK); 1475 | ATTR_BOLD | ATTR_ITALIC \
1476 | ATTR_BLINK);
1480 term.c.attr.fg = defaultfg; 1477 term.c.attr.fg = defaultfg;
1481 term.c.attr.bg = defaultbg; 1478 term.c.attr.bg = defaultbg;
1482 break; 1479 break;
@@ -1645,7 +1642,7 @@ tsetmode(bool priv, bool set, int *args, int narg) {
1645 alt = IS_SET(MODE_ALTSCREEN); 1642 alt = IS_SET(MODE_ALTSCREEN);
1646 if(alt) { 1643 if(alt) {
1647 tclearregion(0, 0, term.col-1, 1644 tclearregion(0, 0, term.col-1,
1648 term.row-1, 0); 1645 term.row-1);
1649 } 1646 }
1650 if(set ^ alt) /* set is always 1 or 0 */ 1647 if(set ^ alt) /* set is always 1 or 0 */
1651 tswapscreen(); 1648 tswapscreen();
@@ -1764,19 +1761,19 @@ csihandle(void) {
1764 sel.bx = -1; 1761 sel.bx = -1;
1765 switch(csiescseq.arg[0]) { 1762 switch(csiescseq.arg[0]) {
1766 case 0: /* below */ 1763 case 0: /* below */
1767 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y, 1); 1764 tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
1768 if(term.c.y < term.row-1) { 1765 if(term.c.y < term.row-1) {
1769 tclearregion(0, term.c.y+1, term.col-1, 1766 tclearregion(0, term.c.y+1, term.col-1,
1770 term.row-1, 1); 1767 term.row-1);
1771 } 1768 }
1772 break; 1769 break;
1773 case 1: /* above */ 1770 case 1: /* above */
1774 if(term.c.y > 1) 1771 if(term.c.y > 1)
1775 tclearregion(0, 0, term.col-1, term.c.y-1, 1); 1772 tclearregion(0, 0, term.col-1, term.c.y-1);
1776 tclearregion(0, term.c.y, term.c.x, term.c.y, 1); 1773 tclearregion(0, term.c.y, term.c.x, term.c.y);
1777 break; 1774 break;
1778 case 2: /* all */ 1775 case 2: /* all */
1779 tclearregion(0, 0, term.col-1, term.row-1, 1); 1776 tclearregion(0, 0, term.col-1, term.row-1);
1780 break; 1777 break;
1781 default: 1778 default:
1782 goto unknown; 1779 goto unknown;
@@ -1786,13 +1783,13 @@ csihandle(void) {
1786 switch(csiescseq.arg[0]) { 1783 switch(csiescseq.arg[0]) {
1787 case 0: /* right */ 1784 case 0: /* right */
1788 tclearregion(term.c.x, term.c.y, term.col-1, 1785 tclearregion(term.c.x, term.c.y, term.col-1,
1789 term.c.y, 1); 1786 term.c.y);
1790 break; 1787 break;
1791 case 1: /* left */ 1788 case 1: /* left */
1792 tclearregion(0, term.c.y, term.c.x, term.c.y, 1); 1789 tclearregion(0, term.c.y, term.c.x, term.c.y);
1793 break; 1790 break;
1794 case 2: /* all */ 1791 case 2: /* all */
1795 tclearregion(0, term.c.y, term.col-1, term.c.y, 1); 1792 tclearregion(0, term.c.y, term.col-1, term.c.y);
1796 break; 1793 break;
1797 } 1794 }
1798 break; 1795 break;
@@ -1818,7 +1815,7 @@ csihandle(void) {
1818 case 'X': /* ECH -- Erase <n> char */ 1815 case 'X': /* ECH -- Erase <n> char */
1819 DEFAULT(csiescseq.arg[0], 1); 1816 DEFAULT(csiescseq.arg[0], 1);
1820 tclearregion(term.c.x, term.c.y, 1817 tclearregion(term.c.x, term.c.y,
1821 term.c.x + csiescseq.arg[0] - 1, term.c.y, 1); 1818 term.c.x + csiescseq.arg[0] - 1, term.c.y);
1822 break; 1819 break;
1823 case 'P': /* DCH -- Delete <n> char */ 1820 case 'P': /* DCH -- Delete <n> char */
1824 DEFAULT(csiescseq.arg[0], 1); 1821 DEFAULT(csiescseq.arg[0], 1);