aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/st.c b/st.c
index 3ebf8c6..01791a5 100644
--- a/st.c
+++ b/st.c
@@ -42,6 +42,7 @@
42#define STR_ARG_SIZ ESC_ARG_SIZ 42#define STR_ARG_SIZ ESC_ARG_SIZ
43 43
44/* macros */ 44/* macros */
45#define IS_SET(flag) ((term.mode & (flag)) != 0)
45#define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) 46#define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
46#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177') 47#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177')
47#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) 48#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
@@ -51,6 +52,17 @@
51/* constants */ 52/* constants */
52#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null" 53#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"
53 54
55enum term_mode {
56 MODE_WRAP = 1 << 0,
57 MODE_INSERT = 1 << 1,
58 MODE_ALTSCREEN = 1 << 2,
59 MODE_CRLF = 1 << 3,
60 MODE_ECHO = 1 << 4,
61 MODE_PRINT = 1 << 5,
62 MODE_UTF8 = 1 << 6,
63 MODE_SIXEL = 1 << 7,
64};
65
54enum cursor_movement { 66enum cursor_movement {
55 CURSOR_SAVE, 67 CURSOR_SAVE,
56 CURSOR_LOAD 68 CURSOR_LOAD
@@ -977,8 +989,6 @@ tnew(int col, int row)
977{ 989{
978 term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } }; 990 term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } };
979 tresize(col, row); 991 tresize(col, row);
980 term.numlock = 1;
981
982 treset(); 992 treset();
983} 993}
984 994
@@ -1414,20 +1424,16 @@ tsetscroll(int t, int b)
1414void 1424void
1415tsetmode(int priv, int set, int *args, int narg) 1425tsetmode(int priv, int set, int *args, int narg)
1416{ 1426{
1417 int *lim, mode; 1427 int alt, *lim;
1418 int alt;
1419 1428
1420 for (lim = args + narg; args < lim; ++args) { 1429 for (lim = args + narg; args < lim; ++args) {
1421 if (priv) { 1430 if (priv) {
1422 switch (*args) { 1431 switch (*args) {
1423 case 1: /* DECCKM -- Cursor key */ 1432 case 1: /* DECCKM -- Cursor key */
1424 MODBIT(term.mode, set, MODE_APPCURSOR); 1433 xsetmode(set, MODE_APPCURSOR);
1425 break; 1434 break;
1426 case 5: /* DECSCNM -- Reverse video */ 1435 case 5: /* DECSCNM -- Reverse video */
1427 mode = term.mode; 1436 xsetmode(set, MODE_REVERSE);
1428 MODBIT(term.mode, set, MODE_REVERSE);
1429 if (mode != term.mode)
1430 redraw();
1431 break; 1437 break;
1432 case 6: /* DECOM -- Origin */ 1438 case 6: /* DECOM -- Origin */
1433 MODBIT(term.c.state, set, CURSOR_ORIGIN); 1439 MODBIT(term.c.state, set, CURSOR_ORIGIN);
@@ -1447,36 +1453,36 @@ tsetmode(int priv, int set, int *args, int narg)
1447 case 12: /* att610 -- Start blinking cursor (IGNORED) */ 1453 case 12: /* att610 -- Start blinking cursor (IGNORED) */
1448 break; 1454 break;
1449 case 25: /* DECTCEM -- Text Cursor Enable Mode */ 1455 case 25: /* DECTCEM -- Text Cursor Enable Mode */
1450 MODBIT(term.mode, !set, MODE_HIDE); 1456 xsetmode(!set, MODE_HIDE);
1451 break; 1457 break;
1452 case 9: /* X10 mouse compatibility mode */ 1458 case 9: /* X10 mouse compatibility mode */
1453 xsetpointermotion(0); 1459 xsetpointermotion(0);
1454 MODBIT(term.mode, 0, MODE_MOUSE); 1460 xsetmode(0, MODE_MOUSE);
1455 MODBIT(term.mode, set, MODE_MOUSEX10); 1461 xsetmode(set, MODE_MOUSEX10);
1456 break; 1462 break;
1457 case 1000: /* 1000: report button press */ 1463 case 1000: /* 1000: report button press */
1458 xsetpointermotion(0); 1464 xsetpointermotion(0);
1459 MODBIT(term.mode, 0, MODE_MOUSE); 1465 xsetmode(0, MODE_MOUSE);
1460 MODBIT(term.mode, set, MODE_MOUSEBTN); 1466 xsetmode(set, MODE_MOUSEBTN);
1461 break; 1467 break;
1462 case 1002: /* 1002: report motion on button press */ 1468 case 1002: /* 1002: report motion on button press */
1463 xsetpointermotion(0); 1469 xsetpointermotion(0);
1464 MODBIT(term.mode, 0, MODE_MOUSE); 1470 xsetmode(0, MODE_MOUSE);
1465 MODBIT(term.mode, set, MODE_MOUSEMOTION); 1471 xsetmode(set, MODE_MOUSEMOTION);
1466 break; 1472 break;
1467 case 1003: /* 1003: enable all mouse motions */ 1473 case 1003: /* 1003: enable all mouse motions */
1468 xsetpointermotion(set); 1474 xsetpointermotion(set);
1469 MODBIT(term.mode, 0, MODE_MOUSE); 1475 xsetmode(0, MODE_MOUSE);
1470 MODBIT(term.mode, set, MODE_MOUSEMANY); 1476 xsetmode(set, MODE_MOUSEMANY);
1471 break; 1477 break;
1472 case 1004: /* 1004: send focus events to tty */ 1478 case 1004: /* 1004: send focus events to tty */
1473 MODBIT(term.mode, set, MODE_FOCUS); 1479 xsetmode(set, MODE_FOCUS);
1474 break; 1480 break;
1475 case 1006: /* 1006: extended reporting mode */ 1481 case 1006: /* 1006: extended reporting mode */
1476 MODBIT(term.mode, set, MODE_MOUSESGR); 1482 xsetmode(set, MODE_MOUSESGR);
1477 break; 1483 break;
1478 case 1034: 1484 case 1034:
1479 MODBIT(term.mode, set, MODE_8BIT); 1485 xsetmode(set, MODE_8BIT);
1480 break; 1486 break;
1481 case 1049: /* swap screen & set/restore cursor as xterm */ 1487 case 1049: /* swap screen & set/restore cursor as xterm */
1482 if (!allowaltscreen) 1488 if (!allowaltscreen)
@@ -1501,7 +1507,7 @@ tsetmode(int priv, int set, int *args, int narg)
1501 tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD); 1507 tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
1502 break; 1508 break;
1503 case 2004: /* 2004: bracketed paste mode */ 1509 case 2004: /* 2004: bracketed paste mode */
1504 MODBIT(term.mode, set, MODE_BRCKTPASTE); 1510 xsetmode(set, MODE_BRCKTPASTE);
1505 break; 1511 break;
1506 /* Not implemented mouse modes. See comments there. */ 1512 /* Not implemented mouse modes. See comments there. */
1507 case 1001: /* mouse highlight mode; can hang the 1513 case 1001: /* mouse highlight mode; can hang the
@@ -1522,8 +1528,8 @@ tsetmode(int priv, int set, int *args, int narg)
1522 switch (*args) { 1528 switch (*args) {
1523 case 0: /* Error (IGNORED) */ 1529 case 0: /* Error (IGNORED) */
1524 break; 1530 break;
1525 case 2: /* KAM -- keyboard action */ 1531 case 2:
1526 MODBIT(term.mode, set, MODE_KBDLOCK); 1532 xsetmode(set, MODE_KBDLOCK);
1527 break; 1533 break;
1528 case 4: /* IRM -- Insertion-replacement */ 1534 case 4: /* IRM -- Insertion-replacement */
1529 MODBIT(term.mode, set, MODE_INSERT); 1535 MODBIT(term.mode, set, MODE_INSERT);
@@ -2230,10 +2236,10 @@ eschandle(uchar ascii)
2230 xloadcols(); 2236 xloadcols();
2231 break; 2237 break;
2232 case '=': /* DECPAM -- Application keypad */ 2238 case '=': /* DECPAM -- Application keypad */
2233 term.mode |= MODE_APPKEYPAD; 2239 xsetmode(1, MODE_APPKEYPAD);
2234 break; 2240 break;
2235 case '>': /* DECPNM -- Normal keypad */ 2241 case '>': /* DECPNM -- Normal keypad */
2236 term.mode &= ~MODE_APPKEYPAD; 2242 xsetmode(0, MODE_APPKEYPAD);
2237 break; 2243 break;
2238 case '7': /* DECSC -- Save Cursor */ 2244 case '7': /* DECSC -- Save Cursor */
2239 tcursor(CURSOR_SAVE); 2245 tcursor(CURSOR_SAVE);
@@ -2526,9 +2532,3 @@ redraw(void)
2526 tfulldirt(); 2532 tfulldirt();
2527 draw(); 2533 draw();
2528} 2534}
2529
2530void
2531numlock(const Arg *dummy)
2532{
2533 term.numlock ^= 1;
2534}