summaryrefslogtreecommitdiff
path: root/src/bin/termptyesc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/termptyesc.c')
-rw-r--r--src/bin/termptyesc.c401
1 files changed, 266 insertions, 135 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index a92b4db..243b8c3 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -110,9 +110,9 @@ _cursor_is_within_margins(const Termpty *ty)
110 ); 110 );
111} 111}
112 112
113enum csi_arg_error { 113enum esc_arg_error {
114 CSI_ARG_NO_VALUE = 1, 114 ESC_ARG_NO_VALUE = 1,
115 CSI_ARG_ERROR = 2 115 ESC_ARG_ERROR = 2
116}; 116};
117 117
118static int 118static int
@@ -124,7 +124,7 @@ _csi_arg_get(Termpty *ty, Eina_Unicode **ptr)
124 if ((b == NULL) || (*b == '\0')) 124 if ((b == NULL) || (*b == '\0'))
125 { 125 {
126 *ptr = NULL; 126 *ptr = NULL;
127 return -CSI_ARG_NO_VALUE; 127 return -ESC_ARG_NO_VALUE;
128 } 128 }
129 129
130 /* Skip potential '?', '>'.... */ 130 /* Skip potential '?', '>'.... */
@@ -135,13 +135,13 @@ _csi_arg_get(Termpty *ty, Eina_Unicode **ptr)
135 { 135 {
136 b++; 136 b++;
137 *ptr = b; 137 *ptr = b;
138 return -CSI_ARG_NO_VALUE; 138 return -ESC_ARG_NO_VALUE;
139 } 139 }
140 140
141 if (*b == '\0') 141 if (*b == '\0')
142 { 142 {
143 *ptr = NULL; 143 *ptr = NULL;
144 return -CSI_ARG_NO_VALUE; 144 return -ESC_ARG_NO_VALUE;
145 } 145 }
146 146
147 while ((*b >= '0') && (*b <= '9')) 147 while ((*b >= '0') && (*b <= '9'))
@@ -177,7 +177,7 @@ error:
177 ERR("Invalid CSI argument"); 177 ERR("Invalid CSI argument");
178 ty->decoding_error = EINA_TRUE; 178 ty->decoding_error = EINA_TRUE;
179 *ptr = NULL; 179 *ptr = NULL;
180 return -CSI_ARG_ERROR; 180 return -ESC_ARG_ERROR;
181} 181}
182 182
183static void 183static void
@@ -207,6 +207,8 @@ _cursor_to_start_of_line(Termpty *ty)
207static void 207static void
208_handle_cursor_control(Termpty *ty, const Eina_Unicode *cc) 208_handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
209{ 209{
210 Termcell *cell;
211
210 switch (*cc) 212 switch (*cc)
211 { 213 {
212 case 0x07: // BEL '\a' (bell) 214 case 0x07: // BEL '\a' (bell)
@@ -220,7 +222,11 @@ _handle_cursor_control(Termpty *ty, const Eina_Unicode *cc)
220 return; 222 return;
221 case 0x09: // HT '\t' (horizontal tab) 223 case 0x09: // HT '\t' (horizontal tab)
222 DBG("->HT"); 224 DBG("->HT");
225 cell = &(TERMPTY_SCREEN(ty, ty->cursor_state.cx, ty->cursor_state.cy));
226 cell->att.tab_inserted = 1;
223 _tab_forward(ty, 1); 227 _tab_forward(ty, 1);
228 cell = &(TERMPTY_SCREEN(ty, ty->cursor_state.cx -1, ty->cursor_state.cy));
229 cell->att.tab_last = 1;
224 return; 230 return;
225 case 0x0a: // LF '\n' (new line) 231 case 0x0a: // LF '\n' (new line)
226 case 0x0b: // VT '\v' (vertical tab) 232 case 0x0b: // VT '\v' (vertical tab)
@@ -295,9 +301,9 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b,
295 // http://ttssh2.sourceforge.jp/manual/en/about/ctrlseq.html 301 // http://ttssh2.sourceforge.jp/manual/en/about/ctrlseq.html
296 switch (arg) 302 switch (arg)
297 { 303 {
298 case -CSI_ARG_ERROR: 304 case -ESC_ARG_ERROR:
299 return; 305 return;
300 /* TODO: -CSI_ARG_NO_VALUE */ 306 /* TODO: -ESC_ARG_NO_VALUE */
301 case 1: 307 case 1:
302 ty->termstate.appcursor = mode; 308 ty->termstate.appcursor = mode;
303 break; 309 break;
@@ -547,9 +553,9 @@ _handle_esc_csi_reset_mode(Termpty *ty, Eina_Unicode cc, Eina_Unicode *b,
547 553
548 switch (arg) 554 switch (arg)
549 { 555 {
550 case -CSI_ARG_ERROR: 556 case -ESC_ARG_ERROR:
551 return; 557 return;
552 /* TODO: -CSI_ARG_NO_VALUE */ 558 /* TODO: -ESC_ARG_NO_VALUE */
553 case 1: 559 case 1:
554 ty->termstate.appcursor = mode; 560 ty->termstate.appcursor = mode;
555 break; 561 break;
@@ -587,7 +593,7 @@ _csi_truecolor_arg_get(Termpty *ty, Eina_Unicode **ptr)
587 if ((b == NULL) || (*b == '\0')) 593 if ((b == NULL) || (*b == '\0'))
588 { 594 {
589 *ptr = NULL; 595 *ptr = NULL;
590 return -CSI_ARG_NO_VALUE; 596 return -ESC_ARG_NO_VALUE;
591 } 597 }
592 598
593 /* by construction, shall be the same separator as the following ones */ 599 /* by construction, shall be the same separator as the following ones */
@@ -595,26 +601,26 @@ _csi_truecolor_arg_get(Termpty *ty, Eina_Unicode **ptr)
595 if ((separator != ';') && (separator != ':')) 601 if ((separator != ';') && (separator != ':'))
596 { 602 {
597 *ptr = NULL; 603 *ptr = NULL;
598 return -CSI_ARG_NO_VALUE; 604 return -ESC_ARG_NO_VALUE;
599 } 605 }
600 606
601 if (*b == separator) 607 if (*b == separator)
602 { 608 {
603 b++; 609 b++;
604 *ptr = b; 610 *ptr = b;
605 return -CSI_ARG_NO_VALUE; 611 return -ESC_ARG_NO_VALUE;
606 } 612 }
607 613
608 if (*b == '\0') 614 if (*b == '\0')
609 { 615 {
610 *ptr = NULL; 616 *ptr = NULL;
611 return -CSI_ARG_NO_VALUE; 617 return -ESC_ARG_NO_VALUE;
612 } 618 }
613 /* invalid values */ 619 /* invalid values */
614 if ((*b < '0') || (*b > '9')) 620 if ((*b < '0') || (*b > '9'))
615 { 621 {
616 *ptr = NULL; 622 *ptr = NULL;
617 return -CSI_ARG_ERROR; 623 return -ESC_ARG_ERROR;
618 } 624 }
619 625
620 while ((*b >= '0') && (*b <= '9')) 626 while ((*b >= '0') && (*b <= '9'))
@@ -624,7 +630,7 @@ _csi_truecolor_arg_get(Termpty *ty, Eina_Unicode **ptr)
624 *ptr = NULL; 630 *ptr = NULL;
625 ERR("Invalid sequence: argument is too large"); 631 ERR("Invalid sequence: argument is too large");
626 ty->decoding_error = EINA_TRUE; 632 ty->decoding_error = EINA_TRUE;
627 return -CSI_ARG_ERROR; 633 return -ESC_ARG_ERROR;
628 } 634 }
629 sum *= 10; 635 sum *= 10;
630 sum += *b - '0'; 636 sum += *b - '0';
@@ -713,9 +719,9 @@ _handle_esc_csi_truecolor_rgb(Termpty *ty, Eina_Unicode **ptr)
713 r = _csi_truecolor_arg_get(ty, ptr); 719 r = _csi_truecolor_arg_get(ty, ptr);
714 g = _csi_truecolor_arg_get(ty, ptr); 720 g = _csi_truecolor_arg_get(ty, ptr);
715 b = _csi_truecolor_arg_get(ty, ptr); 721 b = _csi_truecolor_arg_get(ty, ptr);
716 if ((r == -CSI_ARG_ERROR) || 722 if ((r == -ESC_ARG_ERROR) ||
717 (g == -CSI_ARG_ERROR) || 723 (g == -ESC_ARG_ERROR) ||
718 (b == -CSI_ARG_ERROR)) 724 (b == -ESC_ARG_ERROR))
719 return COL_DEF; 725 return COL_DEF;
720 726
721 if (separator == ':' && *ptr) 727 if (separator == ':' && *ptr)
@@ -730,7 +736,7 @@ _handle_esc_csi_truecolor_rgb(Termpty *ty, Eina_Unicode **ptr)
730 while ((*ptr) && (**ptr != ';')) 736 while ((*ptr) && (**ptr != ';'))
731 { 737 {
732 int arg = _csi_truecolor_arg_get(ty, ptr); 738 int arg = _csi_truecolor_arg_get(ty, ptr);
733 if (arg == -CSI_ARG_ERROR) 739 if (arg == -ESC_ARG_ERROR)
734 break; 740 break;
735 } 741 }
736 } 742 }
@@ -740,11 +746,11 @@ _handle_esc_csi_truecolor_rgb(Termpty *ty, Eina_Unicode **ptr)
740 } 746 }
741 } 747 }
742 748
743 if (r == -CSI_ARG_NO_VALUE) 749 if (r == -ESC_ARG_NO_VALUE)
744 r = 0; 750 r = 0;
745 if (g == -CSI_ARG_NO_VALUE) 751 if (g == -ESC_ARG_NO_VALUE)
746 g = 0; 752 g = 0;
747 if (b == -CSI_ARG_NO_VALUE) 753 if (b == -ESC_ARG_NO_VALUE)
748 b = 0; 754 b = 0;
749 755
750 return _approximate_truecolor_rgb(ty, r, g, b); 756 return _approximate_truecolor_rgb(ty, r, g, b);
@@ -768,9 +774,9 @@ _handle_esc_csi_truecolor_cmy(Termpty *ty, Eina_Unicode **ptr)
768 m = _csi_truecolor_arg_get(ty, ptr); 774 m = _csi_truecolor_arg_get(ty, ptr);
769 y = _csi_truecolor_arg_get(ty, ptr); 775 y = _csi_truecolor_arg_get(ty, ptr);
770 776
771 if ((c == -CSI_ARG_ERROR) || 777 if ((c == -ESC_ARG_ERROR) ||
772 (m == -CSI_ARG_ERROR) || 778 (m == -ESC_ARG_ERROR) ||
773 (y == -CSI_ARG_ERROR)) 779 (y == -ESC_ARG_ERROR))
774 return COL_DEF; 780 return COL_DEF;
775 781
776 if (separator == ':' && *ptr) 782 if (separator == ':' && *ptr)
@@ -785,7 +791,7 @@ _handle_esc_csi_truecolor_cmy(Termpty *ty, Eina_Unicode **ptr)
785 while ((*ptr) && (**ptr != ';')) 791 while ((*ptr) && (**ptr != ';'))
786 { 792 {
787 int arg = _csi_truecolor_arg_get(ty, ptr); 793 int arg = _csi_truecolor_arg_get(ty, ptr);
788 if (arg == -CSI_ARG_ERROR) 794 if (arg == -ESC_ARG_ERROR)
789 break; 795 break;
790 } 796 }
791 } 797 }
@@ -795,11 +801,11 @@ _handle_esc_csi_truecolor_cmy(Termpty *ty, Eina_Unicode **ptr)
795 } 801 }
796 } 802 }
797 803
798 if (c == -CSI_ARG_NO_VALUE) 804 if (c == -ESC_ARG_NO_VALUE)
799 c = 0; 805 c = 0;
800 if (m == -CSI_ARG_NO_VALUE) 806 if (m == -ESC_ARG_NO_VALUE)
801 m = 0; 807 m = 0;
802 if (y == -CSI_ARG_NO_VALUE) 808 if (y == -ESC_ARG_NO_VALUE)
803 y = 0; 809 y = 0;
804 810
805 r = 255 - ((c * 255) / 100); 811 r = 255 - ((c * 255) / 100);
@@ -828,10 +834,10 @@ _handle_esc_csi_truecolor_cmyk(Termpty *ty, Eina_Unicode **ptr)
828 y = _csi_truecolor_arg_get(ty, ptr); 834 y = _csi_truecolor_arg_get(ty, ptr);
829 k = _csi_truecolor_arg_get(ty, ptr); 835 k = _csi_truecolor_arg_get(ty, ptr);
830 836
831 if ((c == -CSI_ARG_ERROR) || 837 if ((c == -ESC_ARG_ERROR) ||
832 (m == -CSI_ARG_ERROR) || 838 (m == -ESC_ARG_ERROR) ||
833 (y == -CSI_ARG_ERROR) || 839 (y == -ESC_ARG_ERROR) ||
834 (k == -CSI_ARG_ERROR)) 840 (k == -ESC_ARG_ERROR))
835 return COL_DEF; 841 return COL_DEF;
836 842
837 if (separator == ':' && *ptr) 843 if (separator == ':' && *ptr)
@@ -847,7 +853,7 @@ _handle_esc_csi_truecolor_cmyk(Termpty *ty, Eina_Unicode **ptr)
847 while ((*ptr) && (**ptr != ';')) 853 while ((*ptr) && (**ptr != ';'))
848 { 854 {
849 int arg = _csi_truecolor_arg_get(ty, ptr); 855 int arg = _csi_truecolor_arg_get(ty, ptr);
850 if (arg == -CSI_ARG_ERROR) 856 if (arg == -ESC_ARG_ERROR)
851 break; 857 break;
852 } 858 }
853 } 859 }
@@ -857,13 +863,13 @@ _handle_esc_csi_truecolor_cmyk(Termpty *ty, Eina_Unicode **ptr)
857 } 863 }
858 } 864 }
859 865
860 if (c == -CSI_ARG_NO_VALUE) 866 if (c == -ESC_ARG_NO_VALUE)
861 c = 0; 867 c = 0;
862 if (m == -CSI_ARG_NO_VALUE) 868 if (m == -ESC_ARG_NO_VALUE)
863 m = 0; 869 m = 0;
864 if (y == -CSI_ARG_NO_VALUE) 870 if (y == -ESC_ARG_NO_VALUE)
865 y = 0; 871 y = 0;
866 if (k == -CSI_ARG_NO_VALUE) 872 if (k == -ESC_ARG_NO_VALUE)
867 k = 0; 873 k = 0;
868 874
869 r = (255 * (100 - c) * (100 - k)) / 100 / 100; 875 r = (255 * (100 - c) * (100 - k)) / 100 / 100;
@@ -891,9 +897,9 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
891 int arg = _csi_arg_get(ty, &b); 897 int arg = _csi_arg_get(ty, &b);
892 switch (arg) 898 switch (arg)
893 { 899 {
894 case -CSI_ARG_ERROR: 900 case -ESC_ARG_ERROR:
895 return; 901 return;
896 case -CSI_ARG_NO_VALUE: 902 case -ESC_ARG_NO_VALUE:
897 EINA_FALLTHROUGH; 903 EINA_FALLTHROUGH;
898 case 0: // reset to normal 904 case 0: // reset to normal
899 termpty_reset_att(&(ty->termstate.att)); 905 termpty_reset_att(&(ty->termstate.att));
@@ -971,9 +977,9 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
971 arg = _csi_arg_get(ty, &b); 977 arg = _csi_arg_get(ty, &b);
972 switch (arg) 978 switch (arg)
973 { 979 {
974 case -CSI_ARG_ERROR: 980 case -ESC_ARG_ERROR:
975 return; 981 return;
976 /* TODO: -CSI_ARG_NO_VALUE */ 982 /* TODO: -ESC_ARG_NO_VALUE */
977 case 1: 983 case 1:
978 ty->termstate.att.fg256 = 0; 984 ty->termstate.att.fg256 = 0;
979 ty->termstate.att.fg = COL_INVIS; 985 ty->termstate.att.fg = COL_INVIS;
@@ -1002,14 +1008,14 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
1002 case 5: 1008 case 5:
1003 // then get next arg - should be color index 0-255 1009 // then get next arg - should be color index 0-255
1004 arg = _csi_arg_get(ty, &b); 1010 arg = _csi_arg_get(ty, &b);
1005 if (arg <= -CSI_ARG_ERROR || arg > 255) 1011 if (arg <= -ESC_ARG_ERROR || arg > 255)
1006 { 1012 {
1007 ERR("Invalid fg color %d", arg); 1013 ERR("Invalid fg color %d", arg);
1008 ty->decoding_error = EINA_TRUE; 1014 ty->decoding_error = EINA_TRUE;
1009 } 1015 }
1010 else 1016 else
1011 { 1017 {
1012 if (arg == -CSI_ARG_NO_VALUE) 1018 if (arg == -ESC_ARG_NO_VALUE)
1013 arg = 0; 1019 arg = 0;
1014 ty->termstate.att.fg256 = 1; 1020 ty->termstate.att.fg256 = 1;
1015 ty->termstate.att.fg = arg; 1021 ty->termstate.att.fg = arg;
@@ -1042,9 +1048,9 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
1042 arg = _csi_arg_get(ty, &b); 1048 arg = _csi_arg_get(ty, &b);
1043 switch (arg) 1049 switch (arg)
1044 { 1050 {
1045 case -CSI_ARG_ERROR: 1051 case -ESC_ARG_ERROR:
1046 return; 1052 return;
1047 /* TODO: -CSI_ARG_NO_VALUE */ 1053 /* TODO: -ESC_ARG_NO_VALUE */
1048 case 1: 1054 case 1:
1049 ty->termstate.att.bg256 = 0; 1055 ty->termstate.att.bg256 = 0;
1050 ty->termstate.att.bg = COL_INVIS; 1056 ty->termstate.att.bg = COL_INVIS;
@@ -1073,14 +1079,14 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr,
1073 case 5: 1079 case 5:
1074 // then get next arg - should be color index 0-255 1080 // then get next arg - should be color index 0-255
1075 arg = _csi_arg_get(ty, &b); 1081 arg = _csi_arg_get(ty, &b);
1076 if (arg <= -CSI_ARG_ERROR || arg > 255) 1082 if (arg <= -ESC_ARG_ERROR || arg > 255)
1077 { 1083 {
1078 ERR("Invalid bg color %d", arg); 1084 ERR("Invalid bg color %d", arg);
1079 ty->decoding_error = EINA_TRUE; 1085 ty->decoding_error = EINA_TRUE;
1080 } 1086 }
1081 else 1087 else
1082 { 1088 {
1083 if (arg == -CSI_ARG_NO_VALUE) 1089 if (arg == -ESC_ARG_NO_VALUE)
1084 arg = 0; 1090 arg = 0;
1085 ty->termstate.att.bg256 = 1; 1091 ty->termstate.att.bg256 = 1;
1086 ty->termstate.att.bg = arg; 1092 ty->termstate.att.bg = arg;
@@ -1164,7 +1170,7 @@ _handle_esc_csi_cnl(Termpty *ty, Eina_Unicode **ptr)
1164 int arg = _csi_arg_get(ty, &b); 1170 int arg = _csi_arg_get(ty, &b);
1165 int max = ty->h; 1171 int max = ty->h;
1166 1172
1167 if (arg == -CSI_ARG_ERROR) 1173 if (arg == -ESC_ARG_ERROR)
1168 return; 1174 return;
1169 if (arg < 1) 1175 if (arg < 1)
1170 arg = 1; 1176 arg = 1;
@@ -1189,7 +1195,7 @@ _handle_esc_csi_cpl(Termpty *ty, Eina_Unicode **ptr)
1189 int arg = _csi_arg_get(ty, &b); 1195 int arg = _csi_arg_get(ty, &b);
1190 int max = ty->h; 1196 int max = ty->h;
1191 1197
1192 if (arg == -CSI_ARG_ERROR) 1198 if (arg == -ESC_ARG_ERROR)
1193 return; 1199 return;
1194 if (arg < 1) 1200 if (arg < 1)
1195 arg = 1; 1201 arg = 1;
@@ -1215,7 +1221,7 @@ _handle_esc_csi_dch(Termpty *ty, Eina_Unicode **ptr)
1215 Termcell *cells; 1221 Termcell *cells;
1216 int x, lim, max; 1222 int x, lim, max;
1217 1223
1218 if (arg == -CSI_ARG_ERROR) 1224 if (arg == -ESC_ARG_ERROR)
1219 return; 1225 return;
1220 1226
1221 DBG("DCH - Delete Character: %d chars", arg); 1227 DBG("DCH - Delete Character: %d chars", arg);
@@ -1273,7 +1279,7 @@ _handle_esc_csi_dsr(Termpty *ty, Eina_Unicode *b)
1273 arg = _csi_arg_get(ty, &b); 1279 arg = _csi_arg_get(ty, &b);
1274 switch (arg) 1280 switch (arg)
1275 { 1281 {
1276 case -CSI_ARG_ERROR: 1282 case -ESC_ARG_ERROR:
1277 return; 1283 return;
1278 case 5: 1284 case 5:
1279 if (question_mark) 1285 if (question_mark)
@@ -1382,7 +1388,7 @@ _handle_esc_csi_dsr(Termpty *ty, Eina_Unicode *b)
1382 { 1388 {
1383 /* DSR-DECCKSR (Memory Checksum) */ 1389 /* DSR-DECCKSR (Memory Checksum) */
1384 int pid = _csi_arg_get(ty, &b); 1390 int pid = _csi_arg_get(ty, &b);
1385 if (pid == -CSI_ARG_NO_VALUE) 1391 if (pid == -ESC_ARG_NO_VALUE)
1386 pid = 65535; 1392 pid = 65535;
1387 len = snprintf(bf, sizeof(bf), "\033P%u!~0000\033\\", 1393 len = snprintf(bf, sizeof(bf), "\033P%u!~0000\033\\",
1388 ((unsigned int)pid) % 65536); 1394 ((unsigned int)pid) % 65536);
@@ -1408,7 +1414,7 @@ _handle_esc_csi_dsr(Termpty *ty, Eina_Unicode *b)
1408 ty->decoding_error = EINA_TRUE; 1414 ty->decoding_error = EINA_TRUE;
1409 } 1415 }
1410 break; 1416 break;
1411 /* TODO: -CSI_ARG_NO_VALUE */ 1417 /* TODO: -ESC_ARG_NO_VALUE */
1412 default: 1418 default:
1413 WRN("unhandled DSR (dec specific: %s) %d", 1419 WRN("unhandled DSR (dec specific: %s) %d",
1414 (question_mark)? "yes": "no", arg); 1420 (question_mark)? "yes": "no", arg);
@@ -1424,7 +1430,7 @@ _handle_esc_csi_decslrm(Termpty *ty, Eina_Unicode **b)
1424 int right = _csi_arg_get(ty, b); 1430 int right = _csi_arg_get(ty, b);
1425 1431
1426 DBG("DECSLRM (%d;%d) Set Left and Right Margins", left, right); 1432 DBG("DECSLRM (%d;%d) Set Left and Right Margins", left, right);
1427 if ((left == -CSI_ARG_ERROR) || (right == -CSI_ARG_ERROR)) 1433 if ((left == -ESC_ARG_ERROR) || (right == -ESC_ARG_ERROR))
1428 goto bad; 1434 goto bad;
1429 1435
1430 TERMPTY_RESTRICT_FIELD(left, 1, ty->w); 1436 TERMPTY_RESTRICT_FIELD(left, 1, ty->w);
@@ -1458,7 +1464,7 @@ _handle_esc_csi_decstbm(Termpty *ty, Eina_Unicode **b)
1458 int bottom = _csi_arg_get(ty, b); 1464 int bottom = _csi_arg_get(ty, b);
1459 1465
1460 DBG("DECSTBM (%d;%d) Set Top and Bottom Margins", top, bottom); 1466 DBG("DECSTBM (%d;%d) Set Top and Bottom Margins", top, bottom);
1461 if ((top == -CSI_ARG_ERROR) || (bottom == -CSI_ARG_ERROR)) 1467 if ((top == -ESC_ARG_ERROR) || (bottom == -ESC_ARG_ERROR))
1462 goto bad; 1468 goto bad;
1463 1469
1464 TERMPTY_RESTRICT_FIELD(top, 1, ty->h); 1470 TERMPTY_RESTRICT_FIELD(top, 1, ty->h);
@@ -1631,12 +1637,12 @@ _handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
1631 1637
1632 DBG("DECFRA (%d; %d;%d;%d;%d) Fill Rectangular Area", 1638 DBG("DECFRA (%d; %d;%d;%d;%d) Fill Rectangular Area",
1633 c, top, left, bottom, right); 1639 c, top, left, bottom, right);
1634 if ((c == -CSI_ARG_ERROR) || 1640 if ((c == -ESC_ARG_ERROR) ||
1635 (c == -CSI_ARG_NO_VALUE) || 1641 (c == -ESC_ARG_NO_VALUE) ||
1636 (top == -CSI_ARG_ERROR) || 1642 (top == -ESC_ARG_ERROR) ||
1637 (left == -CSI_ARG_ERROR) || 1643 (left == -ESC_ARG_ERROR) ||
1638 (bottom == -CSI_ARG_ERROR) || 1644 (bottom == -ESC_ARG_ERROR) ||
1639 (right == -CSI_ARG_ERROR)) 1645 (right == -ESC_ARG_ERROR))
1640 return; 1646 return;
1641 1647
1642 if (! ((c >= 32 && c <= 126) || (c >= 160 && c <= 255))) 1648 if (! ((c >= 32 && c <= 126) || (c >= 160 && c <= 255)))
@@ -1708,10 +1714,10 @@ _handle_esc_csi_deccara(Termpty *ty, Eina_Unicode **ptr,
1708 1714
1709 DBG("DECCARA (%d;%d;%d;%d) Change Attributes in Rectangular Area", 1715 DBG("DECCARA (%d;%d;%d;%d) Change Attributes in Rectangular Area",
1710 top, left, bottom, right); 1716 top, left, bottom, right);
1711 if ((top == -CSI_ARG_ERROR) || 1717 if ((top == -ESC_ARG_ERROR) ||
1712 (left == -CSI_ARG_ERROR) || 1718 (left == -ESC_ARG_ERROR) ||
1713 (bottom == -CSI_ARG_ERROR) || 1719 (bottom == -ESC_ARG_ERROR) ||
1714 (right == -CSI_ARG_ERROR)) 1720 (right == -ESC_ARG_ERROR))
1715 return; 1721 return;
1716 1722
1717 while (b && b < end) 1723 while (b && b < end)
@@ -1719,9 +1725,9 @@ _handle_esc_csi_deccara(Termpty *ty, Eina_Unicode **ptr,
1719 int arg = _csi_arg_get(ty, &b); 1725 int arg = _csi_arg_get(ty, &b);
1720 switch (arg) 1726 switch (arg)
1721 { 1727 {
1722 case -CSI_ARG_ERROR: 1728 case -ESC_ARG_ERROR:
1723 return; 1729 return;
1724 case -CSI_ARG_NO_VALUE: 1730 case -ESC_ARG_NO_VALUE:
1725 EINA_FALLTHROUGH; 1731 EINA_FALLTHROUGH;
1726 case 0: 1732 case 0:
1727 set_bold = set_underline = set_blink = set_inverse = EINA_FALSE; 1733 set_bold = set_underline = set_blink = set_inverse = EINA_FALSE;
@@ -1876,10 +1882,10 @@ _handle_esc_csi_decrara(Termpty *ty, Eina_Unicode **ptr,
1876 1882
1877 DBG("DECRARA (%d;%d;%d;%d) Reverse Attributes in Rectangular Area", 1883 DBG("DECRARA (%d;%d;%d;%d) Reverse Attributes in Rectangular Area",
1878 top, left, bottom, right); 1884 top, left, bottom, right);
1879 if ((top == -CSI_ARG_ERROR) || 1885 if ((top == -ESC_ARG_ERROR) ||
1880 (left == -CSI_ARG_ERROR) || 1886 (left == -ESC_ARG_ERROR) ||
1881 (bottom == -CSI_ARG_ERROR) || 1887 (bottom == -ESC_ARG_ERROR) ||
1882 (right == -CSI_ARG_ERROR)) 1888 (right == -ESC_ARG_ERROR))
1883 return; 1889 return;
1884 1890
1885 while (b && b < end) 1891 while (b && b < end)
@@ -1887,9 +1893,9 @@ _handle_esc_csi_decrara(Termpty *ty, Eina_Unicode **ptr,
1887 int arg = _csi_arg_get(ty, &b); 1893 int arg = _csi_arg_get(ty, &b);
1888 switch (arg) 1894 switch (arg)
1889 { 1895 {
1890 case -CSI_ARG_ERROR: 1896 case -ESC_ARG_ERROR:
1891 return; 1897 return;
1892 case -CSI_ARG_NO_VALUE: 1898 case -ESC_ARG_NO_VALUE:
1893 EINA_FALLTHROUGH; 1899 EINA_FALLTHROUGH;
1894 case 0: 1900 case 0:
1895 reverse_bold = reverse_underline = reverse_blink = reverse_inverse = EINA_TRUE; 1901 reverse_bold = reverse_underline = reverse_blink = reverse_inverse = EINA_TRUE;
@@ -1980,10 +1986,10 @@ _handle_esc_csi_decera(Termpty *ty, Eina_Unicode **b)
1980 DBG("DECERA (%d;%d;%d;%d) Erase Rectangular Area", 1986 DBG("DECERA (%d;%d;%d;%d) Erase Rectangular Area",
1981 top, left, bottom, right); 1987 top, left, bottom, right);
1982 1988
1983 if ((top == -CSI_ARG_ERROR) || 1989 if ((top == -ESC_ARG_ERROR) ||
1984 (left == -CSI_ARG_ERROR) || 1990 (left == -ESC_ARG_ERROR) ||
1985 (bottom == -CSI_ARG_ERROR) || 1991 (bottom == -ESC_ARG_ERROR) ||
1986 (right == -CSI_ARG_ERROR)) 1992 (right == -ESC_ARG_ERROR))
1987 return; 1993 return;
1988 1994
1989 if (_clean_up_rect_coordinates(ty, &top, &left, &bottom, &right) < 0) 1995 if (_clean_up_rect_coordinates(ty, &top, &left, &bottom, &right) < 0)
@@ -2014,14 +2020,14 @@ _handle_esc_csi_deccra(Termpty *ty, Eina_Unicode **b)
2014 2020
2015 DBG("DECFRA (%d;%d;%d;%d -> %d;%d) Copy Rectangular Area", 2021 DBG("DECFRA (%d;%d;%d;%d -> %d;%d) Copy Rectangular Area",
2016 top, left, bottom, right, to_top, to_left); 2022 top, left, bottom, right, to_top, to_left);
2017 if ((top == -CSI_ARG_ERROR) || 2023 if ((top == -ESC_ARG_ERROR) ||
2018 (left == -CSI_ARG_ERROR) || 2024 (left == -ESC_ARG_ERROR) ||
2019 (bottom == -CSI_ARG_ERROR) || 2025 (bottom == -ESC_ARG_ERROR) ||
2020 (right == -CSI_ARG_ERROR) || 2026 (right == -ESC_ARG_ERROR) ||
2021 (p1 == -CSI_ARG_ERROR) || 2027 (p1 == -ESC_ARG_ERROR) ||
2022 (to_top == -CSI_ARG_ERROR) || 2028 (to_top == -ESC_ARG_ERROR) ||
2023 (to_left == -CSI_ARG_ERROR) || 2029 (to_left == -ESC_ARG_ERROR) ||
2024 (p2 == -CSI_ARG_ERROR)) 2030 (p2 == -ESC_ARG_ERROR))
2025 return; 2031 return;
2026 2032
2027 if (_clean_up_rect_coordinates(ty, &top, &left, &bottom, &right) < 0) 2033 if (_clean_up_rect_coordinates(ty, &top, &left, &bottom, &right) < 0)
@@ -2131,7 +2137,7 @@ _handle_esc_csi_cursor_pos_set(Termpty *ty, Eina_Unicode **b,
2131 cy = _csi_arg_get(ty, b); 2137 cy = _csi_arg_get(ty, b);
2132 cx = _csi_arg_get(ty, b); 2138 cx = _csi_arg_get(ty, b);
2133 2139
2134 if ((cx == -CSI_ARG_ERROR) || (cy == -CSI_ARG_ERROR)) 2140 if ((cx == -ESC_ARG_ERROR) || (cy == -ESC_ARG_ERROR))
2135 return; 2141 return;
2136 2142
2137 DBG("cursor pos set (%s) (%d;%d)", (*cc == 'H') ? "CUP" : "HVP", 2143 DBG("cursor pos set (%s) (%d;%d)", (*cc == 'H') ? "CUP" : "HVP",
@@ -2174,9 +2180,9 @@ _handle_esc_csi_decscusr(Termpty *ty, Eina_Unicode **b)
2174 2180
2175 switch (arg) 2181 switch (arg)
2176 { 2182 {
2177 case -CSI_ARG_ERROR: 2183 case -ESC_ARG_ERROR:
2178 return; 2184 return;
2179 case -CSI_ARG_NO_VALUE: 2185 case -ESC_ARG_NO_VALUE:
2180 EINA_FALLTHROUGH; 2186 EINA_FALLTHROUGH;
2181 case 0: 2187 case 0:
2182 EINA_FALLTHROUGH; 2188 EINA_FALLTHROUGH;
@@ -2213,9 +2219,9 @@ _handle_esc_csi_decsace(Termpty *ty, Eina_Unicode **b)
2213 2219
2214 switch (arg) 2220 switch (arg)
2215 { 2221 {
2216 case -CSI_ARG_ERROR: 2222 case -ESC_ARG_ERROR:
2217 return; 2223 return;
2218 case -CSI_ARG_NO_VALUE: 2224 case -ESC_ARG_NO_VALUE:
2219 EINA_FALLTHROUGH; 2225 EINA_FALLTHROUGH;
2220 case 0: 2226 case 0:
2221 EINA_FALLTHROUGH; 2227 EINA_FALLTHROUGH;
@@ -2245,7 +2251,7 @@ _handle_esc_csi_decic(Termpty *ty, Eina_Unicode **b)
2245 2251
2246 DBG("DECIC Insert %d Column", arg); 2252 DBG("DECIC Insert %d Column", arg);
2247 2253
2248 if (arg == -CSI_ARG_ERROR) 2254 if (arg == -ESC_ARG_ERROR)
2249 return; 2255 return;
2250 if (arg < 1) 2256 if (arg < 1)
2251 arg = 1; 2257 arg = 1;
@@ -2296,7 +2302,7 @@ _handle_esc_csi_decdc(Termpty *ty, Eina_Unicode **b)
2296 2302
2297 DBG("DECDC Delete %d Column", arg); 2303 DBG("DECDC Delete %d Column", arg);
2298 2304
2299 if (arg == -CSI_ARG_ERROR) 2305 if (arg == -ESC_ARG_ERROR)
2300 return; 2306 return;
2301 if (arg < 1) 2307 if (arg < 1)
2302 arg = 1; 2308 arg = 1;
@@ -2359,7 +2365,7 @@ _handle_esc_csi_ich(Termpty *ty, Eina_Unicode **ptr)
2359 int old_cx = ty->cursor_state.cx; 2365 int old_cx = ty->cursor_state.cx;
2360 int max = ty->w; 2366 int max = ty->w;
2361 2367
2362 if (arg == -CSI_ARG_ERROR) 2368 if (arg == -ESC_ARG_ERROR)
2363 return; 2369 return;
2364 TERMPTY_RESTRICT_FIELD(arg, 1, ty->w * ty->h); 2370 TERMPTY_RESTRICT_FIELD(arg, 1, ty->w * ty->h);
2365 2371
@@ -2401,7 +2407,7 @@ _handle_esc_csi_cuu(Termpty *ty, Eina_Unicode **ptr)
2401 Eina_Unicode *b = *ptr; 2407 Eina_Unicode *b = *ptr;
2402 int arg = _csi_arg_get(ty, &b); 2408 int arg = _csi_arg_get(ty, &b);
2403 2409
2404 if (arg == -CSI_ARG_ERROR) 2410 if (arg == -ESC_ARG_ERROR)
2405 return; 2411 return;
2406 if (arg < 1) 2412 if (arg < 1)
2407 arg = 1; 2413 arg = 1;
@@ -2423,7 +2429,7 @@ _handle_esc_csi_cud_or_vpr(Termpty *ty, Eina_Unicode **ptr,
2423 Eina_Unicode *b = *ptr; 2429 Eina_Unicode *b = *ptr;
2424 int arg = _csi_arg_get(ty, &b); 2430 int arg = _csi_arg_get(ty, &b);
2425 2431
2426 if (arg == -CSI_ARG_ERROR) 2432 if (arg == -ESC_ARG_ERROR)
2427 return; 2433 return;
2428 2434
2429 if (arg < 1) 2435 if (arg < 1)
@@ -2454,7 +2460,7 @@ _handle_esc_csi_cuf(Termpty *ty, Eina_Unicode **ptr)
2454 Eina_Unicode *b = *ptr; 2460 Eina_Unicode *b = *ptr;
2455 int arg = _csi_arg_get(ty, &b); 2461 int arg = _csi_arg_get(ty, &b);
2456 2462
2457 if (arg == -CSI_ARG_ERROR) 2463 if (arg == -ESC_ARG_ERROR)
2458 return; 2464 return;
2459 if (arg < 1) 2465 if (arg < 1)
2460 arg = 1; 2466 arg = 1;
@@ -2475,7 +2481,7 @@ _handle_esc_csi_cub(Termpty *ty, Eina_Unicode **ptr)
2475 Eina_Unicode *b = *ptr; 2481 Eina_Unicode *b = *ptr;
2476 int arg = _csi_arg_get(ty, &b); 2482 int arg = _csi_arg_get(ty, &b);
2477 2483
2478 if (arg == -CSI_ARG_ERROR) 2484 if (arg == -ESC_ARG_ERROR)
2479 return; 2485 return;
2480 if (arg < 1) 2486 if (arg < 1)
2481 arg = 1; 2487 arg = 1;
@@ -2507,7 +2513,7 @@ _handle_esc_csi_cha(Termpty *ty, Eina_Unicode **ptr,
2507 { 2513 {
2508 DBG("CHA - Cursor Horizontal Absolute: %d", arg); 2514 DBG("CHA - Cursor Horizontal Absolute: %d", arg);
2509 } 2515 }
2510 if (arg == -CSI_ARG_ERROR) 2516 if (arg == -ESC_ARG_ERROR)
2511 return; 2517 return;
2512 if (arg < 1) 2518 if (arg < 1)
2513 arg = 1; 2519 arg = 1;
@@ -2533,7 +2539,7 @@ _handle_esc_csi_cht(Termpty *ty, Eina_Unicode **ptr)
2533 Eina_Unicode *b = *ptr; 2539 Eina_Unicode *b = *ptr;
2534 int arg = _csi_arg_get(ty, &b); 2540 int arg = _csi_arg_get(ty, &b);
2535 2541
2536 if (arg == -CSI_ARG_ERROR) 2542 if (arg == -ESC_ARG_ERROR)
2537 return; 2543 return;
2538 TERMPTY_RESTRICT_FIELD(arg, 1, ty->w); 2544 TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);
2539 DBG("CHT - Cursor Forward Tabulation: %d", arg); 2545 DBG("CHT - Cursor Forward Tabulation: %d", arg);
@@ -2546,7 +2552,7 @@ _handle_esc_csi_ed(Termpty *ty, Eina_Unicode **ptr)
2546 Eina_Unicode *b = *ptr; 2552 Eina_Unicode *b = *ptr;
2547 int arg = _csi_arg_get(ty, &b); 2553 int arg = _csi_arg_get(ty, &b);
2548 2554
2549 if (arg == -CSI_ARG_ERROR) 2555 if (arg == -ESC_ARG_ERROR)
2550 return; 2556 return;
2551 if (arg < 1) 2557 if (arg < 1)
2552 arg = 0; 2558 arg = 0;
@@ -2586,7 +2592,7 @@ _handle_esc_csi_el(Termpty *ty, Eina_Unicode **ptr)
2586 Eina_Unicode *b = *ptr; 2592 Eina_Unicode *b = *ptr;
2587 int arg = _csi_arg_get(ty, &b); 2593 int arg = _csi_arg_get(ty, &b);
2588 2594
2589 if (arg == -CSI_ARG_ERROR) 2595 if (arg == -ESC_ARG_ERROR)
2590 return; 2596 return;
2591 if (arg < 1) 2597 if (arg < 1)
2592 arg = 0; 2598 arg = 0;
@@ -2618,7 +2624,7 @@ _handle_esc_csi_il(Termpty *ty, Eina_Unicode **ptr)
2618 int arg = _csi_arg_get(ty, &b); 2624 int arg = _csi_arg_get(ty, &b);
2619 int sy1, sy2, i; 2625 int sy1, sy2, i;
2620 2626
2621 if (arg == -CSI_ARG_ERROR) 2627 if (arg == -ESC_ARG_ERROR)
2622 return; 2628 return;
2623 2629
2624 TERMPTY_RESTRICT_FIELD(arg, 1, ty->h); 2630 TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
@@ -2656,7 +2662,7 @@ _handle_esc_csi_dl(Termpty *ty, Eina_Unicode **ptr)
2656 int arg = _csi_arg_get(ty, &b); 2662 int arg = _csi_arg_get(ty, &b);
2657 int sy1, sy2, i; 2663 int sy1, sy2, i;
2658 2664
2659 if (arg == -CSI_ARG_ERROR) 2665 if (arg == -ESC_ARG_ERROR)
2660 return; 2666 return;
2661 2667
2662 TERMPTY_RESTRICT_FIELD(arg, 1, ty->h); 2668 TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
@@ -2694,7 +2700,7 @@ _handle_esc_csi_su(Termpty *ty, Eina_Unicode **ptr)
2694 int arg = _csi_arg_get(ty, &b); 2700 int arg = _csi_arg_get(ty, &b);
2695 int i; 2701 int i;
2696 2702
2697 if (arg == -CSI_ARG_ERROR) 2703 if (arg == -ESC_ARG_ERROR)
2698 return; 2704 return;
2699 2705
2700 TERMPTY_RESTRICT_FIELD(arg, 1, ty->h); 2706 TERMPTY_RESTRICT_FIELD(arg, 1, ty->h);
@@ -2710,7 +2716,7 @@ _handle_esc_csi_sd(Termpty *ty, Eina_Unicode **ptr)
2710 int arg = _csi_arg_get(ty, &b); 2716 int arg = _csi_arg_get(ty, &b);
2711 int i; 2717 int i;
2712 2718
2713 if (arg == -CSI_ARG_ERROR) 2719 if (arg == -ESC_ARG_ERROR)
2714 return; 2720 return;
2715 if (arg == 0) 2721 if (arg == 0)
2716 { 2722 {
@@ -2746,9 +2752,9 @@ _handle_esc_csi_decst8c(Termpty *ty, Eina_Unicode **ptr)
2746 int arg = _csi_arg_get(ty, &b); 2752 int arg = _csi_arg_get(ty, &b);
2747 int i; 2753 int i;
2748 2754
2749 if (arg == -CSI_ARG_ERROR) 2755 if (arg == -ESC_ARG_ERROR)
2750 return; 2756 return;
2751 if ((arg != -CSI_ARG_NO_VALUE) && (arg != 5)) 2757 if ((arg != -ESC_ARG_NO_VALUE) && (arg != 5))
2752 { 2758 {
2753 ERR("Invalid DECST8C argument"); 2759 ERR("Invalid DECST8C argument");
2754 ty->decoding_error = EINA_TRUE; 2760 ty->decoding_error = EINA_TRUE;
@@ -2769,13 +2775,13 @@ _handle_esc_csi_ctc(Termpty *ty, Eina_Unicode **ptr)
2769 Eina_Unicode *b = *ptr; 2775 Eina_Unicode *b = *ptr;
2770 int arg = _csi_arg_get(ty, &b); 2776 int arg = _csi_arg_get(ty, &b);
2771 2777
2772 if (arg == -CSI_ARG_ERROR) 2778 if (arg == -ESC_ARG_ERROR)
2773 return; 2779 return;
2774 2780
2775 DBG("CTC - Cursor Tab Control: %d", arg); 2781 DBG("CTC - Cursor Tab Control: %d", arg);
2776 switch (arg) 2782 switch (arg)
2777 { 2783 {
2778 case -CSI_ARG_NO_VALUE: 2784 case -ESC_ARG_NO_VALUE:
2779 EINA_FALLTHROUGH; 2785 EINA_FALLTHROUGH;
2780 case 0: 2786 case 0:
2781 TAB_SET(ty, ty->cursor_state.cx); 2787 TAB_SET(ty, ty->cursor_state.cx);
@@ -2800,12 +2806,12 @@ _handle_esc_csi_tbc(Termpty *ty, Eina_Unicode **ptr)
2800 Eina_Unicode *b = *ptr; 2806 Eina_Unicode *b = *ptr;
2801 int arg = _csi_arg_get(ty, &b); 2807 int arg = _csi_arg_get(ty, &b);
2802 2808
2803 if (arg == -CSI_ARG_ERROR) 2809 if (arg == -ESC_ARG_ERROR)
2804 return; 2810 return;
2805 DBG("TBC - Tab Clear: %d", arg); 2811 DBG("TBC - Tab Clear: %d", arg);
2806 switch (arg) 2812 switch (arg)
2807 { 2813 {
2808 case -CSI_ARG_NO_VALUE: 2814 case -ESC_ARG_NO_VALUE:
2809 EINA_FALLTHROUGH; 2815 EINA_FALLTHROUGH;
2810 case 0: 2816 case 0:
2811 TAB_UNSET(ty, ty->cursor_state.cx); 2817 TAB_UNSET(ty, ty->cursor_state.cx);
@@ -2829,7 +2835,7 @@ _handle_esc_csi_ech(Termpty *ty, Eina_Unicode **ptr)
2829 Eina_Unicode *b = *ptr; 2835 Eina_Unicode *b = *ptr;
2830 int arg = _csi_arg_get(ty, &b); 2836 int arg = _csi_arg_get(ty, &b);
2831 2837
2832 if (arg == -CSI_ARG_ERROR) 2838 if (arg == -ESC_ARG_ERROR)
2833 return; 2839 return;
2834 DBG("ECH - Erase Character: %d", arg); 2840 DBG("ECH - Erase Character: %d", arg);
2835 TERMPTY_RESTRICT_FIELD(arg, 1, ty->w); 2841 TERMPTY_RESTRICT_FIELD(arg, 1, ty->w);
@@ -2843,7 +2849,7 @@ _handle_esc_csi_cbt(Termpty *ty, Eina_Unicode **ptr)
2843 int cx = ty->cursor_state.cx; 2849 int cx = ty->cursor_state.cx;
2844 int arg = _csi_arg_get(ty, &b); 2850 int arg = _csi_arg_get(ty, &b);
2845 2851
2846 if (arg == -CSI_ARG_ERROR) 2852 if (arg == -ESC_ARG_ERROR)
2847 return; 2853 return;
2848 DBG("CBT - Cursor Horizontal Backward Tabulation: %d", arg); 2854 DBG("CBT - Cursor Horizontal Backward Tabulation: %d", arg);
2849 2855
@@ -2867,7 +2873,7 @@ _handle_esc_csi_rep(Termpty *ty, Eina_Unicode **ptr)
2867 Eina_Unicode *b = *ptr; 2873 Eina_Unicode *b = *ptr;
2868 int arg = _csi_arg_get(ty, &b); 2874 int arg = _csi_arg_get(ty, &b);
2869 2875
2870 if (arg == -CSI_ARG_ERROR) 2876 if (arg == -ESC_ARG_ERROR)
2871 return; 2877 return;
2872 DBG("REP - Repeat last character %d times", arg); 2878 DBG("REP - Repeat last character %d times", arg);
2873 2879
@@ -2909,7 +2915,7 @@ _handle_esc_csi_da(Termpty *ty, Eina_Unicode **ptr)
2909 } 2915 }
2910 arg = _csi_arg_get(ty, &b); 2916 arg = _csi_arg_get(ty, &b);
2911 2917
2912 if ((arg == -CSI_ARG_ERROR) || (arg > 0)) 2918 if ((arg == -ESC_ARG_ERROR) || (arg > 0))
2913 return; 2919 return;
2914 2920
2915 DBG("DA - Device Attributes"); 2921 DBG("DA - Device Attributes");
@@ -2971,7 +2977,7 @@ _handle_esc_csi_uts(Termpty *ty, Eina_Unicode **ptr)
2971 Eina_Unicode *b = *ptr; 2977 Eina_Unicode *b = *ptr;
2972 int arg = _csi_arg_get(ty, &b); 2978 int arg = _csi_arg_get(ty, &b);
2973 2979
2974 if (arg == -CSI_ARG_ERROR) 2980 if (arg == -ESC_ARG_ERROR)
2975 return; 2981 return;
2976 DBG("UTS - Unset Tab Stop: %d", arg); 2982 DBG("UTS - Unset Tab Stop: %d", arg);
2977 TERMPTY_RESTRICT_FIELD(arg, 0, ty->w); 2983 TERMPTY_RESTRICT_FIELD(arg, 0, ty->w);
@@ -2985,7 +2991,7 @@ _handle_esc_csi_vpa(Termpty *ty, Eina_Unicode **ptr)
2985 int arg = _csi_arg_get(ty, &b); 2991 int arg = _csi_arg_get(ty, &b);
2986 int max = ty->h + 1; 2992 int max = ty->h + 1;
2987 2993
2988 if (arg == -CSI_ARG_ERROR) 2994 if (arg == -ESC_ARG_ERROR)
2989 return; 2995 return;
2990 DBG("VPA - Cursor Vertical Position Absolute: %d", arg); 2996 DBG("VPA - Cursor Vertical Position Absolute: %d", arg);
2991 if (ty->termstate.restrict_cursor && (ty->termstate.bottom_margin > 0)) 2997 if (ty->termstate.restrict_cursor && (ty->termstate.bottom_margin > 0))
@@ -3003,7 +3009,7 @@ _handle_esc_csi_decswbv(Termpty *ty, Eina_Unicode **ptr)
3003 Eina_Unicode *b = *ptr; 3009 Eina_Unicode *b = *ptr;
3004 int arg = _csi_arg_get(ty, &b); 3010 int arg = _csi_arg_get(ty, &b);
3005 3011
3006 if (arg == -CSI_ARG_ERROR) 3012 if (arg == -ESC_ARG_ERROR)
3007 return; 3013 return;
3008 DBG("DECSWBV - Set Warning Bell Volume: %d", arg); 3014 DBG("DECSWBV - Set Warning Bell Volume: %d", arg);
3009 switch (arg) 3015 switch (arg)
@@ -3032,13 +3038,13 @@ _handle_resize_by_chars(Termpty *ty, Eina_Unicode **ptr)
3032 h = _csi_arg_get(ty, &b); 3038 h = _csi_arg_get(ty, &b);
3033 w = _csi_arg_get(ty, &b); 3039 w = _csi_arg_get(ty, &b);
3034 3040
3035 if ((w == -CSI_ARG_ERROR) || (h == -CSI_ARG_ERROR)) 3041 if ((w == -ESC_ARG_ERROR) || (h == -ESC_ARG_ERROR))
3036 return; 3042 return;
3037 if (w == -CSI_ARG_NO_VALUE) 3043 if (w == -ESC_ARG_NO_VALUE)
3038 { 3044 {
3039 w = ty->w; 3045 w = ty->w;
3040 } 3046 }
3041 if (h == -CSI_ARG_NO_VALUE) 3047 if (h == -ESC_ARG_NO_VALUE)
3042 { 3048 {
3043 h = ty->h; 3049 h = ty->h;
3044 } 3050 }
@@ -3069,13 +3075,107 @@ _handle_resize_by_chars(Termpty *ty, Eina_Unicode **ptr)
3069#endif 3075#endif
3070} 3076}
3071 3077
3078struct _TitleIconElem {
3079 const char *title;
3080 const char *icon;
3081 struct _TitleIconElem *next;
3082};
3083
3084static void
3085_title_icon_stack_push(Termpty *ty, Eina_Unicode **p)
3086{
3087 int arg = _csi_arg_get(ty, p);
3088 TitleIconElem *elem = calloc(sizeof(*elem), 1);
3089
3090 if (!elem)
3091 return;
3092
3093
3094 switch (arg)
3095 {
3096 case -ESC_ARG_ERROR:
3097 free(elem);
3098 return;
3099 case -ESC_ARG_NO_VALUE:
3100 EINA_FALLTHROUGH;
3101 case 0:
3102 elem->title = eina_stringshare_ref(ty->prop.title);
3103 elem->icon = eina_stringshare_ref(ty->prop.icon);
3104 break;
3105 case 1:
3106 elem->icon = eina_stringshare_ref(ty->prop.icon);
3107 break;
3108 case 2:
3109 elem->title = eina_stringshare_ref(ty->prop.title);
3110 break;
3111 default:
3112 break;
3113 }
3114 if (!elem->title)
3115 elem->title = ty->title_icon_stack ?
3116 eina_stringshare_ref(ty->title_icon_stack->title) :
3117 eina_stringshare_ref(ty->prop.title);
3118 if (!elem->icon)
3119 elem->icon = ty->title_icon_stack ?
3120 eina_stringshare_ref(ty->title_icon_stack->icon) :
3121 eina_stringshare_ref(ty->prop.icon);
3122 elem->next = ty->title_icon_stack;
3123 ty->title_icon_stack = elem;
3124}
3125
3126static void
3127_title_icon_stack_pop(Termpty *ty, Eina_Unicode **p)
3128{
3129 int arg = _csi_arg_get(ty, p);
3130 TitleIconElem *elem = ty->title_icon_stack;
3131
3132 if (!elem)
3133 return;
3134
3135 switch (arg)
3136 {
3137 case -ESC_ARG_ERROR:
3138 return;
3139 case -ESC_ARG_NO_VALUE:
3140 EINA_FALLTHROUGH;
3141 case 0:
3142 eina_stringshare_del(ty->prop.icon);
3143 ty->prop.icon = eina_stringshare_ref(elem->icon);
3144 if (ty->cb.set_icon.func)
3145 ty->cb.set_icon.func(ty->cb.set_icon.data);
3146 eina_stringshare_del(ty->prop.title);
3147 ty->prop.title = eina_stringshare_ref(elem->title);
3148 if (ty->cb.set_title.func)
3149 ty->cb.set_title.func(ty->cb.set_title.data);
3150 break;
3151 case 1:
3152 eina_stringshare_del(ty->prop.icon);
3153 ty->prop.icon = eina_stringshare_ref(elem->icon);
3154 if (ty->cb.set_icon.func)
3155 ty->cb.set_icon.func(ty->cb.set_icon.data);
3156 break;
3157 case 2:
3158 eina_stringshare_del(ty->prop.title);
3159 ty->prop.title = eina_stringshare_ref(elem->title);
3160 if (ty->cb.set_title.func)
3161 ty->cb.set_title.func(ty->cb.set_title.data);
3162 break;
3163 default:
3164 break;
3165 }
3166 eina_stringshare_del(elem->icon);
3167 eina_stringshare_del(elem->title);
3168 ty->title_icon_stack = elem->next;
3169 free(elem);
3170}
3171
3072static void 3172static void
3073_handle_window_manipulation(Termpty *ty, Eina_Unicode **ptr) 3173_handle_window_manipulation(Termpty *ty, Eina_Unicode **ptr)
3074{ 3174{
3075 Eina_Unicode *b = *ptr; 3175 Eina_Unicode *b = *ptr;
3076 int arg = _csi_arg_get(ty, &b); 3176 int arg = _csi_arg_get(ty, &b);
3077 3177
3078 if (arg == -CSI_ARG_ERROR) 3178 if (arg == -ESC_ARG_ERROR)
3079 return; 3179 return;
3080 DBG("Window manipulation: %d", arg); 3180 DBG("Window manipulation: %d", arg);
3081 switch (arg) 3181 switch (arg)
@@ -3083,6 +3183,12 @@ _handle_window_manipulation(Termpty *ty, Eina_Unicode **ptr)
3083 case 8: 3183 case 8:
3084 _handle_resize_by_chars(ty, &b); 3184 _handle_resize_by_chars(ty, &b);
3085 break; 3185 break;
3186 case 22:
3187 _title_icon_stack_push(ty, &b);
3188 break;
3189 case 23:
3190 _title_icon_stack_pop(ty, &b);
3191 break;
3086 default: 3192 default:
3087 // many others 3193 // many others
3088 WRN("unhandled window manipulation %d", arg); 3194 WRN("unhandled window manipulation %d", arg);
@@ -3381,22 +3487,44 @@ unhandled:
3381} 3487}
3382 3488
3383static int 3489static int
3384_osc_arg_get(Eina_Unicode **ptr) 3490_osc_arg_get(Termpty *ty, Eina_Unicode **ptr)
3385{ 3491{
3386 Eina_Unicode *b = *ptr; 3492 Eina_Unicode *b = *ptr;
3387 int sum = 0; 3493 int sum = 0;
3388 3494
3495 if ((b == NULL) || (*b == '\0'))
3496 {
3497 *ptr = NULL;
3498 sum = -ESC_ARG_NO_VALUE;
3499 goto error;
3500 }
3501
3389 while (*b >= '0' && *b <= '9') 3502 while (*b >= '0' && *b <= '9')
3390 { 3503 {
3391 sum *= 10; 3504 sum *= 10;
3392 sum += *b - '0'; 3505 sum += *b - '0';
3393 b++; 3506 b++;
3507 if (sum >= 65536)
3508 {
3509 sum = -ESC_ARG_ERROR;
3510 goto error;
3511 }
3394 } 3512 }
3395 if (*b != ';') 3513 if (*b != ';')
3396 sum = -1; 3514 {
3515 sum = -ESC_ARG_ERROR;
3516 goto error;
3517 }
3397 else 3518 else
3398 b++; 3519 b++;
3399 *ptr = b; 3520 *ptr = b;
3521
3522 return sum;
3523
3524error:
3525 ERR("Invalid OSC argument");
3526 ty->decoding_error = EINA_TRUE;
3527 *ptr = NULL;
3400 return sum; 3528 return sum;
3401} 3529}
3402 3530
@@ -3412,7 +3540,7 @@ _eina_unicode_to_hex(Eina_Unicode u)
3412 return -1; 3540 return -1;
3413} 3541}
3414 3542
3415#if defined(__OpenBSD__) 3543#if !defined(HAVE_STRCHRNUL)
3416char * 3544char *
3417strchrnul(const char *s, int c) 3545strchrnul(const char *s, int c)
3418{ 3546{
@@ -3722,18 +3850,20 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
3722 else 3850 else
3723 return 0; 3851 return 0;
3724 3852
3725 arg = _osc_arg_get(&p); 3853 arg = _osc_arg_get(ty, &p);
3726 switch (arg) 3854 switch (arg)
3727 { 3855 {
3728 case -1: 3856 case -ESC_ARG_ERROR:
3729 goto err; 3857 goto err;
3858 case -ESC_ARG_NO_VALUE:
3859 EINA_FALLTHROUGH;
3730 case 0: 3860 case 0:
3731 // title + icon name 3861 // title + icon name
3732 if (!*p) 3862 if (!*p)
3733 goto err; 3863 goto err;
3734 s = eina_unicode_unicode_to_utf8(p, &len); 3864 s = eina_unicode_unicode_to_utf8(p, &len);
3735 if (ty->prop.title) eina_stringshare_del(ty->prop.title); 3865 eina_stringshare_del(ty->prop.title);
3736 if (ty->prop.icon) eina_stringshare_del(ty->prop.icon); 3866 eina_stringshare_del(ty->prop.icon);
3737 if (s) 3867 if (s)
3738 { 3868 {
3739 ty->prop.title = eina_stringshare_add(s); 3869 ty->prop.title = eina_stringshare_add(s);
@@ -3747,14 +3877,15 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
3747 } 3877 }
3748 if (ty->cb.set_title.func) 3878 if (ty->cb.set_title.func)
3749 ty->cb.set_title.func(ty->cb.set_title.data); 3879 ty->cb.set_title.func(ty->cb.set_title.data);
3750 if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data); 3880 if (ty->cb.set_icon.func)
3881 ty->cb.set_icon.func(ty->cb.set_icon.data);
3751 break; 3882 break;
3752 case 1: 3883 case 1:
3753 // icon name 3884 // icon name
3754 if (!*p) 3885 if (!*p)
3755 goto err; 3886 goto err;
3756 s = eina_unicode_unicode_to_utf8(p, &len); 3887 s = eina_unicode_unicode_to_utf8(p, &len);
3757 if (ty->prop.icon) eina_stringshare_del(ty->prop.icon); 3888 eina_stringshare_del(ty->prop.icon);
3758 if (s) 3889 if (s)
3759 { 3890 {
3760 ty->prop.icon = eina_stringshare_add(s); 3891 ty->prop.icon = eina_stringshare_add(s);
@@ -3771,7 +3902,7 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
3771 if (!*p) 3902 if (!*p)
3772 goto err; 3903 goto err;
3773 s = eina_unicode_unicode_to_utf8(p, &len); 3904 s = eina_unicode_unicode_to_utf8(p, &len);
3774 if (ty->prop.title) eina_stringshare_del(ty->prop.title); 3905 eina_stringshare_del(ty->prop.title);
3775 if (s) 3906 if (s)
3776 { 3907 {
3777 ty->prop.title = eina_stringshare_add(s); 3908 ty->prop.title = eina_stringshare_add(s);