annotate src/libvterm/src/screen.c @ 35162:860a5fb8eaf2 default tip

Added tag v9.1.0407 for changeset 08f7c9428f8224d6b24c60f4da1fd12c6354e852
author Christian Brabandt <cb@256bit.org>
date Sat, 11 May 2024 11:45:04 +0200
parents 288bbf09d372
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 #include "vterm_internal.h"
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
3 // vim: set sw=2 :
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 #include <stdio.h>
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 #include <string.h>
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 #include "rect.h"
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 #include "utf8.h"
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 #define UNICODE_SPACE 0x20
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 #define UNICODE_LINEFEED 0x0a
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
13 #undef DEBUG_REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
14
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
15 /* State of the pen at some moment in time, also used in a cell */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 typedef struct
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 {
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
18 /* After the bitfield */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 VTermColor fg, bg;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 unsigned int bold : 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 unsigned int underline : 2;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 unsigned int italic : 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 unsigned int blink : 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 unsigned int reverse : 1;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
26 unsigned int conceal : 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 unsigned int strike : 1;
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
28 unsigned int font : 4; /* 0 to 9 */
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
29 unsigned int small : 1;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
30 unsigned int baseline : 2;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
32 /* Extra state storage that isn't strictly pen-related */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 unsigned int protected_cell : 1;
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
34 unsigned int dwl : 1; /* on a DECDWL or DECDHL line */
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
35 unsigned int dhl : 2; /* on a DECDHL line (1=top 2=bottom) */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 } ScreenPen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
38 /* Internal representation of a screen cell */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 typedef struct
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 uint32_t chars[VTERM_MAX_CHARS_PER_CELL];
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 ScreenPen pen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 } ScreenCell;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 struct VTermScreen
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 VTerm *vt;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 VTermState *state;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 const VTermScreenCallbacks *callbacks;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 void *cbdata;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 VTermDamageSize damage_merge;
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
54 /* start_row == -1 => no damage */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 VTermRect damaged;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 VTermRect pending_scrollrect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 int pending_scroll_downward, pending_scroll_rightward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 int rows;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 int cols;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
61
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
62 unsigned int global_reverse : 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
63 unsigned int reflow : 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
65 /* Primary and Altscreen. buffers[1] is lazily allocated as needed */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 ScreenCell *buffers[2];
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
68 /* buffer will == buffers[0] or buffers[1], depending on altscreen */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 ScreenCell *buffer;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
71 /* buffer for a single screen row used in scrollback storage callbacks */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 VTermScreenCell *sb_buffer;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 ScreenPen pen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 };
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
77 static void clearcell(const VTermScreen *screen, ScreenCell *cell)
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
78 {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
79 cell->chars[0] = 0;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
80 cell->pen = screen->pen;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
81 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
82
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 static ScreenCell *getcell(const VTermScreen *screen, int row, int col)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 if(row < 0 || row >= screen->rows)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 return NULL;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 if(col < 0 || col >= screen->cols)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 return NULL;
18162
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18064
diff changeset
89 if (screen->buffer == NULL)
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18064
diff changeset
90 return NULL;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 return screen->buffer + (screen->cols * row) + col;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
94 static ScreenCell *alloc_buffer(VTermScreen *screen, int rows, int cols)
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 {
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
96 ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * rows * cols);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
98 for(int row = 0; row < rows; row++) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
99 for(int col = 0; col < cols; col++) {
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
100 clearcell(screen, &new_buffer[row * cols + col]);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 return new_buffer;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 static void damagerect(VTermScreen *screen, VTermRect rect)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 VTermRect emit;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 switch(screen->damage_merge) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 case VTERM_DAMAGE_CELL:
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
113 /* Always emit damage event */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 emit = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 case VTERM_DAMAGE_ROW:
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
118 /* Emit damage longer than one row. Try to merge with existing damage in
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
119 * the same row */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 if(rect.end_row > rect.start_row + 1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 // Bigger than 1 line - flush existing, emit this
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 emit = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 else if(screen->damaged.start_row == -1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 // None stored yet
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 screen->damaged = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 return;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 else if(rect.start_row == screen->damaged.start_row) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 // Merge with the stored line
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 if(screen->damaged.start_col > rect.start_col)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 screen->damaged.start_col = rect.start_col;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 if(screen->damaged.end_col < rect.end_col)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 screen->damaged.end_col = rect.end_col;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 return;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 else {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 // Emit the currently stored line, store a new one
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 emit = screen->damaged;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 screen->damaged = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 case VTERM_DAMAGE_SCREEN:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 case VTERM_DAMAGE_SCROLL:
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
147 /* Never emit damage event */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 if(screen->damaged.start_row == -1)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 screen->damaged = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 else {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 rect_expand(&screen->damaged, &rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 return;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 default:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 DEBUG_LOG1("TODO: Maybe merge damage for level %d\n", screen->damage_merge);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 return;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 if(screen->callbacks && screen->callbacks->damage)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 (*screen->callbacks->damage)(emit, screen->cbdata);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 static void damagescreen(VTermScreen *screen)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 VTermRect rect = {0,0,0,0};
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 rect.end_row = screen->rows;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 rect.end_col = screen->cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 damagerect(screen, rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 static int putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 ScreenCell *cell = getcell(screen, pos.row, pos.col);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 if(!cell)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
181 int i;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 for(i = 0; i < VTERM_MAX_CHARS_PER_CELL && info->chars[i]; i++) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 cell->chars[i] = info->chars[i];
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 cell->pen = screen->pen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 if(i < VTERM_MAX_CHARS_PER_CELL)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 cell->chars[i] = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
189 for(int col = 1; col < info->width; col++)
21606
66618893eb2a patch 8.2.1353: crash when drawing double-wide character in terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20957
diff changeset
190 {
66618893eb2a patch 8.2.1353: crash when drawing double-wide character in terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20957
diff changeset
191 ScreenCell *onecell = getcell(screen, pos.row, pos.col + col);
66618893eb2a patch 8.2.1353: crash when drawing double-wide character in terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20957
diff changeset
192 if (onecell == NULL)
66618893eb2a patch 8.2.1353: crash when drawing double-wide character in terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20957
diff changeset
193 break;
66618893eb2a patch 8.2.1353: crash when drawing double-wide character in terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20957
diff changeset
194 onecell->chars[0] = (uint32_t)-1;
66618893eb2a patch 8.2.1353: crash when drawing double-wide character in terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20957
diff changeset
195 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
197 VTermRect rect;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 rect.start_row = pos.row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 rect.end_row = pos.row+1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 rect.start_col = pos.col;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 rect.end_col = pos.col+info->width;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 cell->pen.protected_cell = info->protected_cell;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 cell->pen.dwl = info->dwl;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 cell->pen.dhl = info->dhl;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 damagerect(screen, rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
212 static void sb_pushline_from_row(VTermScreen *screen, int row)
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
213 {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
214 VTermPos pos;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
215 pos.row = row;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
216 for(pos.col = 0; pos.col < screen->cols; pos.col++)
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
217 vterm_screen_get_cell(screen, pos, screen->sb_buffer + pos.col);
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
218
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
219 (screen->callbacks->sb_pushline)(screen->cols, screen->sb_buffer, screen->cbdata);
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
220 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
221
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 static int moverect_internal(VTermRect dest, VTermRect src, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 if(screen->callbacks && screen->callbacks->sb_pushline &&
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
227 dest.start_row == 0 && dest.start_col == 0 && // starts top-left corner
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
228 dest.end_col == screen->cols && // full width
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
229 screen->buffer == screen->buffers[BUFIDX_PRIMARY]) { // not altscreen
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
230 for(int row = 0; row < src.start_row; row++)
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
231 sb_pushline_from_row(screen, row);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
234 int cols = src.end_col - src.start_col;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
235 int downward = src.start_row - dest.start_row;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
237 int init_row, test_row, inc_row;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
238 if(downward < 0) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
239 init_row = dest.end_row - 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
240 test_row = dest.start_row - 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
241 inc_row = -1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
242 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
243 else {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
244 init_row = dest.start_row;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
245 test_row = dest.end_row;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
246 inc_row = +1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
247 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
249 for(int row = init_row; row != test_row; row += inc_row)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
250 memmove(getcell(screen, row, dest.start_col),
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
251 getcell(screen, row + downward, src.start_col),
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
252 cols * sizeof(ScreenCell));
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 static int moverect_user(VTermRect dest, VTermRect src, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 if(screen->callbacks && screen->callbacks->moverect) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262 if(screen->damage_merge != VTERM_DAMAGE_SCROLL)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 // Avoid an infinite loop
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 if((*screen->callbacks->moverect)(dest, src, screen->cbdata))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 damagerect(screen, dest);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 static int erase_internal(VTermRect rect, int selective, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
279 for(int row = rect.start_row; row < screen->state->rows && row < rect.end_row; row++) {
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 const VTermLineInfo *info = vterm_state_get_lineinfo(screen->state, row);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
282 for(int col = rect.start_col; col < rect.end_col; col++) {
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 ScreenCell *cell = getcell(screen, row, col);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
284
20875
88cec48503b8 patch 8.2.0989: crash after resizing a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
285 if (cell == NULL)
88cec48503b8 patch 8.2.0989: crash after resizing a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
286 {
88cec48503b8 patch 8.2.0989: crash after resizing a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
287 DEBUG_LOG2("libvterm: erase_internal() position invalid: %d / %d",
88cec48503b8 patch 8.2.0989: crash after resizing a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
288 row, col);
88cec48503b8 patch 8.2.0989: crash after resizing a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
289 return 1;
88cec48503b8 patch 8.2.0989: crash after resizing a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
290 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291 if(selective && cell->pen.protected_cell)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 continue;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 cell->chars[0] = 0;
32728
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
295 cell->pen = (ScreenPen){
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
296 /* Only copy .fg and .bg; leave things like rv in reset state */
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
297 .fg = screen->pen.fg,
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
298 .bg = screen->pen.bg,
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
299 };
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 cell->pen.dwl = info->doublewidth;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 cell->pen.dhl = info->doubleheight;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308 static int erase_user(VTermRect rect, int selective UNUSED, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312 damagerect(screen, rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 static int erase(VTermRect rect, int selective, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319 erase_internal(rect, selective, user);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320 return erase_user(rect, 0, user);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 static int scrollrect(VTermRect rect, int downward, int rightward, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327 if(screen->damage_merge != VTERM_DAMAGE_SCROLL) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 vterm_scroll_rect(rect, downward, rightward,
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 moverect_internal, erase_internal, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 vterm_scroll_rect(rect, downward, rightward,
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334 moverect_user, erase_user, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 if(screen->damaged.start_row != -1 &&
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 !rect_intersects(&rect, &screen->damaged)) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344 if(screen->pending_scrollrect.start_row == -1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 screen->pending_scrollrect = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 screen->pending_scroll_downward = downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 screen->pending_scroll_rightward = rightward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 else if(rect_equal(&screen->pending_scrollrect, &rect) &&
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 ((screen->pending_scroll_downward == 0 && downward == 0) ||
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 (screen->pending_scroll_rightward == 0 && rightward == 0))) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 screen->pending_scroll_downward += downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 screen->pending_scroll_rightward += rightward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 else {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 screen->pending_scrollrect = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 screen->pending_scroll_downward = downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 screen->pending_scroll_rightward = rightward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 vterm_scroll_rect(rect, downward, rightward,
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 moverect_internal, erase_internal, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 if(screen->damaged.start_row == -1)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 if(rect_contains(&rect, &screen->damaged)) {
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
370 /* Scroll region entirely contains the damage; just move it */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 vterm_rect_move(&screen->damaged, -downward, -rightward);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 rect_clip(&screen->damaged, &rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 }
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
374 /* There are a number of possible cases here, but lets restrict this to only
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
375 * the common case where we might actually gain some performance by
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
376 * optimising it. Namely, a vertical scroll that neatly cuts the damage
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
377 * region in half.
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
378 */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379 else if(rect.start_col <= screen->damaged.start_col &&
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 rect.end_col >= screen->damaged.end_col &&
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 rightward == 0) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 if(screen->damaged.start_row >= rect.start_row &&
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 screen->damaged.start_row < rect.end_row) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 screen->damaged.start_row -= downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 if(screen->damaged.start_row < rect.start_row)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 screen->damaged.start_row = rect.start_row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 if(screen->damaged.start_row > rect.end_row)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 screen->damaged.start_row = rect.end_row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390 if(screen->damaged.end_row >= rect.start_row &&
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391 screen->damaged.end_row < rect.end_row) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 screen->damaged.end_row -= downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 if(screen->damaged.end_row < rect.start_row)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 screen->damaged.end_row = rect.start_row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395 if(screen->damaged.end_row > rect.end_row)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 screen->damaged.end_row = rect.end_row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 else {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 DEBUG_LOG2("TODO: Just flush and redo damaged=" STRFrect " rect=" STRFrect "\n",
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 ARGSrect(screen->damaged), ARGSrect(rect));
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 static int movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 if(screen->callbacks && screen->callbacks->movecursor)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 return (*screen->callbacks->movecursor)(pos, oldpos, visible, screen->cbdata);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 static int setpenattr(VTermAttr attr, VTermValue *val, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 switch(attr) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422 case VTERM_ATTR_BOLD:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423 screen->pen.bold = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 case VTERM_ATTR_UNDERLINE:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 screen->pen.underline = val->number;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 case VTERM_ATTR_ITALIC:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 screen->pen.italic = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 case VTERM_ATTR_BLINK:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 screen->pen.blink = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
433 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 case VTERM_ATTR_REVERSE:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435 screen->pen.reverse = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 return 1;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
437 case VTERM_ATTR_CONCEAL:
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
438 screen->pen.conceal = val->boolean;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
439 return 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 case VTERM_ATTR_STRIKE:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 screen->pen.strike = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 case VTERM_ATTR_FONT:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 screen->pen.font = val->number;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446 case VTERM_ATTR_FOREGROUND:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 screen->pen.fg = val->color;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449 case VTERM_ATTR_BACKGROUND:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450 screen->pen.bg = val->color;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 return 1;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
452 case VTERM_ATTR_SMALL:
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
453 screen->pen.small = val->boolean;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
454 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
455 case VTERM_ATTR_BASELINE:
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
456 screen->pen.baseline = val->number;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
457 return 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 case VTERM_N_ATTRS:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
465
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
466 static int settermprop(VTermProp prop, VTermValue *val, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 switch(prop) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471 case VTERM_PROP_ALTSCREEN:
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
472 if(val->boolean && !screen->buffers[BUFIDX_ALTSCREEN])
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
475 screen->buffer = val->boolean ? screen->buffers[BUFIDX_ALTSCREEN] : screen->buffers[BUFIDX_PRIMARY];
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
476 /* only send a damage event on disable; because during enable there's an
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
477 * erase that sends a damage anyway
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
478 */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479 if(!val->boolean)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 damagescreen(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482 case VTERM_PROP_REVERSE:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
483 screen->global_reverse = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 damagescreen(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 default:
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
487 ; /* ignore */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
488 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 if(screen->callbacks && screen->callbacks->settermprop)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491 return (*screen->callbacks->settermprop)(prop, val, screen->cbdata);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
493 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
495
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
496 static int bell(void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
499
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500 if(screen->callbacks && screen->callbacks->bell)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501 return (*screen->callbacks->bell)(screen->cbdata);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
504 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
505
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
506 /* How many cells are non-blank
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
507 * Returns the position of the first blank cell in the trailing blank end */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
508 static int line_popcount(ScreenCell *buffer, int row, int rows UNUSED, int cols)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
509 {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
510 int col = cols - 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
511 while(col >= 0 && buffer[row * cols + col].chars[0] == 0)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
512 col--;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
513 return col + 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
514 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
515
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
516 #define REFLOW (screen->reflow)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
517
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
518 static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new_cols, int active, VTermStateFields *statefields)
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
519 {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
520 int old_rows = screen->rows;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
521 int old_cols = screen->cols;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
522
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
523 ScreenCell *old_buffer = screen->buffers[bufidx];
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
524 VTermLineInfo *old_lineinfo = statefields->lineinfos[bufidx];
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
525
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
526 ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols);
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
527 VTermLineInfo *new_lineinfo = vterm_allocator_malloc(screen->vt, sizeof(new_lineinfo[0]) * new_rows);
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
528
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
529 // Find the final row of old buffer content
20482
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20480
diff changeset
530 int old_row = old_rows - 1;
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20480
diff changeset
531 int new_row = new_rows - 1;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
532
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
533 VTermPos old_cursor = statefields->pos;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
534 VTermPos new_cursor = { -1, -1 };
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
535
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
536 #ifdef DEBUG_REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
537 fprintf(stderr, "Resizing from %dx%d to %dx%d; cursor was at (%d,%d)\n",
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
538 old_cols, old_rows, new_cols, new_rows, old_cursor.col, old_cursor.row);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
539 #endif
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
540
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
541 /* Keep track of the final row that is knonw to be blank, so we know what
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
542 * spare space we have for scrolling into
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
543 */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
544 int final_blank_row = new_rows;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
545
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
546 while(old_row >= 0) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
547 int old_row_end = old_row;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
548 /* TODO: Stop if dwl or dhl */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
549 while(REFLOW && old_lineinfo && old_row >= 0 && old_lineinfo[old_row].continuation)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
550 old_row--;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
551 int old_row_start = old_row;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
552
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
553 int width = 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
554 for(int row = old_row_start; row <= old_row_end; row++) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
555 if(REFLOW && row < (old_rows - 1) && old_lineinfo[row + 1].continuation)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
556 width += old_cols;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
557 else
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
558 width += line_popcount(old_buffer, row, old_rows, old_cols);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
559 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
560
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
561 if(final_blank_row == (new_row + 1) && width == 0)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
562 final_blank_row = new_row;
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
563
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
564 int new_height = REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
565 ? width ? (width + new_cols - 1) / new_cols : 1
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
566 : 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
567
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
568 int new_row_end = new_row;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
569 int new_row_start = new_row - new_height + 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
570
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
571 old_row = old_row_start;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
572 int old_col = 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
573
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
574 int spare_rows = new_rows - final_blank_row;
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
575
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
576 if(new_row_start < 0 && /* we'd fall off the top */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
577 spare_rows >= 0 && /* we actually have spare rows */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
578 (!active || new_cursor.row == -1 || (new_cursor.row - new_row_start) < new_rows))
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
579 {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
580 /* Attempt to scroll content down into the blank rows at the bottom to
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
581 * make it fit
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
582 */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
583 int downwards = -new_row_start;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
584 if(downwards > spare_rows)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
585 downwards = spare_rows;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
586 int rowcount = new_rows - downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
587
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
588 #ifdef DEBUG_REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
589 fprintf(stderr, " scroll %d rows +%d downwards\n", rowcount, downwards);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
590 #endif
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
591
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
592 memmove(&new_buffer[downwards * new_cols], &new_buffer[0], rowcount * new_cols * sizeof(ScreenCell));
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
593 memmove(&new_lineinfo[downwards], &new_lineinfo[0], rowcount * sizeof(new_lineinfo[0]));
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
594
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
595 new_row += downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
596 new_row_start += downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
597 new_row_end += downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
598
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
599 if(new_cursor.row >= 0)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
600 new_cursor.row += downwards;
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
601
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
602 final_blank_row += downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
603 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
604
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
605 #ifdef DEBUG_REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
606 fprintf(stderr, " rows [%d..%d] <- [%d..%d] width=%d\n",
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
607 new_row_start, new_row_end, old_row_start, old_row_end, width);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
608 #endif
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
609
32728
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
610 if(new_row_start < 0) {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
611 if(old_row_start <= old_cursor.row && old_cursor.row < old_row_end) {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
612 new_cursor.row = 0;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
613 new_cursor.col = old_cursor.col;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
614 if(new_cursor.col >= new_cols)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
615 new_cursor.col = new_cols-1;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
616 }
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
617 break;
32728
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
618 }
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
619
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
620 for(new_row = new_row_start, old_row = old_row_start; new_row <= new_row_end; new_row++) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
621 int count = width >= new_cols ? new_cols : width;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
622 width -= count;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
623
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
624 int new_col = 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
625
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
626 while(count) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
627 /* TODO: This could surely be done a lot faster by memcpy()'ing the entire range */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
628 new_buffer[new_row * new_cols + new_col] = old_buffer[old_row * old_cols + old_col];
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
629
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
630 if(old_cursor.row == old_row && old_cursor.col == old_col)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
631 new_cursor.row = new_row, new_cursor.col = new_col;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
632
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
633 old_col++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
634 if(old_col == old_cols) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
635 old_row++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
636
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
637 if(!REFLOW) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
638 new_col++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
639 break;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
640 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
641 old_col = 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
642 }
20482
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20480
diff changeset
643
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
644 new_col++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
645 count--;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
646 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
647
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
648 if(old_cursor.row == old_row && old_cursor.col >= old_col) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
649 new_cursor.row = new_row, new_cursor.col = (old_cursor.col - old_col + new_col);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
650 if(new_cursor.col >= new_cols)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
651 new_cursor.col = new_cols-1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
652 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
653
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
654 while(new_col < new_cols) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
655 clearcell(screen, &new_buffer[new_row * new_cols + new_col]);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
656 new_col++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
657 }
20482
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20480
diff changeset
658
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
659 new_lineinfo[new_row].continuation = (new_row > new_row_start);
20482
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20480
diff changeset
660 }
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
661
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
662 old_row = old_row_start - 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
663 new_row = new_row_start - 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
664 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
665
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
666 if(old_cursor.row <= old_row) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
667 /* cursor would have moved entirely off the top of the screen; lets just
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
668 * bring it within range */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
669 new_cursor.row = 0, new_cursor.col = old_cursor.col;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
670 if(new_cursor.col >= new_cols)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
671 new_cursor.col = new_cols-1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
672 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
673
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
674 /* We really expect the cursor position to be set by now */
31433
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
675 /* Unfortunately we do get here when "new_rows" is one. We don't want
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
676 * to crash, so until the above code is fixed let's just set the cursor. */
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
677 if(active && (new_cursor.row == -1 || new_cursor.col == -1)) {
31433
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
678 /* fprintf(stderr, "screen_resize failed to update cursor position\n");
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
679 * abort(); */
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
680 if (new_cursor.row < 0)
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
681 new_cursor.row = 0;
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
682 if (new_cursor.col < 0)
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
683 new_cursor.col = 0;
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
684 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
685
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
686 if(old_row >= 0 && bufidx == BUFIDX_PRIMARY) {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
687 /* Push spare lines to scrollback buffer */
32728
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
688 if(screen->callbacks && screen->callbacks->sb_pushline)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
689 for(int row = 0; row <= old_row; row++)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
690 sb_pushline_from_row(screen, row);
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
691 if(active)
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
692 statefields->pos.row -= (old_row + 1);
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
693 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
694 if(new_row >= 0 && bufidx == BUFIDX_PRIMARY &&
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
695 screen->callbacks && screen->callbacks->sb_popline) {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
696 /* Try to backfill rows by popping scrollback buffer */
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
697 while(new_row >= 0) {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
698 VTermPos pos;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
699 if(!(screen->callbacks->sb_popline(old_cols, screen->sb_buffer, screen->cbdata)))
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
700 break;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
701
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
702 pos.row = new_row;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
703 for(pos.col = 0; pos.col < old_cols && pos.col < new_cols; pos.col += screen->sb_buffer[pos.col].width) {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
704 VTermScreenCell *src = &screen->sb_buffer[pos.col];
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
705 ScreenCell *dst = &new_buffer[pos.row * new_cols + pos.col];
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
706
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
707 for(int i = 0; i < VTERM_MAX_CHARS_PER_CELL; i++) {
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
708 dst->chars[i] = src->chars[i];
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
709 if(!src->chars[i])
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
710 break;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
711 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
712
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
713 dst->pen.bold = src->attrs.bold;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
714 dst->pen.underline = src->attrs.underline;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
715 dst->pen.italic = src->attrs.italic;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
716 dst->pen.blink = src->attrs.blink;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
717 dst->pen.reverse = src->attrs.reverse ^ screen->global_reverse;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
718 dst->pen.conceal = src->attrs.conceal;
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
719 dst->pen.strike = src->attrs.strike;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
720 dst->pen.font = src->attrs.font;
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
721 dst->pen.small = src->attrs.small;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
722 dst->pen.baseline = src->attrs.baseline;
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
723
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
724 dst->pen.fg = src->fg;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
725 dst->pen.bg = src->bg;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
726
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
727 if(src->width == 2 && pos.col < (new_cols-1))
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
728 (dst + 1)->chars[0] = (uint32_t) -1;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
729 }
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
730 for( ; pos.col < new_cols; pos.col++)
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
731 clearcell(screen, &new_buffer[pos.row * new_cols + pos.col]);
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
732 new_row--;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
733
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
734 if(active)
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
735 statefields->pos.row++;
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
736 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
737 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
738 if(new_row >= 0) {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
739 /* Scroll new rows back up to the top and fill in blanks at the bottom */
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
740 int moverows = new_rows - new_row - 1;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
741 memmove(&new_buffer[0], &new_buffer[(new_row + 1) * new_cols], moverows * new_cols * sizeof(ScreenCell));
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
742 memmove(&new_lineinfo[0], &new_lineinfo[new_row + 1], moverows * sizeof(new_lineinfo[0]));
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
743
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
744 new_cursor.row -= (new_row + 1);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
745
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
746 for(new_row = moverows; new_row < new_rows; new_row++) {
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
747 for(int col = 0; col < new_cols; col++)
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
748 clearcell(screen, &new_buffer[new_row * new_cols + col]);
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
749 new_lineinfo[new_row] = (VTermLineInfo){ 0 };
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
750 }
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
751 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
752
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
753 vterm_allocator_free(screen->vt, old_buffer);
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
754 screen->buffers[bufidx] = new_buffer;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
755
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
756 vterm_allocator_free(screen->vt, old_lineinfo);
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
757 statefields->lineinfos[bufidx] = new_lineinfo;
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
758
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
759 if(active)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
760 statefields->pos = new_cursor;
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
761
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
762 return;
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
763 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
764
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
765 static int resize(int new_rows, int new_cols, VTermStateFields *fields, void *user)
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
766 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
769 int altscreen_active = (screen->buffers[BUFIDX_ALTSCREEN] && screen->buffer == screen->buffers[BUFIDX_ALTSCREEN]);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
771 int old_rows = screen->rows;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 int old_cols = screen->cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
773
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
774 if(new_cols > old_cols) {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
775 /* Ensure that ->sb_buffer is large enough for a new or and old row */
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
776 if(screen->sb_buffer)
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
777 vterm_allocator_free(screen->vt, screen->sb_buffer);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
778
33324
288bbf09d372 patch 9.0.1927: patch 1916 (fixed terminal size) not optimal
Christian Brabandt <cb@256bit.org>
parents: 33301
diff changeset
779 if (new_cols > VTERM_MAX_COLS)
288bbf09d372 patch 9.0.1927: patch 1916 (fixed terminal size) not optimal
Christian Brabandt <cb@256bit.org>
parents: 33301
diff changeset
780 new_cols = VTERM_MAX_COLS;
33301
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 32728
diff changeset
781
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
782 screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * new_cols);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784
33324
288bbf09d372 patch 9.0.1927: patch 1916 (fixed terminal size) not optimal
Christian Brabandt <cb@256bit.org>
parents: 33301
diff changeset
785 if (new_rows > VTERM_MAX_ROWS)
288bbf09d372 patch 9.0.1927: patch 1916 (fixed terminal size) not optimal
Christian Brabandt <cb@256bit.org>
parents: 33301
diff changeset
786 new_rows = VTERM_MAX_ROWS;
33301
1bc6f0899715 patch 9.0.1916: Crash when allocating large terminal screen
Christian Brabandt <cb@256bit.org>
parents: 32728
diff changeset
787
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
788 resize_buffer(screen, 0, new_rows, new_cols, !altscreen_active, fields);
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
789 if(screen->buffers[BUFIDX_ALTSCREEN])
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
790 resize_buffer(screen, 1, new_rows, new_cols, altscreen_active, fields);
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
791 else if(new_rows != old_rows) {
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
792 /* We don't need a full resize of the altscreen because it isn't enabled
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
793 * but we should at least keep the lineinfo the right size */
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
794 vterm_allocator_free(screen->vt, fields->lineinfos[BUFIDX_ALTSCREEN]);
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
795
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
796 VTermLineInfo *new_lineinfo = vterm_allocator_malloc(screen->vt, sizeof(new_lineinfo[0]) * new_rows);
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
797 for(int row = 0; row < new_rows; row++)
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
798 new_lineinfo[row] = (VTermLineInfo){ 0 };
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
799
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
800 fields->lineinfos[BUFIDX_ALTSCREEN] = new_lineinfo;
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
801 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
802
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
803 screen->buffer = altscreen_active ? screen->buffers[BUFIDX_ALTSCREEN] : screen->buffers[BUFIDX_PRIMARY];
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
804
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
805 screen->rows = new_rows;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 screen->cols = new_cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
807
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
808 if(new_cols <= old_cols) {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
809 if(screen->sb_buffer)
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
810 vterm_allocator_free(screen->vt, screen->sb_buffer);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
811
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
812 screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * new_cols);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
813 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
815 /* TODO: Maaaaybe we can optimise this if there's no reflow happening */
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
816 damagescreen(screen);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
817
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
818 if(screen->callbacks && screen->callbacks->resize)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819 return (*screen->callbacks->resize)(new_rows, new_cols, screen->cbdata);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
820
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
823
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 static int setlineinfo(int row, const VTermLineInfo *newinfo, const VTermLineInfo *oldinfo, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828 if(newinfo->doublewidth != oldinfo->doublewidth ||
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829 newinfo->doubleheight != oldinfo->doubleheight) {
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
830 for(int col = 0; col < screen->cols; col++) {
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
831 ScreenCell *cell = getcell(screen, row, col);
20957
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
832 if (cell == NULL)
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
833 {
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
834 DEBUG_LOG2("libvterm: setlineinfo() position invalid: %d / %d",
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
835 row, col);
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
836 return 1;
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
837 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838 cell->pen.dwl = newinfo->doublewidth;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839 cell->pen.dhl = newinfo->doubleheight;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
840 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
841
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
842 VTermRect rect;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
843 rect.start_row = row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
844 rect.end_row = row + 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
845 rect.start_col = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
846 rect.end_col = newinfo->doublewidth ? screen->cols / 2 : screen->cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847 damagerect(screen, rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
848
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
849 if(newinfo->doublewidth) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
850 rect.start_col = screen->cols / 2;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851 rect.end_col = screen->cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
853 erase_internal(rect, 0, user);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
854 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
855 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
856
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
857 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
858 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
859
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
860 static int sb_clear(void *user) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
861 VTermScreen *screen = user;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
862
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
863 if(screen->callbacks && screen->callbacks->sb_clear)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
864 if((*screen->callbacks->sb_clear)(screen->cbdata))
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
865 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
866
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
867 return 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
868 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
869
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
870 static VTermStateCallbacks state_cbs = {
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
871 &putglyph, // putglyph
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
872 &movecursor, // movecursor
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
873 &scrollrect, // scrollrect
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
874 NULL, // moverect
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
875 &erase, // erase
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
876 NULL, // initpen
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
877 &setpenattr, // setpenattr
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
878 &settermprop, // settermprop
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
879 &bell, // bell
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
880 &resize, // resize
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
881 &setlineinfo, // setlineinfo
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
882 &sb_clear, //sb_clear
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 };
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884
15249
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
885 /*
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
886 * Allocate a new screen and return it.
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
887 * Return NULL when out of memory.
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
888 */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
889 static VTermScreen *screen_new(VTerm *vt)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891 VTermState *state = vterm_obtain_state(vt);
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
892 if(!state)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
893 return NULL;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
894
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
895 VTermScreen *screen = vterm_allocator_malloc(vt, sizeof(VTermScreen));
15249
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
896 if (screen == NULL)
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
897 return NULL;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
898 int rows, cols;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
899
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
900 vterm_get_size(vt, &rows, &cols);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
901
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 screen->vt = vt;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
903 screen->state = state;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905 screen->damage_merge = VTERM_DAMAGE_CELL;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
906 screen->damaged.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
907 screen->pending_scrollrect.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
908
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
909 screen->rows = rows;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910 screen->cols = cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
912 screen->global_reverse = FALSE;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
913 screen->reflow = FALSE;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
914
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
915 screen->callbacks = NULL;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 screen->cbdata = NULL;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
917
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
918 screen->buffers[BUFIDX_PRIMARY] = alloc_buffer(screen, rows, cols);
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
919
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
920 screen->buffer = screen->buffers[BUFIDX_PRIMARY];
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
921
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
922 screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * cols);
15249
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
923 if (screen->buffer == NULL || screen->sb_buffer == NULL)
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
924 {
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
925 vterm_screen_free(screen);
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
926 return NULL;
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
927 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
928
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
929 vterm_state_set_callbacks(screen->state, &state_cbs, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
930
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
931 return screen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
932 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
933
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
934 INTERNAL void vterm_screen_free(VTermScreen *screen)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 {
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
936 vterm_allocator_free(screen->vt, screen->buffers[BUFIDX_PRIMARY]);
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
937 if(screen->buffers[BUFIDX_ALTSCREEN])
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
938 vterm_allocator_free(screen->vt, screen->buffers[BUFIDX_ALTSCREEN]);
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
939
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940 vterm_allocator_free(screen->vt, screen->sb_buffer);
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
941
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
942 vterm_allocator_free(screen->vt, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
943 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
944
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
945 void vterm_screen_reset(VTermScreen *screen, int hard)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
946 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
947 screen->damaged.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
948 screen->pending_scrollrect.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
949 vterm_state_reset(screen->state, hard);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
950 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
951 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
952
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
953 static size_t _get_chars(const VTermScreen *screen, const int utf8, void *buffer, size_t len, const VTermRect rect)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
955 size_t outpos = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
956 int padding = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
957
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958 #define PUT(c) \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
959 if(utf8) { \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
960 size_t thislen = utf8_seqlen(c); \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
961 if(buffer && outpos + thislen <= len) \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
962 outpos += fill_utf8((c), (char *)buffer + outpos); \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
963 else \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
964 outpos += thislen; \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
965 } \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
966 else { \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
967 if(buffer && outpos + 1 <= len) \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
968 ((uint32_t*)buffer)[outpos++] = (c); \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
969 else \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
970 outpos++; \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
971 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
972
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
973 for(int row = rect.start_row; row < rect.end_row; row++) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
974 for(int col = rect.start_col; col < rect.end_col; col++) {
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
975 ScreenCell *cell = getcell(screen, row, col);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
976
20957
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
977 if (cell == NULL)
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
978 {
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
979 DEBUG_LOG2("libvterm: _get_chars() position invalid: %d / %d",
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
980 row, col);
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
981 return 1;
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
982 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
983 if(cell->chars[0] == 0)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
984 // Erased cell, might need a space
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
985 padding++;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
986 else if(cell->chars[0] == (uint32_t)-1)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
987 // Gap behind a double-width char, do nothing
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
988 ;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
989 else {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
990 while(padding) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
991 PUT(UNICODE_SPACE);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
992 padding--;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
993 }
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
994 for(int i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell->chars[i]; i++) {
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
995 PUT(cell->chars[i]);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
996 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
997 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
998 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
999
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1000 if(row < rect.end_row - 1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1001 PUT(UNICODE_LINEFEED);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1002 padding = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1003 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1004 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1005
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1006 return outpos;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1007 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1008
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1009 size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRect rect)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1010 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1011 return _get_chars(screen, 0, chars, len, rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1012 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1013
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1014 size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1015 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1016 return _get_chars(screen, 1, str, len, rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1017 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1018
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
1019 /* Copy internal to external representation of a screen cell */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1020 int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCell *cell)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1021 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1022 ScreenCell *intcell = getcell(screen, pos.row, pos.col);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1023
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1024 if(!intcell)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1025 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1026
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1027 for(int i = 0; i < VTERM_MAX_CHARS_PER_CELL; i++) {
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1028 cell->chars[i] = intcell->chars[i];
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1029 if(!intcell->chars[i])
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1030 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1031 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1032
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1033 cell->attrs.bold = intcell->pen.bold;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1034 cell->attrs.underline = intcell->pen.underline;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1035 cell->attrs.italic = intcell->pen.italic;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1036 cell->attrs.blink = intcell->pen.blink;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1037 cell->attrs.reverse = intcell->pen.reverse ^ screen->global_reverse;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
1038 cell->attrs.conceal = intcell->pen.conceal;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1039 cell->attrs.strike = intcell->pen.strike;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1040 cell->attrs.font = intcell->pen.font;
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
1041 cell->attrs.small = intcell->pen.small;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1042 cell->attrs.baseline = intcell->pen.baseline;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1043
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1044 cell->attrs.dwl = intcell->pen.dwl;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1045 cell->attrs.dhl = intcell->pen.dhl;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1046
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1047 cell->fg = intcell->pen.fg;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1048 cell->bg = intcell->pen.bg;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1049
18064
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1050 if(vterm_get_special_pty_type() == 2) {
18802
3be01cf0a632 patch 8.1.2389: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18267
diff changeset
1051 // Get correct cell width from cell information contained in line buffer
18064
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1052 if(pos.col < (screen->cols - 1) &&
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1053 getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) {
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1054 if(getcell(screen, pos.row, pos.col)->chars[0] == 0x20) {
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1055 getcell(screen, pos.row, pos.col)->chars[0] = 0;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1056 cell->width = 2;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1057 } else if(getcell(screen, pos.row, pos.col)->chars[0] == 0) {
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1058 getcell(screen, pos.row, pos.col + 1)->chars[0] = 0;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1059 cell->width = 1;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1060 } else {
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1061 cell->width = 2;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1062 }
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1063 } else
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1064 cell->width = 1;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1065 } else {
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1066 if(pos.col < (screen->cols - 1) &&
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1067 getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1)
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1068 cell->width = 2;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1069 else
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1070 cell->width = 1;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1071 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1072
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1073 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1074 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1075
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1076 int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1077 {
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
1078 /* This cell is EOL if this and every cell to the right is black */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1079 for(; pos.col < screen->cols; pos.col++) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1080 ScreenCell *cell = getcell(screen, pos.row, pos.col);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1081 if(cell->chars[0] != 0)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1082 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1083 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1084
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1085 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1086 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1087
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1088 VTermScreen *vterm_obtain_screen(VTerm *vt)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1089 {
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1090 if(vt->screen)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1091 return vt->screen;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1092
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1093 vt->screen = screen_new(vt);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1094 return vt->screen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1095 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1096
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1097 void vterm_screen_enable_reflow(VTermScreen *screen, int reflow)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1098 {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1099 screen->reflow = reflow;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1100 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1101
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1102 // Removed, causes a compiler warning and isn't used
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1103 // #undef vterm_screen_set_reflow
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1104 // void vterm_screen_set_reflow(VTermScreen *screen, int reflow)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1105 // {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1106 // vterm_screen_enable_reflow(screen, reflow);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1107 // }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1108
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1109 void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 {
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
1111 if(!screen->buffers[BUFIDX_ALTSCREEN] && altscreen) {
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1112 int rows, cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1113 vterm_get_size(screen->vt, &rows, &cols);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
1115 screen->buffers[BUFIDX_ALTSCREEN] = alloc_buffer(screen, rows, cols);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1116 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1117 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1118
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1119 void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1120 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1121 screen->callbacks = callbacks;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 screen->cbdata = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1123 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1124
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 void *vterm_screen_get_cbdata(VTermScreen *screen)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1126 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1127 return screen->cbdata;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1128 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1129
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
1130 void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermStateFallbacks *fallbacks, void *user)
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1131 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1132 vterm_state_set_unrecognised_fallbacks(screen->state, fallbacks, user);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1133 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1134
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1135 void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1136 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1137 return vterm_state_get_unrecognised_fbdata(screen->state);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1138 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1139
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1140 void vterm_screen_flush_damage(VTermScreen *screen)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1141 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1142 if(screen->pending_scrollrect.start_row != -1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1143 vterm_scroll_rect(screen->pending_scrollrect, screen->pending_scroll_downward, screen->pending_scroll_rightward,
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1144 moverect_user, erase_user, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1145
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1146 screen->pending_scrollrect.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1147 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1148
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1149 if(screen->damaged.start_row != -1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1150 if(screen->callbacks && screen->callbacks->damage)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1151 (*screen->callbacks->damage)(screen->damaged, screen->cbdata);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1152
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1153 screen->damaged.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1154 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1155 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1156
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1157 void vterm_screen_set_damage_merge(VTermScreen *screen, VTermDamageSize size)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1158 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1159 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1160 screen->damage_merge = size;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1161 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1162
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1163 static int attrs_differ(VTermAttrMask attrs, ScreenCell *a, ScreenCell *b)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1164 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1165 if((attrs & VTERM_ATTR_BOLD_MASK) && (a->pen.bold != b->pen.bold))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1166 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1167 if((attrs & VTERM_ATTR_UNDERLINE_MASK) && (a->pen.underline != b->pen.underline))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1168 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1169 if((attrs & VTERM_ATTR_ITALIC_MASK) && (a->pen.italic != b->pen.italic))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1170 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1171 if((attrs & VTERM_ATTR_BLINK_MASK) && (a->pen.blink != b->pen.blink))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1172 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1173 if((attrs & VTERM_ATTR_REVERSE_MASK) && (a->pen.reverse != b->pen.reverse))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1174 return 1;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
1175 if((attrs & VTERM_ATTR_CONCEAL_MASK) && (a->pen.conceal != b->pen.conceal))
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
1176 return 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1177 if((attrs & VTERM_ATTR_STRIKE_MASK) && (a->pen.strike != b->pen.strike))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1178 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1179 if((attrs & VTERM_ATTR_FONT_MASK) && (a->pen.font != b->pen.font))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1180 return 1;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1181 if((attrs & VTERM_ATTR_FOREGROUND_MASK) && !vterm_color_is_equal(&a->pen.fg, &b->pen.fg))
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1182 return 1;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1183 if((attrs & VTERM_ATTR_BACKGROUND_MASK) && !vterm_color_is_equal(&a->pen.bg, &b->pen.bg))
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1184 return 1;
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
1185 if((attrs & VTERM_ATTR_SMALL_MASK) && (a->pen.small != b->pen.small))
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1186 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1187 if((attrs & VTERM_ATTR_BASELINE_MASK) && (a->pen.baseline != b->pen.baseline))
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1188 return 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1189
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1190 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1191 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1192
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1193 int vterm_screen_get_attrs_extent(const VTermScreen *screen, VTermRect *extent, VTermPos pos, VTermAttrMask attrs)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1194 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1195 ScreenCell *target = getcell(screen, pos.row, pos.col);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1196
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1197 // TODO: bounds check
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1198 extent->start_row = pos.row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1199 extent->end_row = pos.row + 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1200
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1201 if(extent->start_col < 0)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1202 extent->start_col = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1203 if(extent->end_col < 0)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1204 extent->end_col = screen->cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1205
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1206 int col;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1207
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1208 for(col = pos.col - 1; col >= extent->start_col; col--)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1209 if(attrs_differ(attrs, target, getcell(screen, pos.row, col)))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1210 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1211 extent->start_col = col + 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1212
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1213 for(col = pos.col + 1; col < extent->end_col; col++)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1214 if(attrs_differ(attrs, target, getcell(screen, pos.row, col)))
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1215 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1216 extent->end_col = col - 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1217
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1218 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1219 }
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1220
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1221 void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *col)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1222 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1223 vterm_state_convert_color_to_rgb(screen->state, col);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1224 }
32728
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1225
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1226 static void reset_default_colours(VTermScreen *screen, ScreenCell *buffer)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1227 {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1228 for(int row = 0; row <= screen->rows - 1; row++)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1229 for(int col = 0; col <= screen->cols - 1; col++) {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1230 ScreenCell *cell = &buffer[row * screen->cols + col];
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1231 if(VTERM_COLOR_IS_DEFAULT_FG(&cell->pen.fg))
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1232 cell->pen.fg = screen->pen.fg;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1233 if(VTERM_COLOR_IS_DEFAULT_BG(&cell->pen.bg))
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1234 cell->pen.bg = screen->pen.bg;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1235 }
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1236 }
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1237
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1238 void vterm_screen_set_default_colors(VTermScreen *screen, const VTermColor *default_fg, const VTermColor *default_bg)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1239 {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1240 vterm_state_set_default_colors(screen->state, default_fg, default_bg);
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1241
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1242 if(default_fg && VTERM_COLOR_IS_DEFAULT_FG(&screen->pen.fg)) {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1243 screen->pen.fg = *default_fg;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1244 screen->pen.fg.type = (screen->pen.fg.type & ~VTERM_COLOR_DEFAULT_MASK)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1245 | VTERM_COLOR_DEFAULT_FG;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1246 }
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1247
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1248 if(default_bg && VTERM_COLOR_IS_DEFAULT_BG(&screen->pen.bg)) {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1249 screen->pen.bg = *default_bg;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1250 screen->pen.bg.type = (screen->pen.bg.type & ~VTERM_COLOR_DEFAULT_MASK)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1251 | VTERM_COLOR_DEFAULT_BG;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1252 }
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1253
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1254 reset_default_colours(screen, screen->buffers[0]);
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1255 if(screen->buffers[1])
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1256 reset_default_colours(screen, screen->buffers[1]);
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 31433
diff changeset
1257 }