aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--st.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/st.c b/st.c
index 4a77d71..657fba7 100644
--- a/st.c
+++ b/st.c
@@ -97,6 +97,7 @@ enum cursor_movement {
97enum cursor_state { 97enum cursor_state {
98 CURSOR_DEFAULT = 0, 98 CURSOR_DEFAULT = 0,
99 CURSOR_WRAPNEXT = 1, 99 CURSOR_WRAPNEXT = 1,
100 CURSOR_ORIGIN = 2
100}; 101};
101 102
102enum glyph_state { 103enum glyph_state {
@@ -300,6 +301,7 @@ static void tdeleteline(int);
300static void tinsertblank(int); 301static void tinsertblank(int);
301static void tinsertblankline(int); 302static void tinsertblankline(int);
302static void tmoveto(int, int); 303static void tmoveto(int, int);
304static void tmoveato(int x, int y);
303static void tnew(int, int); 305static void tnew(int, int);
304static void tnewline(int); 306static void tnewline(int);
305static void tputtab(bool); 307static void tputtab(bool);
@@ -1211,10 +1213,25 @@ csiparse(void) {
1211 } 1213 }
1212} 1214}
1213 1215
1216/* for absolute user moves, when decom is set */
1217void
1218tmoveato(int x, int y) {
1219 tmoveto(x, y + ((term.c.state & CURSOR_ORIGIN) ? term.top: 0));
1220}
1221
1214void 1222void
1215tmoveto(int x, int y) { 1223tmoveto(int x, int y) {
1224 int miny, maxy;
1225
1226 if(term.c.state & CURSOR_ORIGIN) {
1227 miny = term.top;
1228 maxy = term.bot;
1229 } else {
1230 miny = 0;
1231 maxy = term.row - 1;
1232 }
1216 LIMIT(x, 0, term.col-1); 1233 LIMIT(x, 0, term.col-1);
1217 LIMIT(y, 0, term.row-1); 1234 LIMIT(y, miny, maxy);
1218 term.c.state &= ~CURSOR_WRAPNEXT; 1235 term.c.state &= ~CURSOR_WRAPNEXT;
1219 term.c.x = x; 1236 term.c.x = x;
1220 term.c.y = y; 1237 term.c.y = y;
@@ -1456,7 +1473,9 @@ tsetmode(bool priv, bool set, int *args, int narg) {
1456 if(mode != term.mode) 1473 if(mode != term.mode)
1457 redraw(); 1474 redraw();
1458 break; 1475 break;
1459 case 6: /* XXX: DECOM -- Origin */ 1476 case 6: /* DECOM -- Origin */
1477 MODBIT(term.c.state, set, CURSOR_ORIGIN);
1478 tmoveato(0, 0);
1460 break; 1479 break;
1461 case 7: /* DECAWM -- Auto wrap */ 1480 case 7: /* DECAWM -- Auto wrap */
1462 MODBIT(term.mode, set, MODE_WRAP); 1481 MODBIT(term.mode, set, MODE_WRAP);
@@ -1593,7 +1612,7 @@ csihandle(void) {
1593 case 'f': /* HVP */ 1612 case 'f': /* HVP */
1594 DEFAULT(csiescseq.arg[0], 1); 1613 DEFAULT(csiescseq.arg[0], 1);
1595 DEFAULT(csiescseq.arg[1], 1); 1614 DEFAULT(csiescseq.arg[1], 1);
1596 tmoveto(csiescseq.arg[1]-1, csiescseq.arg[0]-1); 1615 tmoveato(csiescseq.arg[1]-1, csiescseq.arg[0]-1);
1597 break; 1616 break;
1598 case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */ 1617 case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */
1599 DEFAULT(csiescseq.arg[0], 1); 1618 DEFAULT(csiescseq.arg[0], 1);
@@ -1667,7 +1686,7 @@ csihandle(void) {
1667 break; 1686 break;
1668 case 'd': /* VPA -- Move to <row> */ 1687 case 'd': /* VPA -- Move to <row> */
1669 DEFAULT(csiescseq.arg[0], 1); 1688 DEFAULT(csiescseq.arg[0], 1);
1670 tmoveto(term.c.x, csiescseq.arg[0]-1); 1689 tmoveato(term.c.x, csiescseq.arg[0]-1);
1671 break; 1690 break;
1672 case 'h': /* SM -- Set terminal mode */ 1691 case 'h': /* SM -- Set terminal mode */
1673 tsetmode(csiescseq.priv, 1, csiescseq.arg, csiescseq.narg); 1692 tsetmode(csiescseq.priv, 1, csiescseq.arg, csiescseq.narg);
@@ -1682,7 +1701,7 @@ csihandle(void) {
1682 DEFAULT(csiescseq.arg[0], 1); 1701 DEFAULT(csiescseq.arg[0], 1);
1683 DEFAULT(csiescseq.arg[1], term.row); 1702 DEFAULT(csiescseq.arg[1], term.row);
1684 tsetscroll(csiescseq.arg[0]-1, csiescseq.arg[1]-1); 1703 tsetscroll(csiescseq.arg[0]-1, csiescseq.arg[1]-1);
1685 tmoveto(0, 0); 1704 tmoveato(0, 0);
1686 } 1705 }
1687 break; 1706 break;
1688 case 's': /* DECSC -- Save cursor position (ANSI.SYS) */ 1707 case 's': /* DECSC -- Save cursor position (ANSI.SYS) */
@@ -2119,10 +2138,10 @@ tresize(int col, int row) {
2119 /* update terminal size */ 2138 /* update terminal size */
2120 term.col = col; 2139 term.col = col;
2121 term.row = row; 2140 term.row = row;
2122 /* make use of the LIMIT in tmoveto */
2123 tmoveto(term.c.x, term.c.y);
2124 /* reset scrolling region */ 2141 /* reset scrolling region */
2125 tsetscroll(0, row-1); 2142 tsetscroll(0, row-1);
2143 /* make use of the LIMIT in tmoveto */
2144 tmoveto(term.c.x, term.c.y);
2126 2145
2127 return (slide > 0); 2146 return (slide > 0);
2128} 2147}