annotate src/libvterm/src/screen.c @ 31433:c9da70c1e6d5 v9.0.1049

patch 9.0.1049: crash when opening a very small terminal window Commit: https://github.com/vim/vim/commit/67578e5bcf7404d40d42876b738b72e68add1a3e Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 12 13:47:44 2022 +0000 patch 9.0.1049: crash when opening a very small terminal window Problem: Crash when opening a very small terminal window. Solution: Instead of crashing fix the cursor position. (closes https://github.com/vim/vim/issues/11697)
author Bram Moolenaar <Bram@vim.org>
date Mon, 12 Dec 2022 15:00:05 +0100
parents bf4f25d50fdd
children b13f723a7ec6
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;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 cell->pen = screen->pen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296 cell->pen.dwl = info->doublewidth;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 cell->pen.dhl = info->doubleheight;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 return 1;
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 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
305 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 VTermScreen *screen = user;
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 damagerect(screen, rect);
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 return 1;
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
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 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
314 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 erase_internal(rect, selective, user);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 return erase_user(rect, 0, user);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 }
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 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
320 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 VTermScreen *screen = user;
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 if(screen->damage_merge != VTERM_DAMAGE_SCROLL) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 vterm_scroll_rect(rect, downward, rightward,
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 moverect_internal, erase_internal, screen);
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 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 vterm_scroll_rect(rect, downward, rightward,
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 moverect_user, erase_user, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 if(screen->damaged.start_row != -1 &&
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 !rect_intersects(&rect, &screen->damaged)) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 vterm_screen_flush_damage(screen);
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
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 if(screen->pending_scrollrect.start_row == -1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 screen->pending_scrollrect = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 screen->pending_scroll_downward = downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 screen->pending_scroll_rightward = rightward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 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
346 ((screen->pending_scroll_downward == 0 && downward == 0) ||
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 (screen->pending_scroll_rightward == 0 && rightward == 0))) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 screen->pending_scroll_downward += downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 screen->pending_scroll_rightward += rightward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 else {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 screen->pending_scrollrect = rect;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 screen->pending_scroll_downward = downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 screen->pending_scroll_rightward = rightward;
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
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 vterm_scroll_rect(rect, downward, rightward,
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 moverect_internal, erase_internal, screen);
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 if(screen->damaged.start_row == -1)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 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
366 /* 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
367 vterm_rect_move(&screen->damaged, -downward, -rightward);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 rect_clip(&screen->damaged, &rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 }
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
370 /* 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
371 * 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
372 * 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
373 * region in half.
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
374 */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375 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
376 rect.end_col >= screen->damaged.end_col &&
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 rightward == 0) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 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
379 screen->damaged.start_row < rect.end_row) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 screen->damaged.start_row -= downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 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
382 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 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
384 screen->damaged.start_row = rect.end_row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 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
387 screen->damaged.end_row < rect.end_row) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 screen->damaged.end_row -= downward;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 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
390 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 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
392 screen->damaged.end_row = rect.end_row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395 else {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 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
397 ARGSrect(screen->damaged), ARGSrect(rect));
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
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 }
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 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
404 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 VTermScreen *screen = user;
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 if(screen->callbacks && screen->callbacks->movecursor)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 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
409
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 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
414 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 VTermScreen *screen = user;
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 switch(attr) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 case VTERM_ATTR_BOLD:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 screen->pen.bold = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 case VTERM_ATTR_UNDERLINE:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422 screen->pen.underline = val->number;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 case VTERM_ATTR_ITALIC:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 screen->pen.italic = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 case VTERM_ATTR_BLINK:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 screen->pen.blink = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 case VTERM_ATTR_REVERSE:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 screen->pen.reverse = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 return 1;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
433 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
434 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
435 return 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 case VTERM_ATTR_STRIKE:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437 screen->pen.strike = val->boolean;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 case VTERM_ATTR_FONT:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 screen->pen.font = val->number;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 case VTERM_ATTR_FOREGROUND:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 screen->pen.fg = val->color;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 case VTERM_ATTR_BACKGROUND:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446 screen->pen.bg = val->color;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 return 1;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
448 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
449 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
450 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
451 case VTERM_ATTR_BASELINE:
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
452 screen->pen.baseline = val->number;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
453 return 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455 case VTERM_N_ATTRS:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 }
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 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460 }
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 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
463 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464 VTermScreen *screen = user;
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 switch(prop) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467 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
468 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
469 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
471 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
472 /* 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
473 * 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
474 */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475 if(!val->boolean)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476 damagescreen(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 case VTERM_PROP_REVERSE:
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479 screen->global_reverse = 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 default:
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
483 ; /* ignore */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 if(screen->callbacks && screen->callbacks->settermprop)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487 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
488
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492 static int bell(void *user)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
493 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 VTermScreen *screen = user;
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 if(screen->callbacks && screen->callbacks->bell)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 return (*screen->callbacks->bell)(screen->cbdata);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
499 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
502 /* 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
503 * 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
504 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
505 {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
506 int col = cols - 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
507 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
508 col--;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
509 return col + 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
510 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
511
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
512 #define REFLOW (screen->reflow)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
513
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
514 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
515 {
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
516 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
517 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
518
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
519 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
520 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
521
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
522 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
523 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
524
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
525 // 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
526 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
527 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
528
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
529 VTermPos old_cursor = statefields->pos;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
530 VTermPos new_cursor = { -1, -1 };
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
531
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
532 #ifdef DEBUG_REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
533 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
534 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
535 #endif
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
536
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
537 /* 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
538 * 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
539 */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
540 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
541
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
542 while(old_row >= 0) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
543 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
544 /* 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
545 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
546 old_row--;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
547 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
548
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
549 int width = 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
550 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
551 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
552 width += old_cols;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
553 else
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
554 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
555 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
556
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
557 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
558 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
559
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
560 int new_height = REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
561 ? 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
562 : 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
563
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
564 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
565 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
566
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
567 old_row = old_row_start;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
568 int old_col = 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
569
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
570 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
571
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
572 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
573 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
574 (!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
575 {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
576 /* 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
577 * make it fit
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
578 */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
579 int downwards = -new_row_start;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
580 if(downwards > spare_rows)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
581 downwards = spare_rows;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
582 int rowcount = new_rows - downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
583
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
584 #ifdef DEBUG_REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
585 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
586 #endif
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 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
589 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
590
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
591 new_row += downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
592 new_row_start += downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
593 new_row_end += downwards;
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 if(new_cursor.row >= 0)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
596 new_cursor.row += downwards;
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
597
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
598 final_blank_row += downwards;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
599 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
600
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
601 #ifdef DEBUG_REFLOW
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
602 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
603 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
604 #endif
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
605
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
606 if(new_row_start < 0)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
607 break;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
608
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
609 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
610 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
611 width -= count;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
612
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
613 int new_col = 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
614
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
615 while(count) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
616 /* 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
617 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
618
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
619 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
620 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
621
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
622 old_col++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
623 if(old_col == old_cols) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
624 old_row++;
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 if(!REFLOW) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
627 new_col++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
628 break;
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 old_col = 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
631 }
20482
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20480
diff changeset
632
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
633 new_col++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
634 count--;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
635 }
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(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
638 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
639 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
640 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
641 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
642
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
643 while(new_col < new_cols) {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
644 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
645 new_col++;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
646 }
20482
dc88c690f19b patch 8.2.0795: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20480
diff changeset
647
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
648 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
649 }
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
650
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
651 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
652 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
653 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
654
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
655 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
656 /* 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
657 * bring it within range */
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
658 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
659 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
660 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
661 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
662
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
663 /* 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
664 /* 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
665 * 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
666 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
667 /* 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
668 * abort(); */
c9da70c1e6d5 patch 9.0.1049: crash when opening a very small terminal window
Bram Moolenaar <Bram@vim.org>
parents: 30894
diff changeset
669 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
670 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
671 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
672 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
673 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
674
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
675 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
676 /* Push spare lines to scrollback buffer */
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
677 for(int row = 0; row <= old_row; row++)
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
678 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
679 if(active)
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
680 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
681 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
682 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
683 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
684 /* 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
685 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
686 VTermPos pos;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
687 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
688 break;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
689
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
690 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
691 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
692 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
693 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
694
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
695 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
696 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
697 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
698 break;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
699 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
700
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
701 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
702 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
703 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
704 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
705 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
706 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
707 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
708 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
709 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
710 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
711
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
712 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
713 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
714
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
715 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
716 (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
717 }
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
718 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
719 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
720 new_row--;
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
721
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
722 if(active)
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
723 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
724 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
725 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
726 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
727 /* 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
728 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
729 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
730 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
731
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
732 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
733
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
734 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
735 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
736 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
737 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
738 }
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
739 }
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
740
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
741 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
742 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
743
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
744 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
745 statefields->lineinfos[bufidx] = new_lineinfo;
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
746
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
747 if(active)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
748 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
749
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
750 return;
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
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
753 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
754 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
757 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
758
30876
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
759 int old_rows = screen->rows;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 int old_cols = screen->cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
762 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
763 /* 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
764 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
765 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
766
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
767 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
768 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769
20480
d0bf39eb2b07 patch 8.2.0794: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20466
diff changeset
770 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
771 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
772 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
773 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
774 /* 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
775 * 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
776 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
777
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
778 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
779 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
780 new_lineinfo[row] = (VTermLineInfo){ 0 };
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
781
2d2758ffd959 patch 9.0.0772: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21606
diff changeset
782 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
783 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
785 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
786
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787 screen->rows = new_rows;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788 screen->cols = new_cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
790 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
791 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
792 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
793
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
794 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
795 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
797 /* 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
798 damagescreen(screen);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
799
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800 if(screen->callbacks && screen->callbacks->resize)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
801 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
802
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
803 return 1;
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
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 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
807 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
808 VTermScreen *screen = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
809
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
810 if(newinfo->doublewidth != oldinfo->doublewidth ||
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
811 newinfo->doubleheight != oldinfo->doubleheight) {
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
812 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
813 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
814 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
815 {
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
816 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
817 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
818 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
819 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
820 cell->pen.dwl = newinfo->doublewidth;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821 cell->pen.dhl = newinfo->doubleheight;
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
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
824 VTermRect rect;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825 rect.start_row = row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 rect.end_row = row + 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827 rect.start_col = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828 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
829 damagerect(screen, rect);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
830
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
831 if(newinfo->doublewidth) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
832 rect.start_col = screen->cols / 2;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 rect.end_col = screen->cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
834
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
835 erase_internal(rect, 0, user);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
836 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
837 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839 return 1;
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 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
843 VTermScreen *screen = user;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
844
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
845 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
846 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
847 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
848
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
849 return 0;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
850 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
851
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852 static VTermStateCallbacks state_cbs = {
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
853 &putglyph, // putglyph
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
854 &movecursor, // movecursor
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
855 &scrollrect, // scrollrect
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
856 NULL, // moverect
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
857 &erase, // erase
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
858 NULL, // initpen
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
859 &setpenattr, // setpenattr
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
860 &settermprop, // settermprop
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
861 &bell, // bell
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
862 &resize, // resize
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
863 &setlineinfo, // setlineinfo
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
864 &sb_clear, //sb_clear
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
865 };
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
866
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
867 /*
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
868 * 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
869 * 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
870 */
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
871 static VTermScreen *screen_new(VTerm *vt)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
872 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
873 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
874 if(!state)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
875 return NULL;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
877 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
878 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
879 return NULL;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
880 int rows, cols;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 vterm_get_size(vt, &rows, &cols);
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 screen->vt = vt;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885 screen->state = state;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
886
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887 screen->damage_merge = VTERM_DAMAGE_CELL;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 screen->damaged.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
889 screen->pending_scrollrect.start_row = -1;
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 screen->rows = rows;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 screen->cols = cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
893
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
894 screen->global_reverse = FALSE;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
895 screen->reflow = FALSE;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
896
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
897 screen->callbacks = NULL;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
898 screen->cbdata = NULL;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
899
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
900 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
901
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
902 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
903
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904 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
905 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
906 {
544490b69e1d patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 14734
diff changeset
907 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
908 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
909 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911 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
912
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
913 return screen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
914 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
915
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 INTERNAL void vterm_screen_free(VTermScreen *screen)
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 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
919 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
920 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
921
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
922 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
923
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
924 vterm_allocator_free(screen->vt, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
925 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
926
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
927 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
928 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
929 screen->damaged.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
930 screen->pending_scrollrect.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
931 vterm_state_reset(screen->state, hard);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
932 vterm_screen_flush_damage(screen);
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
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 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
936 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
937 size_t outpos = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
938 int padding = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
939
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940 #define PUT(c) \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
941 if(utf8) { \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
942 size_t thislen = utf8_seqlen(c); \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
943 if(buffer && outpos + thislen <= len) \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
944 outpos += fill_utf8((c), (char *)buffer + outpos); \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
945 else \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
946 outpos += thislen; \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
947 } \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
948 else { \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
949 if(buffer && outpos + 1 <= len) \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
950 ((uint32_t*)buffer)[outpos++] = (c); \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
951 else \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
952 outpos++; \
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
953 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
955 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
956 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
957 ScreenCell *cell = getcell(screen, row, col);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958
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
959 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
960 {
2f2bc98a8dfb patch 8.2.1030: reducing size of a terminal window may cause a crash
Bram Moolenaar <Bram@vim.org>
parents: 20875
diff changeset
961 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
962 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
963 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
964 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
965 if(cell->chars[0] == 0)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
966 // Erased cell, might need a space
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
967 padding++;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
968 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
969 // 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
970 ;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
971 else {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
972 while(padding) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
973 PUT(UNICODE_SPACE);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
974 padding--;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
975 }
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
976 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
977 PUT(cell->chars[i]);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
978 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
979 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
980 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
981
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
982 if(row < rect.end_row - 1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
983 PUT(UNICODE_LINEFEED);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
984 padding = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
985 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
986 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
987
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
988 return outpos;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
989 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
990
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
991 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
992 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
993 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
994 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
995
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
996 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
997 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
998 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
999 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1000
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
1001 /* 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
1002 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
1003 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1004 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
1005
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1006 if(!intcell)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1007 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1008
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1009 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
1010 cell->chars[i] = intcell->chars[i];
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1011 if(!intcell->chars[i])
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1012 break;
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
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1015 cell->attrs.bold = intcell->pen.bold;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1016 cell->attrs.underline = intcell->pen.underline;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1017 cell->attrs.italic = intcell->pen.italic;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1018 cell->attrs.blink = intcell->pen.blink;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1019 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
1020 cell->attrs.conceal = intcell->pen.conceal;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1021 cell->attrs.strike = intcell->pen.strike;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1022 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
1023 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
1024 cell->attrs.baseline = intcell->pen.baseline;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1025
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1026 cell->attrs.dwl = intcell->pen.dwl;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1027 cell->attrs.dhl = intcell->pen.dhl;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1028
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1029 cell->fg = intcell->pen.fg;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1030 cell->bg = intcell->pen.bg;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1031
18064
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1032 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
1033 // 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
1034 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
1035 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
1036 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
1037 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
1038 cell->width = 2;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1039 } 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
1040 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
1041 cell->width = 1;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1042 } else {
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1043 cell->width = 2;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1044 }
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1045 } else
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1046 cell->width = 1;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1047 } else {
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1048 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
1049 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
1050 cell->width = 2;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1051 else
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1052 cell->width = 1;
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
1053 }
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1054
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1055 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1056 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1057
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1058 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
1059 {
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
1060 /* 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
1061 for(; pos.col < screen->cols; pos.col++) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1062 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
1063 if(cell->chars[0] != 0)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1064 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1065 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1066
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1067 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1068 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1069
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1070 VTermScreen *vterm_obtain_screen(VTerm *vt)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1071 {
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1072 if(vt->screen)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1073 return vt->screen;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1074
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1075 vt->screen = screen_new(vt);
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1076 return vt->screen;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1077 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1078
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1079 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
1080 {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1081 screen->reflow = reflow;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1082 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1083
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1084 // 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
1085 // #undef vterm_screen_set_reflow
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1086 // 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
1087 // {
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1088 // 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
1089 // }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1090
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1091 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
1092 {
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
1093 if(!screen->buffers[BUFIDX_ALTSCREEN] && altscreen) {
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1094 int rows, cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1095 vterm_get_size(screen->vt, &rows, &cols);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1096
20466
3bd0d7cfddc9 patch 8.2.0787: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 18802
diff changeset
1097 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
1098 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1099 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1100
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1101 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
1102 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1103 screen->callbacks = callbacks;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1104 screen->cbdata = user;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1105 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1106
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1107 void *vterm_screen_get_cbdata(VTermScreen *screen)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1108 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1109 return screen->cbdata;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1111
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
1112 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
1113 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114 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
1115 }
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 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
1118 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1119 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
1120 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1121
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 void vterm_screen_flush_damage(VTermScreen *screen)
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 if(screen->pending_scrollrect.start_row != -1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 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
1126 moverect_user, erase_user, screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1127
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1128 screen->pending_scrollrect.start_row = -1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1129 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1130
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1131 if(screen->damaged.start_row != -1) {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1132 if(screen->callbacks && screen->callbacks->damage)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1133 (*screen->callbacks->damage)(screen->damaged, screen->cbdata);
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 screen->damaged.start_row = -1;
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 }
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 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
1140 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1141 vterm_screen_flush_damage(screen);
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1142 screen->damage_merge = size;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1143 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1144
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1145 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
1146 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1147 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
1148 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1149 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
1150 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1151 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
1152 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1153 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
1154 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1155 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
1156 return 1;
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20488
diff changeset
1157 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
1158 return 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1159 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
1160 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1161 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
1162 return 1;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1163 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
1164 return 1;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1165 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
1166 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
1167 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
1168 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1169 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
1170 return 1;
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1171
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1172 return 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1173 }
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1174
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1175 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
1176 {
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1177 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
1178
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1179 // TODO: bounds check
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1180 extent->start_row = pos.row;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1181 extent->end_row = pos.row + 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1182
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1183 if(extent->start_col < 0)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1184 extent->start_col = 0;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1185 if(extent->end_col < 0)
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1186 extent->end_col = screen->cols;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1187
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1188 int col;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 30876
diff changeset
1189
14734
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1190 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
1191 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
1192 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1193 extent->start_col = col + 1;
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 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
1196 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
1197 break;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1198 extent->end_col = col - 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1199
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1200 return 1;
2c72fa16aa70 patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1201 }
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1202
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1203 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
1204 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
1205 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
1206 }