Lines Matching defs:ip
87 #define SUBR_INIT(ip) ip->isw->ite_init(ip)
88 #define SUBR_DEINIT(ip) ip->isw->ite_deinit(ip)
89 #define SUBR_PUTC(ip,c,dy,dx,m) ip->isw->ite_putc(ip,c,dy,dx,m)
90 #define SUBR_CURSOR(ip,flg) ip->isw->ite_cursor(ip,flg)
91 #define SUBR_CLEAR(ip,sy,sx,h,w) ip->isw->ite_clear(ip,sy,sx,h,w)
92 #define SUBR_SCROLL(ip,sy,sx,count,dir) \
93 ip->isw->ite_scroll(ip,sy,sx,count,dir)
95 #define SUBR_SIXEL(ip,sy,sx) ip->isw->ite_sixel(ip,sy,sx)
210 struct ite_softc *ip;
214 ip = device_private(self);
215 ip->device = self;
222 memcpy(&ip->grf, &con_itesoftc.grf,
223 (char *)&ip[1] - (char *)&ip->grf);
225 kbd_ite = ip;
227 ip->grf = gp;
229 aprint_normal(": rows %d cols %d", ip->rows, ip->cols);
231 kbd_ite = ip;
250 struct ite_softc *ip;
252 ip = getitesp(dev);
254 if (ip->flags & ITE_INITED)
258 ip->curx = 0;
259 ip->cury = 0;
260 ip->cursorx = 0;
261 ip->cursory = 0;
263 ip->isw = &itesw[device_unit(ip->device)]; /* XXX */
264 SUBR_INIT(ip);
265 SUBR_CURSOR(ip, DRAW_CURSOR);
266 if (ip->tabs == NULL)
267 ip->tabs = malloc(MAX_TABS * sizeof(u_char),
269 ite_reset(ip);
270 ip->flags |= ITE_INITED;
292 struct ite_softc *ip;
295 (ip = getitesp(dev)) == NULL || (ip->flags & ITE_ALIVE) == 0)
299 ip->flags |= ITE_ACTIVE;
300 ip->flags &= ~(ITE_INGRF|ITE_INITED);
304 ip->flags &= ~ITE_INGRF;
305 if ((ip->flags & ITE_ACTIVE) == 0)
308 ip->flags |= ITE_ACTIVE;
309 if ((ip->flags & ITE_INGRF) != 0)
313 ite_reset(ip);
330 struct ite_softc *ip;
334 (ip = getitesp(dev)) == NULL || (ip->flags & ITE_ALIVE) == 0)
337 ip->flags |= ITE_INGRF;
339 if ((ip->flags & ITE_ACTIVE) == 0)
342 (ip->flags & (ITE_INGRF | ITE_ISCONS | ITE_INITED)) == ITE_INITED)
343 SUBR_DEINIT(ip);
352 if ((flag & 2) == 0 && (ip->flags & ITE_ISCONS) == 0) {
353 ip->flags &= ~ITE_ACTIVE;
370 struct ite_softc *ip;
374 if (unit >= ite_cd.cd_ndevs || (ip = getitesp(dev)) == NULL)
383 if ((ip->flags & ITE_ACTIVE) == 0) {
404 tp->t_winsize.ws_row = ip->rows;
405 tp->t_winsize.ws_col = ip->cols;
557 struct ite_softc *ip;
562 (ip = getitesp(dev)) == NULL)
565 ip->flags &= ~ITE_INITED;
570 ite_reset(struct ite_softc *ip)
574 ip->curx = 0;
575 ip->cury = 0;
576 ip->attribute = 0;
577 ip->save_curx = 0;
578 ip->save_cury = 0;
579 ip->save_attribute = 0;
580 ip->ap = ip->argbuf;
581 ip->emul_level = EMUL_VT300_8;
582 ip->eightbit_C1 = 0;
583 ip->top_margin = 0;
584 ip->bottom_margin = ip->rows - 1;
585 ip->inside_margins = 0; /* origin mode == absolute */
586 ip->linefeed_newline = 0;
587 ip->auto_wrap = 1;
588 ip->cursor_appmode = 0;
589 ip->keypad_appmode = 0;
590 ip->imode = 0;
591 ip->key_repeat = 1;
592 ip->G0 = CSET_ASCII;
593 ip->G1 = CSET_JIS1983;
594 ip->G2 = CSET_JISKANA;
595 ip->G3 = CSET_JIS1990;
596 ip->GL = &ip->G0;
597 ip->GR = &ip->G1;
598 ip->save_GL = 0;
599 ip->save_char = 0;
600 ip->fgcolor = 7;
601 ip->bgcolor = 0;
602 for (i = 0; i < ip->cols; i++)
603 ip->tabs[i] = ((i & 7) == 0);
605 SUBR_CLEAR(ip, 0, 0, ip->rows, ip->cols);
606 attrclr(ip, 0, 0, ip->rows, ip->cols);
925 ite_sendstr(struct ite_softc *ip, const char *str)
933 alignment_display(struct ite_softc *ip)
937 for (j = 0; j < ip->rows; j++)
938 for (i = 0; i < ip->cols; i++)
939 SUBR_PUTC(ip, 'E', j, i, ATTR_NOR);
940 attrclr(ip, 0, 0, ip->rows, ip->cols);
944 snap_cury(struct ite_softc *ip)
947 if (ip->inside_margins != 0) {
948 if (ip->cury < ip->top_margin)
949 ip->cury = ip->top_margin;
950 if (ip->cury > ip->bottom_margin)
951 ip->cury = ip->bottom_margin;
956 ite_dnchar(struct ite_softc *ip, int n)
959 n = uimin(n, ip->cols - ip->curx);
960 if (n < ip->cols - ip->curx) {
961 SUBR_SCROLL(ip, ip->cury, ip->curx + n, n, SCROLL_LEFT);
962 attrmov(ip, ip->cury, ip->curx + n, ip->cury, ip->curx,
963 1, ip->cols - ip->curx - n);
964 attrclr(ip, ip->cury, ip->cols - n, 1, n);
967 SUBR_PUTC(ip, ' ', ip->cury, ip->cols - n - 1, ATTR_NOR);
971 ite_inchar(struct ite_softc *ip, int n)
973 int c = ip->save_char;
975 ip->save_char = 0;
976 n = uimin(n, ip->cols - ip->curx);
977 if (n < ip->cols - ip->curx) {
978 SUBR_SCROLL(ip, ip->cury, ip->curx, n, SCROLL_RIGHT);
979 attrmov(ip, ip->cury, ip->curx, ip->cury, ip->curx + n,
980 1, ip->cols - ip->curx - n);
981 attrclr(ip, ip->cury, ip->curx, 1, n);
984 SUBR_PUTC(ip, ' ', ip->cury, ip->curx + n, ATTR_NOR);
985 ip->save_char = c;
989 ite_clrtoeol(struct ite_softc *ip)
991 int y = ip->cury, x = ip->curx;
993 if (ip->cols - x > 0) {
994 SUBR_CLEAR(ip, y, x, 1, ip->cols - x);
995 attrclr(ip, y, x, 1, ip->cols - x);
1000 ite_clrtobol(struct ite_softc *ip)
1002 int y = ip->cury, x = uimin(ip->curx + 1, ip->cols);
1004 SUBR_CLEAR(ip, y, 0, 1, x);
1005 attrclr(ip, y, 0, 1, x);
1009 ite_clrline(struct ite_softc *ip)
1011 int y = ip->cury;
1013 SUBR_CLEAR(ip, y, 0, 1, ip->cols);
1014 attrclr(ip, y, 0, 1, ip->cols);
1018 ite_clrtoeos(struct ite_softc *ip)
1021 ite_clrtoeol(ip);
1022 if (ip->cury < ip->rows - 1) {
1023 SUBR_CLEAR(ip, ip->cury + 1, 0,
1024 ip->rows - 1 - ip->cury, ip->cols);
1025 attrclr(ip, ip->cury, 0, ip->rows - ip->cury, ip->cols);
1030 ite_clrtobos(struct ite_softc *ip)
1033 ite_clrtobol(ip);
1034 if (ip->cury > 0) {
1035 SUBR_CLEAR(ip, 0, 0, ip->cury, ip->cols);
1036 attrclr(ip, 0, 0, ip->cury, ip->cols);
1041 ite_clrscreen(struct ite_softc *ip)
1044 SUBR_CLEAR(ip, 0, 0, ip->rows, ip->cols);
1045 attrclr(ip, 0, 0, ip->rows, ip->cols);
1049 ite_dnline(struct ite_softc *ip, int n)
1056 if (ip->cury < ip->top_margin || ip->cury > ip->bottom_margin)
1059 n = uimin(n, ip->bottom_margin + 1 - ip->cury);
1060 if (n <= ip->bottom_margin - ip->cury) {
1061 SUBR_SCROLL(ip, ip->cury + n, 0, n, SCROLL_UP);
1062 attrmov(ip, ip->cury + n, 0, ip->cury, 0,
1063 ip->bottom_margin + 1 - ip->cury - n, ip->cols);
1065 SUBR_CLEAR(ip, ip->bottom_margin - n + 1, 0, n, ip->cols);
1066 attrclr(ip, ip->bottom_margin - n + 1, 0, n, ip->cols);
1070 ite_inline(struct ite_softc *ip, int n)
1077 if (ip->cury < ip->top_margin || ip->cury > ip->bottom_margin)
1083 n = uimin(n, ip->bottom_margin + 1 - ip->cury);
1084 if (n <= ip->bottom_margin - ip->cury) {
1085 SUBR_SCROLL(ip, ip->cury, 0, n, SCROLL_DOWN);
1086 attrmov(ip, ip->cury, 0, ip->cury + n, 0,
1087 ip->bottom_margin + 1 - ip->cury - n, ip->cols);
1089 SUBR_CLEAR(ip, ip->cury, 0, n, ip->cols);
1090 attrclr(ip, ip->cury, 0, n, ip->cols);
1091 ip->curx = 0;
1095 ite_index(struct ite_softc *ip)
1098 ++ip->cury;
1099 if ((ip->cury == ip->bottom_margin+1) || (ip->cury == ip->rows)) {
1100 ip->cury--;
1101 SUBR_SCROLL(ip, ip->top_margin + 1, 0, 1, SCROLL_UP);
1102 ite_clrline(ip);
1104 /*clr_attr(ip, ATTR_INV);*/
1108 ite_lf(struct ite_softc *ip)
1111 ++ip->cury;
1112 if (ip->cury > ip->bottom_margin) {
1113 ip->cury--;
1114 SUBR_SCROLL(ip, ip->top_margin + 1, 0, 1, SCROLL_UP);
1115 ite_clrline(ip);
1117 /*SUBR_CURSOR(ip, MOVE_CURSOR);*/
1118 /*clr_attr(ip, ATTR_INV);*/
1120 ip->G0 = CSET_ASCII;
1121 ip->G1 = CSET_JIS1983;
1122 ip->G2 = CSET_JISKANA;
1123 ip->G3 = CSET_JIS1990;
1124 ip->GL = &ip->G0;
1125 ip->GR = &ip->G1;
1126 ip->save_GL = 0;
1127 ip->save_char = 0;
1131 ite_crlf(struct ite_softc *ip)
1134 ip->curx = 0;
1135 ite_lf(ip);
1139 ite_cr(struct ite_softc *ip)
1142 if (ip->curx != 0) {
1143 ip->curx = 0;
1148 ite_rlf(struct ite_softc *ip)
1151 ip->cury--;
1152 if ((ip->cury < 0) || (ip->cury == ip->top_margin - 1)) {
1153 ip->cury++;
1154 SUBR_SCROLL(ip, ip->top_margin, 0, 1, SCROLL_DOWN);
1155 ite_clrline(ip);
1157 clr_attr(ip, ATTR_INV);
1171 ite_argnum(struct ite_softc *ip)
1177 if (ip->ap == ip->argbuf)
1179 ch = *ip->ap;
1180 *ip->ap = 0;
1181 n = atoi(ip->argbuf);
1182 *ip->ap = ch;
1188 ite_zargnum(struct ite_softc *ip)
1194 if (ip->ap == ip->argbuf)
1196 ch = *ip->ap;
1197 *ip->ap = 0; /* terminate string */
1198 n = atoi(ip->argbuf);
1199 *ip->ap = ch;
1207 struct ite_softc *ip;
1210 ip = getitesp(dev);
1213 if ((ip->flags & (ITE_ACTIVE|ITE_INGRF)) != ITE_ACTIVE)
1218 if (ip->escape == 0)
1220 SUBR_CURSOR(ip, START_CURSOROPT);
1223 iteputchar(s[i], ip);
1226 if (ip->escape == 0)
1228 SUBR_CURSOR(ip, END_CURSOROPT);
1232 iteputchar(int c, struct ite_softc *ip)
1238 if ((c >= 0x20 && ip->escape != 0) || ip->escape == DCS) {
1240 if (c >= 0x20 && ip->escape != 0) {
1242 switch (ip->escape) {
1253 ip->escape = 0;
1263 ip->escape = 0;
1269 ip->escape = 0;
1275 ip->escape = 0;
1281 ip->escape = 0;
1287 ip->escape = 0;
1293 ip->escape = 0;
1298 ip->escape = 0;
1304 ip->escape = 0;
1306 if (ip->decsixel_y != 0) {
1307 ite_lf(ip);
1314 ip->escape = 0;
1319 ip->escape = 0;
1324 ip->escape = 0;
1330 ip->escape = ' ';
1337 ip->escape = c;
1363 ip->escape = 0;
1369 ip->escape = '$';
1374 ip->GR = &ip->G1;
1375 ip->escape = 0;
1379 ip->GL = &ip->G2;
1380 ip->escape = 0;
1384 ip->GR = &ip->G2;
1385 ip->escape = 0;
1389 ip->GL = &ip->G3;
1390 ip->escape = 0;
1394 ip->GR = &ip->G3;
1395 ip->escape = 0;
1399 ip->GR = &ip->G1;
1400 ip->escape = 0;
1405 ip->escape = '#';
1410 ite_reset(ip);
1411 SUBR_CURSOR(ip, MOVE_CURSOR);
1412 ip->escape = 0;
1417 ip->save_curx = ip->curx;
1418 ip->save_cury = ip->cury;
1419 ip->save_attribute = ip->attribute;
1420 ip->sc_om = ip->inside_margins;
1421 ip->sc_G0 = ip->G0;
1422 ip->sc_G1 = ip->G1;
1423 ip->sc_G2 = ip->G2;
1424 ip->sc_G3 = ip->G3;
1425 ip->sc_GL = ip->GL;
1426 ip->sc_GR = ip->GR;
1427 ip->escape = 0;
1432 ip->curx = ip->save_curx;
1433 ip->cury = ip->save_cury;
1434 ip->attribute = ip->save_attribute;
1435 ip->inside_margins = ip->sc_om;
1436 ip->G0 = ip->sc_G0;
1437 ip->G1 = ip->sc_G1;
1438 ip->G2 = ip->sc_G2;
1439 ip->G3 = ip->sc_G3;
1440 ip->GL = ip->sc_GL;
1441 ip->GR = ip->sc_GR;
1442 SUBR_CURSOR(ip, MOVE_CURSOR);
1443 ip->escape = 0;
1448 ip->keypad_appmode = 1;
1449 ip->escape = 0;
1454 ip->keypad_appmode = 0;
1455 ip->escape = 0;
1459 if (ip->emul_level == EMUL_VT100) {
1461 ite_sendstr(ip, "\033[61;0c");
1464 ite_sendstr(ip, "\033[63;0c");
1466 ip->escape = 0;
1471 ip->escape = 0;
1479 ip->G0 = CSET_ASCII;
1480 ip->escape = 0;
1483 ip->G0 = CSET_JISKANA;
1484 ip->escape = 0;
1487 ip->G0 = CSET_JISROMA;
1488 ip->escape = 0;
1491 ip->G0 = CSET_DECGRAPH;
1492 ip->escape = 0;
1502 ip->escape = 0;
1507 ip->escape = 0;
1513 ip->G0 = CSET_JIS1978;
1514 ip->escape = 0;
1517 ip->G0 = CSET_JIS1983;
1518 ip->escape = 0;
1521 ip->G0 = CSET_JIS1990;
1522 ip->escape = 0;
1526 ip->escape = 0;
1533 ip->eightbit_C1 = 0;
1534 ip->escape = 0;
1538 ip->eightbit_C1 = 1;
1539 ip->escape = 0;
1544 ip->escape = 0;
1553 ip->escape = 0;
1558 ip->escape = 0;
1563 ip->escape = 0;
1568 ip->escape = 0;
1573 alignment_display(ip);
1574 ip->escape = 0;
1578 ip->escape = 0;
1600 if (ip->ap < ip->argbuf + MAX_ARGSIZE)
1601 *ip->ap++ = c;
1605 *ip->ap = 0;
1606 if (!strncmp(ip->argbuf, "61\"", 3))
1607 ip->emul_level = EMUL_VT100;
1608 else if (!strncmp(ip->argbuf, "63;1\"", 5) ||
1609 !strncmp(ip->argbuf, "62;1\"", 5))
1610 ip->emul_level = EMUL_VT300_7;
1612 ip->emul_level = EMUL_VT300_8;
1613 ip->escape = 0;
1617 *ip->ap = 0;
1618 ip->escape = '?';
1619 ip->ap = ip->argbuf;
1624 *ip->ap = 0;
1625 if (ip->argbuf[0] == '>') {
1626 ite_sendstr(ip, "\033[>24;0;0;0c");
1628 switch (ite_zargnum(ip)) {
1634 if (ip->emul_level ==
1636 ite_sendstr(ip,
1640 ite_sendstr(ip,
1643 ite_sendstr(ip,
1649 ip->escape = 0;
1653 switch (ite_zargnum(ip)) {
1656 ite_sendstr(ip, "\033[0n");
1660 snprintf(ip->argbuf, sizeof(ip->argbuf),
1662 ip->cury + 1, ip->curx + 1);
1663 ite_sendstr(ip, ip->argbuf);
1666 ip->escape = 0;
1670 switch (ite_zargnum(ip)) {
1673 ite_sendstr(ip,
1677 ite_sendstr(ip,
1681 ip->escape = 0;
1686 switch (ite_zargnum(ip)) {
1688 if (ip->curx < ip->cols)
1689 ip->tabs[ip->curx] = 0;
1692 for (n = 0; n < ip->cols; n++)
1693 ip->tabs[n] = 0;
1700 ip->escape = 0;
1705 n = ite_zargnum(ip);
1709 ip->imode = (c == 'h');
1712 ip->linefeed_newline = (c == 'h');
1715 ip->escape = 0;
1720 ite_dnline(ip, ite_argnum(ip));
1721 ip->escape = 0;
1726 ite_inline(ip, ite_argnum(ip));
1727 ip->escape = 0;
1732 ite_dnchar(ip, ite_argnum(ip));
1733 ip->escape = 0;
1738 ite_inchar(ip, ite_argnum(ip));
1739 ip->escape = 0;
1744 ip->escape = 0; /* XXX */
1754 *ip->ap = 0;
1755 x = atoi(ip->argbuf);
1758 ip->curx = uimin(x, ip->cols - 1);
1759 ip->escape = 0;
1760 SUBR_CURSOR(ip, MOVE_CURSOR);
1761 clr_attr(ip, ATTR_INV);
1770 *ip->ap = 0;
1771 y = atoi(ip->argbuf);
1774 if (ip->inside_margins)
1775 y += ip->top_margin;
1776 ip->cury = uimin(y, ip->rows - 1);
1777 ip->escape = 0;
1778 snap_cury(ip);
1779 SUBR_CURSOR(ip, MOVE_CURSOR);
1780 clr_attr(ip, ATTR_INV);
1785 *ip->ap = 0;
1786 y = atoi(ip->argbuf);
1788 cp = strchr(ip->argbuf, ';');
1795 if (ip->inside_margins != 0)
1796 y += ip->top_margin;
1797 ip->cury = uimin(y, ip->rows - 1);
1798 ip->curx = uimin(x, ip->cols - 1);
1799 ip->escape = 0;
1800 snap_cury(ip);
1801 SUBR_CURSOR(ip, MOVE_CURSOR);
1802 /*clr_attr(ip, ATTR_INV);*/
1807 n = ite_argnum(ip);
1808 n = ip->cury - (n ? n : 1);
1811 if (ip->inside_margins)
1812 n = uimax(ip->top_margin, n);
1813 else if (n == ip->top_margin - 1)
1819 n = ip->top_margin;
1820 ip->cury = n;
1821 ip->escape = 0;
1822 SUBR_CURSOR(ip, MOVE_CURSOR);
1823 clr_attr(ip, ATTR_INV);
1828 n = ite_argnum(ip);
1829 n = ip->cury + (n ? n : 1);
1830 n = uimin(ip->rows - 1, n);
1832 if (ip->inside_margins)
1834 n = uimin(ip->bottom_margin, n);
1836 else if (n == ip->bottom_margin + 1)
1842 n = ip->bottom_margin;
1844 ip->cury = n;
1845 ip->escape = 0;
1846 SUBR_CURSOR(ip, MOVE_CURSOR);
1847 clr_attr(ip, ATTR_INV);
1852 n = ite_argnum(ip);
1854 ip->curx = uimin(ip->curx + n, ip->cols - 1);
1855 ip->escape = 0;
1856 SUBR_CURSOR(ip, MOVE_CURSOR);
1857 clr_attr(ip, ATTR_INV);
1862 n = ite_argnum(ip);
1864 n = ip->curx - n;
1865 ip->curx = n >= 0 ? n : 0;
1866 ip->escape = 0;
1867 SUBR_CURSOR(ip, MOVE_CURSOR);
1868 clr_attr(ip, ATTR_INV);
1873 *ip->ap = 0;
1874 n = ite_zargnum(ip);
1876 ite_clrtoeos(ip);
1878 ite_clrtobos(ip);
1880 ite_clrscreen(ip);
1881 ip->escape = 0;
1886 n = ite_zargnum(ip);
1888 ite_clrtoeol(ip);
1890 ite_clrtobol(ip);
1892 ite_clrline(ip);
1893 ip->escape = 0;
1898 n = ite_zargnum(ip);
1901 else if (n > ip->rows-1)
1902 n = ip->rows-1;
1903 SUBR_SCROLL(ip, ip->rows-1, 0, n, SCROLL_UP);
1904 ip->escape = 0;
1909 n = ite_zargnum(ip);
1912 else if (n > ip->rows-1)
1913 n = ip->rows-1;
1914 SUBR_SCROLL(ip, 0, 0, n, SCROLL_DOWN);
1915 ip->escape = 0;
1920 n = ite_argnum(ip) - 1;
1921 n = uimin(n, ip->cols - 1 - ip->curx);
1923 attrclr(ip, ip->cury, ip->curx + n,
1925 SUBR_PUTC(ip, ' ',
1926 ip->cury, ip->curx + n, ATTR_NOR);
1928 ip->escape = 0;
1933 ip->escape = 0;
1938 ip->escape = 0;
1939 *ip->ap = 0;
1940 x = atoi(ip->argbuf);
1942 y = ip->rows;
1943 cp = strchr(ip->argbuf, ';');
1946 y = y ? y : ip->rows;
1952 ip->top_margin = uimin(x, ip->rows - 2);
1953 ip->bottom_margin = uimin(y, ip->rows - 1);
1954 if (ip->inside_margins) {
1955 ip->cury = ip->top_margin;
1957 ip->cury = 0;
1958 ip->curx = 0;
1966 *ip->ap = 0;
1968 if (ip->ap == ip->argbuf)
1969 ip->ap++;
1970 for (c_p = ip->argbuf; c_p < ip->ap; ) {
1974 clr_attr(ip, ATTR_ALL);
1975 ip->fgcolor = 7;
1976 ip->bgcolor = 0;
1981 set_attr(ip, ATTR_BOLD);
1988 clr_attr(ip, ATTR_BOLD);
1993 clr_attr(ip, ATTR_UL);
1998 clr_attr(ip,
2004 clr_attr(ip, ATTR_INV);
2025 ip->fgcolor =
2046 ip->bgcolor =
2051 set_attr(ip, ATTR_UL);
2058 set_attr(ip, ATTR_BLINK);
2063 set_attr(ip, ATTR_INV);
2074 ip->escape = 0;
2079 ite_sendstr(ip, "\033P\033\\");
2080 ip->escape = 0;
2084 ip->escape = 0;
2108 if (ip->ap < ip->argbuf + MAX_ARGSIZE - 1)
2109 *ip->ap++ = c;
2114 *ip->ap = 0;
2115 if (ip->ap == &ip->argbuf[2]) {
2116 if (!strncmp(ip->argbuf, "15", 2))
2118 ite_sendstr(ip, "\033[13n");
2119 else if (!strncmp(ip->argbuf, "25", 2))
2121 ite_sendstr(ip, "\033[20n");
2122 else if (!strncmp(ip->argbuf, "26", 2))
2124 ite_sendstr(ip, "\033[27;1n");
2126 ip->escape = 0;
2131 n = ite_zargnum(ip);
2135 ip->cursor_appmode = (c == 'h');
2153 ip->inside_margins = (c == 'h');
2155 ip->curx = 0;
2156 ip->cury = ip->inside_margins ?
2157 ip->top_margin : 0;
2158 SUBR_CURSOR(ip, MOVE_CURSOR);
2163 ip->auto_wrap = (c == 'h');
2167 ip->key_repeat = (c == 'h');
2171 ip->linefeed_newline = (c == 'h');
2175 SUBR_CURSOR(ip, (c == 'h') ?
2179 ip->escape = 0;
2188 ip->escape = 0;
2195 if (ite_dcs(c, ip) == 0) {
2202 ip->escape = 0;
2225 if (--ip->curx < 0)
2226 ip->curx = 0;
2228 SUBR_CURSOR(ip, MOVE_CURSOR);
2232 for (n = ip->curx + 1; n < ip->cols; n++) {
2233 if (ip->tabs[n]) {
2234 ip->curx = n;
2235 SUBR_CURSOR(ip, MOVE_CURSOR);
2248 if (ip->linefeed_newline)
2249 ite_crlf(ip);
2251 ite_lf(ip);
2255 ite_cr(ip);
2259 ip->GL = &ip->G1;
2263 ip->GL = &ip->G0;
2277 ip->escape = 0; /* cancel any escape sequence in progress */
2284 ip->escape = 0; /* dito, but see below */
2289 ip->escape = ESC;
2300 ite_index(ip);
2304 ite_crlf(ip);
2308 if (ip->curx < ip->cols)
2309 ip->tabs[ip->curx] = 1;
2313 ite_rlf(ip);
2317 ip->save_GL = ip->GR; /* GL XXX EUC */
2318 ip->GR = &ip->G2; /* GL XXX */
2322 ip->save_GL = ip->GR; /* GL XXX EUC */
2323 ip->GR = &ip->G3; /* GL XXX */
2327 ip->escape = DCS;
2329 ip->dcs_cmd = DCS_START;
2331 ip->ap = ip->argbuf;
2335 ip->escape = CSI;
2336 ip->ap = ip->argbuf;
2345 ip->escape = OSC;
2350 ip->escape = PM;
2355 ip->escape = APC;
2362 if (ip->save_char == 0 &&
2363 (*((c & 0x80) ? ip->GR : ip->GL) & CSET_MULTI) != 0) {
2364 ip->save_char = c;
2367 if (ip->imode != 0)
2368 ite_inchar(ip, ip->save_char ? 2 : 1);
2369 iteprecheckwrap(ip);
2371 if ((ip->attribute & ATTR_INV) || attrtest(ip, ATTR_INV)) {
2372 attrset(ip, ATTR_INV);
2373 SUBR_PUTC(ip, c, ip->cury, ip->curx, ATTR_INV);
2376 SUBR_PUTC(ip, c, ip->cury, ip->curx, ATTR_NOR);
2378 SUBR_PUTC(ip, c, ip->cury, ip->curx, ip->attribute);
2380 /*SUBR_CURSOR(ip, DRAW_CURSOR);*/
2381 itecheckwrap(ip);
2382 if (ip->save_char) {
2383 itecheckwrap(ip);
2384 ip->save_char = 0;
2386 if (ip->save_GL) {
2390 ip->GR = ip->save_GL;
2391 ip->save_GL = 0;
2404 ite_dcs(const int c, struct ite_softc *ip)
2425 switch (ip->dcs_cmd) {
2431 ite_lf(ip);
2437 ip->escape = 0;
2441 ip->escape = ESC;
2464 if (ip->ap < ip->argbuf + MAX_ARGSIZE)
2465 *ip->ap++ = c;
2481 ip->ap = ip->argbuf;
2482 cp = strchr(ip->ap, ';');
2486 ip->decsixel_ormode = (mode & 4);
2488 ip->decsixel_ormode = 0;
2491 ip->dcs_cmd = DCS_SIXEL;
2492 ip->decsixel_state = DECSIXEL_INIT;
2493 ip->decsixel_ph = MAX_SIXEL_WIDTH;
2494 ip->decsixel_x = 0;
2495 ip->decsixel_y = 0;
2496 ip->decsixel_repcount = 0;
2497 ip->decsixel_color = ip->fgcolor;
2498 memset(ip->decsixel_buf, 0, sizeof(ip->decsixel_buf));
2505 ip->escape = 0;
2509 ip->escape = ESC;
2519 switch (ip->decsixel_state) {
2528 ip->escape = 0;
2532 ip->escape = ESC;
2536 ip->decsixel_state = c;
2537 ip->decsixel_repcount = 0;
2542 ip->decsixel_state = c;
2543 ip->ap = ip->argbuf;
2547 ip->decsixel_x = 0;
2555 if (ip->decsixel_y + 6 > 15) {
2556 ite_lf(ip);
2557 ip->decsixel_y -= 16;
2559 SUBR_SIXEL(ip, ip->cury, ip->curx);
2560 memset(ip->decsixel_buf, 0,
2561 sizeof(ip->decsixel_buf));
2562 ip->decsixel_x = 0;
2563 ip->decsixel_y += 6;
2568 && ip->decsixel_x < MAX_SIXEL_WIDTH) {
2570 d = table[c - '?'] * ip->decsixel_color;
2571 ip->decsixel_buf[ip->decsixel_x] |= d;
2572 ip->decsixel_x++;
2582 ip->decsixel_repcount =
2583 ip->decsixel_repcount * 10 + (c - '0');
2587 int cnt = MIN(ip->decsixel_repcount,
2588 MAX_SIXEL_WIDTH - ip->decsixel_x);
2589 d = table[c - '?'] * ip->decsixel_color;
2591 ip->decsixel_buf[ip->decsixel_x + i] |=
2594 ip->decsixel_x += cnt;
2595 ip->decsixel_state = DECSIXEL_INIT;
2598 ip->decsixel_state = DECSIXEL_INIT;
2617 if (ip->ap < ip->argbuf + MAX_ARGSIZE)
2618 *ip->ap++ = c;
2623 switch (ip->decsixel_state) {
2626 ip->ap = ip->argbuf;
2627 ip->decsixel_state =
2633 ip->ap = ip->argbuf;
2634 ip->decsixel_state = DECSIXEL_RASTER_PH;
2638 ip->decsixel_ph = ite_zargnum(ip);
2639 ip->ap = ip->argbuf;
2640 ip->decsixel_state = DECSIXEL_RASTER_PV;
2645 ip->decsixel_state = DECSIXEL_INIT;
2669 if (ip->ap < ip->argbuf + MAX_ARGSIZE)
2670 *ip->ap++ = c;
2674 *ip->ap = '\0';
2675 if (strchr(ip->argbuf, ';')) {
2679 ip->decsixel_color =
2680 ite_zargnum(ip) & 7;
2682 ip->decsixel_state = DECSIXEL_INIT;
2683 ip->ap = ip->argbuf;
2698 iteprecheckwrap(struct ite_softc *ip)
2701 if (ip->auto_wrap && ip->curx + (ip->save_char ? 1 : 0) == ip->cols) {
2702 ip->curx = 0;
2703 clr_attr(ip, ATTR_INV);
2704 if (++ip->cury >= ip->bottom_margin + 1) {
2705 ip->cury = ip->bottom_margin;
2706 /*SUBR_CURSOR(ip, MOVE_CURSOR);*/
2707 SUBR_SCROLL(ip, ip->top_margin + 1, 0, 1, SCROLL_UP);
2708 ite_clrtoeol(ip);
2710 SUBR_CURSOR(ip, MOVE_CURSOR);*/
2715 itecheckwrap(struct ite_softc *ip)
2719 if (++ip->curx == ip->cols) {
2720 if (ip->auto_wrap) {
2721 ip->curx = 0;
2722 clr_attr(ip, ATTR_INV);
2723 if (++ip->cury >= ip->bottom_margin + 1) {
2724 ip->cury = ip->bottom_margin;
2725 SUBR_CURSOR(ip, MOVE_CURSOR);
2726 SUBR_SCROLL(ip, ip->top_margin + 1, 0, 1,
2728 ite_clrtoeol(ip);
2733 ip->curx--;
2736 if (ip->curx < ip->cols) {
2737 ip->curx++;
2738 /*SUBR_CURSOR(ip, MOVE_CURSOR);*/
2843 struct ite_softc *ip;
2845 ip = getitesp(cd->cn_dev);
2847 ip->flags |= ITE_ACTIVE | ITE_ISCONS;
2858 itecnfinish(struct ite_softc *ip)
2884 struct ite_softc *ip = getitesp(dev);
2894 (ip->flags & (ITE_ACTIVE|ITE_INGRF)) != ITE_ACTIVE) {
2900 save_escape = ip->escape;
2901 if (ip->escape == DCS) {
2902 ip->escape = 0;
2903 ip->dcs_cmd = DCS_DISCARD;
2907 save_attribute = ip->attribute;
2908 ip->attribute = ITE_KERNEL_ATTR;
2912 ip->attribute = save_attribute;
2915 if (ip->escape == 0) {
2916 ip->escape = save_escape;