• Home
  • History
  • Annotate
  • Raw
  • Download

Lines Matching refs:state

20 static void putglyph(VTermState *state, const uint32_t chars[], int width, VTermPos pos)  in putglyph()  argument
25 .protected_cell = state->protected_cell, in putglyph()
28 if(state->callbacks && state->callbacks->putglyph) in putglyph()
29 if((*state->callbacks->putglyph)(&info, pos, state->cbdata)) in putglyph()
35 static void updatecursor(VTermState *state, VTermPos *oldpos, int cancel_phantom) in updatecursor() argument
37 if(state->pos.col == oldpos->col && state->pos.row == oldpos->row) in updatecursor()
41 state->at_phantom = 0; in updatecursor()
43 if(state->callbacks && state->callbacks->movecursor) in updatecursor()
44 …if((*state->callbacks->movecursor)(state->pos, *oldpos, state->mode.cursor_visible, state->cbdata)) in updatecursor()
48 static void erase(VTermState *state, VTermRect rect, int selective) in erase() argument
50 if(state->callbacks && state->callbacks->erase) in erase()
51 if((*state->callbacks->erase)(rect, selective, state->cbdata)) in erase()
57 VTermState *state = vterm_allocator_malloc(vt, sizeof(VTermState)); in vterm_state_new() local
59 state->vt = vt; in vterm_state_new()
61 state->rows = vt->rows; in vterm_state_new()
62 state->cols = vt->cols; in vterm_state_new()
65 state->default_fg.red = state->default_fg.green = state->default_fg.blue = 240; in vterm_state_new()
66 state->default_bg.red = state->default_bg.green = state->default_bg.blue = 0; in vterm_state_new()
68 state->bold_is_highbright = 0; in vterm_state_new()
70 return state; in vterm_state_new()
73 void vterm_state_free(VTermState *state) in vterm_state_free() argument
75 vterm_allocator_free(state->vt, state->tabstops); in vterm_state_free()
76 vterm_allocator_free(state->vt, state->combine_chars); in vterm_state_free()
77 vterm_allocator_free(state->vt, state); in vterm_state_free()
80 static void scroll(VTermState *state, VTermRect rect, int downward, int rightward) in scroll() argument
85 if(state->callbacks && state->callbacks->scrollrect) in scroll()
86 if((*state->callbacks->scrollrect)(rect, downward, rightward, state->cbdata)) in scroll()
89 if(state->callbacks) in scroll()
91 state->callbacks->moverect, state->callbacks->erase, state->cbdata); in scroll()
94 static void linefeed(VTermState *state) in linefeed() argument
96 if(state->pos.row == SCROLLREGION_BOTTOM(state) - 1) { in linefeed()
98 .start_row = state->scrollregion_top, in linefeed()
99 .end_row = SCROLLREGION_BOTTOM(state), in linefeed()
100 .start_col = SCROLLREGION_LEFT(state), in linefeed()
101 .end_col = SCROLLREGION_RIGHT(state), in linefeed()
104 scroll(state, rect, 1, 0); in linefeed()
106 else if(state->pos.row < state->rows-1) in linefeed()
107 state->pos.row++; in linefeed()
110 static void grow_combine_buffer(VTermState *state) in grow_combine_buffer() argument
112 size_t new_size = state->combine_chars_size * 2; in grow_combine_buffer()
113 uint32_t *new_chars = vterm_allocator_malloc(state->vt, new_size * sizeof(new_chars[0])); in grow_combine_buffer()
115 memcpy(new_chars, state->combine_chars, state->combine_chars_size * sizeof(new_chars[0])); in grow_combine_buffer()
117 vterm_allocator_free(state->vt, state->combine_chars); in grow_combine_buffer()
118 state->combine_chars = new_chars; in grow_combine_buffer()
121 static void set_col_tabstop(VTermState *state, int col) in set_col_tabstop() argument
124 state->tabstops[col >> 3] |= mask; in set_col_tabstop()
127 static void clear_col_tabstop(VTermState *state, int col) in clear_col_tabstop() argument
130 state->tabstops[col >> 3] &= ~mask; in clear_col_tabstop()
133 static int is_col_tabstop(VTermState *state, int col) in is_col_tabstop() argument
136 return state->tabstops[col >> 3] & mask; in is_col_tabstop()
139 static void tab(VTermState *state, int count, int direction) in tab() argument
142 while(state->pos.col >= 0 && state->pos.col < state->cols-1) { in tab()
143 state->pos.col += direction; in tab()
145 if(is_col_tabstop(state, state->pos.col)) in tab()
152 VTermState *state = user; in on_text() local
154 VTermPos oldpos = state->pos; in on_text()
162 state->gsingle_set ? &state->encoding[state->gsingle_set] : in on_text()
163 !(bytes[eaten] & 0x80) ? &state->encoding[state->gl_set] : in on_text()
164 state->vt->mode.utf8 ? &state->encoding_utf8 : in on_text()
165 &state->encoding[state->gr_set]; in on_text()
168 codepoints, &npoints, state->gsingle_set ? 1 : len, in on_text()
171 if(state->gsingle_set && npoints) in on_text()
172 state->gsingle_set = 0; in on_text()
180 …if(state->pos.row == state->combine_pos.row && state->pos.col == state->combine_pos.col + state->c… in on_text()
184 for(printpos = 0; state->combine_chars[printpos]; printpos++) in on_text()
185 printf("U+%04x ", state->combine_chars[printpos]); in on_text()
191 while(state->combine_chars[saved_i]) in on_text()
196 if(saved_i >= state->combine_chars_size) in on_text()
197 grow_combine_buffer(state); in on_text()
198 state->combine_chars[saved_i++] = codepoints[i++]; in on_text()
200 if(saved_i >= state->combine_chars_size) in on_text()
201 grow_combine_buffer(state); in on_text()
202 state->combine_chars[saved_i] = 0; in on_text()
205 for(; state->combine_chars[printpos]; printpos++) in on_text()
206 printf("U+%04x ", state->combine_chars[printpos]); in on_text()
211 putglyph(state, state->combine_chars, state->combine_width, state->combine_pos); in on_text()
246 if(state->at_phantom || state->pos.col + width > state->cols) { in on_text()
247 linefeed(state); in on_text()
248 state->pos.col = 0; in on_text()
249 state->at_phantom = 0; in on_text()
252 if(state->mode.insert) { in on_text()
258 .start_row = state->pos.row, in on_text()
259 .end_row = state->pos.row + 1, in on_text()
260 .start_col = state->pos.col, in on_text()
261 .end_col = state->cols, in on_text()
263 scroll(state, rect, 0, -1); in on_text()
265 putglyph(state, chars, width, state->pos); in on_text()
272 if(save_i >= state->combine_chars_size) in on_text()
273 grow_combine_buffer(state); in on_text()
274 state->combine_chars[save_i] = chars[save_i]; in on_text()
276 if(save_i >= state->combine_chars_size) in on_text()
277 grow_combine_buffer(state); in on_text()
278 state->combine_chars[save_i] = 0; in on_text()
279 state->combine_width = width; in on_text()
280 state->combine_pos = state->pos; in on_text()
283 if(state->pos.col + width >= state->cols) { in on_text()
284 if(state->mode.autowrap) in on_text()
285 state->at_phantom = 1; in on_text()
288 state->pos.col += width; in on_text()
292 updatecursor(state, &oldpos, 0); in on_text()
299 VTermState *state = user; in on_control() local
301 VTermPos oldpos = state->pos; in on_control()
305 if(state->callbacks && state->callbacks->bell) in on_control()
306 (*state->callbacks->bell)(state->cbdata); in on_control()
310 if(state->pos.col > 0) in on_control()
311 state->pos.col--; in on_control()
315 tab(state, 1, +1); in on_control()
321 linefeed(state); in on_control()
322 if(state->mode.newline) in on_control()
323 state->pos.col = 0; in on_control()
327 state->pos.col = 0; in on_control()
331 state->gl_set = 1; in on_control()
335 state->gl_set = 0; in on_control()
339 linefeed(state); in on_control()
343 linefeed(state); in on_control()
344 state->pos.col = 0; in on_control()
348 set_col_tabstop(state, state->pos.col); in on_control()
352 if(state->pos.row == state->scrollregion_top) { in on_control()
354 .start_row = state->scrollregion_top, in on_control()
355 .end_row = SCROLLREGION_BOTTOM(state), in on_control()
356 .start_col = SCROLLREGION_LEFT(state), in on_control()
357 .end_col = SCROLLREGION_RIGHT(state), in on_control()
360 scroll(state, rect, -1, 0); in on_control()
362 else if(state->pos.row > 0) in on_control()
363 state->pos.row--; in on_control()
367 state->gsingle_set = 2; in on_control()
371 state->gsingle_set = 3; in on_control()
378 updatecursor(state, &oldpos, 1); in on_control()
383 static void output_mouse(VTermState *state, int code, int pressed, int modifiers, int col, int row) in output_mouse() argument
387 switch(state->mouse_protocol) { in output_mouse()
397 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "M%c%c%c", in output_mouse()
412 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "M%s", utf8); in output_mouse()
417 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "<%d;%d;%d%c", in output_mouse()
425 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "%d;%d;%dM", in output_mouse()
433 VTermState *state = data; in mousefunc() local
435 int old_col = state->mouse_col; in mousefunc()
436 int old_row = state->mouse_row; in mousefunc()
437 int old_buttons = state->mouse_buttons; in mousefunc()
439 state->mouse_col = col; in mousefunc()
440 state->mouse_row = row; in mousefunc()
444 state->mouse_buttons |= (1 << (button-1)); in mousefunc()
446 state->mouse_buttons &= ~(1 << (button-1)); in mousefunc()
453 if(state->mouse_buttons != old_buttons || button >= 4) { in mousefunc()
455 output_mouse(state, button-1, pressed, modifiers, col, row); in mousefunc()
458 output_mouse(state, button-4 + 0x40, pressed, modifiers, col, row); in mousefunc()
462 if((state->mouse_flags & MOUSE_WANT_DRAG && state->mouse_buttons) || in mousefunc()
463 (state->mouse_flags & MOUSE_WANT_MOVE)) { in mousefunc()
464 int button = state->mouse_buttons & 0x01 ? 1 : in mousefunc()
465 state->mouse_buttons & 0x02 ? 2 : in mousefunc()
466 state->mouse_buttons & 0x04 ? 3 : 4; in mousefunc()
467 output_mouse(state, button-1 + 0x20, 1, modifiers, col, row); in mousefunc()
472 static int settermprop_bool(VTermState *state, VTermProp prop, int v) in settermprop_bool() argument
475 return vterm_state_set_termprop(state, prop, &val); in settermprop_bool()
478 static int settermprop_int(VTermState *state, VTermProp prop, int v) in settermprop_int() argument
481 return vterm_state_set_termprop(state, prop, &val); in settermprop_int()
484 static int settermprop_string(VTermState *state, VTermProp prop, const char *str, size_t len) in settermprop_string() argument
491 return vterm_state_set_termprop(state, prop, &val); in settermprop_string()
494 static void savecursor(VTermState *state, int save) in savecursor() argument
497 state->saved.pos = state->pos; in savecursor()
498 state->saved.mode.cursor_visible = state->mode.cursor_visible; in savecursor()
499 state->saved.mode.cursor_blink = state->mode.cursor_blink; in savecursor()
500 state->saved.mode.cursor_shape = state->mode.cursor_shape; in savecursor()
502 vterm_state_savepen(state, 1); in savecursor()
505 VTermPos oldpos = state->pos; in savecursor()
507 state->pos = state->saved.pos; in savecursor()
509 settermprop_bool(state, VTERM_PROP_CURSORVISIBLE, state->saved.mode.cursor_visible); in savecursor()
510 settermprop_bool(state, VTERM_PROP_CURSORBLINK, state->saved.mode.cursor_blink); in savecursor()
511 settermprop_int (state, VTERM_PROP_CURSORSHAPE, state->saved.mode.cursor_shape); in savecursor()
513 vterm_state_savepen(state, 0); in savecursor()
515 updatecursor(state, &oldpos, 1); in savecursor()
521 VTermState *state = user; in on_escape() local
533 state->vt->mode.ctrl8bit = 0; in on_escape()
537 state->vt->mode.ctrl8bit = 1; in on_escape()
554 for(pos.row = 0; pos.row < state->rows; pos.row++) in on_escape()
555 for(pos.col = 0; pos.col < state->cols; pos.col++) in on_escape()
556 putglyph(state, E, 1, pos); in on_escape()
574 state->encoding[setnum].enc = newenc; in on_escape()
577 (*newenc->init)(newenc, state->encoding[setnum].data); in on_escape()
584 savecursor(state, 1); in on_escape()
588 savecursor(state, 0); in on_escape()
595 state->mode.keypad = 1; in on_escape()
599 state->mode.keypad = 0; in on_escape()
604 VTermPos oldpos = state->pos; in on_escape()
605 vterm_state_reset(state, 1); in on_escape()
606 if(state->callbacks && state->callbacks->movecursor) in on_escape()
607 … (*state->callbacks->movecursor)(state->pos, oldpos, state->mode.cursor_visible, state->cbdata); in on_escape()
612 state->gl_set = 2; in on_escape()
616 state->gl_set = 3; in on_escape()
620 state->gr_set = 1; in on_escape()
624 state->gr_set = 2; in on_escape()
628 state->gr_set = 3; in on_escape()
636 static void set_mode(VTermState *state, int num, int val) in set_mode() argument
640 state->mode.insert = val; in set_mode()
644 state->mode.newline = val; in set_mode()
653 static void set_dec_mode(VTermState *state, int num, int val) in set_dec_mode() argument
657 state->mode.cursor = val; in set_dec_mode()
661 settermprop_bool(state, VTERM_PROP_REVERSE, val); in set_dec_mode()
666 VTermPos oldpos = state->pos; in set_dec_mode()
667 state->mode.origin = val; in set_dec_mode()
668 state->pos.row = state->mode.origin ? state->scrollregion_top : 0; in set_dec_mode()
669 state->pos.col = state->mode.origin ? SCROLLREGION_LEFT(state) : 0; in set_dec_mode()
670 updatecursor(state, &oldpos, 1); in set_dec_mode()
675 state->mode.autowrap = val; in set_dec_mode()
679 settermprop_bool(state, VTERM_PROP_CURSORBLINK, val); in set_dec_mode()
683 settermprop_bool(state, VTERM_PROP_CURSORVISIBLE, val); in set_dec_mode()
687 state->mode.leftrightmargin = val; in set_dec_mode()
694 state->mouse_col = 0; in set_dec_mode()
695 state->mouse_row = 0; in set_dec_mode()
696 state->mouse_buttons = 0; in set_dec_mode()
698 state->mouse_flags = MOUSE_WANT_CLICK; in set_dec_mode()
699 state->mouse_protocol = MOUSE_X10; in set_dec_mode()
702 state->mouse_flags |= MOUSE_WANT_DRAG; in set_dec_mode()
704 state->mouse_flags |= MOUSE_WANT_MOVE; in set_dec_mode()
707 state->mouse_flags = 0; in set_dec_mode()
710 if(state->callbacks && state->callbacks->setmousefunc) in set_dec_mode()
711 (*state->callbacks->setmousefunc)(val ? mousefunc : NULL, state, state->cbdata); in set_dec_mode()
716 state->mouse_protocol = val ? MOUSE_UTF8 : MOUSE_X10; in set_dec_mode()
720 state->mouse_protocol = val ? MOUSE_SGR : MOUSE_X10; in set_dec_mode()
724 state->mouse_protocol = val ? MOUSE_RXVT : MOUSE_X10; in set_dec_mode()
728 settermprop_bool(state, VTERM_PROP_ALTSCREEN, val); in set_dec_mode()
732 savecursor(state, val); in set_dec_mode()
736 settermprop_bool(state, VTERM_PROP_ALTSCREEN, val); in set_dec_mode()
737 savecursor(state, val); in set_dec_mode()
746 static void request_dec_mode(VTermState *state, int num) in request_dec_mode() argument
752 reply = state->mode.cursor; in request_dec_mode()
756 reply = state->mode.screen; in request_dec_mode()
760 reply = state->mode.origin; in request_dec_mode()
764 reply = state->mode.autowrap; in request_dec_mode()
768 reply = state->mode.cursor_blink; in request_dec_mode()
772 reply = state->mode.cursor_visible; in request_dec_mode()
776 reply = state->mode.leftrightmargin; in request_dec_mode()
780 reply = state->mouse_flags == MOUSE_WANT_CLICK; in request_dec_mode()
784 reply = state->mouse_flags == (MOUSE_WANT_CLICK|MOUSE_WANT_DRAG); in request_dec_mode()
788 reply = state->mouse_flags == (MOUSE_WANT_CLICK|MOUSE_WANT_MOVE); in request_dec_mode()
792 reply = state->mouse_protocol == MOUSE_UTF8; in request_dec_mode()
796 reply = state->mouse_protocol == MOUSE_SGR; in request_dec_mode()
800 reply = state->mouse_protocol == MOUSE_RXVT; in request_dec_mode()
804 reply = state->mode.alt_screen; in request_dec_mode()
808 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "?%d;%d$y", num, 0); in request_dec_mode()
812 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "?%d;%d$y", num, reply ? 1 : 2); in request_dec_mode()
817 VTermState *state = user; in on_csi() local
851 VTermPos oldpos = state->pos; in on_csi()
869 rect.start_row = state->pos.row; in on_csi()
870 rect.end_row = state->pos.row + 1; in on_csi()
871 rect.start_col = state->pos.col; in on_csi()
872 rect.end_col = state->cols; in on_csi()
874 scroll(state, rect, 0, -count); in on_csi()
880 state->pos.row -= count; in on_csi()
881 state->at_phantom = 0; in on_csi()
886 state->pos.row += count; in on_csi()
887 state->at_phantom = 0; in on_csi()
892 state->pos.col += count; in on_csi()
893 state->at_phantom = 0; in on_csi()
898 state->pos.col -= count; in on_csi()
899 state->at_phantom = 0; in on_csi()
904 state->pos.col = 0; in on_csi()
905 state->pos.row += count; in on_csi()
906 state->at_phantom = 0; in on_csi()
911 state->pos.col = 0; in on_csi()
912 state->pos.row -= count; in on_csi()
913 state->at_phantom = 0; in on_csi()
918 state->pos.col = val-1; in on_csi()
919 state->at_phantom = 0; in on_csi()
926 state->pos.row = row-1; in on_csi()
927 state->pos.col = col-1; in on_csi()
928 if(state->mode.origin) { in on_csi()
929 state->pos.row += state->scrollregion_top; in on_csi()
930 state->pos.col += SCROLLREGION_LEFT(state); in on_csi()
932 state->at_phantom = 0; in on_csi()
937 tab(state, count, +1); in on_csi()
946 rect.start_row = state->pos.row; rect.end_row = state->pos.row + 1; in on_csi()
947 rect.start_col = state->pos.col; rect.end_col = state->cols; in on_csi()
949 erase(state, rect, selective); in on_csi()
951 rect.start_row = state->pos.row + 1; rect.end_row = state->rows; in on_csi()
954 erase(state, rect, selective); in on_csi()
958 rect.start_row = 0; rect.end_row = state->pos.row; in on_csi()
959 rect.start_col = 0; rect.end_col = state->cols; in on_csi()
961 erase(state, rect, selective); in on_csi()
963 rect.start_row = state->pos.row; rect.end_row = state->pos.row + 1; in on_csi()
964 rect.end_col = state->pos.col + 1; in on_csi()
966 erase(state, rect, selective); in on_csi()
970 rect.start_row = 0; rect.end_row = state->rows; in on_csi()
971 rect.start_col = 0; rect.end_col = state->cols; in on_csi()
972 erase(state, rect, selective); in on_csi()
980 rect.start_row = state->pos.row; in on_csi()
981 rect.end_row = state->pos.row + 1; in on_csi()
986 rect.start_col = state->pos.col; rect.end_col = state->cols; break; in on_csi()
988 rect.start_col = 0; rect.end_col = state->pos.col + 1; break; in on_csi()
990 rect.start_col = 0; rect.end_col = state->cols; break; in on_csi()
996 erase(state, rect, selective); in on_csi()
1003 rect.start_row = state->pos.row; in on_csi()
1004 rect.end_row = SCROLLREGION_BOTTOM(state); in on_csi()
1005 rect.start_col = SCROLLREGION_LEFT(state); in on_csi()
1006 rect.end_col = SCROLLREGION_RIGHT(state); in on_csi()
1008 scroll(state, rect, -count, 0); in on_csi()
1015 rect.start_row = state->pos.row; in on_csi()
1016 rect.end_row = SCROLLREGION_BOTTOM(state); in on_csi()
1017 rect.start_col = SCROLLREGION_LEFT(state); in on_csi()
1018 rect.end_col = SCROLLREGION_RIGHT(state); in on_csi()
1020 scroll(state, rect, count, 0); in on_csi()
1027 rect.start_row = state->pos.row; in on_csi()
1028 rect.end_row = state->pos.row + 1; in on_csi()
1029 rect.start_col = state->pos.col; in on_csi()
1030 rect.end_col = state->cols; in on_csi()
1032 scroll(state, rect, 0, count); in on_csi()
1039 rect.start_row = state->scrollregion_top; in on_csi()
1040 rect.end_row = SCROLLREGION_BOTTOM(state); in on_csi()
1041 rect.start_col = SCROLLREGION_LEFT(state); in on_csi()
1042 rect.end_col = SCROLLREGION_RIGHT(state); in on_csi()
1044 scroll(state, rect, count, 0); in on_csi()
1051 rect.start_row = state->scrollregion_top; in on_csi()
1052 rect.end_row = SCROLLREGION_BOTTOM(state); in on_csi()
1053 rect.start_col = SCROLLREGION_LEFT(state); in on_csi()
1054 rect.end_col = SCROLLREGION_RIGHT(state); in on_csi()
1056 scroll(state, rect, -count, 0); in on_csi()
1063 rect.start_row = state->pos.row; in on_csi()
1064 rect.end_row = state->pos.row + 1; in on_csi()
1065 rect.start_col = state->pos.col; in on_csi()
1066 rect.end_col = state->pos.col + count; in on_csi()
1067 UBOUND(rect.end_col, state->cols); in on_csi()
1069 erase(state, rect, 0); in on_csi()
1074 tab(state, count, -1); in on_csi()
1079 state->pos.col = col-1; in on_csi()
1080 state->at_phantom = 0; in on_csi()
1085 state->pos.col += count; in on_csi()
1086 state->at_phantom = 0; in on_csi()
1093 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "?1;2c"); in on_csi()
1097 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, ">%d;%d;%dc", 0, 100, 0); in on_csi()
1102 state->pos.row = row-1; in on_csi()
1103 if(state->mode.origin) in on_csi()
1104 state->pos.row += state->scrollregion_top; in on_csi()
1105 state->at_phantom = 0; in on_csi()
1110 state->pos.row += count; in on_csi()
1111 state->at_phantom = 0; in on_csi()
1118 state->pos.row = row-1; in on_csi()
1119 state->pos.col = col-1; in on_csi()
1120 if(state->mode.origin) { in on_csi()
1121 state->pos.row += state->scrollregion_top; in on_csi()
1122 state->pos.col += SCROLLREGION_LEFT(state); in on_csi()
1124 state->at_phantom = 0; in on_csi()
1132 clear_col_tabstop(state, state->pos.col); in on_csi()
1136 for(col = 0; col < state->cols; col++) in on_csi()
1137 clear_col_tabstop(state, col); in on_csi()
1151 set_mode(state, CSI_ARG(args[0]), 1); in on_csi()
1156 set_dec_mode(state, CSI_ARG(args[0]), 1); in on_csi()
1161 state->pos.col -= count; in on_csi()
1162 state->at_phantom = 0; in on_csi()
1167 state->pos.row -= count; in on_csi()
1168 state->at_phantom = 0; in on_csi()
1173 set_mode(state, CSI_ARG(args[0]), 0); in on_csi()
1178 set_dec_mode(state, CSI_ARG(args[0]), 0); in on_csi()
1182 vterm_state_setpen(state, args, argcount); in on_csi()
1197 vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "%s0n", qmark); in on_csi()
1200 …vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "%s%d;%dR", qmark, state->pos.row + 1, state->po… in on_csi()
1208 vterm_state_reset(state, 0); in on_csi()
1212 request_dec_mode(state, CSI_ARG(args[0])); in on_csi()
1220 settermprop_bool(state, VTERM_PROP_CURSORBLINK, 1); in on_csi()
1221 settermprop_int (state, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORSHAPE_BLOCK); in on_csi()
1224 settermprop_bool(state, VTERM_PROP_CURSORBLINK, 0); in on_csi()
1225 settermprop_int (state, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORSHAPE_BLOCK); in on_csi()
1228 settermprop_bool(state, VTERM_PROP_CURSORBLINK, 1); in on_csi()
1229 settermprop_int (state, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORSHAPE_UNDERLINE); in on_csi()
1232 settermprop_bool(state, VTERM_PROP_CURSORBLINK, 0); in on_csi()
1233 settermprop_int (state, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORSHAPE_UNDERLINE); in on_csi()
1236 settermprop_bool(state, VTERM_PROP_CURSORBLINK, 1); in on_csi()
1237 settermprop_int (state, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORSHAPE_BAR_LEFT); in on_csi()
1240 settermprop_bool(state, VTERM_PROP_CURSORBLINK, 0); in on_csi()
1241 settermprop_int (state, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORSHAPE_BAR_LEFT); in on_csi()
1252 state->protected_cell = 0; in on_csi()
1255 state->protected_cell = 1; in on_csi()
1262 state->scrollregion_top = CSI_ARG_OR(args[0], 1) - 1; in on_csi()
1263state->scrollregion_bottom = argcount < 2 || CSI_ARG_IS_MISSING(args[1]) ? -1 : CSI_ARG(args[1]); in on_csi()
1264 if(state->scrollregion_top == 0 && state->scrollregion_bottom == state->rows) in on_csi()
1265 state->scrollregion_bottom = -1; in on_csi()
1270 state->scrollregion_left = CSI_ARG_OR(args[0], 1) - 1; in on_csi()
1271 state->scrollregion_right = argcount < 2 || CSI_ARG_IS_MISSING(args[1]) ? -1 : CSI_ARG(args[1]); in on_csi()
1272 if(state->scrollregion_left == 0 && state->scrollregion_right == state->cols) in on_csi()
1273 state->scrollregion_right = -1; in on_csi()
1279 rect.start_row = state->scrollregion_top; in on_csi()
1280 rect.end_row = SCROLLREGION_BOTTOM(state); in on_csi()
1281 rect.start_col = state->pos.col; in on_csi()
1282 rect.end_col = SCROLLREGION_RIGHT(state); in on_csi()
1284 scroll(state, rect, 0, -count); in on_csi()
1291 rect.start_row = state->scrollregion_top; in on_csi()
1292 rect.end_row = SCROLLREGION_BOTTOM(state); in on_csi()
1293 rect.start_col = state->pos.col; in on_csi()
1294 rect.end_col = SCROLLREGION_RIGHT(state); in on_csi()
1296 scroll(state, rect, 0, count); in on_csi()
1304 if(state->mode.origin) { in on_csi()
1305 LBOUND(state->pos.row, state->scrollregion_top); in on_csi()
1306 UBOUND(state->pos.row, state->scrollregion_bottom-1); in on_csi()
1307 LBOUND(state->pos.col, SCROLLREGION_LEFT(state)); in on_csi()
1308 UBOUND(state->pos.col, SCROLLREGION_RIGHT(state)-1); in on_csi()
1311 LBOUND(state->pos.row, 0); in on_csi()
1312 UBOUND(state->pos.row, state->rows-1); in on_csi()
1313 LBOUND(state->pos.col, 0); in on_csi()
1314 UBOUND(state->pos.col, state->cols-1); in on_csi()
1317 updatecursor(state, &oldpos, 1); in on_csi()
1324 VTermState *state = user; in on_osc() local
1330 settermprop_string(state, VTERM_PROP_ICONNAME, command + 2, cmdlen - 2); in on_osc()
1331 settermprop_string(state, VTERM_PROP_TITLE, command + 2, cmdlen - 2); in on_osc()
1335 settermprop_string(state, VTERM_PROP_ICONNAME, command + 2, cmdlen - 2); in on_osc()
1339 settermprop_string(state, VTERM_PROP_TITLE, command + 2, cmdlen - 2); in on_osc()
1346 static void request_status_string(VTermState *state, const char *command, size_t cmdlen) in request_status_string() argument
1353 int argc = vterm_state_getpen(state, args, sizeof(args)/sizeof(args[0])); in request_status_string()
1354 vterm_push_output_sprintf_ctrl(state->vt, C1_DCS, "1$r"); in request_status_string()
1356 vterm_push_output_sprintf(state->vt, in request_status_string()
1361 vterm_push_output_sprintf(state->vt, "m"); in request_status_string()
1362 vterm_push_output_sprintf_ctrl(state->vt, C1_ST, ""); in request_status_string()
1366 …vterm_push_output_sprintf_dcs(state->vt, "1$r%d;%dr", state->scrollregion_top+1, SCROLLREGION_BOTT… in request_status_string()
1369 …vterm_push_output_sprintf_dcs(state->vt, "1$r%d;%ds", SCROLLREGION_LEFT(state)+1, SCROLLREGION_RIG… in request_status_string()
1376 switch(state->mode.cursor_shape) { in request_status_string()
1381 if(state->mode.cursor_blink) in request_status_string()
1383 vterm_push_output_sprintf_dcs(state->vt, "1$r%d q", reply); in request_status_string()
1387 vterm_push_output_sprintf_dcs(state->vt, "1$r%d\"q", state->protected_cell ? 1 : 2); in request_status_string()
1392 vterm_push_output_sprintf_dcs(state->vt, "0$r%.s", (int)cmdlen, command); in request_status_string()
1397 VTermState *state = user; in on_dcs() local
1400 request_status_string(state, command+2, cmdlen-2); in on_dcs()
1409 VTermState *state = user; in on_resize() local
1410 VTermPos oldpos = state->pos; in on_resize()
1412 if(cols != state->cols) { in on_resize()
1413 unsigned char *newtabstops = vterm_allocator_malloc(state->vt, (cols + 7) / 8); in on_resize()
1417 for(col = 0; col < state->cols && col < cols; col++) { in on_resize()
1419 if(state->tabstops[col >> 3] & mask) in on_resize()
1433 vterm_allocator_free(state->vt, state->tabstops); in on_resize()
1434 state->tabstops = newtabstops; in on_resize()
1437 state->rows = rows; in on_resize()
1438 state->cols = cols; in on_resize()
1442 if(state->callbacks && state->callbacks->resize) in on_resize()
1443 (*state->callbacks->resize)(rows, cols, &delta, state->cbdata); in on_resize()
1445 if(state->at_phantom && state->pos.col < cols-1) { in on_resize()
1446 state->at_phantom = 0; in on_resize()
1447 state->pos.col++; in on_resize()
1450 state->pos.row += delta.row; in on_resize()
1451 state->pos.col += delta.col; in on_resize()
1453 if(state->pos.row >= rows) in on_resize()
1454 state->pos.row = rows - 1; in on_resize()
1455 if(state->pos.col >= cols) in on_resize()
1456 state->pos.col = cols - 1; in on_resize()
1458 updatecursor(state, &oldpos, 1); in on_resize()
1475 if(vt->state) in vterm_obtain_state()
1476 return vt->state; in vterm_obtain_state()
1478 VTermState *state = vterm_state_new(vt); in vterm_obtain_state() local
1479 vt->state = state; in vterm_obtain_state()
1481 state->combine_chars_size = 16; in vterm_obtain_state()
1482state->combine_chars = vterm_allocator_malloc(state->vt, state->combine_chars_size * sizeof(state-… in vterm_obtain_state()
1484 state->tabstops = vterm_allocator_malloc(state->vt, (state->cols + 7) / 8); in vterm_obtain_state()
1486 state->encoding_utf8.enc = vterm_lookup_encoding(ENC_UTF8, 'u'); in vterm_obtain_state()
1487 if(*state->encoding_utf8.enc->init) in vterm_obtain_state()
1488 (*state->encoding_utf8.enc->init)(state->encoding_utf8.enc, state->encoding_utf8.data); in vterm_obtain_state()
1490 vterm_set_parser_callbacks(vt, &parser_callbacks, state); in vterm_obtain_state()
1492 return state; in vterm_obtain_state()
1495 void vterm_state_reset(VTermState *state, int hard) in vterm_state_reset() argument
1497 state->scrollregion_top = 0; in vterm_state_reset()
1498 state->scrollregion_bottom = -1; in vterm_state_reset()
1499 state->scrollregion_left = 0; in vterm_state_reset()
1500 state->scrollregion_right = -1; in vterm_state_reset()
1502 state->mode.keypad = 0; in vterm_state_reset()
1503 state->mode.cursor = 0; in vterm_state_reset()
1504 state->mode.autowrap = 1; in vterm_state_reset()
1505 state->mode.insert = 0; in vterm_state_reset()
1506 state->mode.newline = 0; in vterm_state_reset()
1507 state->mode.alt_screen = 0; in vterm_state_reset()
1508 state->mode.origin = 0; in vterm_state_reset()
1509 state->mode.leftrightmargin = 0; in vterm_state_reset()
1511 state->vt->mode.ctrl8bit = 0; in vterm_state_reset()
1513 for(int col = 0; col < state->cols; col++) in vterm_state_reset()
1515 set_col_tabstop(state, col); in vterm_state_reset()
1517 clear_col_tabstop(state, col); in vterm_state_reset()
1519 if(state->callbacks && state->callbacks->initpen) in vterm_state_reset()
1520 (*state->callbacks->initpen)(state->cbdata); in vterm_state_reset()
1522 vterm_state_resetpen(state); in vterm_state_reset()
1524 VTermEncoding *default_enc = state->vt->mode.utf8 ? in vterm_state_reset()
1529 state->encoding[i].enc = default_enc; in vterm_state_reset()
1531 (*default_enc->init)(default_enc, state->encoding[i].data); in vterm_state_reset()
1534 state->gl_set = 0; in vterm_state_reset()
1535 state->gr_set = 1; in vterm_state_reset()
1536 state->gsingle_set = 0; in vterm_state_reset()
1538 state->protected_cell = 0; in vterm_state_reset()
1541 settermprop_bool(state, VTERM_PROP_CURSORVISIBLE, 1); in vterm_state_reset()
1542 settermprop_bool(state, VTERM_PROP_CURSORBLINK, 1); in vterm_state_reset()
1543 settermprop_int (state, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORSHAPE_BLOCK); in vterm_state_reset()
1546 state->pos.row = 0; in vterm_state_reset()
1547 state->pos.col = 0; in vterm_state_reset()
1548 state->at_phantom = 0; in vterm_state_reset()
1550 VTermRect rect = { 0, state->rows, 0, state->cols }; in vterm_state_reset()
1551 erase(state, rect, 0); in vterm_state_reset()
1555 void vterm_state_get_cursorpos(const VTermState *state, VTermPos *cursorpos) in vterm_state_get_cursorpos() argument
1557 *cursorpos = state->pos; in vterm_state_get_cursorpos()
1560 void vterm_state_set_callbacks(VTermState *state, const VTermStateCallbacks *callbacks, void *user) in vterm_state_set_callbacks() argument
1563 state->callbacks = callbacks; in vterm_state_set_callbacks()
1564 state->cbdata = user; in vterm_state_set_callbacks()
1566 if(state->callbacks && state->callbacks->initpen) in vterm_state_set_callbacks()
1567 (*state->callbacks->initpen)(state->cbdata); in vterm_state_set_callbacks()
1570 state->callbacks = NULL; in vterm_state_set_callbacks()
1571 state->cbdata = NULL; in vterm_state_set_callbacks()
1575 int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val) in vterm_state_set_termprop() argument
1579 if(state->callbacks && state->callbacks->settermprop) in vterm_state_set_termprop()
1580 if(!(*state->callbacks->settermprop)(prop, val, state->cbdata)) in vterm_state_set_termprop()
1589 state->mode.cursor_visible = val->boolean; in vterm_state_set_termprop()
1592 state->mode.cursor_blink = val->boolean; in vterm_state_set_termprop()
1595 state->mode.cursor_shape = val->number; in vterm_state_set_termprop()
1598 state->mode.screen = val->boolean; in vterm_state_set_termprop()
1601 state->mode.alt_screen = val->boolean; in vterm_state_set_termprop()
1602 if(state->mode.alt_screen) { in vterm_state_set_termprop()
1606 .end_row = state->rows, in vterm_state_set_termprop()
1607 .end_col = state->cols, in vterm_state_set_termprop()
1609 erase(state, rect, 0); in vterm_state_set_termprop()