1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.c |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * $Id: screen.C,v 1.6 2003/12/02 21:49:46 pcg Exp $ |
4 | * $Id: screen.C,v 1.12 2003/12/18 14:11:47 pcg Exp $ |
5 | * |
5 | * |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
32 | |
32 | |
33 | #include <stdint.h> |
33 | #include <stdint.h> |
34 | #include <wchar.h> |
34 | #include <wchar.h> |
35 | |
35 | |
|
|
36 | #include "salloc.C" // HACK!! |
|
|
37 | |
36 | inline void fill_text (text_t *start, text_t value, int len) |
38 | inline void fill_text (text_t *start, text_t value, int len) |
37 | { |
39 | { |
38 | while (len--) |
40 | while (len--) |
39 | *start++ = value; |
41 | *start++ = value; |
40 | } |
42 | } |
… | |
… | |
87 | /* |
89 | /* |
88 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
90 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
89 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
91 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
90 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
92 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
91 | */ |
93 | */ |
92 | #define drawBuffer (R->TermWin.vt) |
94 | #define drawBuffer TermWin.vt |
93 | |
95 | |
94 | #define CLEAR_ROWS(row, num) \ |
96 | #define CLEAR_ROWS(row, num) \ |
95 | if (R->TermWin.mapped) \ |
97 | if (TermWin.mapped) \ |
96 | XClearArea(R->Xdisplay, drawBuffer, R->TermWin.int_bwidth, \ |
98 | XClearArea (Xdisplay, drawBuffer, TermWin.int_bwidth, \ |
97 | Row2Pixel(row), (unsigned int)R->TermWin.width, \ |
99 | Row2Pixel(row), (unsigned int)TermWin.width, \ |
98 | (unsigned int)Height2Pixel(num), False) |
100 | (unsigned int)Height2Pixel(num), False) |
99 | |
101 | |
100 | #define CLEAR_CHARS(x, y, num) \ |
102 | #define CLEAR_CHARS(x, y, num) \ |
101 | if (R->TermWin.mapped) \ |
103 | if (TermWin.mapped) \ |
102 | XClearArea(R->Xdisplay, drawBuffer, x, y, \ |
104 | XClearArea (Xdisplay, drawBuffer, x, y, \ |
103 | (unsigned int)Width2Pixel(num), \ |
105 | (unsigned int)Width2Pixel(num), \ |
104 | (unsigned int)Height2Pixel(1), False) |
106 | (unsigned int)Height2Pixel(1), False) |
105 | |
107 | |
106 | #define ERASE_ROWS(row, num) \ |
108 | #define ERASE_ROWS(row, num) \ |
107 | XFillRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, \ |
109 | XFillRectangle (Xdisplay, drawBuffer, TermWin.gc, \ |
108 | R->TermWin.int_bwidth, Row2Pixel(row), \ |
110 | TermWin.int_bwidth, Row2Pixel(row), \ |
109 | (unsigned int)R->TermWin.width, \ |
111 | (unsigned int)TermWin.width, \ |
110 | (unsigned int)Height2Pixel(num)) |
112 | (unsigned int)Height2Pixel(num)) |
111 | |
113 | |
112 | /* ------------------------------------------------------------------------- * |
114 | /* ------------------------------------------------------------------------- * |
113 | * SCREEN `COMMON' ROUTINES * |
115 | * SCREEN `COMMON' ROUTINES * |
114 | * ------------------------------------------------------------------------- */ |
116 | * ------------------------------------------------------------------------- */ |
115 | /* Fill part/all of a line with blanks. */ |
117 | /* Fill part/all of a line with blanks. */ |
116 | /* INTPROTO */ |
|
|
117 | void |
118 | void |
118 | rxvt_blank_line(pR_ text_t *et, rend_t *er, unsigned int width, rend_t efs) |
119 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
119 | { |
120 | { |
120 | efs &= ~RS_baseattrMask; |
121 | efs &= ~RS_baseattrMask; |
121 | efs = SET_FONT (efs, R->TermWin.fontset->find_font (' ')); |
122 | efs = SET_FONT (efs, TermWin.fontset->find_font (' ')); |
122 | |
123 | |
123 | while (width--) |
124 | while (width--) |
124 | { |
125 | { |
125 | *et++ = ' '; |
126 | *et++ = ' '; |
126 | *er++ = efs; |
127 | *er++ = efs; |
127 | } |
128 | } |
128 | } |
129 | } |
129 | |
130 | |
130 | /* ------------------------------------------------------------------------- */ |
131 | /* ------------------------------------------------------------------------- */ |
131 | /* Fill a full line with blanks - make sure it is allocated first */ |
132 | /* Fill a full line with blanks - make sure it is allocated first */ |
132 | /* INTPROTO */ |
|
|
133 | void |
133 | void |
134 | rxvt_blank_screen_mem(pR_ text_t **tp, rend_t **rp, unsigned int row, rend_t efs) |
134 | rxvt_term::scr_blank_screen_mem (text_t **tp, rend_t **rp, unsigned int row, rend_t efs) |
135 | { |
135 | { |
136 | int width = R->TermWin.ncol; |
|
|
137 | rend_t *er; |
|
|
138 | |
|
|
139 | #ifdef DEBUG_STRICT |
136 | #ifdef DEBUG_STRICT |
140 | assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); |
137 | assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); |
141 | #endif |
138 | #endif |
142 | if (tp[row] == NULL) { |
139 | if (tp[row] == NULL) |
143 | tp[row] = (text_t *)rxvt_malloc(sizeof(text_t) * width); |
|
|
144 | rp[row] = (rend_t *)rxvt_malloc(sizeof(rend_t) * width); |
|
|
145 | } |
140 | { |
|
|
141 | tp[row] = (text_t *)talloc->alloc (); |
|
|
142 | rp[row] = (rend_t *)ralloc->alloc (); |
|
|
143 | } |
|
|
144 | |
146 | rxvt_blank_line (aR_ tp[row], rp[row], width, efs); |
145 | scr_blank_line (tp[row], rp[row], TermWin.ncol, efs); |
147 | } |
146 | } |
148 | |
147 | |
149 | /* ------------------------------------------------------------------------- * |
148 | /* ------------------------------------------------------------------------- * |
150 | * SCREEN INITIALISATION * |
149 | * SCREEN INITIALISATION * |
151 | * ------------------------------------------------------------------------- */ |
150 | * ------------------------------------------------------------------------- */ |
152 | /* EXTPROTO */ |
|
|
153 | void |
151 | void |
154 | rxvt_scr_reset(pR) |
152 | rxvt_term::scr_reset () |
155 | { |
153 | { |
156 | unsigned int ncol, nrow, prev_ncol, prev_nrow, |
154 | unsigned int ncol, nrow, total_rows, prev_total_rows; |
157 | total_rows, prev_total_rows; |
|
|
158 | unsigned int p, q; |
155 | unsigned int p, q; |
159 | int k; |
156 | int k; |
160 | rend_t setrstyle; |
157 | rend_t setrstyle; |
161 | |
158 | |
162 | D_SCREEN((stderr, "rxvt_scr_reset()")); |
159 | D_SCREEN((stderr, "rxvt_scr_reset()")); |
163 | |
160 | |
164 | R->TermWin.view_start = 0; |
161 | TermWin.view_start = 0; |
165 | R->num_scr = 0; |
162 | num_scr = 0; |
166 | |
163 | |
167 | prev_ncol = R->prev_ncol; |
|
|
168 | prev_nrow = R->prev_nrow; |
|
|
169 | if (R->TermWin.ncol == 0) |
164 | if (TermWin.ncol == 0) |
170 | R->TermWin.ncol = 80; |
165 | TermWin.ncol = 80; |
|
|
166 | |
171 | if (R->TermWin.nrow == 0) |
167 | if (TermWin.nrow == 0) |
172 | R->TermWin.nrow = 24; |
168 | TermWin.nrow = 24; |
|
|
169 | |
173 | ncol = R->TermWin.ncol; |
170 | ncol = TermWin.ncol; |
174 | nrow = R->TermWin.nrow; |
171 | nrow = TermWin.nrow; |
|
|
172 | |
175 | if (ncol == prev_ncol && nrow == prev_nrow) |
173 | if (ncol == prev_ncol && nrow == prev_nrow) |
176 | return; |
174 | return; |
177 | |
175 | |
178 | R->want_refresh = 1; |
176 | want_refresh = 1; |
179 | |
177 | |
180 | total_rows = nrow + R->TermWin.saveLines; |
178 | total_rows = nrow + TermWin.saveLines; |
181 | prev_total_rows = prev_nrow + R->TermWin.saveLines; |
179 | prev_total_rows = prev_nrow + TermWin.saveLines; |
182 | |
180 | |
183 | R->screen.tscroll = 0; |
181 | screen.tscroll = 0; |
184 | R->screen.bscroll = nrow - 1; |
182 | screen.bscroll = nrow - 1; |
185 | |
183 | |
|
|
184 | if (!talloc) |
|
|
185 | { |
|
|
186 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
187 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
188 | } |
|
|
189 | |
186 | if (prev_nrow == 0) { |
190 | if (prev_nrow == 0) |
187 | /* |
191 | { |
|
|
192 | /* |
188 | * A: first time called so just malloc everything : don't rely on realloc |
193 | * first time called so just malloc everything : don't rely on realloc |
189 | * Note: this is still needed so that all the scrollback lines are NULL |
194 | * Note: this is still needed so that all the scrollback lines are NULL |
190 | */ |
195 | */ |
191 | R->screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
196 | screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
192 | R->buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
197 | buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
193 | R->drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
198 | drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
194 | R->swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
199 | swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
195 | |
200 | |
196 | R->screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); |
201 | screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); |
197 | R->swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); |
202 | swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); |
198 | |
203 | |
199 | R->screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
204 | screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
200 | R->buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
205 | buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
201 | R->drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
206 | drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
202 | R->swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
207 | swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
203 | |
208 | |
204 | for (p = 0; p < nrow; p++) { |
209 | for (p = 0; p < nrow; p++) |
|
|
210 | { |
205 | q = p + R->TermWin.saveLines; |
211 | q = p + TermWin.saveLines; |
206 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
212 | scr_blank_screen_mem (screen.text, screen.rend, q, DEFAULT_RSTYLE); |
207 | q, DEFAULT_RSTYLE); |
213 | scr_blank_screen_mem (swap.text, swap.rend, p, DEFAULT_RSTYLE); |
208 | rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, |
|
|
209 | p, DEFAULT_RSTYLE); |
|
|
210 | R->screen.tlen[q] = R->swap.tlen[p] = 0; |
214 | screen.tlen[q] = swap.tlen[p] = 0; |
211 | rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, |
215 | scr_blank_screen_mem (drawn_text, drawn_rend, p, DEFAULT_RSTYLE); |
212 | p, DEFAULT_RSTYLE); |
|
|
213 | } |
216 | } |
|
|
217 | |
214 | MEMSET(R->charsets, 'B', sizeof(R->charsets)); |
218 | MEMSET(charsets, 'B', sizeof(charsets)); |
215 | R->TermWin.nscrolled = 0; /* no saved lines */ |
219 | TermWin.nscrolled = 0; /* no saved lines */ |
216 | R->rstyle = DEFAULT_RSTYLE; |
220 | rstyle = DEFAULT_RSTYLE; |
217 | R->screen.flags = Screen_DefaultFlags; |
221 | screen.flags = Screen_DefaultFlags; |
218 | R->screen.cur.row = R->screen.cur.col = 0; |
222 | screen.cur.row = screen.cur.col = 0; |
219 | R->screen.charset = 0; |
223 | screen.charset = 0; |
220 | R->current_screen = PRIMARY; |
224 | current_screen = PRIMARY; |
221 | rxvt_scr_cursor(aR_ SAVE); |
225 | rxvt_scr_cursor (this, SAVE); |
|
|
226 | |
222 | #if NSCREENS |
227 | #if NSCREENS |
223 | R->swap.flags = Screen_DefaultFlags; |
228 | swap.flags = Screen_DefaultFlags; |
224 | R->swap.cur.row = R->swap.cur.col = 0; |
229 | swap.cur.row = swap.cur.col = 0; |
225 | R->swap.charset = 0; |
230 | swap.charset = 0; |
226 | R->current_screen = SECONDARY; |
231 | current_screen = SECONDARY; |
227 | rxvt_scr_cursor(aR_ SAVE); |
232 | rxvt_scr_cursor (this, SAVE); |
228 | R->current_screen = PRIMARY; |
233 | current_screen = PRIMARY; |
229 | #endif |
234 | #endif |
|
|
235 | |
230 | R->selection.text = NULL; |
236 | selection.text = NULL; |
231 | R->selection.len = 0; |
237 | selection.len = 0; |
232 | R->selection.op = SELECTION_CLEAR; |
238 | selection.op = SELECTION_CLEAR; |
233 | R->selection.screen = PRIMARY; |
239 | selection.screen = PRIMARY; |
234 | R->selection.clicks = 0; |
240 | selection.clicks = 0; |
235 | CLEAR_ALL_SELECTION(R); |
241 | CLEAR_ALL_SELECTION (this); |
236 | R->rvideo = 0; |
242 | rvideo = 0; |
237 | |
243 | } |
238 | } else { |
244 | else |
239 | /* |
245 | { |
|
|
246 | /* |
240 | * B1: add or delete rows as appropriate |
247 | * add or delete rows as appropriate |
241 | */ |
248 | */ |
242 | setrstyle = DEFAULT_RSTYLE; |
249 | setrstyle = DEFAULT_RSTYLE; |
243 | |
250 | |
244 | if (nrow < prev_nrow) { |
251 | if (nrow < prev_nrow) |
|
|
252 | { |
245 | /* delete rows */ |
253 | /* delete rows */ |
246 | k = min(R->TermWin.nscrolled, prev_nrow - nrow); |
254 | k = min (TermWin.nscrolled, prev_nrow - nrow); |
247 | rxvt_scroll_text(aR_ 0, (int)prev_nrow - 1, k, 1); |
255 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
|
|
256 | |
248 | for (p = nrow; p < prev_nrow; p++) { |
257 | for (p = nrow; p < prev_nrow; p++) |
|
|
258 | { |
249 | q = p + R->TermWin.saveLines; |
259 | q = p + TermWin.saveLines; |
250 | if (R->screen.text[q]) { |
260 | if (screen.text[q]) |
|
|
261 | { |
251 | #ifdef DEBUG_STRICT |
262 | #ifdef DEBUG_STRICT |
252 | assert(R->screen.rend[q]); |
263 | assert (screen.rend[q]); |
253 | #endif |
264 | #endif |
254 | free(R->screen.text[q]); |
265 | talloc->free (screen.text[q]); |
255 | free(R->screen.rend[q]); |
266 | ralloc->free (screen.rend[q]); |
256 | } |
267 | } |
257 | if (R->swap.text[p]) { |
268 | if (swap.text[p]) |
|
|
269 | { |
258 | #ifdef DEBUG_STRICT |
270 | #ifdef DEBUG_STRICT |
259 | assert(R->swap.rend[p]); |
271 | assert (swap.rend[p]); |
260 | #endif |
272 | #endif |
261 | free(R->swap.text[p]); |
273 | talloc->free (swap.text[p]); |
262 | free(R->swap.rend[p]); |
274 | ralloc->free (swap.rend[p]); |
263 | } |
275 | } |
264 | #ifdef DEBUG_STRICT |
276 | #ifdef DEBUG_STRICT |
265 | assert(R->drawn_text[p] && R->drawn_rend[p]); |
277 | assert (drawn_text[p] && drawn_rend[p]); |
266 | #endif |
278 | #endif |
267 | free(R->drawn_text[p]); |
279 | talloc->free (drawn_text[p]); |
268 | free(R->drawn_rend[p]); |
280 | ralloc->free (drawn_rend[p]); |
269 | } |
281 | } |
|
|
282 | |
270 | /* we have fewer rows so fix up cursor position */ |
283 | /* we have fewer rows so fix up cursor position */ |
271 | MIN_IT(R->screen.cur.row, (int32_t)nrow - 1); |
284 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
272 | MIN_IT(R->swap.cur.row, (int32_t)nrow - 1); |
285 | MIN_IT (swap.cur.row, (int32_t)nrow - 1); |
273 | |
286 | |
274 | rxvt_scr_reset_realloc(aR); /* realloc _last_ */ |
287 | scr_reset_realloc (); /* realloc _last_ */ |
275 | |
288 | } |
276 | } else if (nrow > prev_nrow) { |
289 | else if (nrow > prev_nrow) |
|
|
290 | { |
277 | /* add rows */ |
291 | /* add rows */ |
278 | rxvt_scr_reset_realloc(aR); /* realloc _first_ */ |
292 | scr_reset_realloc (); /* realloc _first_ */ |
279 | |
293 | |
|
|
294 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
|
|
295 | |
280 | k = min(R->TermWin.nscrolled, nrow - prev_nrow); |
296 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
|
|
297 | |
281 | for (p = prev_total_rows; p < total_rows; p++) { |
298 | for (p = prev_total_rows; p < total_rows; p++) |
|
|
299 | { |
282 | R->screen.tlen[p] = 0; |
300 | screen.tlen[p] = 0; |
283 | R->screen.text[p] = NULL; |
301 | screen.text[p] = NULL; |
284 | R->screen.rend[p] = NULL; |
302 | screen.rend[p] = NULL; |
285 | } |
303 | } |
|
|
304 | |
286 | for (p = prev_total_rows; p < total_rows - k; p++) |
305 | for (p = prev_total_rows; p < total_rows - k; p++) |
287 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
306 | scr_blank_screen_mem (screen.text, screen.rend, p, setrstyle); |
288 | p, setrstyle); |
307 | |
289 | for (p = prev_nrow; p < nrow; p++) { |
308 | for (p = prev_nrow; p < nrow; p++) |
|
|
309 | { |
290 | R->swap.tlen[p] = 0; |
310 | swap.tlen[p] = 0; |
291 | R->swap.text[p] = NULL; |
311 | swap.text[p] = NULL; |
292 | R->swap.rend[p] = NULL; |
312 | swap.rend[p] = NULL; |
293 | R->drawn_text[p] = NULL; |
313 | drawn_text[p] = NULL; |
294 | R->drawn_rend[p] = NULL; |
314 | drawn_rend[p] = NULL; |
295 | rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, |
315 | scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); |
296 | p, setrstyle); |
|
|
297 | rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, |
316 | scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); |
298 | p, setrstyle); |
|
|
299 | } |
317 | } |
|
|
318 | |
300 | if (k > 0) { |
319 | if (k > 0) |
|
|
320 | { |
301 | rxvt_scroll_text(aR_ 0, (int)nrow - 1, -k, 1); |
321 | scr_scroll_text (0, (int)nrow - 1, -k, 1); |
302 | R->screen.cur.row += k; |
322 | screen.cur.row += k; |
303 | R->screen.s_cur.row += k; |
323 | screen.s_cur.row += k; |
304 | R->TermWin.nscrolled -= k; |
324 | TermWin.nscrolled -= k; |
305 | } |
325 | } |
306 | #ifdef DEBUG_STRICT |
326 | #ifdef DEBUG_STRICT |
307 | assert(R->screen.cur.row < R->TermWin.nrow); |
327 | assert(screen.cur.row < TermWin.nrow); |
308 | assert(R->swap.cur.row < R->TermWin.nrow); |
328 | assert(swap.cur.row < TermWin.nrow); |
309 | #else /* drive with your eyes closed */ |
329 | #else /* drive with your eyes closed */ |
|
|
330 | |
310 | MIN_IT(R->screen.cur.row, nrow - 1); |
331 | MIN_IT(screen.cur.row, nrow - 1); |
311 | MIN_IT(R->swap.cur.row, nrow - 1); |
332 | MIN_IT(swap.cur.row, nrow - 1); |
312 | #endif |
333 | #endif |
|
|
334 | TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this |
313 | } |
335 | } |
|
|
336 | |
314 | /* B2: resize columns */ |
337 | /* resize columns */ |
315 | if (ncol != prev_ncol) { |
338 | if (ncol != prev_ncol) |
|
|
339 | { |
|
|
340 | int common = min (prev_ncol, ncol); |
|
|
341 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
342 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
343 | |
316 | for (p = 0; p < total_rows; p++) { |
344 | for (p = 0; p < total_rows; p++) |
|
|
345 | { |
317 | if (R->screen.text[p]) { |
346 | if (screen.text[p]) |
318 | R->screen.text[p] = (text_t *)rxvt_realloc(R->screen.text[p], ncol * sizeof(text_t)); |
347 | { |
319 | R->screen.rend[p] = (rend_t *)rxvt_realloc(R->screen.rend[p], ncol * sizeof(rend_t)); |
348 | text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t; |
|
|
349 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, screen.rend[p], common * sizeof (rend_t)); screen.rend[p] = r; |
|
|
350 | |
320 | MIN_IT(R->screen.tlen[p], (int16_t)ncol); |
351 | MIN_IT(screen.tlen[p], (int16_t)ncol); |
|
|
352 | |
321 | if (ncol > prev_ncol) |
353 | if (ncol > prev_ncol) |
322 | rxvt_blank_line(aR_ |
354 | scr_blank_line (&(screen.text[p][prev_ncol]), |
323 | &(R->screen.text[p][prev_ncol]), |
|
|
324 | &(R->screen.rend[p][prev_ncol]), |
355 | &(screen.rend[p][prev_ncol]), |
325 | ncol - prev_ncol, |
356 | ncol - prev_ncol, |
326 | setrstyle); |
357 | setrstyle); |
327 | } |
358 | } |
328 | } |
359 | } |
|
|
360 | |
329 | for (p = 0; p < nrow; p++) { |
361 | for (p = 0; p < nrow; p++) |
330 | R->drawn_text[p] = (text_t *)rxvt_realloc(R->drawn_text[p], ncol * sizeof(text_t)); |
362 | { |
331 | R->drawn_rend[p] = (rend_t *)rxvt_realloc(R->drawn_rend[p], ncol * sizeof(rend_t)); |
363 | text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t; |
|
|
364 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, drawn_rend[p], common * sizeof (rend_t)); drawn_rend[p] = r; |
|
|
365 | |
|
|
366 | if (ncol > prev_ncol) |
|
|
367 | scr_blank_line (&(drawn_text[p][prev_ncol]), |
|
|
368 | &(drawn_rend[p][prev_ncol]), |
|
|
369 | ncol - prev_ncol, setrstyle); |
|
|
370 | |
332 | if (R->swap.text[p]) { |
371 | if (swap.text[p]) |
333 | R->swap.text[p] = (text_t *)rxvt_realloc(R->swap.text[p], ncol * sizeof(text_t)); |
372 | { |
334 | R->swap.rend[p] = (rend_t *)rxvt_realloc(R->swap.rend[p], ncol * sizeof(rend_t)); |
373 | text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t; |
|
|
374 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, swap.rend[p], common * sizeof (rend_t)); swap.rend[p] = r; |
|
|
375 | |
335 | MIN_IT(R->swap.tlen[p], (int16_t)ncol); |
376 | MIN_IT(swap.tlen[p], (int16_t)ncol); |
|
|
377 | |
336 | if (ncol > prev_ncol) |
378 | if (ncol > prev_ncol) |
337 | rxvt_blank_line(aR_ |
379 | scr_blank_line (&(swap.text[p][prev_ncol]), |
338 | &(R->swap.text[p][prev_ncol]), |
|
|
339 | &(R->swap.rend[p][prev_ncol]), |
380 | &(swap.rend[p][prev_ncol]), |
340 | ncol - prev_ncol, setrstyle); |
381 | ncol - prev_ncol, setrstyle); |
341 | } |
382 | } |
342 | if (ncol > prev_ncol) |
383 | |
343 | rxvt_blank_line(aR_ |
|
|
344 | &(R->drawn_text[p][prev_ncol]), |
|
|
345 | &(R->drawn_rend[p][prev_ncol]), |
|
|
346 | ncol - prev_ncol, setrstyle); |
|
|
347 | } |
384 | } |
|
|
385 | |
348 | MIN_IT(R->screen.cur.col, (int16_t)ncol - 1); |
386 | MIN_IT (screen.cur.col, (int16_t)ncol - 1); |
349 | MIN_IT(R->swap.cur.col, (int16_t)ncol - 1); |
387 | MIN_IT (swap.cur.col, (int16_t)ncol - 1); |
|
|
388 | |
|
|
389 | delete talloc; talloc = ta; |
|
|
390 | delete ralloc; ralloc = ra; |
350 | } |
391 | } |
|
|
392 | |
351 | if (R->tabs) |
393 | if (tabs) |
352 | free(R->tabs); |
394 | free(tabs); |
353 | } |
395 | } |
354 | |
396 | |
|
|
397 | prev_nrow = nrow; |
|
|
398 | prev_ncol = ncol; |
|
|
399 | |
355 | R->tabs = (char *)rxvt_malloc(ncol * sizeof(char)); |
400 | tabs = (char *)rxvt_malloc (ncol * sizeof(char)); |
356 | |
401 | |
357 | for (p = 0; p < ncol; p++) |
402 | for (p = 0; p < ncol; p++) |
358 | R->tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
403 | tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
359 | |
404 | |
360 | R->prev_nrow = nrow; |
|
|
361 | R->prev_ncol = ncol; |
|
|
362 | |
|
|
363 | R->tt_winch (); |
405 | tt_winch (); |
364 | } |
406 | } |
365 | |
407 | |
366 | /* INTPROTO */ |
|
|
367 | void |
408 | void |
368 | rxvt_scr_reset_realloc(pR) |
409 | rxvt_term::scr_reset_realloc() |
369 | { |
410 | { |
370 | uint16_t total_rows, nrow; |
411 | uint16_t total_rows, nrow; |
371 | |
412 | |
372 | nrow = R->TermWin.nrow; |
413 | nrow = TermWin.nrow; |
373 | total_rows = nrow + R->TermWin.saveLines; |
414 | total_rows = nrow + TermWin.saveLines; |
374 | /* *INDENT-OFF* */ |
415 | /* *INDENT-OFF* */ |
375 | R->screen.text = (text_t **)rxvt_realloc(R->screen.text, total_rows * sizeof(text_t *)); |
416 | screen.text = (text_t **)rxvt_realloc(screen.text, total_rows * sizeof(text_t *)); |
376 | R->buf_text = (text_t **)rxvt_realloc(R->buf_text , total_rows * sizeof(text_t *)); |
417 | buf_text = (text_t **)rxvt_realloc(buf_text , total_rows * sizeof(text_t *)); |
377 | R->drawn_text = (text_t **)rxvt_realloc(R->drawn_text , nrow * sizeof(text_t *)); |
418 | drawn_text = (text_t **)rxvt_realloc(drawn_text , nrow * sizeof(text_t *)); |
378 | R->swap.text = (text_t **)rxvt_realloc(R->swap.text , nrow * sizeof(text_t *)); |
419 | swap.text = (text_t **)rxvt_realloc(swap.text , nrow * sizeof(text_t *)); |
379 | |
420 | |
380 | R->screen.tlen = (int16_t *)rxvt_realloc(R->screen.tlen, total_rows * sizeof(int16_t)); |
421 | screen.tlen = (int16_t *)rxvt_realloc(screen.tlen, total_rows * sizeof(int16_t)); |
381 | R->swap.tlen = (int16_t *)rxvt_realloc(R->swap.tlen , total_rows * sizeof(int16_t)); |
422 | swap.tlen = (int16_t *)rxvt_realloc(swap.tlen , total_rows * sizeof(int16_t)); |
382 | |
423 | |
383 | R->screen.rend = (rend_t **)rxvt_realloc(R->screen.rend, total_rows * sizeof(rend_t *)); |
424 | screen.rend = (rend_t **)rxvt_realloc(screen.rend, total_rows * sizeof(rend_t *)); |
384 | R->buf_rend = (rend_t **)rxvt_realloc(R->buf_rend , total_rows * sizeof(rend_t *)); |
425 | buf_rend = (rend_t **)rxvt_realloc(buf_rend , total_rows * sizeof(rend_t *)); |
385 | R->drawn_rend = (rend_t **)rxvt_realloc(R->drawn_rend , nrow * sizeof(rend_t *)); |
426 | drawn_rend = (rend_t **)rxvt_realloc(drawn_rend , nrow * sizeof(rend_t *)); |
386 | R->swap.rend = (rend_t **)rxvt_realloc(R->swap.rend , nrow * sizeof(rend_t *)); |
427 | swap.rend = (rend_t **)rxvt_realloc(swap.rend , nrow * sizeof(rend_t *)); |
387 | /* *INDENT-ON* */ |
428 | /* *INDENT-ON* */ |
388 | } |
429 | } |
389 | |
430 | |
390 | /* ------------------------------------------------------------------------- */ |
431 | /* ------------------------------------------------------------------------- */ |
391 | /* |
432 | /* |
392 | * Free everything. That way malloc debugging can find leakage. |
433 | * Free everything. That way malloc debugging can find leakage. |
393 | */ |
434 | */ |
394 | /* EXTPROTO */ |
|
|
395 | void |
435 | void |
396 | rxvt_scr_release(pR) |
436 | rxvt_term::scr_release() |
397 | { |
437 | { |
398 | uint16_t total_rows; |
438 | uint16_t total_rows; |
399 | int i; |
439 | int i; |
400 | |
440 | |
401 | total_rows = R->TermWin.nrow + R->TermWin.saveLines; |
441 | total_rows = TermWin.nrow + TermWin.saveLines; |
402 | for (i = 0; i < total_rows; i++) { |
442 | |
403 | if (R->screen.text[i]) { /* then so is R->screen.rend[i] */ |
|
|
404 | free(R->screen.text[i]); |
|
|
405 | #ifdef DEBUG_STRICT |
443 | #ifdef DEBUG_STRICT |
|
|
444 | for (i = 0; i < total_rows; i++) |
|
|
445 | { |
|
|
446 | if (screen.text[i]) |
|
|
447 | /* then so is screen.rend[i] */ |
406 | assert(R->screen.rend[i]); |
448 | assert(screen.rend[i]); |
407 | #endif |
|
|
408 | free(R->screen.rend[i]); |
|
|
409 | } |
|
|
410 | } |
449 | } |
411 | for (i = 0; i < R->TermWin.nrow; i++) { |
450 | #endif |
412 | free(R->drawn_text[i]); |
451 | |
413 | free(R->drawn_rend[i]); |
452 | delete talloc; |
414 | free(R->swap.text[i]); |
453 | delete ralloc; |
415 | free(R->swap.rend[i]); |
454 | |
416 | } |
|
|
417 | free(R->screen.text); |
455 | free (screen.text); |
418 | free(R->screen.tlen); |
456 | free (screen.tlen); |
419 | free(R->screen.rend); |
457 | free (screen.rend); |
420 | free(R->drawn_text); |
458 | free (drawn_text); |
421 | free(R->drawn_rend); |
459 | free (drawn_rend); |
422 | free(R->swap.text); |
460 | free (swap.text); |
423 | free(R->swap.tlen); |
461 | free (swap.tlen); |
424 | free(R->swap.rend); |
462 | free (swap.rend); |
425 | free(R->buf_text); |
463 | free (buf_text); |
426 | free(R->buf_rend); |
464 | free (buf_rend); |
427 | free(R->tabs); |
465 | free (tabs); |
428 | |
466 | |
429 | /* NULL these so if anything tries to use them, we'll know about it */ |
467 | /* NULL these so if anything tries to use them, we'll know about it */ |
430 | R->screen.text = R->drawn_text = R->swap.text = NULL; |
468 | screen.text = drawn_text = swap.text = NULL; |
431 | R->screen.rend = R->drawn_rend = R->swap.rend = NULL; |
469 | screen.rend = drawn_rend = swap.rend = NULL; |
432 | R->screen.tlen = R->swap.tlen = NULL; |
470 | screen.tlen = swap.tlen = NULL; |
433 | R->buf_text = NULL; |
471 | buf_text = NULL; |
434 | R->buf_rend = NULL; |
472 | buf_rend = NULL; |
435 | R->tabs = NULL; |
473 | tabs = NULL; |
436 | } |
474 | } |
437 | |
475 | |
438 | /* ------------------------------------------------------------------------- */ |
476 | /* ------------------------------------------------------------------------- */ |
439 | /* |
477 | /* |
440 | * Hard reset |
478 | * Hard reset |
441 | */ |
479 | */ |
442 | /* EXTPROTO */ |
480 | /* EXTPROTO */ |
443 | void |
481 | void |
444 | rxvt_scr_poweron(pR) |
482 | rxvt_scr_poweron(pR) |
445 | { |
483 | { |
446 | D_SCREEN((stderr, "rxvt_scr_poweron()")); |
484 | D_SCREEN((stderr, "rxvt_scr_poweron()")); |
447 | |
485 | |
448 | rxvt_scr_release(aR); |
486 | R->scr_release (); |
449 | R->prev_nrow = R->prev_ncol = 0; |
487 | R->prev_nrow = R->prev_ncol = 0; |
450 | rxvt_scr_reset(aR); |
488 | R->scr_reset (); |
451 | |
489 | |
452 | rxvt_scr_clear(aR); |
490 | R->scr_clear (); |
453 | rxvt_scr_refresh(aR_ SLOW_REFRESH); |
491 | R->scr_refresh (SLOW_REFRESH); |
454 | #ifdef RXVT_GRAPHICS |
492 | #ifdef RXVT_GRAPHICS |
455 | rxvt_Gr_reset(aR); |
493 | rxvt_Gr_reset (aR); |
456 | #endif |
494 | #endif |
457 | } |
495 | } |
458 | |
496 | |
459 | /* ------------------------------------------------------------------------- * |
497 | /* ------------------------------------------------------------------------- * |
460 | * PROCESS SCREEN COMMANDS * |
498 | * PROCESS SCREEN COMMANDS * |
… | |
… | |
576 | if (R->current_screen == PRIMARY |
614 | if (R->current_screen == PRIMARY |
577 | # ifdef RXVT_GRAPHICS |
615 | # ifdef RXVT_GRAPHICS |
578 | && !rxvt_Gr_Displayed(aR) |
616 | && !rxvt_Gr_Displayed(aR) |
579 | # endif |
617 | # endif |
580 | ) |
618 | ) |
581 | rxvt_scroll_text(aR_ 0, (R->prev_nrow - 1), R->prev_nrow, 0); |
619 | R->scr_scroll_text(0, (R->prev_nrow - 1), R->prev_nrow, 0); |
582 | # endif |
620 | # endif |
583 | #endif |
621 | #endif |
584 | return scrn; |
622 | return scrn; |
585 | } |
623 | } |
586 | |
624 | |
… | |
… | |
620 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
658 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
621 | * count positive ==> scroll up |
659 | * count positive ==> scroll up |
622 | * count negative ==> scroll down |
660 | * count negative ==> scroll down |
623 | * spec == 0 for normal routines |
661 | * spec == 0 for normal routines |
624 | */ |
662 | */ |
625 | /* EXTPROTO */ |
|
|
626 | int |
663 | int |
627 | rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) |
664 | rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) |
628 | { |
665 | { |
629 | int i, j; |
666 | int i, j; |
630 | long nscrolled; |
667 | long nscrolled; |
631 | |
668 | |
632 | if (count == 0 || (row1 > row2)) |
669 | if (count == 0 || (row1 > row2)) |
633 | return 0; |
670 | return 0; |
634 | |
671 | |
635 | R->want_refresh = 1; |
672 | want_refresh = 1; |
636 | D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (R->current_screen == PRIMARY) ? "Primary" : "Secondary")); |
673 | D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary")); |
637 | |
674 | |
638 | if ((count > 0) && (row1 == 0) && (R->current_screen == PRIMARY)) { |
675 | if ((count > 0) && (row1 == 0) && (current_screen == PRIMARY)) |
|
|
676 | { |
639 | nscrolled = (long)R->TermWin.nscrolled + (long)count;; |
677 | nscrolled = (long)TermWin.nscrolled + (long)count; |
|
|
678 | |
640 | if (nscrolled > (long)R->TermWin.saveLines) |
679 | if (nscrolled > (long)TermWin.saveLines) |
641 | R->TermWin.nscrolled = R->TermWin.saveLines; |
680 | TermWin.nscrolled = TermWin.saveLines; |
642 | else |
681 | else |
643 | R->TermWin.nscrolled = (uint16_t)nscrolled; |
682 | TermWin.nscrolled = (uint16_t)nscrolled; |
|
|
683 | |
644 | if ((R->Options & Opt_scrollWithBuffer) |
684 | if ((Options & Opt_scrollWithBuffer) |
645 | && R->TermWin.view_start != 0 |
685 | && TermWin.view_start != 0 |
646 | && R->TermWin.view_start != R->TermWin.saveLines) |
686 | && TermWin.view_start != TermWin.saveLines) |
647 | rxvt_scr_page(aR_ UP, count); |
687 | rxvt_scr_page (this, UP, count); |
|
|
688 | } |
648 | } else if (!spec) |
689 | else if (!spec) |
649 | row1 += R->TermWin.saveLines; |
|
|
650 | row2 += R->TermWin.saveLines; |
690 | row1 += TermWin.saveLines; |
651 | |
691 | |
|
|
692 | row2 += TermWin.saveLines; |
|
|
693 | |
652 | if (R->selection.op && R->current_screen == R->selection.screen) { |
694 | if (selection.op && current_screen == selection.screen) |
|
|
695 | { |
653 | i = R->selection.beg.row + R->TermWin.saveLines; |
696 | i = selection.beg.row + TermWin.saveLines; |
654 | j = R->selection.end.row + R->TermWin.saveLines; |
697 | j = selection.end.row + TermWin.saveLines; |
655 | if ((i < row1 && j > row1) |
698 | if ((i < row1 && j > row1) |
656 | || (i < row2 && j > row2) |
699 | || (i < row2 && j > row2) |
657 | || (i - count < row1 && i >= row1) |
700 | || (i - count < row1 && i >= row1) |
658 | || (i - count > row2 && i <= row2) |
701 | || (i - count > row2 && i <= row2) |
659 | || (j - count < row1 && j >= row1) |
702 | || (j - count < row1 && j >= row1) |
660 | || (j - count > row2 && j <= row2)) { |
703 | || (j - count > row2 && j <= row2)) |
|
|
704 | { |
661 | CLEAR_ALL_SELECTION(R); |
705 | CLEAR_ALL_SELECTION (this); |
662 | R->selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
706 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
|
|
707 | } |
663 | } else if (j >= row1 && j <= row2) { |
708 | else if (j >= row1 && j <= row2) |
|
|
709 | { |
664 | /* move selected region too */ |
710 | /* move selected region too */ |
665 | R->selection.beg.row -= count; |
711 | selection.beg.row -= count; |
666 | R->selection.end.row -= count; |
712 | selection.end.row -= count; |
667 | R->selection.mark.row -= count; |
713 | selection.mark.row -= count; |
668 | } |
714 | } |
669 | } |
715 | } |
|
|
716 | |
670 | rxvt_selection_check(aR_ 0); /* _after_ R->TermWin.nscrolled update */ |
717 | rxvt_selection_check (this, 0); /* _after_ TermWin.nscrolled update */ |
671 | |
718 | |
672 | R->num_scr += count; |
719 | num_scr += count; |
673 | j = count; |
720 | j = count; |
|
|
721 | |
674 | if (count < 0) |
722 | if (count < 0) |
675 | count = -count; |
723 | count = -count; |
|
|
724 | |
676 | i = row2 - row1 + 1; |
725 | i = row2 - row1 + 1; |
677 | MIN_IT(count, i); |
726 | MIN_IT(count, i); |
678 | |
727 | |
679 | if (j > 0) { |
728 | if (j > 0) |
|
|
729 | { |
680 | /* A: scroll up */ |
730 | /* A: scroll up */ |
681 | |
731 | |
682 | /* A1: Copy lines that will get clobbered by the rotation */ |
732 | /* A1: Copy lines that will get clobbered by the rotation */ |
683 | for (i = 0, j = row1; i < count; i++, j++) { |
733 | for (i = 0, j = row1; i < count; i++, j++) |
|
|
734 | { |
684 | R->buf_text[i] = R->screen.text[j]; |
735 | buf_text[i] = screen.text[j]; |
685 | R->buf_rend[i] = R->screen.rend[j]; |
736 | buf_rend[i] = screen.rend[j]; |
686 | } |
737 | } |
687 | /* A2: Rotate lines */ |
738 | /* A2: Rotate lines */ |
688 | for (j = row1, i = j + count; i <= row2; i++, j++) { |
739 | for (j = row1, i = j + count; i <= row2; i++, j++) |
|
|
740 | { |
689 | R->screen.tlen[j] = R->screen.tlen[i]; |
741 | screen.tlen[j] = screen.tlen[i]; |
690 | R->screen.text[j] = R->screen.text[i]; |
742 | screen.text[j] = screen.text[i]; |
691 | R->screen.rend[j] = R->screen.rend[i]; |
743 | screen.rend[j] = screen.rend[i]; |
692 | } |
744 | } |
693 | j = row2 - count + 1, i = count; |
745 | j = row2 - count + 1, i = count; |
|
|
746 | } |
694 | } else /* if (j < 0) */ { |
747 | else /* if (j < 0) */ |
|
|
748 | { |
695 | /* B: scroll down */ |
749 | /* B: scroll down */ |
696 | |
750 | |
697 | /* B1: Copy lines that will get clobbered by the rotation */ |
751 | /* B1: Copy lines that will get clobbered by the rotation */ |
698 | for (i = 0, j = row2; i < count; i++, j--) { |
752 | for (i = 0, j = row2; i < count; i++, j--) |
|
|
753 | { |
699 | R->buf_text[i] = R->screen.text[j]; |
754 | buf_text[i] = screen.text[j]; |
700 | R->buf_rend[i] = R->screen.rend[j]; |
755 | buf_rend[i] = screen.rend[j]; |
701 | } |
756 | } |
702 | /* B2: Rotate lines */ |
757 | /* B2: Rotate lines */ |
703 | for (j = row2, i = j - count; i >= row1; i--, j--) { |
758 | for (j = row2, i = j - count; i >= row1; i--, j--) |
|
|
759 | { |
704 | R->screen.tlen[j] = R->screen.tlen[i]; |
760 | screen.tlen[j] = screen.tlen[i]; |
705 | R->screen.text[j] = R->screen.text[i]; |
761 | screen.text[j] = screen.text[i]; |
706 | R->screen.rend[j] = R->screen.rend[i]; |
762 | screen.rend[j] = screen.rend[i]; |
707 | } |
763 | } |
708 | j = row1, i = count; |
764 | j = row1, i = count; |
709 | count = -count; |
765 | count = -count; |
710 | } |
766 | } |
711 | |
767 | |
712 | /* C: Resurrect lines */ |
768 | /* C: Resurrect lines */ |
713 | for (; i--; j++) { |
769 | for (; i--; j++) |
|
|
770 | { |
714 | R->screen.tlen[j] = 0; |
771 | screen.tlen[j] = 0; |
715 | R->screen.text[j] = R->buf_text[i]; |
772 | screen.text[j] = buf_text[i]; |
716 | R->screen.rend[j] = R->buf_rend[i]; |
773 | screen.rend[j] = buf_rend[i]; |
|
|
774 | |
717 | if (!spec) /* line length may not equal TermWin.ncol */ |
775 | if (!spec) /* line length may not equal TermWin.ncol */ |
718 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
776 | scr_blank_screen_mem (screen.text, screen.rend, |
719 | (unsigned int)j, R->rstyle); |
777 | (unsigned int)j, rstyle); |
720 | } |
778 | } |
721 | |
779 | |
722 | #ifdef RXVT_GRAPHICS |
780 | #ifdef RXVT_GRAPHICS |
723 | if (rxvt_Gr_Displayed(aR)) |
781 | if (rxvt_Gr_Displayed (this)) |
724 | rxvt_Gr_scroll(aR_ count); |
782 | rxvt_Gr_scroll(this, count); |
725 | #endif |
783 | #endif |
|
|
784 | |
726 | return count; |
785 | return count; |
727 | } |
786 | } |
728 | |
787 | |
729 | /* ------------------------------------------------------------------------- */ |
788 | /* ------------------------------------------------------------------------- */ |
730 | /* |
789 | /* |
731 | * Add text given in <str> of length <len> to screen struct |
790 | * Add text given in <str> of length <len> to screen struct |
… | |
… | |
752 | nlines += (R->screen.cur.row - R->screen.bscroll); |
811 | nlines += (R->screen.cur.row - R->screen.bscroll); |
753 | if ((nlines > 0) |
812 | if ((nlines > 0) |
754 | && (R->screen.tscroll == 0) |
813 | && (R->screen.tscroll == 0) |
755 | && (R->screen.bscroll == (R->TermWin.nrow - 1))) { |
814 | && (R->screen.bscroll == (R->TermWin.nrow - 1))) { |
756 | /* _at least_ this many lines need to be scrolled */ |
815 | /* _at least_ this many lines need to be scrolled */ |
757 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, nlines, |
816 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, nlines, 0); |
758 | 0); |
|
|
759 | R->screen.cur.row -= nlines; |
817 | R->screen.cur.row -= nlines; |
760 | } |
818 | } |
761 | } |
819 | } |
762 | #ifdef DEBUG_STRICT |
820 | #ifdef DEBUG_STRICT |
763 | assert(R->screen.cur.col < last_col); |
821 | assert(R->screen.cur.col < last_col); |
… | |
… | |
779 | |
837 | |
780 | for (i = 0; i < len;) { |
838 | for (i = 0; i < len;) { |
781 | c = str[i++]; |
839 | c = str[i++]; |
782 | switch (c) { |
840 | switch (c) { |
783 | case '\t': |
841 | case '\t': |
784 | rxvt_scr_tab(aR_ 1); |
842 | rxvt_scr_tab (aR_ 1); |
785 | continue; |
843 | continue; |
786 | case '\n': |
844 | case '\n': |
787 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
845 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
788 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
846 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
789 | R->screen.flags &= ~Screen_WrapNext; |
847 | R->screen.flags &= ~Screen_WrapNext; |
790 | if (R->screen.cur.row == R->screen.bscroll) |
848 | if (R->screen.cur.row == R->screen.bscroll) |
791 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); |
849 | R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, 1, 0); |
792 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
850 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
793 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
851 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
794 | stp = R->screen.text[row]; /* _must_ refresh */ |
852 | stp = R->screen.text[row]; /* _must_ refresh */ |
795 | srp = R->screen.rend[row]; /* _must_ refresh */ |
853 | srp = R->screen.rend[row]; /* _must_ refresh */ |
796 | continue; |
854 | continue; |
… | |
… | |
813 | clearsel = 1; |
871 | clearsel = 1; |
814 | } |
872 | } |
815 | if (R->screen.flags & Screen_WrapNext) { |
873 | if (R->screen.flags & Screen_WrapNext) { |
816 | R->screen.tlen[row] = -1; |
874 | R->screen.tlen[row] = -1; |
817 | if (R->screen.cur.row == R->screen.bscroll) |
875 | if (R->screen.cur.row == R->screen.bscroll) |
818 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); |
876 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, 1, 0); |
819 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
877 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
820 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
878 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
821 | stp = R->screen.text[row]; /* _must_ refresh */ |
879 | stp = R->screen.text[row]; /* _must_ refresh */ |
822 | srp = R->screen.rend[row]; /* _must_ refresh */ |
880 | srp = R->screen.rend[row]; /* _must_ refresh */ |
823 | R->screen.cur.col = 0; |
881 | R->screen.cur.col = 0; |
… | |
… | |
1075 | #endif |
1133 | #endif |
1076 | |
1134 | |
1077 | R->screen.flags &= ~Screen_WrapNext; |
1135 | R->screen.flags &= ~Screen_WrapNext; |
1078 | if ((R->screen.cur.row == R->screen.bscroll && direction == UP) |
1136 | if ((R->screen.cur.row == R->screen.bscroll && direction == UP) |
1079 | || (R->screen.cur.row == R->screen.tscroll && direction == DN)) |
1137 | || (R->screen.cur.row == R->screen.tscroll && direction == DN)) |
1080 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, dirn, 0); |
1138 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, dirn, 0); |
1081 | else |
1139 | else |
1082 | R->screen.cur.row += dirn; |
1140 | R->screen.cur.row += dirn; |
1083 | MAX_IT(R->screen.cur.row, 0); |
1141 | MAX_IT(R->screen.cur.row, 0); |
1084 | MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); |
1142 | MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); |
1085 | rxvt_selection_check(aR_ 0); |
1143 | rxvt_selection_check(aR_ 0); |
… | |
… | |
1094 | */ |
1152 | */ |
1095 | /* EXTPROTO */ |
1153 | /* EXTPROTO */ |
1096 | void |
1154 | void |
1097 | rxvt_scr_erase_line(pR_ int mode) |
1155 | rxvt_scr_erase_line(pR_ int mode) |
1098 | { |
1156 | { |
1099 | unsigned int row, col, num; |
1157 | unsigned int row, col, num; |
1100 | |
1158 | |
1101 | R->want_refresh = 1; |
1159 | R->want_refresh = 1; |
1102 | D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); |
1160 | D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); |
1103 | ZERO_SCROLLBACK(R); |
1161 | ZERO_SCROLLBACK (R); |
1104 | |
1162 | |
1105 | #ifdef RXVT_GRAPHICS |
1163 | #ifdef RXVT_GRAPHICS |
1106 | if (rxvt_Gr_Displayed(aR)) |
1164 | if (rxvt_Gr_Displayed (aR)) |
1107 | rxvt_Gr_scroll(aR_ 0); |
1165 | rxvt_Gr_scroll (aR_ 0); |
1108 | #endif |
1166 | #endif |
1109 | |
1167 | |
1110 | rxvt_selection_check(aR_ 1); |
1168 | rxvt_selection_check (aR_ 1); |
1111 | |
1169 | |
1112 | R->screen.flags &= ~Screen_WrapNext; |
1170 | R->screen.flags &= ~Screen_WrapNext; |
1113 | |
1171 | |
1114 | row = R->TermWin.saveLines + R->screen.cur.row; |
1172 | row = R->TermWin.saveLines + R->screen.cur.row; |
1115 | switch (mode) { |
1173 | switch (mode) |
|
|
1174 | { |
1116 | case 0: /* erase to end of line */ |
1175 | case 0: /* erase to end of line */ |
1117 | col = R->screen.cur.col; |
1176 | col = R->screen.cur.col; |
1118 | num = R->TermWin.ncol - col; |
1177 | num = R->TermWin.ncol - col; |
1119 | MIN_IT(R->screen.tlen[row], (int16_t)col); |
1178 | MIN_IT(R->screen.tlen[row], (int16_t)col); |
1120 | if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) |
1179 | if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) |
1121 | || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) |
1180 | || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) |
1122 | CLEAR_SELECTION(R); |
1181 | CLEAR_SELECTION(R); |
1123 | break; |
1182 | break; |
1124 | case 1: /* erase to beginning of line */ |
1183 | case 1: /* erase to beginning of line */ |
1125 | col = 0; |
1184 | col = 0; |
1126 | num = R->screen.cur.col + 1; |
1185 | num = R->screen.cur.col + 1; |
1127 | if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) |
1186 | if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) |
1128 | || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) |
1187 | || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) |
1129 | CLEAR_SELECTION(R); |
1188 | CLEAR_SELECTION(R); |
1130 | break; |
1189 | break; |
1131 | case 2: /* erase whole line */ |
1190 | case 2: /* erase whole line */ |
1132 | col = 0; |
1191 | col = 0; |
1133 | num = R->TermWin.ncol; |
1192 | num = R->TermWin.ncol; |
1134 | R->screen.tlen[row] = 0; |
1193 | R->screen.tlen[row] = 0; |
1135 | if (R->selection.beg.row <= R->screen.cur.row |
1194 | if (R->selection.beg.row <= R->screen.cur.row |
1136 | && R->selection.end.row >= R->screen.cur.row) |
1195 | && R->selection.end.row >= R->screen.cur.row) |
1137 | CLEAR_SELECTION(R); |
1196 | CLEAR_SELECTION(R); |
1138 | break; |
1197 | break; |
1139 | default: |
1198 | default: |
1140 | return; |
1199 | return; |
1141 | } |
1200 | } |
|
|
1201 | |
1142 | if (R->screen.text[row]) |
1202 | if (R->screen.text[row]) |
1143 | rxvt_blank_line(aR_ |
1203 | R->scr_blank_line (&(R->screen.text[row][col]), |
1144 | &(R->screen.text[row][col]), |
|
|
1145 | &(R->screen.rend[row][col]), num, R->rstyle); |
1204 | &(R->screen.rend[row][col]), num, R->rstyle); |
1146 | else |
1205 | else |
1147 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, row, |
1206 | R->scr_blank_screen_mem (R->screen.text, R->screen.rend, row, R->rstyle); |
1148 | R->rstyle); |
|
|
1149 | } |
1207 | } |
1150 | |
1208 | |
1151 | /* ------------------------------------------------------------------------- */ |
1209 | /* ------------------------------------------------------------------------- */ |
1152 | /* |
1210 | /* |
1153 | * Erase part of whole of the screen |
1211 | * Erase part of whole of the screen |
1154 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1212 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1155 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1213 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1156 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1214 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1157 | */ |
1215 | */ |
1158 | /* EXTPROTO */ |
|
|
1159 | void |
1216 | void |
1160 | rxvt_scr_erase_screen(pR_ int mode) |
1217 | rxvt_term::scr_erase_screen (int mode) |
1161 | { |
1218 | { |
1162 | int num; |
1219 | int num; |
1163 | int32_t row, row_offset; |
1220 | int32_t row, row_offset; |
1164 | rend_t ren; |
1221 | rend_t ren; |
1165 | XGCValues gcvalue; |
1222 | XGCValues gcvalue; |
1166 | |
1223 | |
1167 | R->want_refresh = 1; |
1224 | want_refresh = 1; |
1168 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); |
1225 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row)); |
1169 | ZERO_SCROLLBACK(R); |
1226 | ZERO_SCROLLBACK(this); |
1170 | row_offset = (int32_t)R->TermWin.saveLines; |
1227 | row_offset = (int32_t)TermWin.saveLines; |
1171 | |
1228 | |
1172 | switch (mode) { |
1229 | switch (mode) { |
1173 | case 0: /* erase to end of screen */ |
1230 | case 0: /* erase to end of screen */ |
1174 | rxvt_selection_check(aR_ 1); |
1231 | rxvt_selection_check(this,1); |
1175 | rxvt_scr_erase_line(aR_ 0); |
1232 | rxvt_scr_erase_line(this,0); |
1176 | row = R->screen.cur.row + 1; /* possible OOB */ |
1233 | row = screen.cur.row + 1; /* possible OOB */ |
1177 | num = R->TermWin.nrow - row; |
1234 | num = TermWin.nrow - row; |
1178 | break; |
1235 | break; |
1179 | case 1: /* erase to beginning of screen */ |
1236 | case 1: /* erase to beginning of screen */ |
1180 | rxvt_selection_check(aR_ 3); |
1237 | rxvt_selection_check(this,3); |
1181 | rxvt_scr_erase_line(aR_ 1); |
1238 | rxvt_scr_erase_line(this,1); |
1182 | row = 0; |
1239 | row = 0; |
1183 | num = R->screen.cur.row; |
1240 | num = screen.cur.row; |
1184 | break; |
1241 | break; |
1185 | case 2: /* erase whole screen */ |
1242 | case 2: /* erase whole screen */ |
1186 | rxvt_selection_check(aR_ 3); |
1243 | rxvt_selection_check (this, 3); |
1187 | #ifdef RXVT_GRAPHICS |
1244 | #ifdef RXVT_GRAPHICS |
1188 | rxvt_Gr_ClearScreen(aR); |
1245 | rxvt_Gr_ClearScreen (this); |
1189 | #endif |
1246 | #endif |
1190 | row = 0; |
1247 | row = 0; |
1191 | num = R->TermWin.nrow; |
1248 | num = TermWin.nrow; |
1192 | break; |
1249 | break; |
1193 | default: |
1250 | default: |
1194 | return; |
1251 | return; |
1195 | } |
1252 | } |
1196 | R->refresh_type |= REFRESH_BOUNDS; |
1253 | refresh_type |= REFRESH_BOUNDS; |
1197 | if (R->selection.op && R->current_screen == R->selection.screen |
1254 | if (selection.op && current_screen == selection.screen |
1198 | && ((R->selection.beg.row >= row && R->selection.beg.row <= row + num) |
1255 | && ((selection.beg.row >= row && selection.beg.row <= row + num) |
1199 | || (R->selection.end.row >= row |
1256 | || (selection.end.row >= row |
1200 | && R->selection.end.row <= row + num))) |
1257 | && selection.end.row <= row + num))) |
1201 | CLEAR_SELECTION(R); |
1258 | CLEAR_SELECTION (this); |
1202 | if (row >= R->TermWin.nrow) /* Out Of Bounds */ |
1259 | if (row >= TermWin.nrow) /* Out Of Bounds */ |
1203 | return; |
1260 | return; |
1204 | MIN_IT(num, (R->TermWin.nrow - row)); |
1261 | MIN_IT(num, (TermWin.nrow - row)); |
1205 | if (R->rstyle & (RS_RVid | RS_Uline)) |
1262 | if (rstyle & (RS_RVid | RS_Uline)) |
1206 | ren = (rend_t) ~RS_None; |
1263 | ren = (rend_t) ~RS_None; |
1207 | else if (GET_BASEBG(R->rstyle) == Color_bg) { |
1264 | else if (GET_BASEBG(rstyle) == Color_bg) { |
1208 | ren = DEFAULT_RSTYLE; |
1265 | ren = DEFAULT_RSTYLE; |
1209 | CLEAR_ROWS(row, num); |
1266 | CLEAR_ROWS(row, num); |
1210 | } else { |
1267 | } else { |
1211 | ren = (R->rstyle & (RS_fgMask | RS_bgMask)); |
1268 | ren = (rstyle & (RS_fgMask | RS_bgMask)); |
1212 | gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->rstyle)]; |
1269 | gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)]; |
1213 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1270 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1214 | ERASE_ROWS(row, num); |
1271 | ERASE_ROWS(row, num); |
1215 | gcvalue.foreground = R->PixColors[Color_fg]; |
1272 | gcvalue.foreground = PixColors[Color_fg]; |
1216 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1273 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1217 | } |
1274 | } |
1218 | for (; num--; row++) { |
1275 | for (; num--; row++) { |
1219 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
1276 | scr_blank_screen_mem (screen.text, screen.rend, |
1220 | (unsigned int)(row + row_offset), R->rstyle); |
1277 | (unsigned int)(row + row_offset), rstyle); |
1221 | R->screen.tlen[row + row_offset] = 0; |
1278 | screen.tlen[row + row_offset] = 0; |
1222 | rxvt_blank_line(aR_ |
1279 | scr_blank_line (drawn_text[row], drawn_rend[row], |
1223 | R->drawn_text[row], R->drawn_rend[row], |
|
|
1224 | (unsigned int)R->TermWin.ncol, ren); |
1280 | (unsigned int)TermWin.ncol, ren); |
1225 | } |
1281 | } |
1226 | } |
1282 | } |
1227 | |
1283 | |
1228 | /* ------------------------------------------------------------------------- */ |
1284 | /* ------------------------------------------------------------------------- */ |
1229 | /* |
1285 | /* |
… | |
… | |
1280 | else if (insdel == INSERT) |
1336 | else if (insdel == INSERT) |
1281 | count = end; |
1337 | count = end; |
1282 | } |
1338 | } |
1283 | R->screen.flags &= ~Screen_WrapNext; |
1339 | R->screen.flags &= ~Screen_WrapNext; |
1284 | |
1340 | |
1285 | rxvt_scroll_text(aR_ R->screen.cur.row, R->screen.bscroll, insdel * count, |
1341 | R->scr_scroll_text(R->screen.cur.row, R->screen.bscroll, insdel * count, 0); |
1286 | 0); |
|
|
1287 | } |
1342 | } |
1288 | |
1343 | |
1289 | /* ------------------------------------------------------------------------- */ |
1344 | /* ------------------------------------------------------------------------- */ |
1290 | /* |
1345 | /* |
1291 | * Insert/Delete <count> characters from the current position |
1346 | * Insert/Delete <count> characters from the current position |
… | |
… | |
1340 | R->selection.beg.col += count; |
1395 | R->selection.beg.col += count; |
1341 | R->selection.mark.col += count; /* XXX: yes? */ |
1396 | R->selection.mark.col += count; /* XXX: yes? */ |
1342 | R->selection.end.col += count; |
1397 | R->selection.end.col += count; |
1343 | } |
1398 | } |
1344 | } |
1399 | } |
1345 | rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1400 | R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1346 | (unsigned int)count, R->rstyle); |
1401 | (unsigned int)count, R->rstyle); |
1347 | break; |
1402 | break; |
1348 | case ERASE: |
1403 | case ERASE: |
1349 | R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ |
1404 | R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ |
1350 | rxvt_selection_check(aR_ 1); |
1405 | rxvt_selection_check(aR_ 1); |
1351 | R->screen.cur.col -= count; |
1406 | R->screen.cur.col -= count; |
1352 | rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1407 | R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1353 | (unsigned int)count, R->rstyle); |
1408 | (unsigned int)count, R->rstyle); |
1354 | break; |
1409 | break; |
1355 | case DELETE: |
1410 | case DELETE: |
1356 | tr = srp[R->TermWin.ncol - 1] |
1411 | tr = srp[R->TermWin.ncol - 1] |
1357 | & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1412 | & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1358 | for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) { |
1413 | for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) { |
1359 | stp[col] = stp[col + count]; |
1414 | stp[col] = stp[col + count]; |
1360 | srp[col] = srp[col + count]; |
1415 | srp[col] = srp[col + count]; |
1361 | } |
1416 | } |
1362 | rxvt_blank_line(aR_ |
1417 | R->scr_blank_line (&(stp[R->TermWin.ncol - count]), |
1363 | &(stp[R->TermWin.ncol - count]), |
|
|
1364 | &(srp[R->TermWin.ncol - count]), |
1418 | &(srp[R->TermWin.ncol - count]), |
1365 | (unsigned int)count, tr); |
1419 | (unsigned int)count, tr); |
1366 | if (*slp == -1) /* break line continuation */ |
1420 | if (*slp == -1) /* break line continuation */ |
1367 | *slp = R->TermWin.ncol; |
1421 | *slp = R->TermWin.ncol; |
1368 | *slp -= count; |
1422 | *slp -= count; |
1369 | MAX_IT(*slp, 0); |
1423 | MAX_IT(*slp, 0); |
1370 | if (R->selection.op && R->current_screen == R->selection.screen |
1424 | if (R->selection.op && R->current_screen == R->selection.screen |
… | |
… | |
1515 | |
1569 | |
1516 | gcvalue.foreground = R->PixColors[Color_fg]; |
1570 | gcvalue.foreground = R->PixColors[Color_fg]; |
1517 | gcvalue.background = R->PixColors[Color_bg]; |
1571 | gcvalue.background = R->PixColors[Color_bg]; |
1518 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1572 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1519 | &gcvalue); |
1573 | &gcvalue); |
1520 | rxvt_scr_clear(aR); |
1574 | R->scr_clear (); |
1521 | rxvt_scr_touch(aR_ True); |
1575 | R->scr_touch (true); |
1522 | } |
1576 | } |
1523 | } |
1577 | } |
1524 | |
1578 | |
1525 | /* ------------------------------------------------------------------------- */ |
1579 | /* ------------------------------------------------------------------------- */ |
1526 | /* |
1580 | /* |
… | |
… | |
1629 | PART_BEG = 0, |
1683 | PART_BEG = 0, |
1630 | PART_END, |
1684 | PART_END, |
1631 | RC_COUNT |
1685 | RC_COUNT |
1632 | }; |
1686 | }; |
1633 | |
1687 | |
1634 | /* EXTPROTO */ |
|
|
1635 | void |
1688 | void |
1636 | rxvt_scr_expose(pR_ int x, int y, int width, int height, Bool refresh) |
1689 | rxvt_term::scr_expose (int x, int y, int width, int height, bool refresh) |
1637 | { |
1690 | { |
1638 | int i; |
1691 | int i; |
1639 | row_col_t rc[RC_COUNT]; |
1692 | row_col_t rc[RC_COUNT]; |
1640 | |
1693 | |
1641 | if (R->drawn_text == NULL) /* sanity check */ |
1694 | if (drawn_text == NULL) /* sanity check */ |
1642 | return; |
1695 | return; |
1643 | |
1696 | |
1644 | #ifdef DEBUG_STRICT |
1697 | #ifdef DEBUG_STRICT |
1645 | x = max(x, (int)R->TermWin.int_bwidth); |
1698 | x = max(x, (int)TermWin.int_bwidth); |
1646 | x = min(x, (int)R->TermWin.width); |
1699 | x = min(x, (int)TermWin.width); |
1647 | y = max(y, (int)R->TermWin.int_bwidth); |
1700 | y = max(y, (int)TermWin.int_bwidth); |
1648 | y = min(y, (int)R->TermWin.height); |
1701 | y = min(y, (int)TermWin.height); |
1649 | #endif |
1702 | #endif |
1650 | |
1703 | |
1651 | /* round down */ |
1704 | /* round down */ |
1652 | rc[PART_BEG].col = Pixel2Col(x); |
1705 | rc[PART_BEG].col = Pixel2Col(x); |
1653 | rc[PART_BEG].row = Pixel2Row(y); |
1706 | rc[PART_BEG].row = Pixel2Row(y); |
1654 | /* round up */ |
1707 | /* round up */ |
1655 | rc[PART_END].col = Pixel2Width(x + width + R->TermWin.fwidth - 1); |
1708 | rc[PART_END].col = Pixel2Width(x + width + TermWin.fwidth - 1); |
1656 | rc[PART_END].row = Pixel2Row(y + height + R->TermWin.fheight - 1); |
1709 | rc[PART_END].row = Pixel2Row(y + height + TermWin.fheight - 1); |
1657 | |
1710 | |
1658 | /* sanity checks */ |
1711 | /* sanity checks */ |
1659 | for (i = PART_BEG; i < RC_COUNT; i++) { |
1712 | for (i = PART_BEG; i < RC_COUNT; i++) |
|
|
1713 | { |
1660 | MIN_IT(rc[i].col, R->TermWin.ncol - 1); |
1714 | MIN_IT(rc[i].col, TermWin.ncol - 1); |
1661 | MIN_IT(rc[i].row, R->TermWin.nrow - 1); |
1715 | MIN_IT(rc[i].row, TermWin.nrow - 1); |
1662 | } |
1716 | } |
1663 | |
1717 | |
1664 | D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); |
1718 | D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); |
1665 | |
1719 | |
1666 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1720 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1667 | fill_text (&(R->drawn_text[i][rc[PART_BEG].col]), 0, |
1721 | fill_text (&(drawn_text[i][rc[PART_BEG].col]), 0, |
1668 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1722 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1669 | |
1723 | |
1670 | if (refresh) |
1724 | if (refresh) |
1671 | rxvt_scr_refresh(aR_ SLOW_REFRESH | REFRESH_BOUNDS); |
1725 | scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); |
1672 | } |
1726 | } |
1673 | |
1727 | |
1674 | /* ------------------------------------------------------------------------- */ |
1728 | /* ------------------------------------------------------------------------- */ |
1675 | /* |
1729 | /* |
1676 | * Refresh the entire screen |
1730 | * Refresh the entire screen |
1677 | */ |
1731 | */ |
1678 | /* EXTPROTO */ |
|
|
1679 | void |
1732 | void |
1680 | rxvt_scr_touch(pR_ Bool refresh) |
1733 | rxvt_term::scr_touch (bool refresh) |
1681 | { |
1734 | { |
1682 | rxvt_scr_expose(aR_ 0, 0, R->TermWin.width, R->TermWin.height, refresh); |
1735 | scr_expose (0, 0, TermWin.width, TermWin.height, refresh); |
1683 | } |
1736 | } |
1684 | |
1737 | |
1685 | /* ------------------------------------------------------------------------- */ |
1738 | /* ------------------------------------------------------------------------- */ |
1686 | /* |
1739 | /* |
1687 | * Move the display so that the line represented by scrollbar value Y is at |
1740 | * Move the display so that the line represented by scrollbar value Y is at |
… | |
… | |
1824 | #define FONT_LBEAR(X, Y) \ |
1877 | #define FONT_LBEAR(X, Y) \ |
1825 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1878 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1826 | #define IS_FONT_CHAR(X, Y) \ |
1879 | #define IS_FONT_CHAR(X, Y) \ |
1827 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1880 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1828 | |
1881 | |
1829 | /* EXTPROTO */ |
|
|
1830 | void |
1882 | void |
1831 | rxvt_scr_refresh(pR_ unsigned char refresh_type) |
1883 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1832 | { |
1884 | { |
1833 | unsigned char clearfirst, /* first character writes before cell */ |
1885 | unsigned char clearfirst, /* first character writes before cell */ |
1834 | clearlast, /* last character writes beyond cell */ |
1886 | clearlast, /* last character writes beyond cell */ |
1835 | must_clear, /* use draw_string not draw_image_string */ |
1887 | must_clear, /* use draw_string not draw_image_string */ |
1836 | #ifndef NO_BOLDFONT |
1888 | #ifndef NO_BOLDFONT |
… | |
… | |
1849 | rend_t cc1; /* store colours at cursor position(s) */ |
1901 | rend_t cc1; /* store colours at cursor position(s) */ |
1850 | rend_t cc2; /* store colours at cursor position(s) */ |
1902 | rend_t cc2; /* store colours at cursor position(s) */ |
1851 | #endif |
1903 | #endif |
1852 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1904 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1853 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1905 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1854 | char *buffer; /* local copy of R->buffer */ |
|
|
1855 | |
1906 | |
1856 | if (refresh_type == NO_REFRESH || !R->TermWin.mapped) |
1907 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1857 | return; |
1908 | return; |
1858 | |
1909 | |
1859 | /* |
1910 | /* |
1860 | * A: set up vars |
1911 | * A: set up vars |
1861 | */ |
1912 | */ |
1862 | clearfirst = clearlast = must_clear = wbyte = 0; |
1913 | clearfirst = clearlast = must_clear = wbyte = 0; |
1863 | #ifndef NO_BOLDFONT |
1914 | #ifndef NO_BOLDFONT |
1864 | bfont = 0; |
1915 | bfont = 0; |
1865 | #endif |
1916 | #endif |
1866 | |
1917 | |
1867 | if (R->currmaxcol < R->TermWin.ncol) |
1918 | if (currmaxcol < TermWin.ncol) |
1868 | { |
1919 | { |
1869 | R->currmaxcol = R->TermWin.ncol; |
1920 | currmaxcol = TermWin.ncol; |
1870 | R->buffer = (char *)rxvt_realloc (R->buffer, |
1921 | buffer = (char *)rxvt_realloc (buffer, |
1871 | sizeof(char) * (R->currmaxcol + 1) * MB_CUR_MAX); |
1922 | sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); |
1872 | } |
1923 | } |
1873 | |
1924 | |
1874 | buffer = R->buffer; |
|
|
1875 | R->refresh_count = 0; |
1925 | refresh_count = 0; |
1876 | |
1926 | |
1877 | row_offset = R->TermWin.saveLines - R->TermWin.view_start; |
1927 | row_offset = TermWin.saveLines - TermWin.view_start; |
1878 | |
1928 | |
1879 | if ((refresh_type & REFRESH_BOUNDS)) |
1929 | if ((refresh_type & REFRESH_BOUNDS)) |
1880 | { |
1930 | { |
1881 | clearfirst = clearlast = 1; |
1931 | clearfirst = clearlast = 1; |
1882 | R->refresh_type &= ~REFRESH_BOUNDS; |
1932 | refresh_type &= ~REFRESH_BOUNDS; |
1883 | } |
1933 | } |
1884 | |
1934 | |
1885 | #if defined(XPM_BACKGROUND) |
1935 | #if defined(XPM_BACKGROUND) |
1886 | must_clear |= (R->bgPixmap.pixmap != None); |
1936 | must_clear |= (bgPixmap.pixmap != None); |
1887 | #endif |
1937 | #endif |
1888 | #if defined(TRANSPARENT) |
1938 | #if defined(TRANSPARENT) |
1889 | must_clear |= ((R->Options & Opt_transparent) && R->am_transparent); |
1939 | must_clear |= ((Options & Opt_transparent) && am_transparent); |
1890 | #endif |
1940 | #endif |
1891 | ocrow = R->oldcursor.row; /* is there an old outline cursor on screen? */ |
1941 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1892 | |
1942 | |
1893 | /* |
1943 | /* |
1894 | * B: reverse any characters which are selected |
1944 | * B: reverse any characters which are selected |
1895 | */ |
1945 | */ |
1896 | rxvt_scr_reverse_selection(aR); |
1946 | rxvt_scr_reverse_selection (this); |
1897 | |
1947 | |
1898 | /* |
1948 | /* |
1899 | * C: set the cursor character(s) |
1949 | * C: set the cursor character(s) |
1900 | */ |
1950 | */ |
1901 | { |
1951 | { |
1902 | unsigned char setoldcursor; |
1952 | unsigned char setoldcursor; |
1903 | rend_t ccol1, /* Cursor colour */ |
1953 | rend_t ccol1, /* Cursor colour */ |
1904 | ccol2; /* Cursor colour2 */ |
1954 | ccol2; /* Cursor colour2 */ |
1905 | |
1955 | |
1906 | showcursor = (R->screen.flags & Screen_VisibleCursor); |
1956 | showcursor = (screen.flags & Screen_VisibleCursor); |
1907 | cursorwidth = 0; |
1957 | cursorwidth = 0; |
1908 | #ifdef CURSOR_BLINK |
1958 | #ifdef CURSOR_BLINK |
1909 | if (R->hidden_cursor) |
1959 | if (hidden_cursor) |
1910 | showcursor = 0; |
1960 | showcursor = 0; |
1911 | #endif |
1961 | #endif |
1912 | |
1962 | |
1913 | cursorwidth = 0; |
1963 | cursorwidth = 0; |
1914 | |
1964 | |
1915 | if (showcursor) |
1965 | if (showcursor) |
1916 | { |
1966 | { |
1917 | cursorwidth++; |
1967 | cursorwidth++; |
1918 | |
1968 | |
1919 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
1969 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
1920 | [R->screen.cur.col]); |
1970 | [screen.cur.col]); |
1921 | |
1971 | |
1922 | if (showcursor && R->TermWin.focus) |
1972 | if (showcursor && TermWin.focus) |
1923 | { |
1973 | { |
1924 | *srp ^= RS_RVid; |
1974 | *srp ^= RS_RVid; |
1925 | #ifndef NO_CURSORCOLOR |
1975 | #ifndef NO_CURSORCOLOR |
1926 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1976 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1927 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) |
1977 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
1928 | ccol1 = Color_cursor; |
1978 | ccol1 = Color_cursor; |
1929 | else |
1979 | else |
1930 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1980 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1931 | ccol1 = GET_FGCOLOR(R->rstyle); |
1981 | ccol1 = GET_FGCOLOR(rstyle); |
1932 | #else |
1982 | #else |
1933 | ccol1 = Color_fg; |
1983 | ccol1 = Color_fg; |
1934 | #endif |
1984 | #endif |
1935 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor2)) |
1985 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor2)) |
1936 | ccol2 = Color_cursor2; |
1986 | ccol2 = Color_cursor2; |
1937 | else |
1987 | else |
1938 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1988 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1939 | ccol2 = GET_BGCOLOR(R->rstyle); |
1989 | ccol2 = GET_BGCOLOR(rstyle); |
1940 | #else |
1990 | #else |
1941 | ccol2 = Color_bg; |
1991 | ccol2 = Color_bg; |
1942 | #endif |
1992 | #endif |
1943 | *srp = SET_FGCOLOR(*srp, ccol1); |
1993 | *srp = SET_FGCOLOR(*srp, ccol1); |
1944 | *srp = SET_BGCOLOR(*srp, ccol2); |
1994 | *srp = SET_BGCOLOR(*srp, ccol2); |
… | |
… | |
1950 | } |
2000 | } |
1951 | |
2001 | |
1952 | /* make sure no outline cursor is left around */ |
2002 | /* make sure no outline cursor is left around */ |
1953 | setoldcursor = 0; |
2003 | setoldcursor = 0; |
1954 | if (ocrow != -1) { |
2004 | if (ocrow != -1) { |
1955 | if (R->screen.cur.row + R->TermWin.view_start != ocrow |
2005 | if (screen.cur.row + TermWin.view_start != ocrow |
1956 | || R->screen.cur.col != R->oldcursor.col) { |
2006 | || screen.cur.col != oldcursor.col) { |
1957 | if (ocrow < R->TermWin.nrow |
2007 | if (ocrow < TermWin.nrow |
1958 | && R->oldcursor.col < R->TermWin.ncol) { |
2008 | && oldcursor.col < TermWin.ncol) { |
1959 | R->drawn_rend[ocrow][R->oldcursor.col] ^= (RS_RVid | RS_Uline); |
2009 | drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); |
1960 | } |
2010 | } |
1961 | if (R->TermWin.focus || !showcursor) |
2011 | if (TermWin.focus || !showcursor) |
1962 | R->oldcursor.row = -1; |
2012 | oldcursor.row = -1; |
1963 | else |
2013 | else |
1964 | setoldcursor = 1; |
2014 | setoldcursor = 1; |
1965 | } |
2015 | } |
1966 | } else if (!R->TermWin.focus) |
2016 | } else if (!TermWin.focus) |
1967 | setoldcursor = 1; |
2017 | setoldcursor = 1; |
1968 | if (setoldcursor) { |
2018 | if (setoldcursor) { |
1969 | if (R->screen.cur.row + R->TermWin.view_start >= R->TermWin.nrow) |
2019 | if (screen.cur.row + TermWin.view_start >= TermWin.nrow) |
1970 | R->oldcursor.row = -1; |
2020 | oldcursor.row = -1; |
1971 | else { |
2021 | else { |
1972 | R->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; |
2022 | oldcursor.row = screen.cur.row + TermWin.view_start; |
1973 | R->oldcursor.col = R->screen.cur.col; |
2023 | oldcursor.col = screen.cur.col; |
1974 | } |
2024 | } |
1975 | } |
2025 | } |
1976 | } |
2026 | } |
1977 | |
2027 | |
1978 | #ifndef NO_SLOW_LINK_SUPPORT |
2028 | #ifndef NO_SLOW_LINK_SUPPORT |
1979 | /* |
2029 | /* |
1980 | * D: CopyArea pass - very useful for slower links |
2030 | * D: CopyArea pass - very useful for slower links |
1981 | * This has been deliberately kept simple. |
2031 | * This has been deliberately kept simple. |
1982 | */ |
2032 | */ |
1983 | i = R->num_scr; |
2033 | i = num_scr; |
1984 | if (refresh_type == FAST_REFRESH && R->num_scr_allow && i |
2034 | if (refresh_type == FAST_REFRESH && num_scr_allow && i |
1985 | && abs(i) < R->TermWin.nrow && !must_clear) |
2035 | && abs(i) < TermWin.nrow && !must_clear) |
1986 | { |
2036 | { |
1987 | int16_t nits; |
2037 | int16_t nits; |
1988 | int j; |
2038 | int j; |
1989 | rend_t *drp2; |
2039 | rend_t *drp2; |
1990 | text_t *dtp2; |
2040 | text_t *dtp2; |
1991 | int len, wlen; |
2041 | int len, wlen; |
1992 | |
2042 | |
1993 | j = R->TermWin.nrow; |
2043 | j = TermWin.nrow; |
1994 | wlen = len = -1; |
2044 | wlen = len = -1; |
1995 | row = i > 0 ? 0 : j - 1; |
2045 | row = i > 0 ? 0 : j - 1; |
1996 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2046 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
1997 | { |
2047 | { |
1998 | if (row + i >= 0 && row + i < R->TermWin.nrow && row + i != ocrow) |
2048 | if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow) |
1999 | { |
2049 | { |
2000 | stp = R->screen.text[row + row_offset]; |
2050 | stp = screen.text[row + row_offset]; |
2001 | srp = R->screen.rend[row + row_offset]; |
2051 | srp = screen.rend[row + row_offset]; |
2002 | dtp = R->drawn_text[row]; |
2052 | dtp = drawn_text[row]; |
2003 | dtp2 = R->drawn_text[row + i]; |
2053 | dtp2 = drawn_text[row + i]; |
2004 | drp = R->drawn_rend[row]; |
2054 | drp = drawn_rend[row]; |
2005 | drp2 = R->drawn_rend[row + i]; |
2055 | drp2 = drawn_rend[row + i]; |
2006 | |
2056 | |
2007 | for (nits = 0, col = R->TermWin.ncol; col--; ) |
2057 | for (nits = 0, col = TermWin.ncol; col--; ) |
2008 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2058 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2009 | nits--; |
2059 | nits--; |
2010 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2060 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2011 | nits++; |
2061 | nits++; |
2012 | |
2062 | |
2013 | if (nits > 8) /* XXX: arbitrary choice */ |
2063 | if (nits > 8) /* XXX: arbitrary choice */ |
2014 | { |
2064 | { |
2015 | for (col = R->TermWin.ncol; col--; ) |
2065 | for (col = TermWin.ncol; col--; ) |
2016 | { |
2066 | { |
2017 | *dtp++ = *dtp2++; |
2067 | *dtp++ = *dtp2++; |
2018 | *drp++ = *drp2++; |
2068 | *drp++ = *drp2++; |
2019 | } |
2069 | } |
2020 | |
2070 | |
… | |
… | |
2029 | if (len != -1) |
2079 | if (len != -1) |
2030 | { |
2080 | { |
2031 | /* also comes here at end if needed because of >= above */ |
2081 | /* also comes here at end if needed because of >= above */ |
2032 | if (wlen < len) |
2082 | if (wlen < len) |
2033 | SWAP_IT(wlen, len, int); |
2083 | SWAP_IT(wlen, len, int); |
|
|
2084 | |
2034 | D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
2085 | D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
2035 | XCopyArea(R->Xdisplay, R->TermWin.vt, R->TermWin.vt, |
2086 | XCopyArea (Xdisplay, TermWin.vt, TermWin.vt, |
2036 | R->TermWin.gc, 0, Row2Pixel(len + i), |
2087 | TermWin.gc, 0, Row2Pixel (len + i), |
2037 | (unsigned int)TermWin_TotalWidth(), |
2088 | (unsigned int)TermWin_TotalWidth (), |
2038 | (unsigned int)Height2Pixel(wlen - len + 1), |
2089 | (unsigned int)Height2Pixel (wlen - len + 1), |
2039 | 0, Row2Pixel(len)); |
2090 | 0, Row2Pixel (len)); |
2040 | len = -1; |
2091 | len = -1; |
2041 | } |
2092 | } |
2042 | } |
2093 | } |
2043 | } |
2094 | } |
2044 | #endif |
2095 | #endif |
2045 | |
2096 | |
2046 | /* |
2097 | /* |
2047 | * E: main pass across every character |
2098 | * E: main pass across every character |
2048 | */ |
2099 | */ |
2049 | for (row = 0; row < R->TermWin.nrow; row++) |
2100 | for (row = 0; row < TermWin.nrow; row++) |
2050 | { |
2101 | { |
2051 | stp = R->screen.text[row + row_offset]; |
2102 | stp = screen.text[row + row_offset]; |
2052 | srp = R->screen.rend[row + row_offset]; |
2103 | srp = screen.rend[row + row_offset]; |
2053 | dtp = R->drawn_text[row]; |
2104 | dtp = drawn_text[row]; |
2054 | drp = R->drawn_rend[row]; |
2105 | drp = drawn_rend[row]; |
2055 | |
2106 | |
2056 | /* |
2107 | /* |
2057 | * E2: OK, now the real pass |
2108 | * E2: OK, now the real pass |
2058 | */ |
2109 | */ |
2059 | int ypixel = (int)Row2Pixel(row); |
2110 | int ypixel = (int)Row2Pixel(row); |
2060 | |
2111 | |
2061 | for (col = 0; col < R->TermWin.ncol; col++) |
2112 | for (col = 0; col < TermWin.ncol; col++) |
2062 | { |
2113 | { |
2063 | /* compare new text with old - if exactly the same then continue */ |
2114 | /* compare new text with old - if exactly the same then continue */ |
2064 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2115 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2065 | |
2116 | |
2066 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2117 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
… | |
… | |
2082 | |
2133 | |
2083 | int xpixel = Col2Pixel(col); |
2134 | int xpixel = Col2Pixel(col); |
2084 | |
2135 | |
2085 | // this loop looks very messy, it can probably be optimized |
2136 | // this loop looks very messy, it can probably be optimized |
2086 | // and cleaned a bit by you? |
2137 | // and cleaned a bit by you? |
2087 | for (i = 0; ++col < R->TermWin.ncol; ) |
2138 | for (i = 0; ++col < TermWin.ncol; ) |
2088 | { |
2139 | { |
2089 | if (stp[col] == NOCHAR) |
2140 | if (stp[col] == NOCHAR) |
2090 | { |
2141 | { |
2091 | dtp[col] = stp[col]; |
2142 | dtp[col] = stp[col]; |
2092 | drp[col] = rend; |
2143 | drp[col] = rend; |
… | |
… | |
2118 | } |
2169 | } |
2119 | |
2170 | |
2120 | col--; /* went one too far. move back */ |
2171 | col--; /* went one too far. move back */ |
2121 | count -= i; /* dump any matching trailing chars */ |
2172 | count -= i; /* dump any matching trailing chars */ |
2122 | |
2173 | |
2123 | /* |
2174 | /* |
2124 | * Determine the attributes for the string |
2175 | * Determine the attributes for the string |
2125 | */ |
2176 | */ |
2126 | int fid = GET_FONT(rend); |
2177 | int fid = GET_FONT(rend); |
2127 | fore = GET_FGCOLOR(rend); |
2178 | fore = GET_FGCOLOR(rend); |
2128 | back = GET_BGCOLOR(rend); |
2179 | back = GET_BGCOLOR(rend); |
2129 | rend = GET_ATTR(rend); |
2180 | rend = GET_ATTR(rend); |
2130 | |
2181 | |
2131 | rvid = (rend & RS_RVid) ? 1 : 0; |
2182 | rvid = (rend & RS_RVid) ? 1 : 0; |
2132 | #ifdef OPTION_HC |
2183 | #ifdef OPTION_HC |
2133 | if (!rvid && (rend & RS_Blink)) |
2184 | if (!rvid && (rend & RS_Blink)) |
2134 | { |
2185 | { |
2135 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_HC)) |
2186 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) |
2136 | back = Color_HC; |
2187 | back = Color_HC; |
2137 | else |
2188 | else |
2138 | rvid = !rvid; /* fall back */ |
2189 | rvid = !rvid; /* fall back */ |
2139 | } |
2190 | } |
2140 | #endif |
2191 | #endif |
2141 | if (rvid) |
2192 | if (rvid) |
2142 | { |
2193 | { |
2143 | SWAP_IT(fore, back, int); |
2194 | SWAP_IT(fore, back, int); |
2144 | |
2195 | |
2145 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2196 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2146 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_RV) |
2197 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_RV) |
2147 | # ifndef NO_CURSORCOLOR |
2198 | # ifndef NO_CURSORCOLOR |
2148 | && !ISSET_PIXCOLOR(R, Color_cursor) |
2199 | && !ISSET_PIXCOLOR (this, Color_cursor) |
2149 | # endif |
2200 | # endif |
2150 | ) |
2201 | ) |
2151 | back = Color_RV; |
2202 | back = Color_RV; |
2152 | #endif |
2203 | #endif |
2153 | } |
2204 | } |
2154 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2205 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2155 | else if (rend & RS_Bold) |
2206 | else if (rend & RS_Bold) |
2156 | { |
2207 | { |
2157 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_BD)) |
2208 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD)) |
2158 | { |
2209 | { |
2159 | fore = Color_BD; |
2210 | fore = Color_BD; |
2160 | # ifndef VERYBOLD |
2211 | # ifndef VERYBOLD |
2161 | rend &= ~RS_Bold; /* we've taken care of it */ |
2212 | rend &= ~RS_Bold; /* we've taken care of it */ |
2162 | # endif |
2213 | # endif |
2163 | } |
2214 | } |
2164 | } |
2215 | } |
2165 | else if (rend & RS_Uline) |
2216 | else if (rend & RS_Uline) |
2166 | { |
2217 | { |
2167 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_UL)) |
2218 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) |
2168 | { |
2219 | { |
2169 | fore = Color_UL; |
2220 | fore = Color_UL; |
2170 | rend &= ~RS_Uline; /* we've taken care of it */ |
2221 | rend &= ~RS_Uline; /* we've taken care of it */ |
2171 | } |
2222 | } |
2172 | } |
2223 | } |
2173 | #endif |
2224 | #endif |
2174 | |
2225 | |
2175 | /* |
2226 | /* |
2176 | * Actually do the drawing of the string here |
2227 | * Actually do the drawing of the string here |
2177 | */ |
2228 | */ |
2178 | rxvt_font *font = (*R->TermWin.fontset)[fid]; |
2229 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2179 | |
2230 | |
2180 | if (back == Color_bg) |
2231 | if (back == Color_bg) |
2181 | { |
2232 | { |
2182 | if (must_clear) |
2233 | if (must_clear) |
2183 | { |
2234 | { |
… | |
… | |
2186 | { |
2237 | { |
2187 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2238 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2188 | goto nodraw; |
2239 | goto nodraw; |
2189 | } |
2240 | } |
2190 | |
2241 | |
2191 | CLEAR_CHARS(xpixel, ypixel, count); |
2242 | CLEAR_CHARS (xpixel, ypixel, count); |
2192 | nodraw: ; |
2243 | nodraw: ; |
2193 | } |
2244 | } |
2194 | else |
2245 | else |
2195 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2246 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2196 | } |
2247 | } |
2197 | else |
2248 | else |
2198 | font->draw (xpixel, ypixel, text, count, fore, back); |
2249 | font->draw (xpixel, ypixel, text, count, fore, back); |
2199 | |
2250 | |
2200 | if ((rend & RS_Uline) && (font->descent > 1)) |
2251 | if ((rend & RS_Uline) && (font->descent > 1)) |
2201 | XDrawLine(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2252 | XDrawLine(Xdisplay, drawBuffer, TermWin.gc, |
2202 | xpixel, ypixel + font->ascent + 1, |
2253 | xpixel, ypixel + font->ascent + 1, |
2203 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2254 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2204 | } /* for (col....) */ |
2255 | } /* for (col....) */ |
2205 | } /* for (row....) */ |
2256 | } /* for (row....) */ |
2206 | |
2257 | |
2207 | /* |
2258 | /* |
2208 | * G: cleanup cursor and display outline cursor if necessary |
2259 | * G: cleanup cursor and display outline cursor if necessary |
2209 | */ |
2260 | */ |
2210 | if (showcursor) { |
2261 | if (showcursor) { |
2211 | if (R->TermWin.focus) { |
2262 | if (TermWin.focus) { |
2212 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
2263 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
2213 | [R->screen.cur.col]); |
2264 | [screen.cur.col]); |
2214 | *srp ^= RS_RVid; |
2265 | *srp ^= RS_RVid; |
2215 | #ifndef NO_CURSORCOLOR |
2266 | #ifndef NO_CURSORCOLOR |
2216 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2267 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2217 | #endif |
2268 | #endif |
2218 | } else if (R->oldcursor.row >= 0) { |
2269 | } else if (oldcursor.row >= 0) { |
2219 | #ifndef NO_CURSORCOLOR |
2270 | #ifndef NO_CURSORCOLOR |
2220 | unsigned long gcmask; /* Graphics Context mask */ |
2271 | unsigned long gcmask; /* Graphics Context mask */ |
2221 | |
2272 | |
2222 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) { |
2273 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
2223 | XSetForeground (R->Xdisplay, R->TermWin.gc, R->PixColors[Color_cursor]); |
2274 | XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); |
2224 | } |
|
|
2225 | #endif |
2275 | #endif |
2226 | XDrawRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2276 | XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, |
2227 | Col2Pixel(R->oldcursor.col), |
2277 | Col2Pixel(oldcursor.col), |
2228 | Row2Pixel(R->oldcursor.row), |
2278 | Row2Pixel(oldcursor.row), |
2229 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2279 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2230 | (unsigned int)(Height2Pixel(1) - R->TermWin.lineSpace - 1)); |
2280 | (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); |
2231 | } |
2281 | } |
2232 | } |
2282 | } |
2233 | /* |
2283 | |
|
|
2284 | /* |
2234 | * H: cleanup selection |
2285 | * H: cleanup selection |
2235 | */ |
2286 | */ |
2236 | rxvt_scr_reverse_selection(aR); |
2287 | rxvt_scr_reverse_selection (this); |
2237 | |
2288 | |
2238 | /* |
2289 | /* |
2239 | * I: other general cleanup |
2290 | * I: other general cleanup |
2240 | */ |
2291 | */ |
2241 | if (clearfirst && R->TermWin.int_bwidth) |
2292 | if (clearfirst && TermWin.int_bwidth) |
2242 | /* |
2293 | /* |
2243 | * clear the whole screen height, note that width == 0 is treated |
2294 | * clear the whole screen height, note that width == 0 is treated |
2244 | * specially by XClearArea |
2295 | * specially by XClearArea |
2245 | */ |
2296 | */ |
2246 | XClearArea(R->Xdisplay, R->TermWin.vt, 0, 0, |
2297 | XClearArea(Xdisplay, TermWin.vt, 0, 0, |
2247 | (unsigned int)R->TermWin.int_bwidth, |
2298 | (unsigned int)TermWin.int_bwidth, |
2248 | (unsigned int)TermWin_TotalHeight(), False); |
2299 | (unsigned int)TermWin_TotalHeight(), False); |
2249 | if (clearlast && R->TermWin.int_bwidth) |
2300 | if (clearlast && TermWin.int_bwidth) |
2250 | /* |
2301 | /* |
2251 | * clear the whole screen height, note that width == 0 is treated |
2302 | * clear the whole screen height, note that width == 0 is treated |
2252 | * specially by XClearArea |
2303 | * specially by XClearArea |
2253 | */ |
2304 | */ |
2254 | XClearArea(R->Xdisplay, R->TermWin.vt, |
2305 | XClearArea(Xdisplay, TermWin.vt, |
2255 | R->TermWin.width + R->TermWin.int_bwidth, 0, |
2306 | TermWin.width + TermWin.int_bwidth, 0, |
2256 | (unsigned int)R->TermWin.int_bwidth, |
2307 | (unsigned int)TermWin.int_bwidth, |
2257 | (unsigned int)TermWin_TotalHeight(), False); |
2308 | (unsigned int)TermWin_TotalHeight(), False); |
2258 | if (refresh_type & SMOOTH_REFRESH) |
2309 | if (refresh_type & SMOOTH_REFRESH) |
2259 | XSync(R->Xdisplay, False); |
2310 | XSync(Xdisplay, False); |
2260 | |
2311 | |
2261 | R->num_scr = 0; |
2312 | num_scr = 0; |
2262 | R->num_scr_allow = 1; |
2313 | num_scr_allow = 1; |
2263 | R->want_refresh = 0; /* screen is current */ |
2314 | want_refresh = 0; /* screen is current */ |
2264 | } |
2315 | } |
2265 | /* ------------------------------------------------------------------------- */ |
|
|
2266 | |
2316 | |
2267 | /* EXTPROTO */ |
2317 | /* ------------------------------------------------------------------------- */ |
2268 | void |
2318 | void |
2269 | rxvt_scr_clear(pR) |
2319 | rxvt_term::scr_clear() |
2270 | { |
2320 | { |
2271 | if (!R->TermWin.mapped) |
2321 | if (!TermWin.mapped) |
2272 | return; |
2322 | return; |
|
|
2323 | |
2273 | R->num_scr_allow = 0; |
2324 | num_scr_allow = 0; |
2274 | R->want_refresh = 1; |
2325 | want_refresh = 1; |
2275 | #ifdef TRANSPARENT |
2326 | #ifdef TRANSPARENT |
2276 | if ((R->Options & Opt_transparent) && (R->am_pixmap_trans == 0)) { |
2327 | if ((Options & Opt_transparent) && (am_pixmap_trans == 0)) |
2277 | int i; |
2328 | { |
|
|
2329 | int i; |
2278 | |
2330 | |
2279 | if (!(R->Options & Opt_transparent_all)) |
2331 | if (!(Options & Opt_transparent_all)) |
2280 | i = 0; |
2332 | i = 0; |
2281 | else |
2333 | else |
2282 | i = (int)(sizeof(R->TermWin.parent) / sizeof(Window)); |
2334 | i = (int)(sizeof(TermWin.parent) / sizeof(Window)); |
2283 | for (; i--;) |
2335 | |
|
|
2336 | while (i--) |
2284 | if (R->TermWin.parent[i] != None) |
2337 | if (TermWin.parent[i] != None) |
2285 | XClearWindow(R->Xdisplay, R->TermWin.parent[i]); |
2338 | XClearWindow(Xdisplay, TermWin.parent[i]); |
2286 | } |
2339 | } |
2287 | #endif |
2340 | #endif |
|
|
2341 | |
2288 | XClearWindow(R->Xdisplay, R->TermWin.vt); |
2342 | XClearWindow (Xdisplay, TermWin.vt); |
2289 | } |
2343 | } |
2290 | |
2344 | |
2291 | /* ------------------------------------------------------------------------- */ |
2345 | /* ------------------------------------------------------------------------- */ |
2292 | /* INTPROTO */ |
2346 | /* INTPROTO */ |
2293 | void |
2347 | void |
… | |
… | |
2395 | |
2449 | |
2396 | /* ------------------------------------------------------------------------- */ |
2450 | /* ------------------------------------------------------------------------- */ |
2397 | /* |
2451 | /* |
2398 | * Paste a selection direct to the command fd |
2452 | * Paste a selection direct to the command fd |
2399 | */ |
2453 | */ |
2400 | /* INTPROTO */ |
|
|
2401 | void |
2454 | void |
2402 | rxvt_PasteIt (pR_ const unsigned char *data, unsigned int nitems) |
2455 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2403 | { |
2456 | { |
2404 | unsigned int i, j, n; |
2457 | unsigned int i, j, n; |
2405 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2458 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2406 | |
2459 | |
|
|
2460 | #if 0 |
|
|
2461 | /* a paste should act like the user is typing, so check scrollTtyKeypress */ |
|
|
2462 | ZERO_SCROLLBACK (r); |
|
|
2463 | #endif |
|
|
2464 | |
2407 | /* convert normal newline chars into common keyboard Return key sequence */ |
2465 | /* convert normal newline chars into common keyboard Return key sequence */ |
2408 | for (i = 0; i < nitems; i += PROP_SIZE) |
2466 | for (i = 0; i < len; i += PROP_SIZE) |
2409 | { |
2467 | { |
2410 | n = min (nitems - i, PROP_SIZE); |
2468 | n = min (len - i, PROP_SIZE); |
2411 | MEMCPY (ds, data + i, n); |
2469 | MEMCPY (ds, data + i, n); |
|
|
2470 | |
2412 | for (j = 0; j < n; j++) |
2471 | for (j = 0; j < n; j++) |
2413 | if (ds[j] == '\n') |
2472 | if (ds[j] == '\n') |
2414 | ds[j] = '\r'; |
2473 | ds[j] = '\r'; |
|
|
2474 | |
2415 | R->tt_write (ds, (int)n); |
2475 | tt_write (ds, (int)n); |
2416 | } |
2476 | } |
2417 | |
2477 | |
2418 | free(ds); |
2478 | free(ds); |
2419 | } |
2479 | } |
2420 | |
2480 | |
… | |
… | |
2425 | */ |
2485 | */ |
2426 | /* EXTPROTO */ |
2486 | /* EXTPROTO */ |
2427 | int |
2487 | int |
2428 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2488 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2429 | { |
2489 | { |
2430 | long nread = 0; |
2490 | long nread = 0; |
2431 | unsigned long bytes_after; |
2491 | unsigned long bytes_after; |
2432 | XTextProperty ct; |
2492 | XTextProperty ct; |
2433 | #ifdef MULTICHAR_SET |
2493 | int dummy_count; |
2434 | int dummy_count; |
2494 | char **cl; |
2435 | char **cl; |
|
|
2436 | #endif |
|
|
2437 | |
2495 | |
2438 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2496 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2439 | |
2497 | |
2440 | if (prop == None) { /* check for failed XConvertSelection */ |
2498 | if (prop == None) /* check for failed XConvertSelection */ |
2441 | #ifdef MULTICHAR_SET |
2499 | { |
2442 | if ((R->selection_type & Sel_CompoundText)) { |
2500 | if ((R->selection_type & Sel_CompoundText)) |
|
|
2501 | { |
2443 | int selnum = R->selection_type & Sel_whereMask; |
2502 | int selnum = R->selection_type & Sel_whereMask; |
2444 | |
2503 | |
2445 | R->selection_type = 0; |
2504 | R->selection_type = 0; |
2446 | if (selnum != Sel_direct) |
2505 | if (selnum != Sel_direct) |
2447 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
2506 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
|
|
2507 | } |
2448 | } |
2508 | |
2449 | #endif |
|
|
2450 | return 0; |
2509 | return 0; |
2451 | } |
2510 | } |
|
|
2511 | |
2452 | for (;;) { |
2512 | for (;;) |
|
|
2513 | { |
2453 | if (XGetWindowProperty(R->Xdisplay, win, prop, (long)(nread / 4), |
2514 | if (XGetWindowProperty(R->Xdisplay, win, prop, (long)(nread / 4), |
2454 | (long)(PROP_SIZE / 4), delete_prop, |
2515 | (long)(PROP_SIZE / 4), delete_prop, |
2455 | AnyPropertyType, &ct.encoding, &ct.format, |
2516 | AnyPropertyType, &ct.encoding, &ct.format, |
2456 | &ct.nitems, &bytes_after, |
2517 | &ct.nitems, &bytes_after, |
2457 | &ct.value) != Success) |
2518 | &ct.value) != Success) |
2458 | break; |
2519 | break; |
|
|
2520 | |
2459 | if (ct.encoding == 0) { |
2521 | if (ct.encoding == 0) |
|
|
2522 | { |
2460 | D_SELECT((stderr, "rxvt_selection_paste: property didn't exist!")); |
2523 | D_SELECT((stderr, "rxvt_selection_paste: property didn't exist!")); |
2461 | break; |
2524 | break; |
2462 | } |
2525 | } |
|
|
2526 | |
2463 | if (ct.value == NULL) { |
2527 | if (ct.value == NULL) |
|
|
2528 | { |
2464 | D_SELECT((stderr, "rxvt_selection_paste: property shooting blanks!")); |
2529 | D_SELECT((stderr, "rxvt_selection_paste: property shooting blanks!")); |
2465 | continue; |
2530 | continue; |
2466 | } |
2531 | } |
|
|
2532 | |
2467 | if (ct.nitems == 0) { |
2533 | if (ct.nitems == 0) |
|
|
2534 | { |
2468 | D_SELECT((stderr, "rxvt_selection_paste: property empty - also INCR end")); |
2535 | D_SELECT((stderr, "rxvt_selection_paste: property empty - also INCR end")); |
2469 | if (R->selection_wait == Sel_normal && nread == 0) { |
2536 | if (R->selection_wait == Sel_normal && nread == 0) |
|
|
2537 | { |
2470 | /* |
2538 | /* |
2471 | * pass through again trying CUT_BUFFER0 if we've come from |
2539 | * pass through again trying CUT_BUFFER0 if we've come from |
2472 | * XConvertSelection() but nothing was presented |
2540 | * XConvertSelection() but nothing was presented |
2473 | */ |
2541 | */ |
2474 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2542 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2475 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
2543 | rxvt_selection_paste (aR_ Xroot, XA_CUT_BUFFER0, False); |
2476 | } |
2544 | } |
|
|
2545 | |
2477 | nread = -1; /* discount any previous stuff */ |
2546 | nread = -1; /* discount any previous stuff */ |
2478 | break; |
2547 | break; |
2479 | } |
2548 | } |
|
|
2549 | |
2480 | nread += ct.nitems; |
2550 | nread += ct.nitems; |
2481 | #ifdef MULTICHAR_SET |
|
|
2482 | if (XmbTextPropertyToTextList(R->Xdisplay, &ct, &cl, |
2551 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2483 | &dummy_count) == Success && cl) { |
2552 | &dummy_count) == Success && cl) |
2484 | rxvt_PasteIt(aR_ cl[0], STRLEN(cl[0])); |
2553 | { |
|
|
2554 | R->paste ((unsigned char *)cl[0], STRLEN (cl[0])); |
2485 | XFreeStringList(cl); |
2555 | XFreeStringList (cl); |
|
|
2556 | } |
2486 | } else |
2557 | else |
2487 | #endif |
2558 | R->paste (ct.value, ct.nitems); |
2488 | rxvt_PasteIt(aR_ ct.value, (unsigned int)ct.nitems); |
2559 | |
2489 | if (bytes_after == 0) |
2560 | if (bytes_after == 0) |
2490 | break; |
2561 | break; |
|
|
2562 | |
2491 | XFree(ct.value); |
2563 | XFree (ct.value); |
2492 | } |
2564 | } |
|
|
2565 | |
2493 | if (ct.value) |
2566 | if (ct.value) |
2494 | XFree(ct.value); |
2567 | XFree (ct.value); |
|
|
2568 | |
2495 | if (R->selection_wait == Sel_normal) |
2569 | if (R->selection_wait == Sel_normal) |
2496 | R->selection_wait = Sel_none; |
2570 | R->selection_wait = Sel_none; |
|
|
2571 | |
2497 | D_SELECT((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); |
2572 | D_SELECT((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); |
2498 | return (int)nread; |
2573 | return (int)nread; |
|
|
2574 | } |
|
|
2575 | |
|
|
2576 | void |
|
|
2577 | rxvt_term::incr_cb (time_watcher &w) |
|
|
2578 | { |
|
|
2579 | w.stop (); |
|
|
2580 | selection_wait = Sel_none; |
|
|
2581 | |
|
|
2582 | rxvt_print_error("data loss: timeout on INCR selection paste"); |
2499 | } |
2583 | } |
2500 | |
2584 | |
2501 | /* |
2585 | /* |
2502 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2586 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2503 | */ |
2587 | */ |
… | |
… | |
2535 | } else if (R->selection_wait == Sel_incr) { |
2619 | } else if (R->selection_wait == Sel_incr) { |
2536 | reget_time = 1; |
2620 | reget_time = 1; |
2537 | if (rxvt_selection_paste(aR_ win, prop, True) == -1) { |
2621 | if (rxvt_selection_paste(aR_ win, prop, True) == -1) { |
2538 | D_SELECT((stderr, "rxvt_selection_property: INCR: clean end")); |
2622 | D_SELECT((stderr, "rxvt_selection_property: INCR: clean end")); |
2539 | R->selection_wait = Sel_none; |
2623 | R->selection_wait = Sel_none; |
2540 | R->timeout[TIMEOUT_INCR].tv_sec = 0; /* turn off timer */ |
2624 | R->incr_ev.stop (); |
2541 | } |
2625 | } |
2542 | } |
2626 | } |
2543 | if (reget_time) { /* received more data so reget time */ |
2627 | if (reget_time) /* received more data so reget time */ |
2544 | (void)gettimeofday(&(R->timeout[TIMEOUT_INCR]), NULL); |
2628 | R->incr_ev.start (NOW + 10); |
2545 | R->timeout[TIMEOUT_INCR].tv_sec += 10; /* ten seconds wait */ |
|
|
2546 | } |
|
|
2547 | } |
2629 | } |
2548 | /* ------------------------------------------------------------------------- */ |
2630 | /* ------------------------------------------------------------------------- */ |
2549 | /* |
2631 | /* |
2550 | * Request the current selection: |
2632 | * Request the current selection: |
2551 | * Order: > internal selection if available |
2633 | * Order: > internal selection if available |
… | |
… | |
2563 | if (x < 0 || x >= R->TermWin.width || y < 0 || y >= R->TermWin.height) |
2645 | if (x < 0 || x >= R->TermWin.width || y < 0 || y >= R->TermWin.height) |
2564 | return; /* outside window */ |
2646 | return; /* outside window */ |
2565 | |
2647 | |
2566 | if (R->selection.text != NULL) { /* internal selection */ |
2648 | if (R->selection.text != NULL) { /* internal selection */ |
2567 | D_SELECT((stderr, "rxvt_selection_request: pasting internal")); |
2649 | D_SELECT((stderr, "rxvt_selection_request: pasting internal")); |
2568 | rxvt_PasteIt(aR_ R->selection.text, R->selection.len); |
2650 | R->paste (R->selection.text, R->selection.len); |
2569 | return; |
2651 | return; |
2570 | } else { |
2652 | } else { |
2571 | int i; |
2653 | int i; |
2572 | |
2654 | |
2573 | R->selection_request_time = tm; |
2655 | R->selection_request_time = tm; |
2574 | R->selection_wait = Sel_normal; |
2656 | R->selection_wait = Sel_normal; |
2575 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
2657 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
2576 | #ifdef MULTICHAR_SET |
|
|
2577 | R->selection_type = Sel_CompoundText; |
2658 | R->selection_type = Sel_CompoundText; |
2578 | #else |
|
|
2579 | R->selection_type = 0; |
|
|
2580 | #endif |
|
|
2581 | if (rxvt_selection_request_other(aR_ |
2659 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2582 | #ifdef MULTICHAR_SET |
|
|
2583 | R->xa[XA_COMPOUND_TEXT], |
|
|
2584 | #else |
|
|
2585 | XA_STRING, |
|
|
2586 | #endif |
|
|
2587 | i)) |
|
|
2588 | return; |
2660 | return; |
2589 | } |
2661 | } |
2590 | } |
2662 | } |
2591 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2663 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2592 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2664 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
… | |
… | |
2749 | /* ------------------------------------------------------------------------- */ |
2821 | /* ------------------------------------------------------------------------- */ |
2750 | /* |
2822 | /* |
2751 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2823 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2752 | * EXT: button 1 press |
2824 | * EXT: button 1 press |
2753 | */ |
2825 | */ |
2754 | /* EXTPROTO */ |
|
|
2755 | void |
2826 | void |
2756 | rxvt_selection_click(pR_ int clicks, int x, int y) |
2827 | rxvt_term::selection_click (int clicks, int x, int y) |
2757 | { |
2828 | { |
2758 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2829 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2759 | |
2830 | |
2760 | clicks = ((clicks - 1) % 3) + 1; |
2831 | clicks = ((clicks - 1) % 3) + 1; |
2761 | R->selection.clicks = clicks; /* save clicks so extend will work */ |
2832 | selection.clicks = clicks; /* save clicks so extend will work */ |
2762 | |
2833 | |
2763 | rxvt_selection_start_colrow(aR_ Pixel2Col(x), Pixel2Row(y)); |
2834 | rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y)); |
|
|
2835 | |
2764 | if (clicks == 2 || clicks == 3) |
2836 | if (clicks == 2 || clicks == 3) |
2765 | rxvt_selection_extend_colrow(aR_ R->selection.mark.col, |
2837 | rxvt_selection_extend_colrow (this, selection.mark.col, |
2766 | R->selection.mark.row |
|
|
2767 | + R->TermWin.view_start, |
2838 | selection.mark.row + TermWin.view_start, |
2768 | 0, /* button 3 */ |
2839 | 0, /* button 3 */ |
2769 | 1, /* button press */ |
2840 | 1, /* button press */ |
2770 | 0); /* click change */ |
2841 | 0); /* click change */ |
2771 | } |
2842 | } |
2772 | |
2843 | |
2773 | /* ------------------------------------------------------------------------- */ |
2844 | /* ------------------------------------------------------------------------- */ |
2774 | /* |
2845 | /* |
2775 | * Mark a selection at the specified col/row |
2846 | * Mark a selection at the specified col/row |
… | |
… | |
2801 | */ |
2872 | */ |
2802 | |
2873 | |
2803 | /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ |
2874 | /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ |
2804 | #define DELIMIT_TEXT(x) \ |
2875 | #define DELIMIT_TEXT(x) \ |
2805 | (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR(R->rs[Rs_cutchars], (x)) != NULL)) |
2876 | (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR(R->rs[Rs_cutchars], (x)) != NULL)) |
2806 | #ifdef MULTICHAR_SET |
|
|
2807 | # define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0) |
|
|
2808 | #else |
|
|
2809 | # define DELIMIT_REND(x) 1 |
2877 | #define DELIMIT_REND(x) 1 |
2810 | #endif |
|
|
2811 | |
2878 | |
2812 | /* INTPROTO */ |
2879 | /* INTPROTO */ |
2813 | void |
2880 | void |
2814 | rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
2881 | rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
2815 | { |
2882 | { |
… | |
… | |
2889 | * EXT: button 3 press; button 1 or 3 drag |
2956 | * EXT: button 3 press; button 1 or 3 drag |
2890 | * flag == 0 ==> button 1 |
2957 | * flag == 0 ==> button 1 |
2891 | * flag == 1 ==> button 3 press |
2958 | * flag == 1 ==> button 3 press |
2892 | * flag == 2 ==> button 3 motion |
2959 | * flag == 2 ==> button 3 motion |
2893 | */ |
2960 | */ |
2894 | /* EXTPROTO */ |
|
|
2895 | void |
2961 | void |
2896 | rxvt_selection_extend(pR_ int x, int y, int flag) |
2962 | rxvt_term::selection_extend (int x, int y, int flag) |
2897 | { |
2963 | { |
2898 | int col, row; |
2964 | int col, row; |
2899 | |
2965 | |
2900 | col = Pixel2Col(x); |
2966 | col = Pixel2Col(x); |
2901 | row = Pixel2Row(y); |
2967 | row = Pixel2Row(y); |
2902 | MAX_IT(row, 0); |
2968 | MAX_IT(row, 0); |
2903 | MIN_IT(row, (int)R->TermWin.nrow - 1); |
2969 | MIN_IT(row, (int)TermWin.nrow - 1); |
2904 | MAX_IT(col, 0); |
2970 | MAX_IT(col, 0); |
2905 | MIN_IT(col, (int)R->TermWin.ncol); |
2971 | MIN_IT(col, (int)TermWin.ncol); |
|
|
2972 | |
2906 | #ifndef NO_NEW_SELECTION |
2973 | #ifndef NO_NEW_SELECTION |
2907 | /* |
2974 | /* |
2908 | * If we're selecting characters (single click) then we must check first |
2975 | * If we're selecting characters (single click) then we must check first |
2909 | * if we are at the same place as the original mark. If we are then |
2976 | * if we are at the same place as the original mark. If we are then |
2910 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
2977 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
2911 | * be _past_ a character for it to be selected. |
2978 | * be _past_ a character for it to be selected. |
2912 | */ |
2979 | */ |
2913 | if (R->selection_style != OLD_SELECT) { |
2980 | if (selection_style != OLD_SELECT) |
|
|
2981 | { |
2914 | if (((R->selection.clicks % 3) == 1) && !flag |
2982 | if (((selection.clicks % 3) == 1) && !flag |
2915 | && (col == R->selection.mark.col |
2983 | && (col == selection.mark.col |
2916 | && (row == R->selection.mark.row + R->TermWin.view_start))) { |
2984 | && (row == selection.mark.row + TermWin.view_start))) |
|
|
2985 | { |
2917 | /* select nothing */ |
2986 | /* select nothing */ |
2918 | R->selection.beg.row = R->selection.end.row = 0; |
2987 | selection.beg.row = selection.end.row = 0; |
2919 | R->selection.beg.col = R->selection.end.col = 0; |
2988 | selection.beg.col = selection.end.col = 0; |
2920 | R->selection.clicks = 4; |
2989 | selection.clicks = 4; |
2921 | R->want_refresh = 1; |
2990 | want_refresh = 1; |
2922 | D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); |
2991 | D_SELECT((stderr, "rxvt_selection_extend() selection.clicks = 4")); |
2923 | return; |
2992 | return; |
2924 | } |
2993 | } |
2925 | } |
2994 | } |
2926 | #endif |
2995 | #endif |
2927 | if (R->selection.clicks == 4) |
2996 | if (selection.clicks == 4) |
2928 | R->selection.clicks = 1; |
2997 | selection.clicks = 1; |
|
|
2998 | |
2929 | rxvt_selection_extend_colrow(aR_ col, row, !!flag, /* ? button 3 */ |
2999 | rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */ |
2930 | flag == 1 ? 1 : 0, /* ? button press */ |
3000 | flag == 1 ? 1 : 0, /* ? button press */ |
2931 | 0); /* no click change */ |
3001 | 0); /* no click change */ |
2932 | } |
3002 | } |
2933 | |
3003 | |
2934 | /* ------------------------------------------------------------------------- */ |
3004 | /* ------------------------------------------------------------------------- */ |
2935 | /* |
3005 | /* |
2936 | * Extend the selection to the specified col/row |
3006 | * Extend the selection to the specified col/row |
… | |
… | |
3190 | /* ------------------------------------------------------------------------- */ |
3260 | /* ------------------------------------------------------------------------- */ |
3191 | /* |
3261 | /* |
3192 | * Double click on button 3 when already selected |
3262 | * Double click on button 3 when already selected |
3193 | * EXT: button 3 double click |
3263 | * EXT: button 3 double click |
3194 | */ |
3264 | */ |
3195 | /* EXTPROTO */ |
|
|
3196 | void |
3265 | void |
3197 | rxvt_selection_rotate(pR_ int x, int y) |
3266 | rxvt_term::selection_rotate (int x, int y) |
3198 | { |
3267 | { |
3199 | R->selection.clicks = R->selection.clicks % 3 + 1; |
3268 | selection.clicks = selection.clicks % 3 + 1; |
3200 | rxvt_selection_extend_colrow(aR_ Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3269 | rxvt_selection_extend_colrow (this, Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3201 | } |
3270 | } |
3202 | |
3271 | |
3203 | /* ------------------------------------------------------------------------- */ |
3272 | /* ------------------------------------------------------------------------- */ |
3204 | /* |
3273 | /* |
3205 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3274 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
… | |
… | |
3309 | * ------------------------------------------------------------------------- */ |
3378 | * ------------------------------------------------------------------------- */ |
3310 | |
3379 | |
3311 | /* |
3380 | /* |
3312 | * return col/row values corresponding to x/y pixel values |
3381 | * return col/row values corresponding to x/y pixel values |
3313 | */ |
3382 | */ |
3314 | /* EXTPROTO */ |
|
|
3315 | void |
3383 | void |
3316 | rxvt_pixel_position(pR_ int *x, int *y) |
3384 | rxvt_term::pixel_position (int *x, int *y) |
3317 | { |
3385 | { |
3318 | *x = Pixel2Col(*x); |
3386 | *x = Pixel2Col(*x); |
3319 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3387 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3320 | *y = Pixel2Row(*y); |
3388 | *y = Pixel2Row(*y); |
3321 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3389 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3322 | } |
3390 | } |
|
|
3391 | |
3323 | /* ------------------------------------------------------------------------- */ |
3392 | /* ------------------------------------------------------------------------- */ |
3324 | #ifdef USE_XIM |
3393 | #ifdef USE_XIM |
3325 | /* EXTPROTO */ |
|
|
3326 | void |
3394 | void |
3327 | rxvt_setPosition(pR_ XPoint *pos) |
3395 | rxvt_term::set_position (XPoint *pos) |
3328 | { |
3396 | { |
3329 | XWindowAttributes xwa; |
3397 | XWindowAttributes xwa; |
3330 | |
3398 | |
3331 | XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &xwa); |
3399 | XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa); |
3332 | pos->x = Col2Pixel(R->screen.cur.col) + xwa.x; |
3400 | pos->x = Col2Pixel (screen.cur.col) + xwa.x; |
3333 | pos->y = Height2Pixel((R->screen.cur.row + 1)) + xwa.y |
3401 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3334 | - R->TermWin.lineSpace; |
|
|
3335 | } |
3402 | } |
|
|
3403 | |
3336 | #endif |
3404 | #endif |
3337 | /* ------------------------------------------------------------------------- */ |
3405 | /* ------------------------------------------------------------------------- */ |
3338 | |
3406 | |
3339 | /* ------------------------------------------------------------------------- * |
3407 | /* ------------------------------------------------------------------------- * |
3340 | * DEBUG ROUTINES * |
3408 | * DEBUG ROUTINES * |