Mercurial > vim
annotate src/libvterm/src/termscreen.c @ 17133:2a9a5e69fb3e v8.1.1566
patch 8.1.1566: error message when terminal closes in another tab
commit https://github.com/vim/vim/commit/517f71ab17c265602465eaee3775dcfe8afe0478
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 17 22:40:41 2019 +0200
patch 8.1.1566: error message when terminal closes in another tab
Problem: Error message when terminal closes while it is not in the current
tab.
Solution: Also set "do_set_w_closing" when using the special autocommand
window. (closes #4552)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 17 Jun 2019 22:45:05 +0200 |
parents | a1229400434a |
children | 811a12a78164 |
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 |
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
|
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 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 /* State of the pen at some moment in time, also used in a cell */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 typedef struct |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 /* After the bitfield */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 VTermColor fg, bg; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 unsigned int bold : 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 unsigned int underline : 2; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 unsigned int italic : 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 unsigned int blink : 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 unsigned int reverse : 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 unsigned int strike : 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 unsigned int font : 4; /* 0 to 9 */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 /* Extra state storage that isn't strictly pen-related */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 unsigned int protected_cell : 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 unsigned int dwl : 1; /* on a DECDWL or DECDHL line */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 unsigned int dhl : 2; /* on a DECDHL line (1=top 2=bottom) */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 } ScreenPen; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 /* Internal representation of a screen cell */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 typedef struct |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 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
|
37 ScreenPen pen; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 } ScreenCell; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 struct VTermScreen |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 VTerm *vt; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 VTermState *state; |
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 const VTermScreenCallbacks *callbacks; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 void *cbdata; |
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 VTermDamageSize damage_merge; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 /* start_row == -1 => no damage */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 VTermRect damaged; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 VTermRect pending_scrollrect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 int pending_scroll_downward, pending_scroll_rightward; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 int rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 int cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 int global_reverse; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 /* Primary and Altscreen. buffers[1] is lazily allocated as needed */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 ScreenCell *buffers[2]; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 /* buffer will == buffers[0] or buffers[1], depending on altscreen */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 ScreenCell *buffer; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 /* buffer for a single screen row used in scrollback storage callbacks */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 VTermScreenCell *sb_buffer; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 ScreenPen pen; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 }; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 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
|
73 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 if(row < 0 || row >= screen->rows) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 return NULL; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 if(col < 0 || col >= screen->cols) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 return NULL; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 return screen->buffer + (screen->cols * row) + col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 static ScreenCell *realloc_buffer(VTermScreen *screen, ScreenCell *buffer, int new_rows, int new_cols) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 int row, col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 |
16429
a1229400434a
patch 8.1.1219: not checking for NULL return from alloc()
Bram Moolenaar <Bram@vim.org>
parents:
15249
diff
changeset
|
86 if (new_buffer == NULL) |
a1229400434a
patch 8.1.1219: not checking for NULL return from alloc()
Bram Moolenaar <Bram@vim.org>
parents:
15249
diff
changeset
|
87 return NULL; |
14734
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 for(row = 0; row < new_rows; row++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 for(col = 0; col < new_cols; col++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 ScreenCell *new_cell = new_buffer + row*new_cols + col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 if(buffer && row < screen->rows && col < screen->cols) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 *new_cell = buffer[row * screen->cols + col]; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 else { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 new_cell->chars[0] = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 new_cell->pen = screen->pen; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 |
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
|
101 vterm_allocator_free(screen->vt, buffer); |
14734
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 return new_buffer; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 } |
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 static void damagerect(VTermScreen *screen, VTermRect rect) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 VTermRect emit; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 switch(screen->damage_merge) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 case VTERM_DAMAGE_CELL: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 /* Always emit damage event */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 emit = rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 case VTERM_DAMAGE_ROW: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 /* Emit damage longer than one row. Try to merge with existing damage in |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 * the same row */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 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
|
120 // 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
|
121 vterm_screen_flush_damage(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 emit = rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 else if(screen->damaged.start_row == -1) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 // None stored yet |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 screen->damaged = rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 return; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
128 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
129 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
|
130 // Merge with the stored line |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
131 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
|
132 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 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
|
134 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 return; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
136 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
137 else { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
138 // 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
|
139 emit = screen->damaged; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
140 screen->damaged = rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 case VTERM_DAMAGE_SCREEN: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
145 case VTERM_DAMAGE_SCROLL: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
146 /* Never emit damage event */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
147 if(screen->damaged.start_row == -1) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
148 screen->damaged = rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
149 else { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
150 rect_expand(&screen->damaged, &rect); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
151 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
152 return; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
153 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
154 default: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
155 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
|
156 return; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
157 } |
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 if(screen->callbacks && screen->callbacks->damage) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
160 (*screen->callbacks->damage)(emit, screen->cbdata); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
161 } |
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 static void damagescreen(VTermScreen *screen) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 VTermRect rect = {0,0,0,0}; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 rect.end_row = screen->rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
167 rect.end_col = screen->cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 damagerect(screen, rect); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
170 } |
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 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
|
173 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 int i; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 int col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 VTermRect rect; |
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 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 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
|
180 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 if(!cell) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 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
|
185 cell->chars[i] = info->chars[i]; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 cell->pen = screen->pen; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 if(i < VTERM_MAX_CHARS_PER_CELL) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 cell->chars[i] = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 for(col = 1; col < info->width; col++) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 getcell(screen, pos.row, pos.col + col)->chars[0] = (uint32_t)-1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 rect.start_row = pos.row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 rect.end_row = pos.row+1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 rect.start_col = pos.col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 rect.end_col = pos.col+info->width; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
198 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 cell->pen.protected_cell = info->protected_cell; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 cell->pen.dwl = info->dwl; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 cell->pen.dhl = info->dhl; |
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 damagerect(screen, rect); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
204 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
205 return 1; |
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 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
208 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
|
209 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
210 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
211 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 if(screen->callbacks && screen->callbacks->sb_pushline && |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 dest.start_row == 0 && dest.start_col == 0 && // starts top-left corner |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 dest.end_col == screen->cols && // full width |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
215 screen->buffer == screen->buffers[0]) { // not altscreen |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
216 VTermPos pos; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
217 for(pos.row = 0; pos.row < src.start_row; pos.row++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 for(pos.col = 0; pos.col < screen->cols; pos.col++) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
219 (void)vterm_screen_get_cell(screen, pos, screen->sb_buffer + pos.col); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
221 (screen->callbacks->sb_pushline)(screen->cols, screen->sb_buffer, screen->cbdata); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
222 } |
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 |
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 int cols = src.end_col - src.start_col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 int downward = src.start_row - dest.start_row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
228 int init_row, test_row, inc_row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
229 int row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
230 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
231 if(downward < 0) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
232 init_row = dest.end_row - 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
233 test_row = dest.start_row - 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
234 inc_row = -1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
235 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
236 else { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
237 init_row = dest.start_row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
238 test_row = dest.end_row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
239 inc_row = +1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
240 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
241 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
242 for(row = init_row; row != test_row; row += inc_row) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
243 memmove(getcell(screen, row, dest.start_col), |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
244 getcell(screen, row + downward, src.start_col), |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
245 cols * sizeof(ScreenCell)); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
246 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
247 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
248 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
249 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
251 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
|
252 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
253 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
254 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
255 if(screen->callbacks && screen->callbacks->moverect) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 if(screen->damage_merge != VTERM_DAMAGE_SCROLL) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
257 // Avoid an infinite loop |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 vterm_screen_flush_damage(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
259 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 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
|
261 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
262 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
263 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
264 damagerect(screen, dest); |
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 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
267 } |
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 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
|
270 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
271 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
272 int row, col; |
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 for(row = rect.start_row; row < screen->state->rows && row < rect.end_row; row++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
275 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
|
276 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
277 for(col = rect.start_col; col < rect.end_col; col++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
278 ScreenCell *cell = getcell(screen, row, col); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
279 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
280 if(selective && cell->pen.protected_cell) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
281 continue; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
282 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
283 cell->chars[0] = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
284 cell->pen = screen->pen; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
285 cell->pen.dwl = info->doublewidth; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
286 cell->pen.dhl = info->doubleheight; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
287 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
288 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
289 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
290 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
291 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
292 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
293 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
|
294 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
295 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
296 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
297 damagerect(screen, rect); |
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 return 1; |
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 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
302 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
|
303 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
304 erase_internal(rect, selective, user); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
305 return erase_user(rect, 0, user); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
306 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
307 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
308 static int 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
|
309 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
310 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
311 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
312 if(screen->damage_merge != VTERM_DAMAGE_SCROLL) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
313 vterm_scroll_rect(rect, downward, rightward, |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
314 moverect_internal, erase_internal, screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
315 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
316 vterm_screen_flush_damage(screen); |
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 vterm_scroll_rect(rect, downward, rightward, |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
319 moverect_user, erase_user, screen); |
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 return 1; |
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 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
324 if(screen->damaged.start_row != -1 && |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
325 !rect_intersects(&rect, &screen->damaged)) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
326 vterm_screen_flush_damage(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
327 } |
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 if(screen->pending_scrollrect.start_row == -1) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
330 screen->pending_scrollrect = rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
331 screen->pending_scroll_downward = downward; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
332 screen->pending_scroll_rightward = rightward; |
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 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
|
335 ((screen->pending_scroll_downward == 0 && downward == 0) || |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
336 (screen->pending_scroll_rightward == 0 && rightward == 0))) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
337 screen->pending_scroll_downward += downward; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
338 screen->pending_scroll_rightward += rightward; |
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 else { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
341 vterm_screen_flush_damage(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
342 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
343 screen->pending_scrollrect = rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
344 screen->pending_scroll_downward = downward; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
345 screen->pending_scroll_rightward = rightward; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
346 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
347 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
348 vterm_scroll_rect(rect, downward, rightward, |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
349 moverect_internal, erase_internal, screen); |
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 if(screen->damaged.start_row == -1) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
352 return 1; |
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 if(rect_contains(&rect, &screen->damaged)) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
355 /* Scroll region entirely contains the damage; just move it */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
356 vterm_rect_move(&screen->damaged, -downward, -rightward); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
357 rect_clip(&screen->damaged, &rect); |
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 /* There are a number of possible cases here, but lets restrict this to only |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
360 * the common case where we might actually gain some performance by |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
361 * optimising it. Namely, a vertical scroll that neatly cuts the damage |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
362 * region in half. |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
363 */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
364 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
|
365 rect.end_col >= screen->damaged.end_col && |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
366 rightward == 0) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
367 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
|
368 screen->damaged.start_row < rect.end_row) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
369 screen->damaged.start_row -= downward; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
370 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
|
371 screen->damaged.start_row = rect.start_row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
372 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
|
373 screen->damaged.start_row = rect.end_row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
374 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
375 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
|
376 screen->damaged.end_row < rect.end_row) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
377 screen->damaged.end_row -= downward; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
378 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
|
379 screen->damaged.end_row = rect.start_row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
380 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
|
381 screen->damaged.end_row = rect.end_row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
382 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
383 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
384 else { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
385 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
|
386 ARGSrect(screen->damaged), ARGSrect(rect)); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
387 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
388 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
389 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
390 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
391 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
392 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
|
393 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
394 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
395 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
396 if(screen->callbacks && screen->callbacks->movecursor) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
397 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
|
398 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
399 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
400 } |
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 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
|
403 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
404 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
405 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
406 switch(attr) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
407 case VTERM_ATTR_BOLD: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
408 screen->pen.bold = val->boolean; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
409 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
410 case VTERM_ATTR_UNDERLINE: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
411 screen->pen.underline = val->number; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
412 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
413 case VTERM_ATTR_ITALIC: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
414 screen->pen.italic = val->boolean; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
415 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
416 case VTERM_ATTR_BLINK: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
417 screen->pen.blink = val->boolean; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
418 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
419 case VTERM_ATTR_REVERSE: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
420 screen->pen.reverse = val->boolean; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
421 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
422 case VTERM_ATTR_STRIKE: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
423 screen->pen.strike = val->boolean; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
424 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
425 case VTERM_ATTR_FONT: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
426 screen->pen.font = val->number; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
427 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
428 case VTERM_ATTR_FOREGROUND: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
429 screen->pen.fg = val->color; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
430 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
431 case VTERM_ATTR_BACKGROUND: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
432 screen->pen.bg = val->color; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
433 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
434 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
435 case VTERM_N_ATTRS: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
436 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
437 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
438 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
439 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
440 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
441 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
442 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
|
443 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
444 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
445 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
446 switch(prop) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
447 case VTERM_PROP_ALTSCREEN: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
448 if(val->boolean && !screen->buffers[1]) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
449 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
450 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
451 screen->buffer = val->boolean ? screen->buffers[1] : screen->buffers[0]; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
452 /* only send a damage event on disable; because during enable there's an |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
453 * erase that sends a damage anyway |
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 if(!val->boolean) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
456 damagescreen(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
457 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
458 case VTERM_PROP_REVERSE: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
459 screen->global_reverse = val->boolean; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
460 damagescreen(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
461 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
462 default: |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
463 ; /* ignore */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
464 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
465 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
466 if(screen->callbacks && screen->callbacks->settermprop) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
467 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
|
468 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
469 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
470 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
471 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
472 static int bell(void *user) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
473 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
474 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
475 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
476 if(screen->callbacks && screen->callbacks->bell) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
477 return (*screen->callbacks->bell)(screen->cbdata); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
478 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
479 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
480 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
481 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
482 static int resize(int new_rows, int new_cols, VTermPos *delta, void *user) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
483 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
484 VTermScreen *screen = user; |
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 int is_altscreen = (screen->buffers[1] && screen->buffer == screen->buffers[1]); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
487 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
488 int old_rows = screen->rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
489 int old_cols = screen->cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
490 int first_blank_row; |
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 if(!is_altscreen && new_rows < old_rows) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
493 // Fewer rows - determine if we're going to scroll at all, and if so, push |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
494 // those lines to scrollback |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
495 VTermPos pos = { 0, 0 }; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
496 VTermPos cursor = screen->state->pos; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
497 // Find the first blank row after the cursor. |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
498 for(pos.row = old_rows - 1; pos.row >= new_rows; pos.row--) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
499 if(!vterm_screen_is_eol(screen, pos) || cursor.row == pos.row) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
500 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
501 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
502 first_blank_row = pos.row + 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
503 if(first_blank_row > new_rows) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
504 VTermRect rect = {0,0,0,0}; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
505 rect.end_row = old_rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
506 rect.end_col = old_cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
507 scrollrect(rect, first_blank_row - new_rows, 0, user); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
508 vterm_screen_flush_damage(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
509 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
510 delta->row -= first_blank_row - new_rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
511 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
512 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
513 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
514 screen->buffers[0] = realloc_buffer(screen, screen->buffers[0], new_rows, new_cols); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
515 if(screen->buffers[1]) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
516 screen->buffers[1] = realloc_buffer(screen, screen->buffers[1], new_rows, new_cols); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
517 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
518 screen->buffer = is_altscreen ? screen->buffers[1] : screen->buffers[0]; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
519 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
520 screen->rows = new_rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
521 screen->cols = new_cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
522 |
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
|
523 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
|
524 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
525 screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * new_cols); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
526 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
527 if(new_cols > old_cols) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
528 VTermRect rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
529 rect.start_row = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
530 rect.end_row = old_rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
531 rect.start_col = old_cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
532 rect.end_col = new_cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
533 damagerect(screen, rect); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
534 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
535 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
536 if(new_rows > old_rows) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
537 if(!is_altscreen && screen->callbacks && screen->callbacks->sb_popline) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
538 int rows = new_rows - old_rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
539 while(rows) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
540 VTermRect rect = {0,0,0,0}; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
541 VTermPos pos = { 0, 0 }; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
542 if(!(screen->callbacks->sb_popline(screen->cols, screen->sb_buffer, screen->cbdata))) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
543 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
544 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
545 rect.end_row = screen->rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
546 rect.end_col = screen->cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
547 scrollrect(rect, -1, 0, user); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
548 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
549 for(pos.col = 0; pos.col < screen->cols; pos.col += screen->sb_buffer[pos.col].width) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
550 vterm_screen_set_cell(screen, pos, screen->sb_buffer + pos.col); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
551 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
552 rect.end_row = 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
553 damagerect(screen, rect); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
554 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
555 vterm_screen_flush_damage(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
556 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
557 rows--; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
558 delta->row++; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
559 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
560 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
561 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
562 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
563 VTermRect rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
564 rect.start_row = old_rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
565 rect.end_row = new_rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
566 rect.start_col = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
567 rect.end_col = new_cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
568 damagerect(screen, rect); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
569 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
570 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
571 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
572 if(screen->callbacks && screen->callbacks->resize) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
573 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
|
574 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
575 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
576 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
577 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
578 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
|
579 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
580 VTermScreen *screen = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
581 int col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
582 VTermRect rect; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
583 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
584 if(newinfo->doublewidth != oldinfo->doublewidth || |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
585 newinfo->doubleheight != oldinfo->doubleheight) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
586 for(col = 0; col < screen->cols; col++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
587 ScreenCell *cell = getcell(screen, row, col); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
588 cell->pen.dwl = newinfo->doublewidth; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
589 cell->pen.dhl = newinfo->doubleheight; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
590 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
591 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
592 rect.start_row = row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
593 rect.end_row = row + 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
594 rect.start_col = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
595 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
|
596 damagerect(screen, rect); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
597 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
598 if(newinfo->doublewidth) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
599 rect.start_col = screen->cols / 2; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
600 rect.end_col = screen->cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
601 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
602 erase_internal(rect, 0, user); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
603 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
604 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
605 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
606 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
607 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
608 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
609 static VTermStateCallbacks state_cbs = { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
610 &putglyph, /* putglyph */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
611 &movecursor, /* movecursor */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
612 &scrollrect, /* scrollrect */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
613 NULL, /* moverect */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
614 &erase, /* erase */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
615 NULL, /* initpen */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
616 &setpenattr, /* setpenattr */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
617 &settermprop, /* settermprop */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
618 &bell, /* bell */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
619 &resize, /* resize */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
620 &setlineinfo /* setlineinfo */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
621 }; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
622 |
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
|
623 /* |
544490b69e1d
patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
14734
diff
changeset
|
624 * 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
|
625 * 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
|
626 */ |
14734
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
627 static VTermScreen *screen_new(VTerm *vt) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
628 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
629 VTermState *state = vterm_obtain_state(vt); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
630 VTermScreen *screen; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
631 int rows, cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
632 |
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
|
633 if (state == NULL) |
14734
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
634 return NULL; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
635 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
|
636 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
|
637 return NULL; |
14734
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
638 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
639 vterm_get_size(vt, &rows, &cols); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
640 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
641 screen->vt = vt; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
642 screen->state = state; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
643 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
644 screen->damage_merge = VTERM_DAMAGE_CELL; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
645 screen->damaged.start_row = -1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
646 screen->pending_scrollrect.start_row = -1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
647 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
648 screen->rows = rows; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
649 screen->cols = cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
650 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
651 screen->callbacks = NULL; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
652 screen->cbdata = NULL; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
653 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
654 screen->buffers[0] = realloc_buffer(screen, NULL, rows, cols); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
655 screen->buffer = screen->buffers[0]; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
656 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
|
657 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
|
658 { |
544490b69e1d
patch 8.1.0633: crash when out of memory while opening a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
14734
diff
changeset
|
659 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
|
660 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
|
661 } |
14734
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
662 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
663 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
|
664 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
665 return screen; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
666 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
667 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
668 INTERNAL void vterm_screen_free(VTermScreen *screen) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
669 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
670 vterm_allocator_free(screen->vt, screen->buffers[0]); |
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
|
671 vterm_allocator_free(screen->vt, screen->buffers[1]); |
14734
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
672 vterm_allocator_free(screen->vt, screen->sb_buffer); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
673 vterm_allocator_free(screen->vt, screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
674 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
675 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
676 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
|
677 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
678 screen->damaged.start_row = -1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
679 screen->pending_scrollrect.start_row = -1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
680 vterm_state_reset(screen->state, hard); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
681 vterm_screen_flush_damage(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
682 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
683 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
684 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
|
685 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
686 size_t outpos = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
687 int padding = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
688 int row, col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
689 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
690 #define PUT(c) \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
691 if(utf8) { \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
692 size_t thislen = utf8_seqlen(c); \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
693 if(buffer && outpos + thislen <= len) \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
694 outpos += fill_utf8((c), (char *)buffer + outpos); \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
695 else \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
696 outpos += thislen; \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
697 } \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
698 else { \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
699 if(buffer && outpos + 1 <= len) \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
700 ((uint32_t*)buffer)[outpos++] = (c); \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
701 else \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
702 outpos++; \ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
703 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
704 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
705 for(row = rect.start_row; row < rect.end_row; row++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
706 for(col = rect.start_col; col < rect.end_col; col++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
707 ScreenCell *cell = getcell(screen, row, col); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
708 int i; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
709 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
710 if(cell->chars[0] == 0) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
711 // Erased cell, might need a space |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
712 padding++; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
713 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
|
714 // 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
|
715 ; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
716 else { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
717 while(padding) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
718 PUT(UNICODE_SPACE); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
719 padding--; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
720 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
721 for(i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell->chars[i]; i++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
722 PUT(cell->chars[i]); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
723 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
724 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
725 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
726 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
727 if(row < rect.end_row - 1) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
728 PUT(UNICODE_LINEFEED); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
729 padding = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
730 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
731 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
732 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
733 return outpos; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
734 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
735 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
736 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
|
737 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
738 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
|
739 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
740 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
741 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
|
742 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
743 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
|
744 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
745 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
746 /* Copy internal to external representation of a screen cell */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
747 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
|
748 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
749 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
|
750 int i; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
751 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
752 if(!intcell) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
753 return 0; |
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 for(i = 0; ; i++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
756 cell->chars[i] = intcell->chars[i]; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
757 if(!intcell->chars[i]) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
758 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
759 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
760 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
761 cell->attrs.bold = intcell->pen.bold; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
762 cell->attrs.underline = intcell->pen.underline; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
763 cell->attrs.italic = intcell->pen.italic; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
764 cell->attrs.blink = intcell->pen.blink; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
765 cell->attrs.reverse = intcell->pen.reverse ^ screen->global_reverse; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
766 cell->attrs.strike = intcell->pen.strike; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
767 cell->attrs.font = intcell->pen.font; |
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 cell->attrs.dwl = intcell->pen.dwl; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
770 cell->attrs.dhl = intcell->pen.dhl; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
771 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
772 cell->fg = intcell->pen.fg; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
773 cell->bg = intcell->pen.bg; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
774 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
775 if(pos.col < (screen->cols - 1) && |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
776 getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
777 cell->width = 2; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
778 else |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
779 cell->width = 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
780 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
781 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
782 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
783 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
784 /* Copy external to internal representation of a screen cell */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
785 /* static because it's only used internally for sb_popline during resize */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
786 static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
787 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
788 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
|
789 int i; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
790 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
791 if(!intcell) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
792 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
793 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
794 for(i = 0; ; i++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
795 intcell->chars[i] = cell->chars[i]; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
796 if(!cell->chars[i]) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
797 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
798 } |
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 intcell->pen.bold = cell->attrs.bold; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
801 intcell->pen.underline = cell->attrs.underline; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
802 intcell->pen.italic = cell->attrs.italic; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
803 intcell->pen.blink = cell->attrs.blink; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
804 intcell->pen.reverse = cell->attrs.reverse ^ screen->global_reverse; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
805 intcell->pen.strike = cell->attrs.strike; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
806 intcell->pen.font = cell->attrs.font; |
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 intcell->pen.fg = cell->fg; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
809 intcell->pen.bg = cell->bg; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
810 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
811 if(cell->width == 2) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
812 getcell(screen, pos.row, pos.col + 1)->chars[0] = (uint32_t)-1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
813 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
814 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
815 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
816 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
817 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
|
818 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
819 /* This cell is EOL if this and every cell to the right is black */ |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
820 for(; pos.col < screen->cols; pos.col++) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
821 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
|
822 if(cell->chars[0] != 0) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
823 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
824 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
825 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
826 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
827 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
828 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
829 VTermScreen *vterm_obtain_screen(VTerm *vt) |
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(!vt->screen) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
832 vt->screen = screen_new(vt); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
833 return vt->screen; |
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 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
836 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
|
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 if(!screen->buffers[1] && altscreen) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
840 int rows, cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
841 vterm_get_size(screen->vt, &rows, &cols); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
842 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
843 screen->buffers[1] = realloc_buffer(screen, NULL, rows, cols); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
844 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
845 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
846 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
847 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
|
848 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
849 screen->callbacks = callbacks; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
850 screen->cbdata = user; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
851 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
852 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
853 void *vterm_screen_get_cbdata(VTermScreen *screen) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
854 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
855 return screen->cbdata; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
856 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
857 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
858 void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
859 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
860 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
|
861 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
862 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
863 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
|
864 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
865 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
|
866 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
867 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
868 void vterm_screen_flush_damage(VTermScreen *screen) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
869 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
870 if(screen->pending_scrollrect.start_row != -1) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
871 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
|
872 moverect_user, erase_user, screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
873 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
874 screen->pending_scrollrect.start_row = -1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
875 } |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
876 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
877 if(screen->damaged.start_row != -1) { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
878 if(screen->callbacks && screen->callbacks->damage) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
879 (*screen->callbacks->damage)(screen->damaged, screen->cbdata); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
880 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
881 screen->damaged.start_row = -1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
882 } |
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 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
885 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
|
886 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
887 vterm_screen_flush_damage(screen); |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
888 screen->damage_merge = size; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
889 } |
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 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
|
892 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
893 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
|
894 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
895 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
|
896 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
897 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
|
898 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
899 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
|
900 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
901 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
|
902 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
903 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
|
904 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
905 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
|
906 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
907 if((attrs & VTERM_ATTR_FOREGROUND_MASK) && !vterm_color_equal(a->pen.fg, b->pen.fg)) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
908 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
909 if((attrs & VTERM_ATTR_BACKGROUND_MASK) && !vterm_color_equal(a->pen.bg, b->pen.bg)) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
910 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
911 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
912 return 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
913 } |
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 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
|
916 { |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
917 int col; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
918 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
919 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
|
920 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
921 // TODO: bounds check |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
922 extent->start_row = pos.row; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
923 extent->end_row = pos.row + 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
924 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
925 if(extent->start_col < 0) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
926 extent->start_col = 0; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
927 if(extent->end_col < 0) |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
928 extent->end_col = screen->cols; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
929 |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
930 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
|
931 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
|
932 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
933 extent->start_col = col + 1; |
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 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
|
936 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
|
937 break; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
938 extent->end_col = col - 1; |
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 return 1; |
2c72fa16aa70
patch 8.1.0379: build dependencies are incomplete
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
941 } |