Lines Matching refs:screen
39 static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell);
71 static inline ScreenCell *getcell(const VTermScreen *screen, int row, int col) in getcell() argument
73 if(row < 0 || row >= screen->rows) in getcell()
75 if(col < 0 || col >= screen->cols) in getcell()
77 return screen->buffer + (screen->cols * row) + col; in getcell()
80 static ScreenCell *realloc_buffer(VTermScreen *screen, ScreenCell *buffer, int new_rows, int new_co… in realloc_buffer() argument
82 …ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_co… in realloc_buffer()
88 if(buffer && row < screen->rows && col < screen->cols) in realloc_buffer()
89 *new_cell = buffer[row * screen->cols + col]; in realloc_buffer()
92 new_cell->pen = screen->pen; in realloc_buffer()
98 vterm_allocator_free(screen->vt, buffer); in realloc_buffer()
103 static void damagerect(VTermScreen *screen, VTermRect rect) in damagerect() argument
107 switch(screen->damage_merge) { in damagerect()
118 vterm_screen_flush_damage(screen); in damagerect()
121 else if(screen->damaged.start_row == -1) { in damagerect()
123 screen->damaged = rect; in damagerect()
126 else if(rect.start_row == screen->damaged.start_row) { in damagerect()
128 if(screen->damaged.start_col > rect.start_col) in damagerect()
129 screen->damaged.start_col = rect.start_col; in damagerect()
130 if(screen->damaged.end_col < rect.end_col) in damagerect()
131 screen->damaged.end_col = rect.end_col; in damagerect()
136 emit = screen->damaged; in damagerect()
137 screen->damaged = rect; in damagerect()
144 if(screen->damaged.start_row == -1) in damagerect()
145 screen->damaged = rect; in damagerect()
147 rect_expand(&screen->damaged, &rect); in damagerect()
152 DEBUG_LOG("TODO: Maybe merge damage for level %d\n", screen->damage_merge); in damagerect()
156 if(screen->callbacks && screen->callbacks->damage) in damagerect()
157 (*screen->callbacks->damage)(emit, screen->cbdata); in damagerect()
160 static void damagescreen(VTermScreen *screen) in damagescreen() argument
164 .end_row = screen->rows, in damagescreen()
166 .end_col = screen->cols, in damagescreen()
169 damagerect(screen, rect); in damagescreen()
174 VTermScreen *screen = user; in putglyph() local
175 ScreenCell *cell = getcell(screen, pos.row, pos.col); in putglyph()
183 cell->pen = screen->pen; in putglyph()
189 getcell(screen, pos.row, pos.col + col)->chars[0] = (uint32_t)-1; in putglyph()
202 damagerect(screen, rect); in putglyph()
209 VTermScreen *screen = user; in moverect_internal() local
211 if(screen->callbacks && screen->callbacks->sb_pushline && in moverect_internal()
213 dest.end_col == screen->cols && // full width in moverect_internal()
214 screen->buffer == screen->buffers[0]) { // not altscreen in moverect_internal()
217 for(pos.col = 0; pos.col < screen->cols; pos.col++) in moverect_internal()
218 vterm_screen_get_cell(screen, pos, screen->sb_buffer + pos.col); in moverect_internal()
220 (screen->callbacks->sb_pushline)(screen->cols, screen->sb_buffer, screen->cbdata); in moverect_internal()
240 memmove(getcell(screen, row, dest.start_col), in moverect_internal()
241 getcell(screen, row + downward, src.start_col), in moverect_internal()
249 VTermScreen *screen = user; in moverect_user() local
251 if(screen->callbacks && screen->callbacks->moverect) { in moverect_user()
252 if(screen->damage_merge != VTERM_DAMAGE_SCROLL) in moverect_user()
254 vterm_screen_flush_damage(screen); in moverect_user()
256 if((*screen->callbacks->moverect)(dest, src, screen->cbdata)) in moverect_user()
260 damagerect(screen, dest); in moverect_user()
267 VTermScreen *screen = user; in erase_internal() local
269 for(int row = rect.start_row; row < screen->state->rows && row < rect.end_row; row++) { in erase_internal()
270 const VTermLineInfo *info = vterm_state_get_lineinfo(screen->state, row); in erase_internal()
273 ScreenCell *cell = getcell(screen, row, col); in erase_internal()
279 cell->pen = screen->pen; in erase_internal()
290 VTermScreen *screen = user; in erase_user() local
292 damagerect(screen, rect); in erase_user()
305 VTermScreen *screen = user; in scrollrect() local
307 if(screen->damage_merge != VTERM_DAMAGE_SCROLL) { in scrollrect()
309 moverect_internal, erase_internal, screen); in scrollrect()
311 vterm_screen_flush_damage(screen); in scrollrect()
314 moverect_user, erase_user, screen); in scrollrect()
319 if(screen->damaged.start_row != -1 && in scrollrect()
320 !rect_intersects(&rect, &screen->damaged)) { in scrollrect()
321 vterm_screen_flush_damage(screen); in scrollrect()
324 if(screen->pending_scrollrect.start_row == -1) { in scrollrect()
325 screen->pending_scrollrect = rect; in scrollrect()
326 screen->pending_scroll_downward = downward; in scrollrect()
327 screen->pending_scroll_rightward = rightward; in scrollrect()
329 else if(rect_equal(&screen->pending_scrollrect, &rect) && in scrollrect()
330 ((screen->pending_scroll_downward == 0 && downward == 0) || in scrollrect()
331 (screen->pending_scroll_rightward == 0 && rightward == 0))) { in scrollrect()
332 screen->pending_scroll_downward += downward; in scrollrect()
333 screen->pending_scroll_rightward += rightward; in scrollrect()
336 vterm_screen_flush_damage(screen); in scrollrect()
338 screen->pending_scrollrect = rect; in scrollrect()
339 screen->pending_scroll_downward = downward; in scrollrect()
340 screen->pending_scroll_rightward = rightward; in scrollrect()
344 moverect_internal, erase_internal, screen); in scrollrect()
346 if(screen->damaged.start_row == -1) in scrollrect()
349 if(rect_contains(&rect, &screen->damaged)) { in scrollrect()
351 vterm_rect_move(&screen->damaged, -downward, -rightward); in scrollrect()
352 rect_clip(&screen->damaged, &rect); in scrollrect()
359 else if(rect.start_col <= screen->damaged.start_col && in scrollrect()
360 rect.end_col >= screen->damaged.end_col && in scrollrect()
362 if(screen->damaged.start_row >= rect.start_row && in scrollrect()
363 screen->damaged.start_row < rect.end_row) { in scrollrect()
364 screen->damaged.start_row -= downward; in scrollrect()
365 if(screen->damaged.start_row < rect.start_row) in scrollrect()
366 screen->damaged.start_row = rect.start_row; in scrollrect()
367 if(screen->damaged.start_row > rect.end_row) in scrollrect()
368 screen->damaged.start_row = rect.end_row; in scrollrect()
370 if(screen->damaged.end_row >= rect.start_row && in scrollrect()
371 screen->damaged.end_row < rect.end_row) { in scrollrect()
372 screen->damaged.end_row -= downward; in scrollrect()
373 if(screen->damaged.end_row < rect.start_row) in scrollrect()
374 screen->damaged.end_row = rect.start_row; in scrollrect()
375 if(screen->damaged.end_row > rect.end_row) in scrollrect()
376 screen->damaged.end_row = rect.end_row; in scrollrect()
381 ARGSrect(screen->damaged), ARGSrect(rect)); in scrollrect()
389 VTermScreen *screen = user; in movecursor() local
391 if(screen->callbacks && screen->callbacks->movecursor) in movecursor()
392 return (*screen->callbacks->movecursor)(pos, oldpos, visible, screen->cbdata); in movecursor()
399 VTermScreen *screen = user; in setpenattr() local
403 screen->pen.bold = val->boolean; in setpenattr()
406 screen->pen.underline = val->number; in setpenattr()
409 screen->pen.italic = val->boolean; in setpenattr()
412 screen->pen.blink = val->boolean; in setpenattr()
415 screen->pen.reverse = val->boolean; in setpenattr()
418 screen->pen.strike = val->boolean; in setpenattr()
421 screen->pen.font = val->number; in setpenattr()
424 screen->pen.fg = val->color; in setpenattr()
427 screen->pen.bg = val->color; in setpenattr()
439 VTermScreen *screen = user; in settermprop() local
443 if(val->boolean && !screen->buffers[1]) in settermprop()
446 screen->buffer = val->boolean ? screen->buffers[1] : screen->buffers[0]; in settermprop()
451 damagescreen(screen); in settermprop()
454 screen->global_reverse = val->boolean; in settermprop()
455 damagescreen(screen); in settermprop()
461 if(screen->callbacks && screen->callbacks->settermprop) in settermprop()
462 return (*screen->callbacks->settermprop)(prop, val, screen->cbdata); in settermprop()
469 VTermScreen *screen = user; in bell() local
471 if(screen->callbacks && screen->callbacks->bell) in bell()
472 return (*screen->callbacks->bell)(screen->cbdata); in bell()
479 VTermScreen *screen = user; in resize() local
481 int is_altscreen = (screen->buffers[1] && screen->buffer == screen->buffers[1]); in resize()
483 int old_rows = screen->rows; in resize()
484 int old_cols = screen->cols; in resize()
490 VTermPos cursor = screen->state->pos; in resize()
493 if(!vterm_screen_is_eol(screen, pos) || cursor.row == pos.row) in resize()
505 vterm_screen_flush_damage(screen); in resize()
511 screen->buffers[0] = realloc_buffer(screen, screen->buffers[0], new_rows, new_cols); in resize()
512 if(screen->buffers[1]) in resize()
513 screen->buffers[1] = realloc_buffer(screen, screen->buffers[1], new_rows, new_cols); in resize()
515 screen->buffer = is_altscreen ? screen->buffers[1] : screen->buffers[0]; in resize()
517 screen->rows = new_rows; in resize()
518 screen->cols = new_cols; in resize()
520 if(screen->sb_buffer) in resize()
521 vterm_allocator_free(screen->vt, screen->sb_buffer); in resize()
523 screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * new_cols); in resize()
532 damagerect(screen, rect); in resize()
536 if(!is_altscreen && screen->callbacks && screen->callbacks->sb_popline) { in resize()
539 if(!(screen->callbacks->sb_popline(screen->cols, screen->sb_buffer, screen->cbdata))) in resize()
544 .end_row = screen->rows, in resize()
546 .end_col = screen->cols, in resize()
551 for(pos.col = 0; pos.col < screen->cols; pos.col += screen->sb_buffer[pos.col].width) in resize()
552 vterm_screen_set_cell(screen, pos, screen->sb_buffer + pos.col); in resize()
555 damagerect(screen, rect); in resize()
557 vterm_screen_flush_damage(screen); in resize()
570 damagerect(screen, rect); in resize()
573 if(screen->callbacks && screen->callbacks->resize) in resize()
574 return (*screen->callbacks->resize)(new_rows, new_cols, screen->cbdata); in resize()
581 VTermScreen *screen = user; in setlineinfo() local
585 for(int col = 0; col < screen->cols; col++) { in setlineinfo()
586 ScreenCell *cell = getcell(screen, row, col); in setlineinfo()
595 .end_col = newinfo->doublewidth ? screen->cols / 2 : screen->cols, in setlineinfo()
597 damagerect(screen, rect); in setlineinfo()
600 rect.start_col = screen->cols / 2; in setlineinfo()
601 rect.end_col = screen->cols; in setlineinfo()
628 VTermScreen *screen = vterm_allocator_malloc(vt, sizeof(VTermScreen)); in screen_new() local
633 screen->vt = vt; in screen_new()
634 screen->state = state; in screen_new()
636 screen->damage_merge = VTERM_DAMAGE_CELL; in screen_new()
637 screen->damaged.start_row = -1; in screen_new()
638 screen->pending_scrollrect.start_row = -1; in screen_new()
640 screen->rows = rows; in screen_new()
641 screen->cols = cols; in screen_new()
643 screen->callbacks = NULL; in screen_new()
644 screen->cbdata = NULL; in screen_new()
646 screen->buffers[0] = realloc_buffer(screen, NULL, rows, cols); in screen_new()
648 screen->buffer = screen->buffers[0]; in screen_new()
650 screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * cols); in screen_new()
652 vterm_state_set_callbacks(screen->state, &state_cbs, screen); in screen_new()
654 return screen; in screen_new()
657 INTERNAL void vterm_screen_free(VTermScreen *screen) in vterm_screen_free() argument
659 vterm_allocator_free(screen->vt, screen->buffers[0]); in vterm_screen_free()
660 if(screen->buffers[1]) in vterm_screen_free()
661 vterm_allocator_free(screen->vt, screen->buffers[1]); in vterm_screen_free()
663 vterm_allocator_free(screen->vt, screen->sb_buffer); in vterm_screen_free()
665 vterm_allocator_free(screen->vt, screen); in vterm_screen_free()
668 void vterm_screen_reset(VTermScreen *screen, int hard) in vterm_screen_reset() argument
670 screen->damaged.start_row = -1; in vterm_screen_reset()
671 screen->pending_scrollrect.start_row = -1; in vterm_screen_reset()
672 vterm_state_reset(screen->state, hard); in vterm_screen_reset()
673 vterm_screen_flush_damage(screen); in vterm_screen_reset()
676 static size_t _get_chars(const VTermScreen *screen, const int utf8, void *buffer, size_t len, const… in _get_chars() argument
698 ScreenCell *cell = getcell(screen, row, col); in _get_chars()
726 size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRe… in vterm_screen_get_chars() argument
728 return _get_chars(screen, 0, chars, len, rect); in vterm_screen_get_chars()
731 size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect) in vterm_screen_get_text() argument
733 return _get_chars(screen, 1, str, len, rect); in vterm_screen_get_text()
737 int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCell *cell) in vterm_screen_get_cell() argument
739 ScreenCell *intcell = getcell(screen, pos.row, pos.col); in vterm_screen_get_cell()
753 cell->attrs.reverse = intcell->pen.reverse ^ screen->global_reverse; in vterm_screen_get_cell()
763 if(pos.col < (screen->cols - 1) && in vterm_screen_get_cell()
764 getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) in vterm_screen_get_cell()
774 static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell) in vterm_screen_set_cell() argument
776 ScreenCell *intcell = getcell(screen, pos.row, pos.col); in vterm_screen_set_cell()
790 intcell->pen.reverse = cell->attrs.reverse ^ screen->global_reverse; in vterm_screen_set_cell()
798 getcell(screen, pos.row, pos.col + 1)->chars[0] = (uint32_t)-1; in vterm_screen_set_cell()
803 int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos) in vterm_screen_is_eol() argument
806 for(; pos.col < screen->cols; pos.col++) { in vterm_screen_is_eol()
807 ScreenCell *cell = getcell(screen, pos.row, pos.col); in vterm_screen_is_eol()
817 if(vt->screen) in vterm_obtain_screen()
818 return vt->screen; in vterm_obtain_screen()
820 VTermScreen *screen = screen_new(vt); in vterm_obtain_screen() local
821 vt->screen = screen; in vterm_obtain_screen()
823 return screen; in vterm_obtain_screen()
826 void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen) in vterm_screen_enable_altscreen() argument
829 if(!screen->buffers[1] && altscreen) { in vterm_screen_enable_altscreen()
831 vterm_get_size(screen->vt, &rows, &cols); in vterm_screen_enable_altscreen()
833 screen->buffers[1] = realloc_buffer(screen, NULL, rows, cols); in vterm_screen_enable_altscreen()
837 void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *u… in vterm_screen_set_callbacks() argument
839 screen->callbacks = callbacks; in vterm_screen_set_callbacks()
840 screen->cbdata = user; in vterm_screen_set_callbacks()
843 void *vterm_screen_get_cbdata(VTermScreen *screen) in vterm_screen_get_cbdata() argument
845 return screen->cbdata; in vterm_screen_get_cbdata()
848 void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallb… in vterm_screen_set_unrecognised_fallbacks() argument
850 vterm_state_set_unrecognised_fallbacks(screen->state, fallbacks, user); in vterm_screen_set_unrecognised_fallbacks()
853 void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen) in vterm_screen_get_unrecognised_fbdata() argument
855 return vterm_state_get_unrecognised_fbdata(screen->state); in vterm_screen_get_unrecognised_fbdata()
858 void vterm_screen_flush_damage(VTermScreen *screen) in vterm_screen_flush_damage() argument
860 if(screen->pending_scrollrect.start_row != -1) { in vterm_screen_flush_damage()
861 …vterm_scroll_rect(screen->pending_scrollrect, screen->pending_scroll_downward, screen->pending_scr… in vterm_screen_flush_damage()
862 moverect_user, erase_user, screen); in vterm_screen_flush_damage()
864 screen->pending_scrollrect.start_row = -1; in vterm_screen_flush_damage()
867 if(screen->damaged.start_row != -1) { in vterm_screen_flush_damage()
868 if(screen->callbacks && screen->callbacks->damage) in vterm_screen_flush_damage()
869 (*screen->callbacks->damage)(screen->damaged, screen->cbdata); in vterm_screen_flush_damage()
871 screen->damaged.start_row = -1; in vterm_screen_flush_damage()
875 void vterm_screen_set_damage_merge(VTermScreen *screen, VTermDamageSize size) in vterm_screen_set_damage_merge() argument
877 vterm_screen_flush_damage(screen); in vterm_screen_set_damage_merge()
878 screen->damage_merge = size; in vterm_screen_set_damage_merge()
905 int vterm_screen_get_attrs_extent(const VTermScreen *screen, VTermRect *extent, VTermPos pos, VTerm… in vterm_screen_get_attrs_extent() argument
907 ScreenCell *target = getcell(screen, pos.row, pos.col); in vterm_screen_get_attrs_extent()
916 extent->end_col = screen->cols; in vterm_screen_get_attrs_extent()
921 if(attrs_differ(attrs, target, getcell(screen, pos.row, col))) in vterm_screen_get_attrs_extent()
926 if(attrs_differ(attrs, target, getcell(screen, pos.row, col))) in vterm_screen_get_attrs_extent()
933 void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *col) in vterm_screen_convert_color_to_rgb() argument
935 vterm_state_convert_color_to_rgb(screen->state, col); in vterm_screen_convert_color_to_rgb()