1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*---------------------------------------------------------------------------* |
2 | * File: screen.C |
2 | * File: screen.C |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
5 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.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 |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
26 | |
26 | |
27 | #include "../config.h" /* NECESSARY */ |
27 | #include "../config.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
29 | #include "rxvtperl.h" /* NECESSARY */ |
29 | #include "rxvtperl.h" /* NECESSARY */ |
30 | |
30 | |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
|
|
32 | |
|
|
33 | #include <inttypes.h> |
31 | #include <inttypes.h> |
34 | |
32 | |
35 | #include "salloc.C" // HACK, should be a seperate compile! |
33 | #include "salloc.C" // HACK, should be a seperate compile! |
36 | |
34 | |
37 | inline void fill_text (text_t *start, text_t value, int len) |
35 | static inline void fill_text (text_t *start, text_t value, int len) |
38 | { |
36 | { |
39 | while (len--) |
37 | while (len--) |
40 | *start++ = value; |
38 | *start++ = value; |
41 | } |
39 | } |
42 | |
40 | |
… | |
… | |
47 | |
45 | |
48 | /* ------------------------------------------------------------------------- * |
46 | /* ------------------------------------------------------------------------- * |
49 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
47 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
50 | * ------------------------------------------------------------------------- */ |
48 | * ------------------------------------------------------------------------- */ |
51 | #define ZERO_SCROLLBACK() \ |
49 | #define ZERO_SCROLLBACK() \ |
52 | if (OPTION (Opt_scrollTtyOutput)) \ |
50 | if (option (Opt_scrollTtyOutput)) \ |
53 | view_start = 0 |
51 | view_start = 0 |
54 | #define CLEAR_SELECTION() \ |
52 | #define CLEAR_SELECTION() \ |
55 | selection.beg.row = selection.beg.col \ |
53 | selection.beg.row = selection.beg.col \ |
56 | = selection.end.row = selection.end.col = 0 |
54 | = selection.end.row = selection.end.col = 0 |
57 | #define CLEAR_ALL_SELECTION() \ |
55 | #define CLEAR_ALL_SELECTION() \ |
… | |
… | |
85 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
83 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
86 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
84 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
87 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
85 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
88 | |
86 | |
89 | /* |
87 | /* |
90 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
|
|
91 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
88 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
92 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
|
|
93 | */ |
89 | */ |
94 | #define drawBuffer vt |
|
|
95 | |
|
|
96 | #define CLEAR_ROWS(row, num) \ |
|
|
97 | if (mapped) \ |
|
|
98 | XClearArea (display->display, drawBuffer, 0, \ |
|
|
99 | Row2Pixel (row), (unsigned int)width, \ |
|
|
100 | (unsigned int)Height2Pixel (num), False) |
|
|
101 | |
|
|
102 | #define CLEAR_CHARS(x, y, num) \ |
90 | #define CLEAR_CHARS(x, y, num) \ |
103 | if (mapped) \ |
91 | if (mapped) \ |
104 | XClearArea (display->display, drawBuffer, x, y, \ |
92 | XClearArea (dpy, vt, x, y, \ |
105 | (unsigned int)Width2Pixel (num), \ |
93 | (unsigned int)Width2Pixel (num), \ |
106 | (unsigned int)Height2Pixel (1), False) |
94 | (unsigned int)Height2Pixel (1), False) |
107 | |
|
|
108 | #define ERASE_ROWS(row, num) \ |
|
|
109 | XFillRectangle (display->display, drawBuffer, gc, \ |
|
|
110 | 0, Row2Pixel (row), \ |
|
|
111 | (unsigned int)width, \ |
|
|
112 | (unsigned int)Height2Pixel (num)) |
|
|
113 | |
95 | |
114 | /* ------------------------------------------------------------------------- * |
96 | /* ------------------------------------------------------------------------- * |
115 | * SCREEN `COMMON' ROUTINES * |
97 | * SCREEN `COMMON' ROUTINES * |
116 | * ------------------------------------------------------------------------- */ |
98 | * ------------------------------------------------------------------------- */ |
117 | |
99 | |
118 | /* Fill part/all of a line with blanks. */ |
100 | /* Fill part/all of a line with blanks. */ |
119 | void |
101 | void |
120 | rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) |
102 | rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW |
121 | { |
103 | { |
122 | if (!l.t) |
104 | if (!l.t) |
123 | { |
105 | { |
124 | lalloc (l); |
106 | lalloc (l); |
125 | col = 0; |
107 | col = 0; |
126 | width = ncol; |
108 | width = ncol; |
127 | } |
109 | } |
128 | |
110 | |
129 | l.touch (); |
111 | l.touch (); |
130 | |
112 | |
131 | efs &= ~RS_baseattrMask; |
113 | efs &= ~RS_baseattrMask; // remove italic etc. fontstyles |
132 | efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); |
114 | efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); |
133 | |
115 | |
134 | text_t *et = l.t + col; |
116 | text_t *et = l.t + col; |
135 | rend_t *er = l.r + col; |
117 | rend_t *er = l.r + col; |
136 | |
118 | |
… | |
… | |
142 | } |
124 | } |
143 | |
125 | |
144 | /* ------------------------------------------------------------------------- */ |
126 | /* ------------------------------------------------------------------------- */ |
145 | /* Fill a full line with blanks - make sure it is allocated first */ |
127 | /* Fill a full line with blanks - make sure it is allocated first */ |
146 | void |
128 | void |
147 | rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) |
129 | rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW |
148 | { |
130 | { |
149 | scr_blank_line (l, 0, ncol, efs); |
131 | scr_blank_line (l, 0, ncol, efs); |
150 | |
132 | |
151 | l.l = 0; |
133 | l.l = 0; |
152 | l.f = 0; |
134 | l.f = 0; |
… | |
… | |
161 | { |
143 | { |
162 | #if ENABLE_OVERLAY |
144 | #if ENABLE_OVERLAY |
163 | scr_overlay_off (); |
145 | scr_overlay_off (); |
164 | #endif |
146 | #endif |
165 | |
147 | |
|
|
148 | rvideo_mode = false; |
166 | view_start = 0; |
149 | view_start = 0; |
167 | num_scr = 0; |
150 | num_scr = 0; |
168 | |
151 | |
169 | if (ncol == 0) |
152 | if (ncol == 0) |
170 | ncol = 80; |
153 | ncol = 80; |
… | |
… | |
173 | nrow = 24; |
156 | nrow = 24; |
174 | |
157 | |
175 | if (ncol == prev_ncol && nrow == prev_nrow) |
158 | if (ncol == prev_ncol && nrow == prev_nrow) |
176 | return; |
159 | return; |
177 | |
160 | |
|
|
161 | if (current_screen != PRIMARY) |
|
|
162 | scr_swap_screen (); |
|
|
163 | |
178 | // we need at least two lines for wrapping to work correctly |
164 | // we need at least two lines for wrapping to work correctly |
179 | if (nrow + saveLines < 2) |
165 | while (nrow + saveLines < 2) |
180 | { |
166 | { |
181 | //TODO//FIXME |
167 | //TODO//FIXME |
182 | saveLines++; |
168 | saveLines++; |
183 | prev_nrow--; |
169 | prev_nrow--; |
184 | nsaved++; |
170 | top_row--; |
185 | } |
171 | } |
186 | |
172 | |
187 | want_refresh = 1; |
173 | want_refresh = 1; |
188 | |
174 | |
189 | int prev_total_rows = prev_nrow + saveLines; |
175 | int prev_total_rows = prev_nrow + saveLines; |
… | |
… | |
194 | |
180 | |
195 | if (!row_buf) |
181 | if (!row_buf) |
196 | { |
182 | { |
197 | /* |
183 | /* |
198 | * first time called so just malloc everything: don't rely on realloc |
184 | * first time called so just malloc everything: don't rely on realloc |
199 | * Note: this is still needed so that all the scrollback lines are NULL |
|
|
200 | */ |
185 | */ |
201 | nsaved = 0; /* no saved lines */ |
186 | top_row = 0; |
202 | term_start = 0; |
187 | term_start = 0; |
203 | |
188 | |
204 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
189 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
205 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
190 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
206 | |
191 | |
207 | row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
192 | row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); |
208 | temp_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
|
|
209 | drawn_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
193 | drawn_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
210 | swap_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
194 | swap_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
211 | |
195 | |
212 | for (int row = nrow; row--; ) |
196 | for (int row = nrow; row--; ) |
213 | { |
197 | { |
214 | scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); |
198 | scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); |
215 | scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
199 | scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
… | |
… | |
236 | selection.text = NULL; |
220 | selection.text = NULL; |
237 | selection.len = 0; |
221 | selection.len = 0; |
238 | selection.op = SELECTION_CLEAR; |
222 | selection.op = SELECTION_CLEAR; |
239 | selection.screen = PRIMARY; |
223 | selection.screen = PRIMARY; |
240 | selection.clicks = 0; |
224 | selection.clicks = 0; |
241 | CLEAR_ALL_SELECTION (); |
|
|
242 | rvideo = 0; |
|
|
243 | } |
225 | } |
244 | else |
226 | else |
245 | { |
227 | { |
246 | /* |
228 | /* |
247 | * add or delete rows as appropriate |
229 | * add or delete rows as appropriate |
… | |
… | |
260 | } |
242 | } |
261 | } |
243 | } |
262 | #endif |
244 | #endif |
263 | |
245 | |
264 | drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); |
246 | drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); |
265 | temp_buf = (line_t *)rxvt_realloc (temp_buf , nrow * sizeof (line_t)); |
|
|
266 | swap_buf = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t)); |
247 | swap_buf = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t)); |
267 | |
248 | |
268 | for (int row = min (nrow, prev_nrow); row--; ) |
249 | for (int row = min (nrow, prev_nrow); row--; ) |
269 | { |
250 | { |
270 | lresize (drawn_buf[row]); |
251 | lresize (drawn_buf[row]); |
… | |
… | |
275 | { |
256 | { |
276 | swap_buf [row].clear (); scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
257 | swap_buf [row].clear (); scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
277 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
258 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
278 | } |
259 | } |
279 | |
260 | |
|
|
261 | line_t *old_buf = row_buf; |
280 | line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
262 | row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); |
281 | |
263 | |
282 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
264 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
283 | int pend = MOD (term_start - nsaved , prev_total_rows); |
265 | int pend = MOD (term_start + top_row , prev_total_rows); |
284 | int q = total_rows; // rewrapped row |
266 | int q = total_rows; // rewrapped row |
285 | |
267 | |
286 | if (nsaved) |
268 | if (top_row) |
287 | { |
269 | { |
288 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
270 | // Re-wrap lines. This is rather ugly, possibly because I am too dumb |
289 | // to come up with a lean and mean algorithm. |
271 | // to come up with a lean and mean algorithm. |
290 | |
272 | |
291 | row_col_t ocur = screen.cur; |
273 | row_col_t ocur = screen.cur; |
292 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
274 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
293 | |
275 | |
… | |
… | |
327 | qline->l = ncol; |
309 | qline->l = ncol; |
328 | qline->is_longer (1); |
310 | qline->is_longer (1); |
329 | |
311 | |
330 | int qcol = 0; |
312 | int qcol = 0; |
331 | |
313 | |
|
|
314 | // see below for cursor adjustment rationale |
|
|
315 | if (p == ocur.row) |
|
|
316 | screen.cur.row = q - (total_rows - nrow); |
|
|
317 | |
332 | // fill a single destination line |
318 | // fill a single destination line |
333 | while (lofs < llen && qcol < ncol) |
319 | while (lofs < llen && qcol < ncol) |
334 | { |
320 | { |
335 | int prow = lofs / prev_ncol; |
321 | int prow = lofs / prev_ncol; |
336 | int pcol = lofs % prev_ncol; |
322 | int pcol = lofs % prev_ncol; |
… | |
… | |
346 | |
332 | |
347 | line_t &pline = old_buf [prow]; |
333 | line_t &pline = old_buf [prow]; |
348 | |
334 | |
349 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
335 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
350 | |
336 | |
351 | assert (len); |
|
|
352 | assert (pline.t); |
|
|
353 | |
|
|
354 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
337 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
355 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
338 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
356 | |
339 | |
357 | lofs += len; |
340 | lofs += len; |
358 | qcol += len; |
341 | qcol += len; |
… | |
… | |
364 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
347 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
365 | } |
348 | } |
366 | while (p != pend && q > 0); |
349 | while (p != pend && q > 0); |
367 | |
350 | |
368 | term_start = total_rows - nrow; |
351 | term_start = total_rows - nrow; |
369 | nsaved = term_start - q; |
352 | top_row = q - term_start; |
370 | |
353 | |
371 | // make sure all terminal lines exist |
354 | // make sure all terminal lines exist |
372 | while (nsaved < 0) |
355 | while (top_row > 0) |
373 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
356 | scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); |
374 | } |
357 | } |
375 | else |
358 | else |
376 | { |
359 | { |
377 | // if no scrollback exists (yet), wing, instead of wrap |
360 | // if no scrollback exists (yet), wing, instead of wrap |
378 | |
361 | |
379 | for (int row = min (nrow, prev_nrow); row--; ) |
362 | for (int row = min (nrow, prev_nrow); row--; ) |
380 | { |
363 | { |
381 | line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; |
364 | line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; |
382 | line_t &qline = row_buf [row]; |
365 | line_t &qline = row_buf [row]; |
383 | |
366 | |
… | |
… | |
391 | } |
374 | } |
392 | |
375 | |
393 | term_start = 0; |
376 | term_start = 0; |
394 | } |
377 | } |
395 | |
378 | |
396 | #ifdef DEBUG_STRICT //TODO: remove |
|
|
397 | for (int i = -nsaved; i < nrow; i++) |
|
|
398 | assert (ROW (i).t); |
|
|
399 | #endif |
|
|
400 | |
|
|
401 | free (old_buf); |
379 | free (old_buf); |
402 | delete old_ta; |
380 | delete old_ta; |
403 | delete old_ra; |
381 | delete old_ra; |
404 | |
382 | |
405 | clamp_it (screen.cur.row, 0, nrow - 1); |
383 | clamp_it (screen.cur.row, 0, nrow - 1); |
406 | clamp_it (screen.cur.col, 0, ncol - 1); |
384 | clamp_it (screen.cur.col, 0, ncol - 1); |
407 | |
385 | |
408 | if (tabs) |
|
|
409 | free (tabs); |
386 | free (tabs); |
410 | } |
387 | } |
|
|
388 | |
|
|
389 | CLEAR_ALL_SELECTION (); |
411 | |
390 | |
412 | prev_nrow = nrow; |
391 | prev_nrow = nrow; |
413 | prev_ncol = ncol; |
392 | prev_ncol = ncol; |
414 | |
393 | |
415 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
394 | tabs = (char *)rxvt_malloc (ncol); |
416 | |
395 | |
417 | for (int col = ncol; col--; ) |
396 | for (int col = ncol; --col; ) |
418 | tabs [col] = col % TABSIZE == 0; |
397 | tabs [col] = col % TABSIZE == 0; |
419 | |
398 | |
|
|
399 | if (current_screen != PRIMARY) |
|
|
400 | scr_swap_screen (); |
|
|
401 | |
420 | tt_winch (); |
402 | tt_winch (); |
421 | |
403 | |
422 | HOOK_INVOKE ((this, HOOK_RESET, DT_END)); |
404 | HOOK_INVOKE ((this, HOOK_RESET, DT_END)); |
423 | } |
405 | } |
424 | |
406 | |
425 | /* ------------------------------------------------------------------------- */ |
407 | /* ------------------------------------------------------------------------- */ |
426 | /* |
408 | /* |
427 | * Free everything. That way malloc debugging can find leakage. |
409 | * Free everything. That way malloc debugging can find leakage. |
428 | */ |
410 | */ |
429 | void |
411 | void |
430 | rxvt_term::scr_release () |
412 | rxvt_term::scr_release () NOTHROW |
431 | { |
413 | { |
|
|
414 | if (row_buf) |
|
|
415 | { |
432 | delete talloc; talloc = 0; |
416 | delete talloc; talloc = 0; |
433 | delete ralloc; ralloc = 0; |
417 | delete ralloc; ralloc = 0; |
434 | |
418 | |
435 | free (row_buf); |
419 | free (row_buf); |
436 | free (swap_buf); |
420 | free (swap_buf); |
437 | free (drawn_buf); |
421 | free (drawn_buf); |
438 | free (temp_buf); |
|
|
439 | free (tabs); |
422 | free (tabs); |
440 | |
423 | |
441 | row_buf = 0; // signal that we freed all the arrays |
424 | row_buf = 0; // signal that we freed all the arrays |
|
|
425 | } |
442 | } |
426 | } |
443 | |
427 | |
444 | /* ------------------------------------------------------------------------- */ |
428 | /* ------------------------------------------------------------------------- */ |
445 | /* |
429 | /* |
446 | * Hard reset |
430 | * Hard reset |
… | |
… | |
451 | scr_release (); |
435 | scr_release (); |
452 | prev_nrow = prev_ncol = 0; |
436 | prev_nrow = prev_ncol = 0; |
453 | scr_reset (); |
437 | scr_reset (); |
454 | |
438 | |
455 | scr_clear (true); |
439 | scr_clear (true); |
456 | scr_refresh (SLOW_REFRESH); |
440 | scr_refresh (); |
457 | } |
441 | } |
458 | |
442 | |
459 | /* ------------------------------------------------------------------------- * |
443 | /* ------------------------------------------------------------------------- * |
460 | * PROCESS SCREEN COMMANDS * |
444 | * PROCESS SCREEN COMMANDS * |
461 | * ------------------------------------------------------------------------- */ |
445 | * ------------------------------------------------------------------------- */ |
… | |
… | |
463 | * Save and Restore cursor |
447 | * Save and Restore cursor |
464 | * XTERM_SEQ: Save cursor : ESC 7 |
448 | * XTERM_SEQ: Save cursor : ESC 7 |
465 | * XTERM_SEQ: Restore cursor: ESC 8 |
449 | * XTERM_SEQ: Restore cursor: ESC 8 |
466 | */ |
450 | */ |
467 | void |
451 | void |
468 | rxvt_term::scr_cursor (int mode) |
452 | rxvt_term::scr_cursor (cursor_mode mode) NOTHROW |
469 | { |
453 | { |
470 | screen_t *s; |
454 | screen_t *s; |
471 | |
455 | |
472 | #if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) |
456 | #if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) |
473 | if (current_screen == SECONDARY) |
457 | if (current_screen == SECONDARY) |
… | |
… | |
505 | assert (s->cur.row >= 0); |
489 | assert (s->cur.row >= 0); |
506 | assert (s->cur.col >= 0); |
490 | assert (s->cur.col >= 0); |
507 | #endif |
491 | #endif |
508 | } |
492 | } |
509 | |
493 | |
|
|
494 | void |
|
|
495 | rxvt_term::scr_swap_screen () |
|
|
496 | { |
|
|
497 | if (!option (Opt_secondaryScreen)) |
|
|
498 | return; |
|
|
499 | |
|
|
500 | for (int i = prev_nrow; i--; ) |
|
|
501 | ::swap (ROW(i), swap_buf [i]); |
|
|
502 | |
|
|
503 | ::swap (screen.cur, swap.cur); |
|
|
504 | |
|
|
505 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
|
|
506 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
|
|
507 | } |
|
|
508 | |
510 | /* ------------------------------------------------------------------------- */ |
509 | /* ------------------------------------------------------------------------- */ |
511 | /* |
510 | /* |
512 | * Swap between primary and secondary screens |
511 | * Swap between primary and secondary screens |
513 | * XTERM_SEQ: Primary screen : ESC [ ? 4 7 h |
512 | * XTERM_SEQ: Primary screen : ESC [ ? 4 7 h |
514 | * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l |
513 | * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l |
515 | */ |
514 | */ |
516 | int |
515 | void |
517 | rxvt_term::scr_change_screen (int scrn) |
516 | rxvt_term::scr_change_screen (int scrn) |
518 | { |
517 | { |
|
|
518 | if (scrn == current_screen) |
|
|
519 | return; |
|
|
520 | |
519 | want_refresh = 1; |
521 | want_refresh = 1; |
520 | view_start = 0; |
522 | view_start = 0; |
521 | |
523 | |
522 | if (current_screen == scrn) |
|
|
523 | return scrn; |
|
|
524 | |
|
|
525 | selection_check (2); /* check for boundary cross */ |
524 | selection_check (2); /* check for boundary cross */ |
526 | |
525 | |
527 | int i = current_screen; current_screen = scrn; scrn = i; |
526 | int i = current_screen; current_screen = scrn; scrn = i; |
528 | |
527 | |
529 | ::swap (screen.cur.row, swap.cur.row); |
|
|
530 | ::swap (screen.cur.col, swap.cur.col); |
|
|
531 | |
|
|
532 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
|
|
533 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
|
|
534 | |
|
|
535 | #if NSCREENS |
528 | #if NSCREENS |
536 | if (OPTION (Opt_secondaryScreen)) |
529 | if (option (Opt_secondaryScreen)) |
537 | { |
530 | { |
538 | num_scr = 0; |
531 | num_scr = 0; |
539 | |
532 | |
540 | for (int i = prev_nrow; i--; ) |
533 | scr_swap_screen (); |
541 | ::swap (ROW(i), swap_buf [i]); |
|
|
542 | |
534 | |
543 | ::swap (screen.charset, swap.charset); |
535 | ::swap (screen.charset, swap.charset); |
544 | ::swap (screen.flags, swap.flags); |
536 | ::swap (screen.flags, swap.flags); |
545 | screen.flags |= Screen_VisibleCursor; |
537 | screen.flags |= Screen_VisibleCursor; |
546 | swap.flags |= Screen_VisibleCursor; |
538 | swap.flags |= Screen_VisibleCursor; |
547 | } |
539 | } |
548 | else |
540 | else |
549 | #endif |
541 | #endif |
550 | if (OPTION (Opt_secondaryScroll)) |
542 | if (option (Opt_secondaryScroll)) |
551 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
543 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
552 | |
|
|
553 | return scrn; |
|
|
554 | } |
544 | } |
555 | |
545 | |
556 | // clear WrapNext indicator, solidifying position on next line |
546 | // clear WrapNext indicator, solidifying position on next line |
557 | void |
547 | void |
558 | rxvt_term::scr_do_wrap () |
548 | rxvt_term::scr_do_wrap () NOTHROW |
559 | { |
549 | { |
560 | if (!(screen.flags & Screen_WrapNext)) |
550 | if (!(screen.flags & Screen_WrapNext)) |
561 | return; |
551 | return; |
562 | |
552 | |
563 | screen.flags &= ~Screen_WrapNext; |
553 | screen.flags &= ~Screen_WrapNext; |
… | |
… | |
573 | /* ------------------------------------------------------------------------- */ |
563 | /* ------------------------------------------------------------------------- */ |
574 | /* |
564 | /* |
575 | * Change the colour for following text |
565 | * Change the colour for following text |
576 | */ |
566 | */ |
577 | void |
567 | void |
578 | rxvt_term::scr_color (unsigned int color, int fgbg) |
568 | rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW |
579 | { |
569 | { |
580 | if (color > maxTermCOLOR) |
570 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
581 | color = fgbg; |
571 | color = fgbg; |
582 | |
572 | |
583 | if (fgbg == Color_fg) |
573 | if (fgbg == Color_fg) |
584 | rstyle = SET_FGCOLOR (rstyle, color); |
574 | rstyle = SET_FGCOLOR (rstyle, color); |
585 | else |
575 | else |
… | |
… | |
589 | /* ------------------------------------------------------------------------- */ |
579 | /* ------------------------------------------------------------------------- */ |
590 | /* |
580 | /* |
591 | * Change the rendition style for following text |
581 | * Change the rendition style for following text |
592 | */ |
582 | */ |
593 | void |
583 | void |
594 | rxvt_term::scr_rendition (int set, int style) |
584 | rxvt_term::scr_rendition (int set, int style) NOTHROW |
595 | { |
585 | { |
596 | if (set) |
586 | if (set) |
597 | rstyle |= style; |
587 | rstyle |= style; |
598 | else if (style == ~RS_None) |
588 | else if (style == ~RS_None) |
599 | rstyle = DEFAULT_RSTYLE; |
589 | rstyle = DEFAULT_RSTYLE; |
600 | else |
590 | else |
601 | rstyle &= ~style; |
591 | rstyle &= ~style; |
602 | } |
592 | } |
603 | |
593 | |
604 | /* ------------------------------------------------------------------------- */ |
594 | /* ------------------------------------------------------------------------- */ |
605 | /* |
595 | /* |
606 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
596 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
607 | * count positive ==> scroll up |
597 | * count positive ==> scroll up |
608 | * count negative ==> scroll down |
598 | * count negative ==> scroll down |
609 | */ |
599 | */ |
610 | int |
600 | int |
611 | rxvt_term::scr_scroll_text (int row1, int row2, int count) |
601 | rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW |
612 | { |
602 | { |
613 | if (count == 0 || (row1 > row2)) |
603 | if (count == 0 || (row1 > row2)) |
614 | return 0; |
604 | return 0; |
615 | |
605 | |
616 | want_refresh = 1; |
606 | want_refresh = 1; |
617 | num_scr += count; |
607 | num_scr += count; |
618 | |
608 | |
619 | if (count > 0 |
609 | if (count > 0 |
620 | && row1 == 0 |
610 | && row1 == 0 |
621 | && row2 == nrow - 1 |
|
|
622 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
611 | && (current_screen == PRIMARY || option (Opt_secondaryScroll))) |
623 | { |
612 | { |
624 | nsaved = min (nsaved + count, saveLines); |
613 | top_row = max (top_row - count, -saveLines); |
625 | |
614 | |
626 | HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END)); |
615 | // scroll everything up 'count' lines |
627 | |
|
|
628 | term_start = (term_start + count) % total_rows; |
616 | term_start = (term_start + count) % total_rows; |
629 | |
617 | |
|
|
618 | // sever bottommost line |
|
|
619 | { |
|
|
620 | line_t &l = ROW(row2 - count); |
|
|
621 | l.is_longer (0); |
|
|
622 | l.touch (); |
|
|
623 | } |
|
|
624 | |
|
|
625 | // erase newly scrolled-in lines |
|
|
626 | for (int i = count; i--; ) |
|
|
627 | { |
|
|
628 | line_t &l = ROW(nrow - 1 - i); |
|
|
629 | |
|
|
630 | // optimize if already cleared, can be significant on slow machines |
|
|
631 | // could be rolled into scr_blank_screen_mem |
|
|
632 | if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask))) |
|
|
633 | { |
|
|
634 | scr_blank_line (l, 0, l.l, rstyle); |
|
|
635 | l.l = 0; |
|
|
636 | l.f = 0; |
|
|
637 | } |
|
|
638 | else |
|
|
639 | scr_blank_screen_mem (l, rstyle); |
|
|
640 | } |
|
|
641 | |
|
|
642 | // now copy lines below the scroll region bottom to the |
|
|
643 | // bottom of the screen again, so they look as if they |
|
|
644 | // hadn't moved. |
|
|
645 | for (int i = nrow; --i > row2; ) |
|
|
646 | { |
|
|
647 | line_t &l1 = ROW(i - count); |
|
|
648 | line_t &l2 = ROW(i); |
|
|
649 | |
|
|
650 | ::swap (l1, l2); |
|
|
651 | l2.touch (); |
|
|
652 | } |
|
|
653 | |
|
|
654 | // move and/or clear selection, if any |
630 | if (selection.op && current_screen == selection.screen) |
655 | if (selection.op && current_screen == selection.screen) |
631 | { |
656 | { |
632 | selection.beg.row -= count; |
657 | selection.beg.row -= count; |
633 | selection.end.row -= count; |
658 | selection.end.row -= count; |
634 | selection.mark.row -= count; |
659 | selection.mark.row -= count; |
635 | |
660 | |
636 | if (selection.beg.row < -nsaved |
661 | if (selection.beg.row < top_row |
637 | || selection.end.row < -nsaved |
662 | || selection.end.row < top_row |
638 | || selection.mark.row < -nsaved) |
663 | || selection.mark.row < top_row) |
639 | { |
664 | { |
640 | CLEAR_ALL_SELECTION (); |
665 | CLEAR_ALL_SELECTION (); |
641 | selection.op = SELECTION_CLEAR; |
666 | selection.op = SELECTION_CLEAR; |
642 | } |
667 | } |
643 | } |
668 | } |
644 | |
669 | |
645 | for (int i = count; i--; ) |
670 | // finally move the view window, if desired |
646 | { |
|
|
647 | // basically thi is a slightly optimized scr_blank_screen_mem |
|
|
648 | // it is worth the effort on slower machines |
|
|
649 | line_t &l = ROW(row2 - i); |
|
|
650 | |
|
|
651 | scr_blank_line (l, 0, l.l, rstyle); |
|
|
652 | |
|
|
653 | l.l = 0; |
|
|
654 | l.f = 0; |
|
|
655 | } |
|
|
656 | |
|
|
657 | if (OPTION (Opt_scrollWithBuffer) |
671 | if (option (Opt_scrollWithBuffer) |
658 | && view_start != 0 |
672 | && view_start != 0 |
659 | && view_start != saveLines) |
673 | && view_start != -saveLines) |
660 | scr_page (UP, count); |
674 | scr_page (UP, count); |
|
|
675 | |
|
|
676 | if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) |
|
|
677 | HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); |
661 | } |
678 | } |
662 | else |
679 | else |
663 | { |
680 | { |
664 | if (selection.op && current_screen == selection.screen) |
681 | if (selection.op && current_screen == selection.screen) |
665 | { |
682 | { |
… | |
… | |
677 | { |
694 | { |
678 | /* move selected region too */ |
695 | /* move selected region too */ |
679 | selection.beg.row -= count; |
696 | selection.beg.row -= count; |
680 | selection.end.row -= count; |
697 | selection.end.row -= count; |
681 | selection.mark.row -= count; |
698 | selection.mark.row -= count; |
682 | |
699 | |
683 | selection_check (0); |
700 | selection_check (0); |
684 | } |
701 | } |
685 | } |
702 | } |
686 | |
703 | |
687 | // use a simple and robust scrolling algorithm, this |
704 | // use a simple and robust scrolling algorithm, this |
… | |
… | |
689 | |
706 | |
690 | int rows = row2 - row1 + 1; |
707 | int rows = row2 - row1 + 1; |
691 | |
708 | |
692 | min_it (count, rows); |
709 | min_it (count, rows); |
693 | |
710 | |
|
|
711 | line_t *temp_buf = row_buf + total_rows; |
|
|
712 | |
694 | for (int row = 0; row < rows; row++) |
713 | for (int row = 0; row < rows; row++) |
695 | { |
714 | { |
696 | temp_buf [row] = ROW(row1 + (row + count + rows) % rows); |
715 | temp_buf [row] = ROW(row1 + (row + count + rows) % rows); |
697 | |
716 | |
698 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
717 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
… | |
… | |
709 | /* ------------------------------------------------------------------------- */ |
728 | /* ------------------------------------------------------------------------- */ |
710 | /* |
729 | /* |
711 | * Add text given in <str> of length <len> to screen struct |
730 | * Add text given in <str> of length <len> to screen struct |
712 | */ |
731 | */ |
713 | void |
732 | void |
714 | rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) |
733 | rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW |
715 | { |
734 | { |
716 | if (len <= 0) /* sanity */ |
735 | if (len <= 0) /* sanity */ |
717 | return; |
736 | return; |
718 | |
737 | |
719 | unsigned char checksel; |
738 | unsigned char checksel; |
… | |
… | |
725 | ZERO_SCROLLBACK (); |
744 | ZERO_SCROLLBACK (); |
726 | |
745 | |
727 | if (minlines > 0) |
746 | if (minlines > 0) |
728 | { |
747 | { |
729 | minlines += screen.cur.row - screen.bscroll; |
748 | minlines += screen.cur.row - screen.bscroll; |
|
|
749 | min_it (minlines, screen.cur.row - top_row); |
730 | |
750 | |
731 | if (minlines > 0 |
751 | if (minlines > 0 |
732 | && screen.tscroll == 0 |
752 | && screen.tscroll == 0 |
733 | && screen.bscroll == nrow - 1) |
753 | && screen.bscroll == nrow - 1) |
734 | { |
754 | { |
… | |
… | |
739 | } |
759 | } |
740 | |
760 | |
741 | #ifdef DEBUG_STRICT |
761 | #ifdef DEBUG_STRICT |
742 | assert (screen.cur.col < ncol); |
762 | assert (screen.cur.col < ncol); |
743 | assert (screen.cur.row < nrow |
763 | assert (screen.cur.row < nrow |
744 | && screen.cur.row >= -nsaved); |
764 | && screen.cur.row >= top_row); |
745 | #endif |
765 | #endif |
746 | int row = screen.cur.row; |
766 | int row = screen.cur.row; |
747 | |
767 | |
748 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
768 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
749 | |
769 | |
… | |
… | |
795 | CLEAR_SELECTION (); |
815 | CLEAR_SELECTION (); |
796 | } |
816 | } |
797 | |
817 | |
798 | if (screen.flags & Screen_WrapNext) |
818 | if (screen.flags & Screen_WrapNext) |
799 | { |
819 | { |
|
|
820 | scr_do_wrap (); |
|
|
821 | |
800 | max_it (line->l, ncol); |
822 | line->l = ncol; |
801 | line->is_longer (1); |
823 | line->is_longer (1); |
802 | |
824 | |
803 | scr_do_wrap (); |
|
|
804 | |
|
|
805 | row = screen.cur.row; |
825 | row = screen.cur.row; |
806 | line = &ROW(row); /* _must_ refresh */ |
826 | line = &ROW(row); /* _must_ refresh */ |
807 | } |
827 | } |
808 | |
828 | |
809 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
829 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
810 | if (IN_RANGE_INC (c, 0xd800, 0xdfff)) |
830 | if (IN_RANGE_INC (c, 0xd800, 0xdfff)) |
811 | c = 0xfffd; |
831 | c = 0xfffd; |
812 | |
832 | |
813 | // rely on wcwidth to tell us the character width, at least for non-latin1 |
833 | // rely on wcwidth to tell us the character width, do wcwidth before |
814 | // do wcwidth before further replacements, as wcwidth might return -1 |
834 | // further replacements, as wcwidth might return -1 for the line |
815 | // for the line drawing characters below as they might be invalid in the current |
835 | // drawing characters below as they might be invalid in the current |
816 | // locale. |
836 | // locale. |
817 | int width = c < 0x100 ? 1 : wcwidth (c); |
837 | int width = WCWIDTH (c); |
818 | |
838 | |
819 | if (charsets [screen.charset] == '0') // DEC SPECIAL |
839 | if (charsets [screen.charset] == '0') // DEC SPECIAL |
820 | { |
840 | { |
821 | // vt100 special graphics and line drawing |
841 | // vt100 special graphics and line drawing |
822 | // 5f-7e standard vt100 |
842 | // 5f-7e standard vt100 |
… | |
… | |
973 | /* |
993 | /* |
974 | * Process Backspace. Move back the cursor back a position, wrap if have to |
994 | * Process Backspace. Move back the cursor back a position, wrap if have to |
975 | * XTERM_SEQ: CTRL-H |
995 | * XTERM_SEQ: CTRL-H |
976 | */ |
996 | */ |
977 | void |
997 | void |
978 | rxvt_term::scr_backspace () |
998 | rxvt_term::scr_backspace () NOTHROW |
979 | { |
999 | { |
980 | want_refresh = 1; |
|
|
981 | |
|
|
982 | if (screen.cur.col == 0) |
1000 | if (screen.cur.col == 0) |
983 | { |
1001 | { |
984 | if (screen.cur.row > 0) |
1002 | if (screen.cur.row > 0) |
985 | { |
1003 | { |
986 | #ifdef TERMCAP_HAS_BW |
1004 | #ifdef TERMCAP_HAS_BW |
987 | screen.cur.col = ncol - 1; |
1005 | screen.cur.col = ncol - 1; |
988 | screen.cur.row--; |
1006 | --screen.cur.row; |
989 | return; |
1007 | |
|
|
1008 | want_refresh = 1; |
990 | #endif |
1009 | #endif |
991 | } |
1010 | } |
992 | } |
1011 | } |
993 | else if (!(screen.flags & Screen_WrapNext)) |
1012 | else |
994 | scr_gotorc (0, -1, RELATIVE); |
1013 | scr_gotorc (0, -1, RELATIVE); |
995 | |
|
|
996 | screen.flags &= ~Screen_WrapNext; |
|
|
997 | } |
1014 | } |
998 | |
1015 | |
999 | /* ------------------------------------------------------------------------- */ |
1016 | /* ------------------------------------------------------------------------- */ |
1000 | /* |
1017 | /* |
1001 | * Process Horizontal Tab |
1018 | * Process Horizontal Tab |
1002 | * count: +ve = forward; -ve = backwards |
1019 | * count: +ve = forward; -ve = backwards |
1003 | * XTERM_SEQ: CTRL-I |
1020 | * XTERM_SEQ: CTRL-I |
1004 | */ |
1021 | */ |
1005 | void |
1022 | void |
1006 | rxvt_term::scr_tab (int count, bool ht) |
1023 | rxvt_term::scr_tab (int count, bool ht) NOTHROW |
1007 | { |
1024 | { |
1008 | int i, x; |
1025 | int i, x; |
1009 | |
1026 | |
1010 | want_refresh = 1; |
1027 | want_refresh = 1; |
1011 | i = x = screen.cur.col; |
1028 | i = x = screen.cur.col; |
… | |
… | |
1024 | x = i; |
1041 | x = i; |
1025 | |
1042 | |
1026 | if (!--count) |
1043 | if (!--count) |
1027 | break; |
1044 | break; |
1028 | } |
1045 | } |
1029 | else |
1046 | else |
1030 | ht &= l.t[i] == ' ' |
1047 | ht &= l.t[i] == ' ' |
1031 | && RS_SAME (l.r[i], base_rend); |
1048 | && RS_SAME (l.r[i], base_rend); |
1032 | |
1049 | |
1033 | if (count) |
1050 | if (count) |
1034 | x = ncol - 1; |
1051 | x = ncol - 1; |
1035 | |
1052 | |
1036 | // store horizontal tab commands as characters inside the text |
1053 | // store horizontal tab commands as characters inside the text |
1037 | // buffer so they can be selected and pasted. |
1054 | // buffer so they can be selected and pasted. |
1038 | if (ht && OPTION (Opt_pastableTabs)) |
1055 | if (ht && option (Opt_pastableTabs)) |
1039 | { |
1056 | { |
1040 | base_rend = SET_FONT (base_rend, 0); |
1057 | base_rend = SET_FONT (base_rend, 0); |
1041 | |
1058 | |
1042 | l.touch (x); |
1059 | l.touch (x); |
1043 | |
1060 | |
… | |
… | |
1076 | * Process DEC Back Index |
1093 | * Process DEC Back Index |
1077 | * XTERM_SEQ: ESC 6 |
1094 | * XTERM_SEQ: ESC 6 |
1078 | * Move cursor left in row. If we're at the left boundary, shift everything |
1095 | * Move cursor left in row. If we're at the left boundary, shift everything |
1079 | * in that row right. Clear left column. |
1096 | * in that row right. Clear left column. |
1080 | */ |
1097 | */ |
1081 | #if ENABLE_FRILLS |
1098 | #if !ENABLE_MINIMAL |
1082 | void |
1099 | void |
1083 | rxvt_term::scr_backindex () |
1100 | rxvt_term::scr_backindex () NOTHROW |
1084 | { |
1101 | { |
1085 | if (screen.cur.col > 0) |
1102 | if (screen.cur.col > 0) |
1086 | scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); |
1103 | scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); |
1087 | else |
1104 | else |
1088 | scr_insdel_chars (1, INSERT); |
1105 | scr_insdel_chars (1, INSERT); |
… | |
… | |
1093 | * Process DEC Forward Index |
1110 | * Process DEC Forward Index |
1094 | * XTERM_SEQ: ESC 9 |
1111 | * XTERM_SEQ: ESC 9 |
1095 | * Move cursor right in row. If we're at the right boundary, shift everything |
1112 | * Move cursor right in row. If we're at the right boundary, shift everything |
1096 | * in that row left. Clear right column. |
1113 | * in that row left. Clear right column. |
1097 | */ |
1114 | */ |
1098 | #if ENABLE_FRILLS |
1115 | #if !ENABLE_MINIMAL |
1099 | void |
1116 | void |
1100 | rxvt_term::scr_forwardindex () |
1117 | rxvt_term::scr_forwardindex () NOTHROW |
1101 | { |
1118 | { |
1102 | if (screen.cur.col < ncol - 1) |
1119 | if (screen.cur.col < ncol - 1) |
1103 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1120 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1104 | else |
1121 | else |
1105 | { |
1122 | { |
… | |
… | |
1118 | /* ------------------------------------------------------------------------- */ |
1135 | /* ------------------------------------------------------------------------- */ |
1119 | /* |
1136 | /* |
1120 | * Goto Row/Column |
1137 | * Goto Row/Column |
1121 | */ |
1138 | */ |
1122 | void |
1139 | void |
1123 | rxvt_term::scr_gotorc (int row, int col, int relative) |
1140 | rxvt_term::scr_gotorc (int row, int col, int relative) NOTHROW |
1124 | { |
1141 | { |
1125 | want_refresh = 1; |
1142 | want_refresh = 1; |
1126 | ZERO_SCROLLBACK (); |
1143 | ZERO_SCROLLBACK (); |
1127 | |
1144 | |
1128 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1145 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
… | |
… | |
1150 | } |
1167 | } |
1151 | } |
1168 | } |
1152 | else |
1169 | else |
1153 | { |
1170 | { |
1154 | if (screen.flags & Screen_Relative) |
1171 | if (screen.flags & Screen_Relative) |
|
|
1172 | { |
1155 | { /* relative origin mode */ |
1173 | /* relative origin mode */ |
1156 | screen.cur.row = row + screen.tscroll; |
1174 | screen.cur.row = row + screen.tscroll; |
1157 | min_it (screen.cur.row, screen.bscroll); |
1175 | min_it (screen.cur.row, screen.bscroll); |
1158 | } |
1176 | } |
1159 | else |
1177 | else |
1160 | screen.cur.row = row; |
1178 | screen.cur.row = row; |
… | |
… | |
1166 | /* ------------------------------------------------------------------------- */ |
1184 | /* ------------------------------------------------------------------------- */ |
1167 | /* |
1185 | /* |
1168 | * direction should be UP or DN |
1186 | * direction should be UP or DN |
1169 | */ |
1187 | */ |
1170 | void |
1188 | void |
1171 | rxvt_term::scr_index (enum page_dirn direction) |
1189 | rxvt_term::scr_index (enum page_dirn direction) NOTHROW |
1172 | { |
1190 | { |
1173 | int dirn; |
1191 | int dirn; |
1174 | |
1192 | |
1175 | want_refresh = 1; |
1193 | want_refresh = 1; |
1176 | ZERO_SCROLLBACK (); |
1194 | ZERO_SCROLLBACK (); |
… | |
… | |
1193 | /* |
1211 | /* |
1194 | * Erase part or whole of a line |
1212 | * Erase part or whole of a line |
1195 | * XTERM_SEQ: Clear line to right: ESC [ 0 K |
1213 | * XTERM_SEQ: Clear line to right: ESC [ 0 K |
1196 | * XTERM_SEQ: Clear line to left : ESC [ 1 K |
1214 | * XTERM_SEQ: Clear line to left : ESC [ 1 K |
1197 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1215 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
|
|
1216 | * extension: clear to right unless wrapped: ESC [ 3 K |
1198 | */ |
1217 | */ |
1199 | void |
1218 | void |
1200 | rxvt_term::scr_erase_line (int mode) |
1219 | rxvt_term::scr_erase_line (int mode) NOTHROW |
1201 | { |
1220 | { |
1202 | unsigned int col, num; |
1221 | unsigned int col, num; |
1203 | |
1222 | |
1204 | want_refresh = 1; |
1223 | want_refresh = 1; |
1205 | ZERO_SCROLLBACK (); |
1224 | ZERO_SCROLLBACK (); |
… | |
… | |
1211 | line.touch (); |
1230 | line.touch (); |
1212 | line.is_longer (0); |
1231 | line.is_longer (0); |
1213 | |
1232 | |
1214 | switch (mode) |
1233 | switch (mode) |
1215 | { |
1234 | { |
|
|
1235 | case 3: |
|
|
1236 | if (screen.flags & Screen_WrapNext) |
|
|
1237 | return; |
|
|
1238 | |
|
|
1239 | /* fall through */ |
|
|
1240 | |
1216 | case 0: /* erase to end of line */ |
1241 | case 0: /* erase to end of line */ |
1217 | col = screen.cur.col; |
1242 | col = screen.cur.col; |
1218 | num = ncol - col; |
1243 | num = ncol - col; |
1219 | min_it (line.l, col); |
1244 | min_it (line.l, col); |
|
|
1245 | |
1220 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1246 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1221 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1247 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1222 | CLEAR_SELECTION (); |
1248 | CLEAR_SELECTION (); |
1223 | break; |
1249 | break; |
|
|
1250 | |
1224 | case 1: /* erase to beginning of line */ |
1251 | case 1: /* erase to beginning of line */ |
1225 | col = 0; |
1252 | col = 0; |
1226 | num = screen.cur.col + 1; |
1253 | num = screen.cur.col + 1; |
|
|
1254 | |
1227 | if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur) |
1255 | if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur) |
1228 | || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur)) |
1256 | || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur)) |
1229 | CLEAR_SELECTION (); |
1257 | CLEAR_SELECTION (); |
1230 | break; |
1258 | break; |
|
|
1259 | |
1231 | case 2: /* erase whole line */ |
1260 | case 2: /* erase whole line */ |
1232 | col = 0; |
1261 | col = 0; |
1233 | num = ncol; |
1262 | num = ncol; |
1234 | line.l = 0; |
1263 | line.l = 0; |
1235 | if (selection.beg.row <= screen.cur.row |
1264 | if (selection.beg.row <= screen.cur.row |
… | |
… | |
1249 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1278 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1250 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1279 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1251 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1280 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1252 | */ |
1281 | */ |
1253 | void |
1282 | void |
1254 | rxvt_term::scr_erase_screen (int mode) |
1283 | rxvt_term::scr_erase_screen (int mode) NOTHROW |
1255 | { |
1284 | { |
1256 | int num; |
1285 | int num; |
1257 | int32_t row; |
1286 | int32_t row; |
1258 | rend_t ren; |
1287 | rend_t ren; |
1259 | XGCValues gcvalue; |
1288 | XGCValues gcvalue; |
… | |
… | |
1293 | if (row >= nrow) /* Out Of Bounds */ |
1322 | if (row >= nrow) /* Out Of Bounds */ |
1294 | return; |
1323 | return; |
1295 | |
1324 | |
1296 | min_it (num, nrow - row); |
1325 | min_it (num, nrow - row); |
1297 | |
1326 | |
|
|
1327 | /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */ |
1298 | if (rstyle & (RS_RVid | RS_Uline)) |
1328 | if (rstyle & (RS_RVid | RS_Uline)) |
1299 | ren = (rend_t) ~RS_None; |
1329 | ren = (rend_t) ~RS_None; |
1300 | else if (GET_BASEBG (rstyle) == Color_bg) |
1330 | else if (GET_BASEBG (rstyle) == Color_bg) |
1301 | { |
1331 | { |
1302 | ren = DEFAULT_RSTYLE; |
1332 | ren = DEFAULT_RSTYLE; |
1303 | CLEAR_ROWS (row, num); |
1333 | |
|
|
1334 | if (mapped) |
|
|
1335 | XClearArea (dpy, vt, 0, |
|
|
1336 | Row2Pixel (row), (unsigned int)width, |
|
|
1337 | (unsigned int)Height2Pixel (num), False); |
1304 | } |
1338 | } |
1305 | else |
1339 | else |
1306 | { |
1340 | { |
1307 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1341 | ren = rstyle & (RS_fgMask | RS_bgMask); |
|
|
1342 | |
1308 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1343 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1309 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1344 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1310 | ERASE_ROWS (row, num); |
1345 | XFillRectangle (dpy, vt, gc, |
|
|
1346 | 0, Row2Pixel (row), |
|
|
1347 | (unsigned int)width, |
|
|
1348 | (unsigned int)Height2Pixel (num)); |
1311 | gcvalue.foreground = pix_colors[Color_fg]; |
1349 | gcvalue.foreground = pix_colors[Color_fg]; |
1312 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1350 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1313 | } |
1351 | } |
1314 | |
1352 | |
1315 | for (; num--; row++) |
1353 | for (; num--; row++) |
1316 | { |
1354 | { |
1317 | scr_blank_screen_mem (ROW(row), rstyle); |
1355 | scr_blank_screen_mem (ROW(row), rstyle); |
1318 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1356 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1319 | } |
1357 | } |
1320 | } |
1358 | } |
1321 | |
1359 | |
1322 | #if ENABLE_FRILLS |
1360 | #if !ENABLE_MINIMAL |
1323 | void |
1361 | void |
1324 | rxvt_term::scr_erase_savelines () |
1362 | rxvt_term::scr_erase_savelines () NOTHROW |
1325 | { |
1363 | { |
1326 | want_refresh = 1; |
1364 | want_refresh = 1; |
1327 | ZERO_SCROLLBACK (); |
1365 | ZERO_SCROLLBACK (); |
1328 | |
1366 | |
1329 | nsaved = 0; |
1367 | top_row = 0; |
1330 | } |
1368 | } |
1331 | #endif |
1369 | #endif |
1332 | |
1370 | |
1333 | /* ------------------------------------------------------------------------- */ |
1371 | /* ------------------------------------------------------------------------- */ |
1334 | /* |
1372 | /* |
1335 | * Fill the screen with `E's |
1373 | * Fill the screen with `E's |
1336 | * XTERM_SEQ: Screen Alignment Test: ESC # 8 |
1374 | * XTERM_SEQ: Screen Alignment Test: ESC # 8 |
1337 | */ |
1375 | */ |
1338 | void |
1376 | void |
1339 | rxvt_term::scr_E () |
1377 | rxvt_term::scr_E () NOTHROW |
1340 | { |
1378 | { |
1341 | rend_t fs; |
1379 | rend_t fs; |
1342 | |
1380 | |
1343 | want_refresh = 1; |
1381 | want_refresh = 1; |
1344 | ZERO_SCROLLBACK (); |
1382 | ZERO_SCROLLBACK (); |
… | |
… | |
1365 | /* ------------------------------------------------------------------------- */ |
1403 | /* ------------------------------------------------------------------------- */ |
1366 | /* |
1404 | /* |
1367 | * Insert/Delete <count> lines |
1405 | * Insert/Delete <count> lines |
1368 | */ |
1406 | */ |
1369 | void |
1407 | void |
1370 | rxvt_term::scr_insdel_lines (int count, int insdel) |
1408 | rxvt_term::scr_insdel_lines (int count, int insdel) NOTHROW |
1371 | { |
1409 | { |
1372 | int end; |
1410 | int end; |
1373 | |
1411 | |
1374 | ZERO_SCROLLBACK (); |
1412 | ZERO_SCROLLBACK (); |
1375 | |
1413 | |
… | |
… | |
1395 | /* ------------------------------------------------------------------------- */ |
1433 | /* ------------------------------------------------------------------------- */ |
1396 | /* |
1434 | /* |
1397 | * Insert/Delete <count> characters from the current position |
1435 | * Insert/Delete <count> characters from the current position |
1398 | */ |
1436 | */ |
1399 | void |
1437 | void |
1400 | rxvt_term::scr_insdel_chars (int count, int insdel) |
1438 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1401 | { |
1439 | { |
1402 | int col, row; |
1440 | int col, row; |
1403 | rend_t tr; |
1441 | rend_t tr; |
1404 | |
1442 | |
1405 | want_refresh = 1; |
1443 | want_refresh = 1; |
… | |
… | |
1436 | { |
1474 | { |
1437 | if (selection.end.row != screen.cur.row |
1475 | if (selection.end.row != screen.cur.row |
1438 | || (selection.end.col + count >= ncol)) |
1476 | || (selection.end.col + count >= ncol)) |
1439 | CLEAR_SELECTION (); |
1477 | CLEAR_SELECTION (); |
1440 | else |
1478 | else |
|
|
1479 | { |
1441 | { /* shift selection */ |
1480 | /* shift selection */ |
1442 | selection.beg.col += count; |
1481 | selection.beg.col += count; |
1443 | selection.mark.col += count; /* XXX: yes? */ |
1482 | selection.mark.col += count; /* XXX: yes? */ |
1444 | selection.end.col += count; |
1483 | selection.end.col += count; |
1445 | } |
1484 | } |
1446 | } |
1485 | } |
… | |
… | |
1493 | /* |
1532 | /* |
1494 | * Set the scrolling region |
1533 | * Set the scrolling region |
1495 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1534 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1496 | */ |
1535 | */ |
1497 | void |
1536 | void |
1498 | rxvt_term::scr_scroll_region (int top, int bot) |
1537 | rxvt_term::scr_scroll_region (int top, int bot) NOTHROW |
1499 | { |
1538 | { |
1500 | max_it (top, 0); |
1539 | max_it (top, 0); |
1501 | min_it (bot, nrow - 1); |
1540 | min_it (bot, nrow - 1); |
1502 | |
1541 | |
1503 | if (top > bot) |
1542 | if (top > bot) |
… | |
… | |
1513 | * Make the cursor visible/invisible |
1552 | * Make the cursor visible/invisible |
1514 | * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h |
1553 | * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h |
1515 | * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l |
1554 | * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l |
1516 | */ |
1555 | */ |
1517 | void |
1556 | void |
1518 | rxvt_term::scr_cursor_visible (int mode) |
1557 | rxvt_term::scr_cursor_visible (int mode) NOTHROW |
1519 | { |
1558 | { |
1520 | want_refresh = 1; |
1559 | want_refresh = 1; |
1521 | |
1560 | |
1522 | if (mode) |
1561 | if (mode) |
1523 | screen.flags |= Screen_VisibleCursor; |
1562 | screen.flags |= Screen_VisibleCursor; |
… | |
… | |
1530 | * Set/unset automatic wrapping |
1569 | * Set/unset automatic wrapping |
1531 | * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h |
1570 | * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h |
1532 | * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l |
1571 | * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l |
1533 | */ |
1572 | */ |
1534 | void |
1573 | void |
1535 | rxvt_term::scr_autowrap (int mode) |
1574 | rxvt_term::scr_autowrap (int mode) NOTHROW |
1536 | { |
1575 | { |
1537 | if (mode) |
1576 | if (mode) |
1538 | screen.flags |= Screen_Autowrap; |
1577 | screen.flags |= Screen_Autowrap; |
1539 | else |
1578 | else |
1540 | screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); |
1579 | screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); |
… | |
… | |
1549 | * and the cursor cannot be moved outside. |
1588 | * and the cursor cannot be moved outside. |
1550 | * XTERM_SEQ: Set Absolute: ESC [ ? 6 h |
1589 | * XTERM_SEQ: Set Absolute: ESC [ ? 6 h |
1551 | * XTERM_SEQ: Set Relative: ESC [ ? 6 l |
1590 | * XTERM_SEQ: Set Relative: ESC [ ? 6 l |
1552 | */ |
1591 | */ |
1553 | void |
1592 | void |
1554 | rxvt_term::scr_relative_origin (int mode) |
1593 | rxvt_term::scr_relative_origin (int mode) NOTHROW |
1555 | { |
1594 | { |
1556 | if (mode) |
1595 | if (mode) |
1557 | screen.flags |= Screen_Relative; |
1596 | screen.flags |= Screen_Relative; |
1558 | else |
1597 | else |
1559 | screen.flags &= ~Screen_Relative; |
1598 | screen.flags &= ~Screen_Relative; |
… | |
… | |
1566 | * Set insert/replace mode |
1605 | * Set insert/replace mode |
1567 | * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h |
1606 | * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h |
1568 | * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l |
1607 | * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l |
1569 | */ |
1608 | */ |
1570 | void |
1609 | void |
1571 | rxvt_term::scr_insert_mode (int mode) |
1610 | rxvt_term::scr_insert_mode (int mode) NOTHROW |
1572 | { |
1611 | { |
1573 | if (mode) |
1612 | if (mode) |
1574 | screen.flags |= Screen_Insert; |
1613 | screen.flags |= Screen_Insert; |
1575 | else |
1614 | else |
1576 | screen.flags &= ~Screen_Insert; |
1615 | screen.flags &= ~Screen_Insert; |
… | |
… | |
1582 | * XTERM_SEQ: Set tab at current column : ESC H |
1621 | * XTERM_SEQ: Set tab at current column : ESC H |
1583 | * XTERM_SEQ: Clear tab at current column: ESC [ 0 g |
1622 | * XTERM_SEQ: Clear tab at current column: ESC [ 0 g |
1584 | * XTERM_SEQ: Clear all tabs : ESC [ 3 g |
1623 | * XTERM_SEQ: Clear all tabs : ESC [ 3 g |
1585 | */ |
1624 | */ |
1586 | void |
1625 | void |
1587 | rxvt_term::scr_set_tab (int mode) |
1626 | rxvt_term::scr_set_tab (int mode) NOTHROW |
1588 | { |
1627 | { |
1589 | if (mode < 0) |
1628 | if (mode < 0) |
1590 | memset (tabs, 0, ncol * sizeof (char)); |
1629 | memset (tabs, 0, ncol); |
1591 | else if (screen.cur.col < ncol) |
1630 | else if (screen.cur.col < ncol) |
1592 | tabs [screen.cur.col] = !!mode; |
1631 | tabs [screen.cur.col] = !!mode; |
1593 | } |
1632 | } |
1594 | |
1633 | |
1595 | /* ------------------------------------------------------------------------- */ |
1634 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1597 | * Set reverse/normal video |
1636 | * Set reverse/normal video |
1598 | * XTERM_SEQ: Reverse video: ESC [ ? 5 h |
1637 | * XTERM_SEQ: Reverse video: ESC [ ? 5 h |
1599 | * XTERM_SEQ: Normal video : ESC [ ? 5 l |
1638 | * XTERM_SEQ: Normal video : ESC [ ? 5 l |
1600 | */ |
1639 | */ |
1601 | void |
1640 | void |
1602 | rxvt_term::scr_rvideo_mode (int mode) |
1641 | rxvt_term::scr_rvideo_mode (bool on) NOTHROW |
1603 | { |
1642 | { |
1604 | XGCValues gcvalue; |
1643 | rvideo_mode = on; |
1605 | |
1644 | |
|
|
1645 | #ifndef NO_BELL |
|
|
1646 | on ^= rvideo_bell; |
|
|
1647 | #endif |
|
|
1648 | |
1606 | if (rvideo != mode) |
1649 | if (rvideo_state != on) |
1607 | { |
1650 | { |
1608 | rvideo = mode; |
1651 | rvideo_state = on; |
|
|
1652 | |
1609 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1653 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1610 | #if XPM_BACKGROUND |
1654 | #ifdef HAVE_BG_PIXMAP |
1611 | if (bgPixmap.pixmap == None) |
1655 | if (bgPixmap.pixmap == None) |
1612 | #endif |
1656 | #endif |
1613 | #if TRANSPARENT |
1657 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
1614 | if (! OPTION (Opt_transparent) || am_transparent == 0) |
|
|
1615 | #endif |
|
|
1616 | XSetWindowBackground (display->display, vt, |
|
|
1617 | pix_colors[Color_bg]); |
|
|
1618 | |
1658 | |
|
|
1659 | XGCValues gcvalue; |
1619 | gcvalue.foreground = pix_colors[Color_fg]; |
1660 | gcvalue.foreground = pix_colors[Color_fg]; |
1620 | gcvalue.background = pix_colors[Color_bg]; |
1661 | gcvalue.background = pix_colors[Color_bg]; |
1621 | XChangeGC (display->display, gc, GCBackground | GCForeground, |
1662 | XChangeGC (dpy, gc, GCBackground | GCForeground, &gcvalue); |
1622 | &gcvalue); |
1663 | |
1623 | scr_clear (); |
1664 | scr_clear (); |
1624 | scr_touch (true); |
1665 | scr_touch (true); |
1625 | } |
1666 | } |
1626 | } |
1667 | } |
1627 | |
1668 | |
… | |
… | |
1629 | /* |
1670 | /* |
1630 | * Report current cursor position |
1671 | * Report current cursor position |
1631 | * XTERM_SEQ: Report position: ESC [ 6 n |
1672 | * XTERM_SEQ: Report position: ESC [ 6 n |
1632 | */ |
1673 | */ |
1633 | void |
1674 | void |
1634 | rxvt_term::scr_report_position () |
1675 | rxvt_term::scr_report_position () NOTHROW |
1635 | { |
1676 | { |
1636 | tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); |
1677 | tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); |
1637 | } |
1678 | } |
1638 | |
1679 | |
1639 | /* ------------------------------------------------------------------------- * |
1680 | /* ------------------------------------------------------------------------- * |
… | |
… | |
1642 | |
1683 | |
1643 | /* |
1684 | /* |
1644 | * Set font style |
1685 | * Set font style |
1645 | */ |
1686 | */ |
1646 | void |
1687 | void |
1647 | rxvt_term::set_font_style () |
1688 | rxvt_term::set_font_style () NOTHROW |
1648 | { |
1689 | { |
1649 | #if 0 |
1690 | #if 0 |
1650 | switch (charsets [screen.charset]) |
1691 | switch (charsets [screen.charset]) |
1651 | { |
1692 | { |
1652 | case '0': /* DEC Special Character & Line Drawing Set */ |
1693 | case '0': /* DEC Special Character & Line Drawing Set */ |
… | |
… | |
1674 | * XTERM_SEQ: Invoke G1 character set: CTRL-N |
1715 | * XTERM_SEQ: Invoke G1 character set: CTRL-N |
1675 | * XTERM_SEQ: Invoke G2 character set: ESC N |
1716 | * XTERM_SEQ: Invoke G2 character set: ESC N |
1676 | * XTERM_SEQ: Invoke G3 character set: ESC O |
1717 | * XTERM_SEQ: Invoke G3 character set: ESC O |
1677 | */ |
1718 | */ |
1678 | void |
1719 | void |
1679 | rxvt_term::scr_charset_choose (int set) |
1720 | rxvt_term::scr_charset_choose (int set) NOTHROW |
1680 | { |
1721 | { |
1681 | screen.charset = set; |
1722 | screen.charset = set; |
1682 | set_font_style (); |
1723 | set_font_style (); |
1683 | } |
1724 | } |
1684 | |
1725 | |
… | |
… | |
1690 | * XTERM_SEQ: Set G2 character set: ESC * <C> |
1731 | * XTERM_SEQ: Set G2 character set: ESC * <C> |
1691 | * XTERM_SEQ: Set G3 character set: ESC + <C> |
1732 | * XTERM_SEQ: Set G3 character set: ESC + <C> |
1692 | * See set_font_style for possible values for <C> |
1733 | * See set_font_style for possible values for <C> |
1693 | */ |
1734 | */ |
1694 | void |
1735 | void |
1695 | rxvt_term::scr_charset_set (int set, unsigned int ch) |
1736 | rxvt_term::scr_charset_set (int set, unsigned int ch) NOTHROW |
1696 | { |
1737 | { |
1697 | charsets[set] = (unsigned char)ch; |
1738 | charsets[set] = (unsigned char)ch; |
1698 | set_font_style (); |
1739 | set_font_style (); |
1699 | } |
1740 | } |
1700 | |
1741 | |
… | |
… | |
1705 | |
1746 | |
1706 | /* |
1747 | /* |
1707 | * refresh matching text. |
1748 | * refresh matching text. |
1708 | */ |
1749 | */ |
1709 | bool |
1750 | bool |
1710 | rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) |
1751 | rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW |
1711 | { |
1752 | { |
1712 | bool found = false; |
1753 | bool found = false; |
1713 | |
1754 | |
1714 | for (int i = 0; i < nrow; i++) |
1755 | for (int i = 0; i < nrow; i++) |
1715 | { |
1756 | { |
1716 | int col = 0; |
|
|
1717 | rend_t *drp = drawn_buf[i].r; |
1757 | rend_t *drp = drawn_buf[i].r; |
1718 | |
1758 | |
1719 | for (; col < ncol; col++, drp++) |
1759 | for (int col = 0; col < ncol; col++, drp++) |
1720 | if ((*drp & mask) == value) |
1760 | if ((*drp & mask) == value) |
1721 | { |
1761 | { |
1722 | found = true; |
1762 | found = true; |
1723 | *drp = ~value; |
1763 | *drp = ~value; |
1724 | } |
1764 | } |
… | |
… | |
1735 | PART_END, |
1775 | PART_END, |
1736 | RC_COUNT |
1776 | RC_COUNT |
1737 | }; |
1777 | }; |
1738 | |
1778 | |
1739 | void |
1779 | void |
1740 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1780 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) NOTHROW |
1741 | { |
1781 | { |
1742 | int i; |
1782 | int i; |
1743 | row_col_t rc[RC_COUNT]; |
1783 | row_col_t rc[RC_COUNT]; |
1744 | |
1784 | |
1745 | if (!drawn_buf) /* sanity check */ |
1785 | if (!drawn_buf) /* sanity check */ |
… | |
… | |
1764 | for (i = PART_BEG; i < RC_COUNT; i++) |
1804 | for (i = PART_BEG; i < RC_COUNT; i++) |
1765 | { |
1805 | { |
1766 | min_it (rc[i].col, ncol - 1); |
1806 | min_it (rc[i].col, ncol - 1); |
1767 | min_it (rc[i].row, nrow - 1); |
1807 | min_it (rc[i].row, nrow - 1); |
1768 | } |
1808 | } |
1769 | |
1809 | // TODO: this line somehow causes segfault if scr_expose() is called just after resize |
1770 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1810 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1771 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1811 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1772 | |
1812 | |
|
|
1813 | num_scr_allow = 0; |
|
|
1814 | |
1773 | if (refresh) |
1815 | if (refresh) |
1774 | scr_refresh (SLOW_REFRESH); |
1816 | scr_refresh (); |
1775 | } |
1817 | } |
1776 | |
1818 | |
1777 | /* ------------------------------------------------------------------------- */ |
1819 | /* ------------------------------------------------------------------------- */ |
1778 | /* |
1820 | /* |
1779 | * Refresh the entire screen |
1821 | * Refresh the entire screen |
1780 | */ |
1822 | */ |
1781 | void |
1823 | void |
1782 | rxvt_term::scr_touch (bool refresh) |
1824 | rxvt_term::scr_touch (bool refresh) NOTHROW |
1783 | { |
1825 | { |
1784 | scr_expose (0, 0, width, height, refresh); |
1826 | scr_expose (0, 0, width, height, refresh); |
1785 | } |
1827 | } |
1786 | |
1828 | |
1787 | /* ------------------------------------------------------------------------- */ |
1829 | /* ------------------------------------------------------------------------- */ |
1788 | /* |
1830 | /* |
1789 | * Move the display so that the line represented by scrollbar value Y is at |
1831 | * Move the display so that the line represented by scrollbar value Y is at |
1790 | * the top of the screen |
1832 | * the top of the screen |
1791 | */ |
1833 | */ |
1792 | int |
1834 | void |
1793 | rxvt_term::scr_move_to (int y, int len) |
1835 | rxvt_term::scr_move_to (int y, int len) NOTHROW |
1794 | { |
1836 | { |
1795 | long p = 0; |
1837 | scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); |
1796 | unsigned int oldviewstart; |
|
|
1797 | |
|
|
1798 | oldviewstart = view_start; |
|
|
1799 | |
|
|
1800 | if (y < len) |
|
|
1801 | { |
|
|
1802 | p = (nrow + nsaved) * (len - y) / len; |
|
|
1803 | p -= (long) (nrow - 1); |
|
|
1804 | p = max (p, 0); |
|
|
1805 | } |
|
|
1806 | |
|
|
1807 | view_start = (unsigned int)min (p, nsaved); |
|
|
1808 | |
|
|
1809 | return scr_changeview (oldviewstart); |
|
|
1810 | } |
1838 | } |
1811 | |
1839 | |
1812 | /* ------------------------------------------------------------------------- */ |
1840 | /* ------------------------------------------------------------------------- */ |
1813 | /* |
1841 | /* |
1814 | * Page the screen up/down nlines |
1842 | * Page the screen up/down nlines |
1815 | * direction should be UP or DN |
1843 | * direction should be UP or DN |
1816 | */ |
1844 | */ |
1817 | int |
1845 | bool |
1818 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1846 | rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW |
1819 | { |
1847 | { |
1820 | int n; |
1848 | int new_view_start = |
1821 | unsigned int oldviewstart; |
|
|
1822 | |
|
|
1823 | oldviewstart = view_start; |
|
|
1824 | |
|
|
1825 | if (direction == UP) |
|
|
1826 | { |
|
|
1827 | n = view_start + nlines; |
|
|
1828 | view_start = min (n, nsaved); |
|
|
1829 | } |
|
|
1830 | else |
|
|
1831 | { |
|
|
1832 | n = view_start - nlines; |
1849 | direction == UP ? view_start - nlines |
1833 | view_start = max (n, 0); |
1850 | : view_start + nlines; |
1834 | } |
|
|
1835 | |
1851 | |
1836 | return scr_changeview (oldviewstart); |
1852 | return scr_changeview (new_view_start); |
1837 | } |
1853 | } |
1838 | |
1854 | |
1839 | int |
1855 | bool |
1840 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1856 | rxvt_term::scr_changeview (int new_view_start) NOTHROW |
1841 | { |
1857 | { |
|
|
1858 | clamp_it (new_view_start, top_row, 0); |
|
|
1859 | |
1842 | if (view_start != oldviewstart) |
1860 | if (new_view_start == view_start) |
1843 | { |
1861 | return false; |
|
|
1862 | |
|
|
1863 | num_scr += new_view_start - view_start; |
|
|
1864 | view_start = new_view_start; |
|
|
1865 | want_refresh = 1; |
|
|
1866 | |
1844 | HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
1867 | HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
1845 | |
1868 | |
1846 | want_refresh = 1; |
1869 | return true; |
1847 | num_scr -= (view_start - oldviewstart); |
|
|
1848 | } |
|
|
1849 | |
|
|
1850 | return (int)view_start - (int)oldviewstart; |
|
|
1851 | } |
1870 | } |
1852 | |
1871 | |
1853 | /* ------------------------------------------------------------------------- */ |
1872 | #ifndef NO_BELL |
1854 | void |
1873 | void |
|
|
1874 | rxvt_term::bell_cb (ev::timer &w, int revents) |
|
|
1875 | { |
|
|
1876 | rvideo_bell = false; |
|
|
1877 | scr_rvideo_mode (rvideo_mode); |
|
|
1878 | refresh_check (); |
|
|
1879 | } |
|
|
1880 | #endif |
|
|
1881 | |
|
|
1882 | /* ------------------------------------------------------------------------- */ |
|
|
1883 | void |
1855 | rxvt_term::scr_bell () |
1884 | rxvt_term::scr_bell () NOTHROW |
1856 | { |
1885 | { |
1857 | #ifndef NO_BELL |
1886 | #ifndef NO_BELL |
1858 | |
1887 | |
1859 | # ifndef NO_MAPALERT |
1888 | # ifndef NO_MAPALERT |
1860 | # ifdef MAPALERT_OPTION |
1889 | # ifdef MAPALERT_OPTION |
1861 | if (OPTION (Opt_mapAlert)) |
1890 | if (option (Opt_mapAlert)) |
1862 | # endif |
1891 | # endif |
1863 | XMapWindow (display->display, parent[0]); |
1892 | XMapWindow (dpy, parent[0]); |
1864 | # endif |
1893 | # endif |
1865 | |
1894 | |
1866 | if (OPTION (Opt_visualBell)) |
1895 | # if ENABLE_FRILLS |
|
|
1896 | if (option (Opt_urgentOnBell)) |
|
|
1897 | { |
|
|
1898 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1899 | { |
|
|
1900 | h->flags |= XUrgencyHint; |
|
|
1901 | XSetWMHints (dpy, parent[0], h); |
|
|
1902 | } |
1867 | { |
1903 | } |
1868 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1904 | # endif |
|
|
1905 | |
|
|
1906 | if (option (Opt_visualBell)) |
|
|
1907 | { |
|
|
1908 | rvideo_bell = true; |
|
|
1909 | scr_rvideo_mode (rvideo_mode); |
|
|
1910 | flush (); |
|
|
1911 | |
1869 | rxvt_usleep (VISUAL_BELL_DURATION); |
1912 | bell_ev.start (VISUAL_BELL_DURATION); |
1870 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
|
|
1871 | } |
1913 | } |
1872 | else |
1914 | else |
1873 | XBell (display->display, 0); |
1915 | XBell (dpy, 0); |
1874 | |
|
|
1875 | #endif |
1916 | #endif |
1876 | } |
1917 | } |
1877 | |
1918 | |
1878 | /* ------------------------------------------------------------------------- */ |
1919 | /* ------------------------------------------------------------------------- */ |
1879 | /* ARGSUSED */ |
1920 | /* ARGSUSED */ |
1880 | void |
1921 | void |
1881 | rxvt_term::scr_printscreen (int fullhist) |
1922 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1882 | { |
1923 | { |
1883 | #ifdef PRINTPIPE |
1924 | #ifdef PRINTPIPE |
1884 | int nrows, row_start; |
1925 | int nrows, row_start; |
1885 | FILE *fd; |
1926 | FILE *fd = popen_printer (); |
1886 | |
1927 | |
1887 | if ((fd = popen_printer ()) == NULL) |
1928 | if (!fd) |
1888 | return; |
1929 | return; |
1889 | |
1930 | |
1890 | if (fullhist) |
1931 | if (fullhist) |
1891 | { |
1932 | { |
1892 | nrows = nrow + nsaved; |
1933 | nrows = nrow - top_row; |
1893 | row_start = -nsaved; |
1934 | row_start = top_row; |
1894 | } |
1935 | } |
1895 | else |
1936 | else |
1896 | { |
1937 | { |
1897 | nrows = nrow; |
1938 | nrows = nrow; |
1898 | row_start = -view_start; |
1939 | row_start = view_start; |
1899 | } |
1940 | } |
1900 | |
1941 | |
1901 | wctomb (0, 0); |
1942 | wctomb (0, 0); |
1902 | |
1943 | |
1903 | for (int r1 = 0; r1 < nrows; r1++) |
1944 | for (int r1 = 0; r1 < nrows; r1++) |
… | |
… | |
1935 | * Refresh the screen |
1976 | * Refresh the screen |
1936 | * drawn_text/drawn_rend contain the screen information before the update. |
1977 | * drawn_text/drawn_rend contain the screen information before the update. |
1937 | * screen.text/screen.rend contain what the screen will change to. |
1978 | * screen.text/screen.rend contain what the screen will change to. |
1938 | */ |
1979 | */ |
1939 | void |
1980 | void |
1940 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1981 | rxvt_term::scr_refresh () NOTHROW |
1941 | { |
1982 | { |
1942 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1983 | unsigned char have_bg, |
1943 | showcursor; /* show the cursor */ |
1984 | showcursor; /* show the cursor */ |
1944 | int16_t col, row, /* column/row we're processing */ |
1985 | int16_t col, row, /* column/row we're processing */ |
1945 | ocrow; /* old cursor row */ |
1986 | ocrow; /* old cursor row */ |
1946 | int i; /* tmp */ |
1987 | int i; /* tmp */ |
1947 | #ifndef NO_CURSORCOLOR |
1988 | #ifndef NO_CURSORCOLOR |
1948 | rend_t cc1; /* store colours at cursor position (s) */ |
1989 | rend_t cc1; /* store colours at cursor position (s) */ |
1949 | #endif |
1990 | #endif |
1950 | rend_t *crp; // cursor rendition pointer |
1991 | rend_t *crp; // cursor rendition pointer |
|
|
1992 | rend_t ccol1, /* Cursor colour */ |
|
|
1993 | ccol2; /* Cursor colour2 */ |
1951 | |
1994 | |
1952 | want_refresh = 0; /* screen is current */ |
1995 | want_refresh = 0; /* screen is current */ |
1953 | |
1996 | |
1954 | if (refresh_type == NO_REFRESH || !mapped) |
1997 | if (refresh_type == NO_REFRESH || !mapped) |
1955 | return; |
1998 | return; |
1956 | |
1999 | |
1957 | /* |
2000 | /* |
1958 | * A: set up vars |
2001 | * A: set up vars |
1959 | */ |
2002 | */ |
1960 | must_clear = 0; |
|
|
1961 | refresh_count = 0; |
2003 | refresh_count = 0; |
1962 | |
2004 | |
1963 | #if XPM_BACKGROUND |
2005 | have_bg = 0; |
|
|
2006 | #ifdef HAVE_BG_PIXMAP |
1964 | must_clear |= bgPixmap.pixmap != None; |
2007 | have_bg = bgPixmap.pixmap != None; |
1965 | #endif |
|
|
1966 | #if TRANSPARENT |
|
|
1967 | must_clear |= OPTION (Opt_transparent) && am_transparent; |
|
|
1968 | #endif |
2008 | #endif |
1969 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2009 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1970 | |
2010 | |
1971 | /* |
2011 | /* |
1972 | * B: reverse any characters which are selected |
2012 | * B: reverse any characters which are selected |
… | |
… | |
1976 | /* |
2016 | /* |
1977 | * C: set the cursor character (s) |
2017 | * C: set the cursor character (s) |
1978 | */ |
2018 | */ |
1979 | { |
2019 | { |
1980 | unsigned char setoldcursor; |
2020 | unsigned char setoldcursor; |
1981 | rend_t ccol1, /* Cursor colour */ |
|
|
1982 | ccol2; /* Cursor colour2 */ |
|
|
1983 | |
2021 | |
1984 | showcursor = (screen.flags & Screen_VisibleCursor); |
2022 | showcursor = (screen.flags & Screen_VisibleCursor); |
1985 | #ifdef CURSOR_BLINK |
2023 | #ifdef CURSOR_BLINK |
1986 | if (hidden_cursor) |
2024 | if (hidden_cursor) |
1987 | showcursor = 0; |
2025 | showcursor = 0; |
… | |
… | |
1994 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2032 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
1995 | col--; |
2033 | col--; |
1996 | |
2034 | |
1997 | crp = &ROW(screen.cur.row).r[col]; |
2035 | crp = &ROW(screen.cur.row).r[col]; |
1998 | |
2036 | |
|
|
2037 | #ifndef NO_CURSORCOLOR |
|
|
2038 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
|
|
2039 | if (ISSET_PIXCOLOR (Color_cursor)) |
|
|
2040 | ccol1 = Color_cursor; |
|
|
2041 | else |
|
|
2042 | #endif |
|
|
2043 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2044 | ccol1 = fgcolor_of (rstyle); |
|
|
2045 | #else |
|
|
2046 | ccol1 = Color_fg; |
|
|
2047 | #endif |
|
|
2048 | |
|
|
2049 | #ifndef NO_CURSORCOLOR |
|
|
2050 | if (ISSET_PIXCOLOR (Color_cursor2)) |
|
|
2051 | ccol2 = Color_cursor2; |
|
|
2052 | else |
|
|
2053 | #endif |
|
|
2054 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2055 | ccol2 = bgcolor_of (rstyle); |
|
|
2056 | #else |
|
|
2057 | ccol2 = Color_bg; |
|
|
2058 | #endif |
|
|
2059 | |
1999 | if (showcursor && focus) |
2060 | if (showcursor && focus) |
2000 | { |
2061 | { |
2001 | if (OPTION (Opt_cursorUnderline)) |
2062 | if (option (Opt_cursorUnderline)) |
2002 | *crp ^= RS_Uline; |
2063 | *crp ^= RS_Uline; |
2003 | else |
2064 | else |
2004 | { |
2065 | { |
2005 | *crp ^= RS_RVid; |
2066 | *crp ^= RS_RVid; |
2006 | |
|
|
2007 | #ifndef NO_CURSORCOLOR |
|
|
2008 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
|
|
2009 | if (ISSET_PIXCOLOR (Color_cursor)) |
|
|
2010 | ccol1 = Color_cursor; |
|
|
2011 | else |
|
|
2012 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2013 | ccol1 = fgcolor_of (rstyle); |
|
|
2014 | #else |
|
|
2015 | ccol1 = Color_fg; |
|
|
2016 | #endif |
|
|
2017 | if (ISSET_PIXCOLOR (Color_cursor2)) |
|
|
2018 | ccol2 = Color_cursor2; |
|
|
2019 | else |
|
|
2020 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2021 | ccol2 = bgcolor_of (rstyle); |
|
|
2022 | #else |
|
|
2023 | ccol2 = Color_bg; |
|
|
2024 | #endif |
|
|
2025 | *crp = SET_FGCOLOR (*crp, ccol1); |
2067 | *crp = SET_FGCOLOR (*crp, ccol1); |
2026 | *crp = SET_BGCOLOR (*crp, ccol2); |
2068 | *crp = SET_BGCOLOR (*crp, ccol2); |
2027 | #endif |
|
|
2028 | } |
2069 | } |
2029 | } |
2070 | } |
2030 | } |
2071 | } |
2031 | |
2072 | |
2032 | /* make sure no outline cursor is left around */ |
2073 | /* make sure no outline cursor is left around */ |
2033 | setoldcursor = 0; |
2074 | setoldcursor = 0; |
2034 | if (ocrow != -1) |
2075 | if (ocrow != -1) |
2035 | { |
2076 | { |
2036 | if (screen.cur.row + view_start != ocrow |
2077 | if (screen.cur.row - view_start != ocrow |
2037 | || screen.cur.col != oldcursor.col) |
2078 | || screen.cur.col != oldcursor.col) |
2038 | { |
2079 | { |
2039 | if (ocrow < nrow |
2080 | if (ocrow < nrow |
2040 | && oldcursor.col < ncol) |
2081 | && oldcursor.col < ncol) |
2041 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2082 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
… | |
… | |
2049 | else if (!focus) |
2090 | else if (!focus) |
2050 | setoldcursor = 1; |
2091 | setoldcursor = 1; |
2051 | |
2092 | |
2052 | if (setoldcursor) |
2093 | if (setoldcursor) |
2053 | { |
2094 | { |
2054 | if (screen.cur.row + view_start >= nrow) |
2095 | if (screen.cur.row - view_start >= nrow) |
2055 | oldcursor.row = -1; |
2096 | oldcursor.row = -1; |
2056 | else |
2097 | else |
2057 | { |
2098 | { |
2058 | oldcursor.row = screen.cur.row + view_start; |
2099 | oldcursor.row = screen.cur.row - view_start; |
2059 | oldcursor.col = screen.cur.col; |
2100 | oldcursor.col = screen.cur.col; |
2060 | } |
2101 | } |
2061 | } |
2102 | } |
2062 | } |
2103 | } |
2063 | |
2104 | |
… | |
… | |
2069 | #ifndef NO_SLOW_LINK_SUPPORT |
2110 | #ifndef NO_SLOW_LINK_SUPPORT |
2070 | /* |
2111 | /* |
2071 | * D: CopyArea pass - very useful for slower links |
2112 | * D: CopyArea pass - very useful for slower links |
2072 | * This has been deliberately kept simple. |
2113 | * This has been deliberately kept simple. |
2073 | */ |
2114 | */ |
2074 | i = num_scr; |
|
|
2075 | if (!display->is_local |
2115 | if (!display->is_local |
2076 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2116 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2077 | && abs (num_scr) < nrow && !must_clear) |
2117 | && abs (num_scr) < nrow && !have_bg) |
2078 | { |
2118 | { |
2079 | int16_t nits; |
2119 | int16_t nits; |
|
|
2120 | int i = num_scr; |
2080 | int j; |
2121 | int j; |
2081 | int len, wlen; |
2122 | int len, wlen; |
|
|
2123 | dLocal (int, num_scr); |
2082 | |
2124 | |
2083 | j = nrow; |
2125 | j = nrow; |
2084 | wlen = len = -1; |
2126 | wlen = len = -1; |
2085 | row = i > 0 ? 0 : j - 1; |
2127 | row = i > 0 ? 0 : j - 1; |
|
|
2128 | |
2086 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2129 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2087 | { |
2130 | { |
2088 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2131 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2089 | { |
2132 | { |
2090 | line_t s = ROW(row - view_start); |
2133 | line_t s = ROW(view_start + row); |
2091 | line_t d = drawn_buf[row]; |
2134 | line_t d = drawn_buf[row]; |
2092 | line_t d2 = drawn_buf[row + i]; |
2135 | line_t d2 = drawn_buf[row + i]; |
2093 | |
2136 | |
2094 | for (nits = 0, col = ncol; col--; ) |
2137 | for (nits = 0, col = ncol; col--; ) |
2095 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2138 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
… | |
… | |
2111 | wlen = row; |
2154 | wlen = row; |
2112 | continue; |
2155 | continue; |
2113 | } |
2156 | } |
2114 | } |
2157 | } |
2115 | |
2158 | |
2116 | if (len != -1) |
2159 | if (len >= 0) |
2117 | { |
2160 | { |
2118 | /* also comes here at end if needed because of >= above */ |
2161 | /* also comes here at end if needed because of >= above */ |
2119 | if (wlen < len) |
2162 | if (wlen < len) |
2120 | ::swap (wlen, len); |
2163 | ::swap (wlen, len); |
2121 | |
2164 | |
|
|
2165 | XGCValues gcv; |
|
|
2166 | |
|
|
2167 | gcv.graphics_exposures = 1; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); |
2122 | XCopyArea (display->display, vt, vt, |
2168 | XCopyArea (dpy, vt, vt, |
2123 | gc, 0, Row2Pixel (len + i), |
2169 | gc, 0, Row2Pixel (len + i), |
2124 | (unsigned int)this->width, |
2170 | (unsigned int)this->width, |
2125 | (unsigned int)Height2Pixel (wlen - len + 1), |
2171 | (unsigned int)Height2Pixel (wlen - len + 1), |
2126 | 0, Row2Pixel (len)); |
2172 | 0, Row2Pixel (len)); |
|
|
2173 | gcv.graphics_exposures = 0; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); |
|
|
2174 | |
2127 | len = -1; |
2175 | len = -1; |
2128 | } |
2176 | } |
2129 | } |
2177 | } |
2130 | } |
2178 | } |
2131 | #endif |
2179 | #endif |
… | |
… | |
2133 | /* |
2181 | /* |
2134 | * E: main pass across every character |
2182 | * E: main pass across every character |
2135 | */ |
2183 | */ |
2136 | for (row = 0; row < nrow; row++) |
2184 | for (row = 0; row < nrow; row++) |
2137 | { |
2185 | { |
2138 | text_t *stp = ROW(row - view_start).t; |
2186 | text_t *stp = ROW(view_start + row).t; |
2139 | rend_t *srp = ROW(row - view_start).r; |
2187 | rend_t *srp = ROW(view_start + row).r; |
2140 | text_t *dtp = drawn_buf[row].t; |
2188 | text_t *dtp = drawn_buf[row].t; |
2141 | rend_t *drp = drawn_buf[row].r; |
2189 | rend_t *drp = drawn_buf[row].r; |
2142 | |
2190 | |
2143 | /* |
2191 | /* |
2144 | * E2: OK, now the real pass |
2192 | * E2: OK, now the real pass |
… | |
… | |
2187 | count++; |
2235 | count++; |
2188 | |
2236 | |
2189 | if (stp[col] != dtp[col] |
2237 | if (stp[col] != dtp[col] |
2190 | || !RS_SAME (srp[col], drp[col])) |
2238 | || !RS_SAME (srp[col], drp[col])) |
2191 | { |
2239 | { |
2192 | if (must_clear && (i++ > count / 2)) |
2240 | if (have_bg && (i++ > count / 2)) |
2193 | break; |
2241 | break; |
2194 | |
2242 | |
2195 | dtp[col] = stp[col]; |
2243 | dtp[col] = stp[col]; |
2196 | drp[col] = rend; |
2244 | drp[col] = rend; |
2197 | i = 0; |
2245 | i = 0; |
2198 | } |
2246 | } |
2199 | else if (must_clear || (stp[col] != ' ' && ++i >= 16)) |
2247 | else if (have_bg || (stp[col] != ' ' && ++i >= 16)) |
2200 | break; |
2248 | break; |
2201 | } |
2249 | } |
2202 | |
2250 | |
2203 | col--; /* went one too far. move back */ |
2251 | col--; /* went one too far. move back */ |
2204 | count -= i; /* dump any matching trailing chars */ |
2252 | count -= i; /* dump any matching trailing chars */ |
… | |
… | |
2214 | int back = bgcolor_of (rend); // desired background |
2262 | int back = bgcolor_of (rend); // desired background |
2215 | |
2263 | |
2216 | // only do special processing if any attributes are set, which is unlikely |
2264 | // only do special processing if any attributes are set, which is unlikely |
2217 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2265 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2218 | { |
2266 | { |
2219 | #if ENABLE_STYLES |
|
|
2220 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2221 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
|
|
2222 | drp[col + 1] = ~srp[col + 1]; |
|
|
2223 | |
|
|
2224 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2225 | while (text > stp |
|
|
2226 | && srp[text - stp - 1] & RS_Careful |
|
|
2227 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2228 | text--, count++, xpixel -= fwidth; |
|
|
2229 | #endif |
|
|
2230 | |
|
|
2231 | bool invert = rend & RS_RVid; |
2267 | bool invert = rend & RS_RVid; |
2232 | |
2268 | |
2233 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2269 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2234 | if (rend & RS_Bold |
|
|
2235 | && fore == Color_fg) |
2270 | if (rend & RS_Bold && fore == Color_fg) |
2236 | { |
2271 | { |
2237 | if (ISSET_PIXCOLOR (Color_BD)) |
2272 | if (ISSET_PIXCOLOR (Color_BD)) |
2238 | fore = Color_BD; |
2273 | fore = Color_BD; |
2239 | # if !ENABLE_STYLES |
2274 | # if !ENABLE_STYLES |
2240 | else |
2275 | else |
2241 | invert = !invert; |
2276 | invert = !invert; |
2242 | # endif |
2277 | # endif |
2243 | } |
2278 | } |
2244 | |
2279 | |
2245 | if (rend & RS_Italic |
2280 | if (rend & RS_Italic && fore == Color_fg) |
2246 | && fore == Color_fg) |
|
|
2247 | { |
2281 | { |
2248 | if (ISSET_PIXCOLOR (Color_IT)) |
2282 | if (ISSET_PIXCOLOR (Color_IT)) |
2249 | fore = Color_IT; |
2283 | fore = Color_IT; |
2250 | # if !ENABLE_STYLES |
2284 | # if !ENABLE_STYLES |
2251 | else |
2285 | else |
2252 | invert = !invert; |
2286 | invert = !invert; |
2253 | # endif |
2287 | # endif |
2254 | } |
2288 | } |
2255 | |
2289 | |
2256 | if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) |
2290 | if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL)) |
2257 | fore = Color_UL; |
2291 | fore = Color_UL; |
2258 | #endif |
2292 | #endif |
2259 | |
2293 | |
2260 | if (invert) |
2294 | if (invert) |
2261 | { |
2295 | { |
|
|
2296 | #ifdef OPTION_HC |
|
|
2297 | if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col) |
|
|
2298 | || !ISSET_PIXCOLOR (Color_HC)) |
|
|
2299 | #endif |
|
|
2300 | /* invert the column if no highlightColor is set or it is the |
|
|
2301 | * current cursor column */ |
2262 | ::swap (fore, back); |
2302 | ::swap (fore, back); |
|
|
2303 | #ifdef OPTION_HC |
|
|
2304 | else if (ISSET_PIXCOLOR (Color_HC)) |
|
|
2305 | back = Color_HC; |
|
|
2306 | #endif |
2263 | |
2307 | |
2264 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2308 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2309 | # ifndef OPTION_HC |
2265 | if (ISSET_PIXCOLOR (Color_RV)) |
2310 | if (ISSET_PIXCOLOR (Color_RV)) |
2266 | back = Color_RV; |
2311 | back = Color_RV; |
2267 | |
2312 | # endif |
2268 | if (fore == back) |
2313 | if (fore == back) |
2269 | { |
2314 | { |
2270 | fore = Color_bg; |
2315 | fore = Color_bg; |
2271 | back = Color_fg; |
2316 | back = Color_fg; |
2272 | } |
2317 | } |
… | |
… | |
2274 | } |
2319 | } |
2275 | |
2320 | |
2276 | #ifdef TEXT_BLINK |
2321 | #ifdef TEXT_BLINK |
2277 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
2322 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
2278 | { |
2323 | { |
2279 | if (!text_blink_ev.active) |
2324 | if (!text_blink_ev.is_active ()) |
2280 | { |
2325 | { |
2281 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
2326 | text_blink_ev.again (); |
2282 | hidden_text = 0; |
2327 | hidden_text = 0; |
2283 | } |
2328 | } |
2284 | else if (hidden_text) |
2329 | else if (hidden_text) |
2285 | fore = back; |
2330 | fore = back; |
2286 | } |
2331 | } |
2287 | #endif |
2332 | #endif |
|
|
2333 | |
|
|
2334 | #if ENABLE_STYLES |
|
|
2335 | // "careful" (too wide) character handling |
|
|
2336 | |
|
|
2337 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2338 | while (text > stp |
|
|
2339 | && srp[text - stp - 1] & RS_Careful |
|
|
2340 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2341 | text--, count++, xpixel -= fwidth; |
|
|
2342 | |
|
|
2343 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2344 | for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) |
|
|
2345 | drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; |
|
|
2346 | |
|
|
2347 | // force redraw before "careful" characters to avoid pixel droppings |
|
|
2348 | for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) |
|
|
2349 | drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; |
|
|
2350 | #endif |
2288 | } |
2351 | } |
2289 | |
2352 | |
2290 | /* |
2353 | /* |
2291 | * Actually do the drawing of the string here |
2354 | * Actually do the drawing of the string here |
2292 | */ |
2355 | */ |
2293 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2356 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2294 | |
2357 | |
2295 | if (back == fore) |
|
|
2296 | font->clear_rect (*drawable, xpixel, ypixel, |
|
|
2297 | fwidth * count, fheight, |
|
|
2298 | back); |
|
|
2299 | else if (back == Color_bg) |
2358 | if (have_bg && back == Color_bg) |
2300 | { |
2359 | { |
2301 | if (must_clear) |
2360 | // this is very ugly, maybe push it into ->draw? |
2302 | { |
|
|
2303 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2304 | |
2361 | |
2305 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2362 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2306 | if (text[i] != ' ') |
2363 | if (text[i] != ' ') |
2307 | { |
2364 | { |
2308 | font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); |
2365 | font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_transparent); |
2309 | break; |
2366 | goto did_clear; |
2310 | } |
|
|
2311 | } |
2367 | } |
2312 | else |
2368 | |
2313 | font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); |
2369 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2370 | did_clear: ; |
2314 | } |
2371 | } |
2315 | else |
2372 | else |
2316 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2373 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2317 | |
2374 | |
2318 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2375 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2319 | { |
2376 | { |
2320 | #if ENABLE_FRILLS |
2377 | #if ENABLE_FRILLS |
2321 | if (ISSET_PIXCOLOR (Color_underline)) |
2378 | if (ISSET_PIXCOLOR (Color_underline)) |
2322 | XSetForeground (display->display, gc, pix_colors[Color_underline]); |
2379 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2323 | else |
2380 | else |
2324 | #endif |
2381 | #endif |
2325 | XSetForeground (display->display, gc, pix_colors[fore]); |
2382 | XSetForeground (dpy, gc, pix_colors[fore]); |
2326 | |
2383 | |
2327 | XDrawLine (display->display, drawBuffer, gc, |
2384 | XDrawLine (dpy, vt, gc, |
2328 | xpixel, ypixel + font->ascent + 1, |
2385 | xpixel, ypixel + font->ascent + 1, |
2329 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2386 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2330 | } |
2387 | } |
2331 | } /* for (col....) */ |
2388 | } /* for (col....) */ |
2332 | } /* for (row....) */ |
2389 | } /* for (row....) */ |
… | |
… | |
2341 | */ |
2398 | */ |
2342 | if (showcursor) |
2399 | if (showcursor) |
2343 | { |
2400 | { |
2344 | if (focus) |
2401 | if (focus) |
2345 | { |
2402 | { |
2346 | if (OPTION (Opt_cursorUnderline)) |
2403 | if (option (Opt_cursorUnderline)) |
2347 | *crp ^= RS_Uline; |
2404 | *crp ^= RS_Uline; |
2348 | else |
2405 | else |
2349 | { |
2406 | { |
2350 | *crp ^= RS_RVid; |
2407 | *crp ^= RS_RVid; |
2351 | #ifndef NO_CURSORCOLOR |
2408 | #ifndef NO_CURSORCOLOR |
… | |
… | |
2365 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2422 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2366 | cursorwidth++; |
2423 | cursorwidth++; |
2367 | |
2424 | |
2368 | #ifndef NO_CURSORCOLOR |
2425 | #ifndef NO_CURSORCOLOR |
2369 | if (ISSET_PIXCOLOR (Color_cursor)) |
2426 | if (ISSET_PIXCOLOR (Color_cursor)) |
2370 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
2427 | XSetForeground (dpy, gc, pix_colors[Color_cursor]); |
|
|
2428 | else |
2371 | #endif |
2429 | #endif |
|
|
2430 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2372 | |
2431 | |
2373 | XDrawRectangle (display->display, drawBuffer, gc, |
2432 | XDrawRectangle (dpy, vt, gc, |
2374 | Col2Pixel (col), |
2433 | Col2Pixel (col), |
2375 | Row2Pixel (oldcursor.row), |
2434 | Row2Pixel (oldcursor.row), |
2376 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2435 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2377 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2436 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2378 | } |
2437 | } |
… | |
… | |
2381 | /* |
2440 | /* |
2382 | * H: cleanup selection |
2441 | * H: cleanup selection |
2383 | */ |
2442 | */ |
2384 | scr_reverse_selection (); |
2443 | scr_reverse_selection (); |
2385 | |
2444 | |
2386 | if (refresh_type & SMOOTH_REFRESH) |
|
|
2387 | XFlush (display->display); |
|
|
2388 | |
|
|
2389 | num_scr = 0; |
2445 | num_scr = 0; |
2390 | num_scr_allow = 1; |
2446 | num_scr_allow = 1; |
2391 | } |
2447 | } |
2392 | |
2448 | |
2393 | void |
2449 | void |
2394 | rxvt_term::scr_remap_chars (line_t &l) |
2450 | rxvt_term::scr_remap_chars (line_t &l) NOTHROW |
2395 | { |
2451 | { |
2396 | if (!l.t) |
2452 | if (!l.t) |
2397 | return; |
2453 | return; |
2398 | |
2454 | |
2399 | l.touch (); // maybe a bit of an overkill, but it's not performance-relevant |
2455 | l.touch (); // maybe a bit of an overkill, but it's not performance-relevant |
… | |
… | |
2401 | for (int i = ncol; i--; ) |
2457 | for (int i = ncol; i--; ) |
2402 | l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); |
2458 | l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); |
2403 | } |
2459 | } |
2404 | |
2460 | |
2405 | void |
2461 | void |
2406 | rxvt_term::scr_remap_chars () |
2462 | rxvt_term::scr_remap_chars () NOTHROW |
2407 | { |
2463 | { |
2408 | for (int i = total_rows; i--; ) |
2464 | for (int i = total_rows; i--; ) |
2409 | scr_remap_chars (row_buf [i]); |
2465 | scr_remap_chars (row_buf [i]); |
2410 | |
2466 | |
2411 | for (int i = nrow; i--; ) |
2467 | for (int i = nrow; i--; ) |
… | |
… | |
2414 | scr_remap_chars (swap_buf [i]); |
2470 | scr_remap_chars (swap_buf [i]); |
2415 | } |
2471 | } |
2416 | } |
2472 | } |
2417 | |
2473 | |
2418 | void |
2474 | void |
2419 | rxvt_term::scr_recolour () |
2475 | rxvt_term::scr_recolour () NOTHROW |
2420 | { |
2476 | { |
2421 | if (1 |
2477 | #ifdef HAVE_BG_PIXMAP |
2422 | #if TRANSPARENT |
2478 | bgPixmap.apply (); |
2423 | && !am_transparent |
2479 | #else |
2424 | #endif |
2480 | |
2425 | #if XPM_BACKGROUND |
|
|
2426 | && !bgPixmap.pixmap |
|
|
2427 | #endif |
|
|
2428 | ) |
|
|
2429 | { |
|
|
2430 | XSetWindowBackground (display->display, parent[0], pix_colors[Color_border]); |
2481 | XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); |
2431 | XClearWindow (display->display, parent[0]); |
2482 | XClearWindow (dpy, parent[0]); |
2432 | XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); |
2483 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2433 | #if HAVE_SCROLLBARS |
2484 | |
2434 | if (scrollBar.win) |
2485 | if (scrollBar.win) |
2435 | { |
2486 | { |
2436 | XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); |
2487 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2437 | scrollBar.setIdle (); |
2488 | scrollBar.state = STATE_IDLE; |
2438 | scrollbar_show (0); |
2489 | scrollBar.show (0); |
2439 | } |
|
|
2440 | #endif |
|
|
2441 | } |
2490 | } |
2442 | |
2491 | |
|
|
2492 | #endif |
|
|
2493 | |
|
|
2494 | /* bgPixmap.apply () does not do the following : */ |
2443 | scr_clear (); |
2495 | scr_clear (); |
2444 | scr_touch (true); |
2496 | scr_touch (true); |
2445 | want_refresh = 1; |
2497 | want_refresh = 1; |
2446 | } |
2498 | } |
2447 | |
2499 | |
2448 | /* ------------------------------------------------------------------------- */ |
2500 | /* ------------------------------------------------------------------------- */ |
2449 | void |
2501 | void |
2450 | rxvt_term::scr_clear (bool really) |
2502 | rxvt_term::scr_clear (bool really) NOTHROW |
2451 | { |
2503 | { |
2452 | if (!mapped) |
2504 | if (!mapped) |
2453 | return; |
2505 | return; |
2454 | |
2506 | |
2455 | num_scr_allow = 0; |
2507 | num_scr_allow = 0; |
2456 | want_refresh = 1; |
2508 | want_refresh = 1; |
2457 | |
2509 | |
2458 | if (really) |
2510 | if (really) |
2459 | XClearWindow (display->display, vt); |
2511 | XClearWindow (dpy, vt); |
2460 | } |
2512 | } |
2461 | |
2513 | |
2462 | /* ------------------------------------------------------------------------- */ |
|
|
2463 | void |
2514 | void |
|
|
2515 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW |
|
|
2516 | { |
|
|
2517 | int view_end = view_start + nrow; |
|
|
2518 | int row, col; |
|
|
2519 | |
|
|
2520 | for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++) |
|
|
2521 | { |
|
|
2522 | text_t *stp = ROW(row).t; |
|
|
2523 | rend_t *srp = ROW(row).r; |
|
|
2524 | |
|
|
2525 | for (col = beg_col; col < end_col; col++) |
|
|
2526 | srp[col] ^= rstyle1; |
|
|
2527 | |
|
|
2528 | while (col-- > beg_col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) |
|
|
2529 | srp[col] ^= rstyle2; |
|
|
2530 | |
|
|
2531 | if (++col < end_col) |
|
|
2532 | srp[col] ^= rstyle2; |
|
|
2533 | } |
|
|
2534 | } |
|
|
2535 | |
|
|
2536 | void |
|
|
2537 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) NOTHROW |
|
|
2538 | { |
|
|
2539 | int view_end = view_start + nrow; |
|
|
2540 | int row, col; |
|
|
2541 | |
|
|
2542 | if (beg_row >= view_start) |
|
|
2543 | { |
|
|
2544 | col = beg_col; |
|
|
2545 | row = beg_row; |
|
|
2546 | } |
|
|
2547 | else |
|
|
2548 | { |
|
|
2549 | col = 0; |
|
|
2550 | row = view_start; |
|
|
2551 | } |
|
|
2552 | |
|
|
2553 | for (; row < min (end_row, view_end); row++, col = 0) |
|
|
2554 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
|
|
2555 | srp[col] ^= rstyle; |
|
|
2556 | |
|
|
2557 | if (row == end_row) |
|
|
2558 | for (rend_t *srp = ROW(row).r; col < end_col; col++) |
|
|
2559 | srp[col] ^= rstyle; |
|
|
2560 | } |
|
|
2561 | |
|
|
2562 | /* ------------------------------------------------------------------------- */ |
|
|
2563 | void |
2464 | rxvt_term::scr_reverse_selection () |
2564 | rxvt_term::scr_reverse_selection () NOTHROW |
2465 | { |
2565 | { |
2466 | if (selection.op |
2566 | if (selection.op |
2467 | && current_screen == selection.screen |
2567 | && current_screen == selection.screen |
2468 | && selection.end.row >= -view_start) |
2568 | && selection.end.row >= view_start) |
2469 | { |
2569 | { |
2470 | int view_end = -view_start + nrow; |
2570 | #if !ENABLE_MINIMAL |
2471 | int row, col; |
|
|
2472 | |
|
|
2473 | #if ENABLE_FRILLS |
|
|
2474 | if (selection.rect) |
2571 | if (selection.rect) |
2475 | { |
2572 | scr_xor_rect (selection.beg.row, selection.beg.col, |
2476 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
2573 | selection.end.row, selection.end.col, |
2477 | { |
2574 | RS_RVid, RS_RVid | RS_Uline); |
2478 | text_t *stp = ROW(row).t; |
|
|
2479 | rend_t *srp = ROW(row).r; |
|
|
2480 | |
|
|
2481 | for (col = selection.beg.col; col < selection.end.col; col++) |
|
|
2482 | srp[col] ^= RS_RVid; |
|
|
2483 | |
|
|
2484 | while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) |
|
|
2485 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2486 | |
|
|
2487 | if (++col < selection.end.col) |
|
|
2488 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2489 | } |
|
|
2490 | } |
|
|
2491 | else |
2575 | else |
2492 | #endif |
2576 | #endif |
2493 | { |
2577 | scr_xor_span (selection.beg.row, selection.beg.col, |
2494 | if (selection.beg.row >= -view_start) |
2578 | selection.end.row, selection.end.col, |
2495 | { |
2579 | RS_RVid); |
2496 | col = selection.beg.col; |
|
|
2497 | row = selection.beg.row; |
|
|
2498 | } |
|
|
2499 | else |
|
|
2500 | { |
|
|
2501 | col = 0; |
|
|
2502 | row = -view_start; |
|
|
2503 | } |
|
|
2504 | |
|
|
2505 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
|
|
2506 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
|
|
2507 | srp[col] ^= RS_RVid; |
|
|
2508 | |
|
|
2509 | if (row == selection.end.row) |
|
|
2510 | for (rend_t *srp = ROW(row).r; col < selection.end.col; col++) |
|
|
2511 | srp[col] ^= RS_RVid; |
|
|
2512 | } |
|
|
2513 | } |
2580 | } |
2514 | } |
2581 | } |
2515 | |
2582 | |
2516 | /* ------------------------------------------------------------------------- */ |
2583 | /* ------------------------------------------------------------------------- */ |
2517 | /* |
2584 | /* |
2518 | * Dump the whole scrollback and screen to the passed filedescriptor. The |
2585 | * Dump the whole scrollback and screen to the passed filedescriptor. The |
2519 | * invoking routine must close the fd. |
2586 | * invoking routine must close the fd. |
2520 | */ |
2587 | */ |
2521 | #if 0 |
2588 | #if 0 |
2522 | void |
2589 | void |
2523 | rxvt_term::scr_dump (int fd) |
2590 | rxvt_term::scr_dump (int fd) NOTHROW |
2524 | { |
2591 | { |
2525 | int row, wrote; |
2592 | int row, wrote; |
2526 | unsigned int width, towrite; |
2593 | unsigned int width, towrite; |
2527 | char r1[] = "\n"; |
2594 | char r1[] = "\n"; |
2528 | |
2595 | |
2529 | for (row = saveLines - nsaved; |
2596 | for (row = saveLines + top_row; |
2530 | row < saveLines + nrow - 1; row++) |
2597 | row < saveLines + nrow - 1; row++) |
2531 | { |
2598 | { |
2532 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2599 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2533 | : ncol; |
2600 | : ncol; |
2534 | for (towrite = width; towrite; towrite -= wrote) |
2601 | for (towrite = width; towrite; towrite -= wrote) |
… | |
… | |
2547 | |
2614 | |
2548 | /* ------------------------------------------------------------------------- * |
2615 | /* ------------------------------------------------------------------------- * |
2549 | * CHARACTER SELECTION * |
2616 | * CHARACTER SELECTION * |
2550 | * ------------------------------------------------------------------------- */ |
2617 | * ------------------------------------------------------------------------- */ |
2551 | void |
2618 | void |
2552 | rxvt_term::selection_check (int check_more) |
2619 | rxvt_term::selection_check (int check_more) NOTHROW |
2553 | { |
2620 | { |
2554 | row_col_t pos; |
2621 | row_col_t pos; |
2555 | |
2622 | |
2556 | if (!selection.op) |
2623 | if (!selection.op) |
2557 | return; |
2624 | return; |
2558 | |
2625 | |
2559 | pos.row = pos.col = 0; |
2626 | pos.row = pos.col = 0; |
2560 | if (!IN_RANGE_EXC (selection.beg.row, -nsaved, nrow) |
2627 | if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) |
2561 | || !IN_RANGE_EXC (selection.mark.row, -nsaved, nrow) |
2628 | || !IN_RANGE_EXC (selection.mark.row, top_row, nrow) |
2562 | || !IN_RANGE_EXC (selection.end.row, -nsaved, nrow) |
2629 | || !IN_RANGE_EXC (selection.end.row, top_row, nrow) |
2563 | || (check_more == 1 |
2630 | || (check_more == 1 |
2564 | && current_screen == selection.screen |
2631 | && current_screen == selection.screen |
2565 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
2632 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
2566 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
2633 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
2567 | || (check_more == 2 |
2634 | || (check_more == 2 |
… | |
… | |
2578 | /* ------------------------------------------------------------------------- */ |
2645 | /* ------------------------------------------------------------------------- */ |
2579 | /* |
2646 | /* |
2580 | * Paste a selection direct to the command fd |
2647 | * Paste a selection direct to the command fd |
2581 | */ |
2648 | */ |
2582 | void |
2649 | void |
2583 | rxvt_term::paste (char *data, unsigned int len) |
2650 | rxvt_term::paste (char *data, unsigned int len) NOTHROW |
2584 | { |
2651 | { |
2585 | /* convert normal newline chars into common keyboard Return key sequence */ |
2652 | /* convert normal newline chars into common keyboard Return key sequence */ |
2586 | for (unsigned int i = 0; i < len; i++) |
2653 | for (unsigned int i = 0; i < len; i++) |
2587 | if (data[i] == C0_LF) |
2654 | if (data[i] == C0_LF) |
2588 | data[i] = C0_CR; |
2655 | data[i] = C0_CR; |
2589 | |
2656 | |
|
|
2657 | if (priv_modes & PrivMode_BracketPaste) |
|
|
2658 | tt_printf ("\e[200~"); |
|
|
2659 | |
2590 | tt_write (data, len); |
2660 | tt_write (data, len); |
|
|
2661 | |
|
|
2662 | if (priv_modes & PrivMode_BracketPaste) |
|
|
2663 | tt_printf ("\e[201~"); |
2591 | } |
2664 | } |
2592 | |
2665 | |
2593 | /* ------------------------------------------------------------------------- */ |
2666 | /* ------------------------------------------------------------------------- */ |
2594 | /* |
2667 | /* |
2595 | * Respond to a notification that a primary selection has been sent |
2668 | * Respond to a notification that a primary selection has been sent |
2596 | * EXT: SelectionNotify |
2669 | * EXT: SelectionNotify |
2597 | */ |
2670 | */ |
2598 | void |
2671 | void |
2599 | rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) |
2672 | rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) NOTHROW |
2600 | { |
2673 | { |
2601 | if (prop == None) /* check for failed XConvertSelection */ |
2674 | if (prop == None) /* check for failed XConvertSelection */ |
2602 | { |
2675 | { |
2603 | if ((selection_type & Sel_CompoundText)) |
2676 | if ((selection_type & Sel_CompoundText)) |
2604 | { |
2677 | { |
… | |
… | |
2624 | } |
2697 | } |
2625 | |
2698 | |
2626 | unsigned long bytes_after; |
2699 | unsigned long bytes_after; |
2627 | XTextProperty ct; |
2700 | XTextProperty ct; |
2628 | |
2701 | |
2629 | if (XGetWindowProperty (display->display, win, prop, |
2702 | if (XGetWindowProperty (dpy, win, prop, |
2630 | 0, PROP_SIZE / 4, |
2703 | 0, PROP_SIZE / 4, |
2631 | delete_prop, AnyPropertyType, |
2704 | delete_prop, AnyPropertyType, |
2632 | &ct.encoding, &ct.format, |
2705 | &ct.encoding, &ct.format, |
2633 | &ct.nitems, &bytes_after, |
2706 | &ct.nitems, &bytes_after, |
2634 | &ct.value) != Success) |
2707 | &ct.value) != Success) |
… | |
… | |
2643 | if (bytes_after) |
2716 | if (bytes_after) |
2644 | { |
2717 | { |
2645 | // fetch and append remaining data |
2718 | // fetch and append remaining data |
2646 | XTextProperty ct2; |
2719 | XTextProperty ct2; |
2647 | |
2720 | |
2648 | if (XGetWindowProperty (display->display, win, prop, |
2721 | if (XGetWindowProperty (dpy, win, prop, |
2649 | ct.nitems / 4, (bytes_after + 3) / 4, |
2722 | ct.nitems / 4, (bytes_after + 3) / 4, |
2650 | delete_prop, AnyPropertyType, |
2723 | delete_prop, AnyPropertyType, |
2651 | &ct2.encoding, &ct2.format, |
2724 | &ct2.encoding, &ct2.format, |
2652 | &ct2.nitems, &bytes_after, |
2725 | &ct2.nitems, &bytes_after, |
2653 | &ct2.value) != Success) |
2726 | &ct2.value) != Success) |
… | |
… | |
2666 | |
2739 | |
2667 | if (ct.encoding == xa[XA_INCR]) |
2740 | if (ct.encoding == xa[XA_INCR]) |
2668 | { |
2741 | { |
2669 | // INCR selection, start handshake |
2742 | // INCR selection, start handshake |
2670 | if (!delete_prop) |
2743 | if (!delete_prop) |
2671 | XDeleteProperty (display->display, win, prop); |
2744 | XDeleteProperty (dpy, win, prop); |
2672 | |
2745 | |
2673 | selection_wait = Sel_incr; |
2746 | selection_wait = Sel_incr; |
2674 | incr_buf_fill = 0; |
2747 | incr_buf_fill = 0; |
2675 | incr_ev.start (NOW + 10); |
2748 | incr_ev.start (10); |
2676 | |
2749 | |
2677 | goto bailout; |
2750 | goto bailout; |
2678 | } |
2751 | } |
2679 | |
2752 | |
2680 | if (ct.nitems == 0) |
2753 | if (ct.nitems == 0) |
… | |
… | |
2689 | ct.nitems = incr_buf_fill; |
2762 | ct.nitems = incr_buf_fill; |
2690 | incr_buf = 0; |
2763 | incr_buf = 0; |
2691 | incr_buf_size = 0; |
2764 | incr_buf_size = 0; |
2692 | incr_ev.stop (); |
2765 | incr_ev.stop (); |
2693 | } |
2766 | } |
2694 | else |
2767 | else |
2695 | { |
2768 | { |
2696 | if (selection_wait == Sel_normal |
2769 | if (selection_wait == Sel_normal |
2697 | && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion |
2770 | && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion |
2698 | { |
2771 | { |
2699 | /* |
2772 | /* |
… | |
… | |
2706 | goto bailout; |
2779 | goto bailout; |
2707 | } |
2780 | } |
2708 | } |
2781 | } |
2709 | else if (selection_wait == Sel_incr) |
2782 | else if (selection_wait == Sel_incr) |
2710 | { |
2783 | { |
2711 | incr_ev.start (NOW + 10); |
2784 | incr_ev.start (10); |
2712 | |
2785 | |
2713 | while (incr_buf_fill + ct.nitems > incr_buf_size) |
2786 | while (incr_buf_fill + ct.nitems > incr_buf_size) |
2714 | { |
2787 | { |
2715 | incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; |
2788 | incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; |
2716 | incr_buf = (char *)realloc (incr_buf, incr_buf_size); |
2789 | incr_buf = (char *)realloc (incr_buf, incr_buf_size); |
… | |
… | |
2723 | } |
2796 | } |
2724 | |
2797 | |
2725 | char **cl; |
2798 | char **cl; |
2726 | int cr; |
2799 | int cr; |
2727 | |
2800 | |
2728 | #if ENABLE_FRILLS |
2801 | #if !ENABLE_MINIMAL |
2729 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
2802 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
2730 | // so recode it manually |
2803 | // so recode it manually |
2731 | if (ct.encoding == xa[XA_UTF8_STRING]) |
2804 | if (ct.encoding == xa[XA_UTF8_STRING]) |
2732 | { |
2805 | { |
2733 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2806 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
… | |
… | |
2737 | paste (s, strlen (s)); |
2810 | paste (s, strlen (s)); |
2738 | free (s); |
2811 | free (s); |
2739 | } |
2812 | } |
2740 | else |
2813 | else |
2741 | #endif |
2814 | #endif |
2742 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2815 | if (XmbTextPropertyToTextList (dpy, &ct, &cl, &cr) >= 0 |
2743 | && cl) |
2816 | && cl) |
2744 | { |
2817 | { |
2745 | for (int i = 0; i < cr; i++) |
2818 | for (int i = 0; i < cr; i++) |
2746 | paste (cl[i], strlen (cl[i])); |
2819 | paste (cl[i], strlen (cl[i])); |
2747 | |
2820 | |
… | |
… | |
2756 | if (selection_wait == Sel_normal) |
2829 | if (selection_wait == Sel_normal) |
2757 | selection_wait = Sel_none; |
2830 | selection_wait = Sel_none; |
2758 | } |
2831 | } |
2759 | |
2832 | |
2760 | void |
2833 | void |
2761 | rxvt_term::incr_cb (time_watcher &w) |
2834 | rxvt_term::incr_cb (ev::timer &w, int revents) NOTHROW |
2762 | { |
2835 | { |
2763 | selection_wait = Sel_none; |
2836 | selection_wait = Sel_none; |
2764 | |
2837 | |
2765 | incr_buf_size = 0; |
2838 | incr_buf_size = 0; |
2766 | free (incr_buf); |
2839 | free (incr_buf); |
2767 | |
2840 | |
2768 | rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); |
2841 | rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); |
2769 | } |
2842 | } |
2770 | |
2843 | |
2771 | void |
2844 | void |
2772 | rxvt_term::selection_property (Window win, Atom prop) |
2845 | rxvt_term::selection_property (Window win, Atom prop) NOTHROW |
2773 | { |
2846 | { |
2774 | if (prop == None || selection_wait != Sel_incr) |
2847 | if (prop == None || selection_wait != Sel_incr) |
2775 | return; |
2848 | return; |
2776 | |
2849 | |
2777 | selection_paste (win, prop, true); |
2850 | selection_paste (win, prop, true); |
2778 | } |
2851 | } |
2779 | |
2852 | |
2780 | /* ------------------------------------------------------------------------- */ |
2853 | /* ------------------------------------------------------------------------- */ |
2781 | /* |
2854 | /* |
2782 | * Request the current selection: |
2855 | * Request the current selection: |
2783 | * Order: > internal selection if available |
2856 | * Order: > internal selection if available |
2784 | * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) |
2857 | * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) |
2785 | * > CUT_BUFFER0 |
2858 | * > CUT_BUFFER0 |
2786 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2859 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2787 | * will auto fallback to CUT_BUFFER0 |
2860 | * will auto fallback to CUT_BUFFER0 |
2788 | * EXT: button 2 release |
2861 | * EXT: button 2 release |
2789 | */ |
2862 | */ |
2790 | void |
2863 | void |
2791 | rxvt_term::selection_request (Time tm, int x, int y) |
2864 | rxvt_term::selection_request (Time tm, int selnum) NOTHROW |
2792 | { |
2865 | { |
2793 | if (x < 0 || x >= width || y < 0 || y >= height) |
2866 | if (selection.text && selnum == Sel_Primary) |
2794 | return; /* outside window */ |
2867 | { |
2795 | |
|
|
2796 | if (selection.text) |
|
|
2797 | { /* internal selection */ |
2868 | /* internal selection */ |
2798 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2869 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2799 | paste (str, strlen (str)); |
2870 | paste (str, strlen (str)); |
2800 | free (str); |
2871 | free (str); |
2801 | return; |
2872 | return; |
2802 | } |
2873 | } |
2803 | else |
2874 | else |
2804 | { |
2875 | { |
2805 | int i; |
|
|
2806 | |
|
|
2807 | selection_request_time = tm; |
2876 | selection_request_time = tm; |
2808 | selection_wait = Sel_normal; |
2877 | selection_wait = Sel_normal; |
2809 | |
2878 | |
2810 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) |
|
|
2811 | { |
|
|
2812 | #if X_HAVE_UTF8_STRING |
2879 | #if X_HAVE_UTF8_STRING |
2813 | selection_type = Sel_UTF8String; |
2880 | selection_type = Sel_UTF8String; |
2814 | if (selection_request_other (xa[XA_UTF8_STRING], i)) |
2881 | if (selection_request_other (xa[XA_UTF8_STRING], selnum)) |
2815 | return; |
2882 | return; |
2816 | #else |
2883 | #else |
2817 | selection_type = Sel_CompoundText; |
2884 | selection_type = Sel_CompoundText; |
2818 | if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) |
2885 | if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum)) |
2819 | return; |
2886 | return; |
2820 | #endif |
2887 | #endif |
2821 | } |
|
|
2822 | } |
2888 | } |
2823 | |
2889 | |
2824 | selection_wait = Sel_none; /* don't loop in selection_paste () */ |
2890 | selection_wait = Sel_none; /* don't loop in selection_paste () */ |
2825 | selection_paste (display->root, XA_CUT_BUFFER0, false); |
2891 | selection_paste (display->root, XA_CUT_BUFFER0, false); |
2826 | } |
2892 | } |
2827 | |
2893 | |
2828 | int |
2894 | int |
2829 | rxvt_term::selection_request_other (Atom target, int selnum) |
2895 | rxvt_term::selection_request_other (Atom target, int selnum) NOTHROW |
2830 | { |
2896 | { |
2831 | Atom sel; |
2897 | Atom sel; |
2832 | |
2898 | |
2833 | selection_type |= selnum; |
2899 | selection_type |= selnum; |
2834 | |
2900 | |
… | |
… | |
2837 | else if (selnum == Sel_Secondary) |
2903 | else if (selnum == Sel_Secondary) |
2838 | sel = XA_SECONDARY; |
2904 | sel = XA_SECONDARY; |
2839 | else |
2905 | else |
2840 | sel = xa[XA_CLIPBOARD]; |
2906 | sel = xa[XA_CLIPBOARD]; |
2841 | |
2907 | |
2842 | if (XGetSelectionOwner (display->display, sel) != None) |
2908 | if (XGetSelectionOwner (dpy, sel) != None) |
2843 | { |
2909 | { |
2844 | XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], |
2910 | XConvertSelection (dpy, sel, target, xa[XA_VT_SELECTION], |
2845 | vt, selection_request_time); |
2911 | vt, selection_request_time); |
2846 | return 1; |
2912 | return 1; |
2847 | } |
2913 | } |
2848 | |
2914 | |
2849 | return 0; |
2915 | return 0; |
… | |
… | |
2853 | /* |
2919 | /* |
2854 | * Clear all selected text |
2920 | * Clear all selected text |
2855 | * EXT: SelectionClear |
2921 | * EXT: SelectionClear |
2856 | */ |
2922 | */ |
2857 | void |
2923 | void |
2858 | rxvt_term::selection_clear () |
2924 | rxvt_term::selection_clear () NOTHROW |
2859 | { |
2925 | { |
2860 | want_refresh = 1; |
2926 | want_refresh = 1; |
2861 | free (selection.text); |
2927 | free (selection.text); |
2862 | selection.text = NULL; |
2928 | selection.text = NULL; |
2863 | selection.len = 0; |
2929 | selection.len = 0; |
… | |
… | |
2912 | |
2978 | |
2913 | int end_col; |
2979 | int end_col; |
2914 | |
2980 | |
2915 | for (; row <= selection.end.row; row++, col = 0) |
2981 | for (; row <= selection.end.row; row++, col = 0) |
2916 | { |
2982 | { |
2917 | #if ENABLE_FRILLS |
2983 | #if !ENABLE_MINIMAL |
2918 | if (selection.rect) |
2984 | if (selection.rect) |
2919 | { |
2985 | { |
2920 | col = selection.beg.col; |
2986 | col = selection.beg.col; |
2921 | end_col = ncol + 1; |
2987 | end_col = ncol + 1; |
2922 | } |
2988 | } |
… | |
… | |
2925 | end_col = ROW(row).l; |
2991 | end_col = ROW(row).l; |
2926 | |
2992 | |
2927 | col = max (col, 0); |
2993 | col = max (col, 0); |
2928 | |
2994 | |
2929 | if (row == selection.end.row |
2995 | if (row == selection.end.row |
2930 | #if ENABLE_FRILLS |
2996 | #if !ENABLE_MINIMAL |
2931 | || selection.rect |
2997 | || selection.rect |
2932 | #endif |
2998 | #endif |
2933 | ) |
2999 | ) |
2934 | min_it (end_col, selection.end.col); |
3000 | min_it (end_col, selection.end.col); |
2935 | |
3001 | |
… | |
… | |
2958 | #endif |
3024 | #endif |
2959 | else |
3025 | else |
2960 | new_selection_text[ofs++] = *t++; |
3026 | new_selection_text[ofs++] = *t++; |
2961 | } |
3027 | } |
2962 | |
3028 | |
2963 | #if ENABLE_FRILLS |
3029 | #if !ENABLE_MINIMAL |
2964 | if (selection.rect) |
3030 | if (selection.rect) |
2965 | { |
3031 | { |
2966 | while (ofs |
3032 | while (ofs |
2967 | && new_selection_text[ofs - 1] != C0_LF |
3033 | && new_selection_text[ofs - 1] != C0_LF |
2968 | && unicode::is_space (new_selection_text[ofs - 1])) |
3034 | && unicode::is_space (new_selection_text[ofs - 1])) |
… | |
… | |
2998 | |
3064 | |
2999 | selection_grab (tm); |
3065 | selection_grab (tm); |
3000 | } |
3066 | } |
3001 | |
3067 | |
3002 | bool |
3068 | bool |
3003 | rxvt_term::selection_grab (Time tm) |
3069 | rxvt_term::selection_grab (Time tm) NOTHROW |
3004 | { |
3070 | { |
3005 | selection_time = tm; |
3071 | selection_time = tm; |
3006 | |
3072 | |
3007 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
3073 | XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm); |
3008 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
3074 | if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt) |
3009 | { |
3075 | { |
3010 | display->set_selection_owner (this); |
3076 | display->set_selection_owner (this); |
3011 | return true; |
3077 | return true; |
3012 | } |
3078 | } |
3013 | else |
3079 | else |
|
|
3080 | { |
|
|
3081 | selection_clear (); |
3014 | return false; |
3082 | return false; |
|
|
3083 | } |
3015 | |
3084 | |
3016 | #if 0 |
3085 | #if 0 |
3017 | XTextProperty ct; |
3086 | XTextProperty ct; |
3018 | |
3087 | |
3019 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3088 | if (XwcTextListToTextProperty (dpy, &selection.text, 1, XStringStyle, &ct) >= 0) |
3020 | { |
3089 | { |
3021 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3090 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3022 | XFree (ct.value); |
3091 | XFree (ct.value); |
3023 | } |
3092 | } |
3024 | #endif |
3093 | #endif |
… | |
… | |
3028 | /* |
3097 | /* |
3029 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3098 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3030 | * EXT: button 1 press |
3099 | * EXT: button 1 press |
3031 | */ |
3100 | */ |
3032 | void |
3101 | void |
3033 | rxvt_term::selection_click (int clicks, int x, int y) |
3102 | rxvt_term::selection_click (int clicks, int x, int y) NOTHROW |
3034 | { |
3103 | { |
3035 | clicks = ((clicks - 1) % 3) + 1; |
3104 | clicks = ((clicks - 1) % 3) + 1; |
3036 | selection.clicks = clicks; /* save clicks so extend will work */ |
3105 | selection.clicks = clicks; /* save clicks so extend will work */ |
3037 | |
3106 | |
|
|
3107 | if (clicks == 2 && !selection.rect |
|
|
3108 | && HOOK_INVOKE ((this, HOOK_SEL_EXTEND, DT_END))) |
|
|
3109 | { |
|
|
3110 | MEvent.clicks = 1; // what a mess |
|
|
3111 | selection.screen = current_screen; |
|
|
3112 | selection.op = SELECTION_CONT; |
|
|
3113 | return; |
|
|
3114 | } |
|
|
3115 | |
3038 | selection_start_colrow (Pixel2Col (x), Pixel2Row (y)); |
3116 | selection_start_colrow (Pixel2Col (x), Pixel2Row (y)); |
3039 | |
3117 | |
3040 | if (clicks == 2 || clicks == 3) |
3118 | if (clicks == 2 || clicks == 3) |
3041 | selection_extend_colrow (selection.mark.col, |
3119 | selection_extend_colrow (selection.mark.col, |
3042 | selection.mark.row + view_start, |
3120 | selection.mark.row - view_start, |
3043 | 0, /* button 3 */ |
3121 | 0, /* button 3 */ |
3044 | 1, /* button press */ |
3122 | 1, /* button press */ |
3045 | 0); /* click change */ |
3123 | 0); /* click change */ |
3046 | } |
3124 | } |
3047 | |
3125 | |
3048 | /* ------------------------------------------------------------------------- */ |
3126 | /* ------------------------------------------------------------------------- */ |
3049 | /* |
3127 | /* |
3050 | * Mark a selection at the specified col/row |
3128 | * Mark a selection at the specified col/row |
3051 | */ |
3129 | */ |
3052 | void |
3130 | void |
3053 | rxvt_term::selection_start_colrow (int col, int row) |
3131 | rxvt_term::selection_start_colrow (int col, int row) NOTHROW |
3054 | { |
3132 | { |
3055 | want_refresh = 1; |
3133 | want_refresh = 1; |
3056 | |
3134 | |
3057 | selection.mark.row = row - view_start; |
3135 | selection.mark.row = row + view_start; |
3058 | selection.mark.col = col; |
3136 | selection.mark.col = col; |
3059 | |
3137 | |
3060 | selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1); |
3138 | selection.mark.row = clamp (selection.mark.row, top_row, nrow - 1); |
3061 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3139 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3062 | |
3140 | |
3063 | while (selection.mark.col > 0 |
3141 | while (selection.mark.col > 0 |
3064 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3142 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3065 | --selection.mark.col; |
3143 | --selection.mark.col; |
3066 | |
3144 | |
3067 | if (selection.op) |
3145 | if (selection.op) |
|
|
3146 | { |
3068 | { /* clear the old selection */ |
3147 | /* clear the old selection */ |
3069 | selection.beg.row = selection.end.row = selection.mark.row; |
3148 | selection.beg.row = selection.end.row = selection.mark.row; |
3070 | selection.beg.col = selection.end.col = selection.mark.col; |
3149 | selection.beg.col = selection.end.col = selection.mark.col; |
3071 | } |
3150 | } |
3072 | |
3151 | |
3073 | selection.op = SELECTION_INIT; |
3152 | selection.op = SELECTION_INIT; |
… | |
… | |
3084 | #define DELIMIT_TEXT(x) \ |
3163 | #define DELIMIT_TEXT(x) \ |
3085 | (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) |
3164 | (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) |
3086 | #define DELIMIT_REND(x) 1 |
3165 | #define DELIMIT_REND(x) 1 |
3087 | |
3166 | |
3088 | void |
3167 | void |
3089 | rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
3168 | rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW |
3090 | { |
3169 | { |
3091 | int col, row, dirnadd, tcol, trow, w1, w2; |
3170 | int col, row, dirnadd, tcol, trow, w1, w2; |
3092 | row_col_t bound; |
3171 | row_col_t bound; |
3093 | text_t *stp; |
3172 | text_t *stp; |
3094 | rend_t *srp; |
3173 | rend_t *srp; |
3095 | |
3174 | |
3096 | if (dirn == UP) |
3175 | if (dirn == UP) |
3097 | { |
3176 | { |
3098 | bound.row = - nsaved - 1; |
3177 | bound.row = top_row - 1; |
3099 | bound.col = 0; |
3178 | bound.col = 0; |
3100 | dirnadd = -1; |
3179 | dirnadd = -1; |
3101 | } |
3180 | } |
3102 | else |
3181 | else |
3103 | { |
3182 | { |
… | |
… | |
3168 | * flag == 0 ==> button 1 |
3247 | * flag == 0 ==> button 1 |
3169 | * flag == 1 ==> button 3 press |
3248 | * flag == 1 ==> button 3 press |
3170 | * flag == 2 ==> button 3 motion |
3249 | * flag == 2 ==> button 3 motion |
3171 | */ |
3250 | */ |
3172 | void |
3251 | void |
3173 | rxvt_term::selection_extend (int x, int y, int flag) |
3252 | rxvt_term::selection_extend (int x, int y, int flag) NOTHROW |
3174 | { |
3253 | { |
3175 | int col = clamp (Pixel2Col (x), 0, ncol); |
3254 | int col = clamp (Pixel2Col (x), 0, ncol); |
3176 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3255 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3177 | |
3256 | |
3178 | /* |
3257 | /* |
… | |
… | |
3181 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3260 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3182 | * be _past_ a character for it to be selected. |
3261 | * be _past_ a character for it to be selected. |
3183 | */ |
3262 | */ |
3184 | if (((selection.clicks % 3) == 1) && !flag |
3263 | if (((selection.clicks % 3) == 1) && !flag |
3185 | && (col == selection.mark.col |
3264 | && (col == selection.mark.col |
3186 | && (row == selection.mark.row + view_start))) |
3265 | && (row == selection.mark.row - view_start))) |
3187 | { |
3266 | { |
3188 | /* select nothing */ |
3267 | /* select nothing */ |
3189 | selection.beg.row = selection.end.row = 0; |
3268 | selection.beg.row = selection.end.row = 0; |
3190 | selection.beg.col = selection.end.col = 0; |
3269 | selection.beg.col = selection.end.col = 0; |
3191 | selection.clicks = 4; |
3270 | selection.clicks = 4; |
… | |
… | |
3204 | /* ------------------------------------------------------------------------- */ |
3283 | /* ------------------------------------------------------------------------- */ |
3205 | /* |
3284 | /* |
3206 | * Extend the selection to the specified col/row |
3285 | * Extend the selection to the specified col/row |
3207 | */ |
3286 | */ |
3208 | void |
3287 | void |
3209 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) |
3288 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW |
3210 | { |
3289 | { |
3211 | row_col_t pos; |
3290 | row_col_t pos; |
3212 | enum { |
3291 | enum { |
3213 | LEFT, RIGHT |
3292 | LEFT, RIGHT |
3214 | } closeto = RIGHT; |
3293 | } closeto = RIGHT; |
… | |
… | |
3246 | selection.beg.col = selection.end.col = selection.mark.col; |
3325 | selection.beg.col = selection.end.col = selection.mark.col; |
3247 | selection.beg.row = selection.end.row = selection.mark.row; |
3326 | selection.beg.row = selection.end.row = selection.mark.row; |
3248 | } |
3327 | } |
3249 | |
3328 | |
3250 | pos.col = col; |
3329 | pos.col = col; |
3251 | pos.row = row - view_start; |
3330 | pos.row = view_start + row; |
3252 | |
3331 | |
3253 | /* |
3332 | /* |
3254 | * This is mainly xterm style selection with a couple of differences, mainly |
3333 | * This is mainly xterm style selection with a couple of differences, mainly |
3255 | * in the way button3 drag extension works. |
3334 | * in the way button3 drag extension works. |
3256 | * We're either doing: button1 drag; button3 press; or button3 drag |
3335 | * We're either doing: button1 drag; button3 press; or button3 drag |
… | |
… | |
3262 | * a point/word/line which is either the start or end of the selection |
3341 | * a point/word/line which is either the start or end of the selection |
3263 | * and it was decided by whichever point/word/line was `fixed' at the |
3342 | * and it was decided by whichever point/word/line was `fixed' at the |
3264 | * time of the most recent button3 press |
3343 | * time of the most recent button3 press |
3265 | */ |
3344 | */ |
3266 | if (button3 && buttonpress) |
3345 | if (button3 && buttonpress) |
|
|
3346 | { |
3267 | { /* button3 press */ |
3347 | /* button3 press */ |
3268 | /* |
3348 | /* |
3269 | * first determine which edge of the selection we are closest to |
3349 | * first determine which edge of the selection we are closest to |
3270 | */ |
3350 | */ |
3271 | if (ROWCOL_IS_BEFORE (pos, selection.beg) |
3351 | if (ROWCOL_IS_BEFORE (pos, selection.beg) |
3272 | || (!ROWCOL_IS_AFTER (pos, selection.end) |
3352 | || (!ROWCOL_IS_AFTER (pos, selection.end) |
… | |
… | |
3290 | selection.mark.row = selection.beg.row; |
3370 | selection.mark.row = selection.beg.row; |
3291 | selection.mark.col = selection.beg.col; |
3371 | selection.mark.col = selection.beg.col; |
3292 | } |
3372 | } |
3293 | } |
3373 | } |
3294 | else |
3374 | else |
|
|
3375 | { |
3295 | { /* button1 drag or button3 drag */ |
3376 | /* button1 drag or button3 drag */ |
3296 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3377 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3297 | { |
3378 | { |
3298 | if (selection.mark.row == selection.end.row |
3379 | if (selection.mark.row == selection.end.row |
3299 | && selection.mark.col == selection.end.col |
3380 | && selection.mark.col == selection.end.col |
3300 | && clickchange |
3381 | && clickchange |
… | |
… | |
3317 | |
3398 | |
3318 | if (selection.clicks == 1) |
3399 | if (selection.clicks == 1) |
3319 | { |
3400 | { |
3320 | if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN |
3401 | if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN |
3321 | && !ROW(selection.beg.row).is_longer () |
3402 | && !ROW(selection.beg.row).is_longer () |
3322 | #if ENABLE_FRILLS |
3403 | #if !ENABLE_MINIMAL |
3323 | && !selection.rect |
3404 | && !selection.rect |
3324 | #endif |
3405 | #endif |
3325 | ) |
3406 | ) |
3326 | selection.beg.col = ncol; |
3407 | selection.beg.col = ncol; |
3327 | |
3408 | |
3328 | if ( |
3409 | if ( |
3329 | selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN |
3410 | selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN |
3330 | && !ROW(selection.end.row).is_longer () |
3411 | && !ROW(selection.end.row).is_longer () |
3331 | #if ENABLE_FRILLS |
3412 | #if !ENABLE_MINIMAL |
3332 | && !selection.rect |
3413 | && !selection.rect |
3333 | #endif |
3414 | #endif |
3334 | ) |
3415 | ) |
3335 | selection.end.col = ncol; |
3416 | selection.end.col = ncol; |
3336 | } |
3417 | } |
3337 | else if (selection.clicks == 2) |
3418 | else if (selection.clicks == 2) |
3338 | { |
3419 | { |
3339 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3420 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3340 | selection.end.col--; |
3421 | selection.end.col--; |
3341 | |
3422 | |
3342 | if (!HOOK_INVOKE ((this, HOOK_SEL_EXTEND, DT_END))) |
|
|
3343 | { |
|
|
3344 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3423 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3345 | selection_delimit_word (DN, &selection.end, &selection.end); |
3424 | selection_delimit_word (DN, &selection.end, &selection.end); |
3346 | } |
|
|
3347 | } |
3425 | } |
3348 | else if (selection.clicks == 3) |
3426 | else if (selection.clicks == 3) |
3349 | { |
3427 | { |
3350 | #if ENABLE_FRILLS |
3428 | #if ENABLE_FRILLS |
3351 | if (OPTION (Opt_tripleclickwords)) |
3429 | if (option (Opt_tripleclickwords)) |
3352 | { |
3430 | { |
3353 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3431 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3354 | |
3432 | |
3355 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3433 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3356 | { |
3434 | { |
3357 | if (!ROW(end_row).is_longer ()) |
3435 | if (!ROW(end_row).is_longer ()) |
3358 | { |
3436 | { |
3359 | selection.end.row = end_row; |
3437 | selection.end.row = end_row; |
3360 | selection.end.col = ROW(end_row).l; |
3438 | selection.end.col = ROW(end_row).l; |
|
|
3439 | # if !ENABLE_MINIMAL |
3361 | selection_remove_trailing_spaces (); |
3440 | selection_remove_trailing_spaces (); |
|
|
3441 | # endif |
3362 | break; |
3442 | break; |
3363 | } |
3443 | } |
3364 | } |
3444 | } |
3365 | } |
3445 | } |
3366 | else |
3446 | else |
… | |
… | |
3382 | selection.end.row++; |
3462 | selection.end.row++; |
3383 | } |
3463 | } |
3384 | } |
3464 | } |
3385 | |
3465 | |
3386 | if (button3 && buttonpress) |
3466 | if (button3 && buttonpress) |
|
|
3467 | { |
3387 | { /* mark may need to be changed */ |
3468 | /* mark may need to be changed */ |
3388 | if (closeto == LEFT) |
3469 | if (closeto == LEFT) |
3389 | { |
3470 | { |
3390 | selection.mark.row = selection.end.row; |
3471 | selection.mark.row = selection.end.row; |
3391 | selection.mark.col = selection.end.col - (selection.clicks == 2); |
3472 | selection.mark.col = selection.end.col - (selection.clicks == 2); |
3392 | } |
3473 | } |
… | |
… | |
3395 | selection.mark.row = selection.beg.row; |
3476 | selection.mark.row = selection.beg.row; |
3396 | selection.mark.col = selection.beg.col; |
3477 | selection.mark.col = selection.beg.col; |
3397 | } |
3478 | } |
3398 | } |
3479 | } |
3399 | |
3480 | |
3400 | #if ENABLE_FRILLS |
3481 | #if !ENABLE_MINIMAL |
3401 | if (selection.rect && selection.beg.col > selection.end.col) |
3482 | if (selection.rect && selection.beg.col > selection.end.col) |
3402 | ::swap (selection.beg.col, selection.end.col); |
3483 | ::swap (selection.beg.col, selection.end.col); |
3403 | #endif |
3484 | #endif |
3404 | } |
3485 | } |
3405 | |
3486 | |
3406 | #if ENABLE_FRILLS |
3487 | #if !ENABLE_MINIMAL |
3407 | void |
3488 | void |
3408 | rxvt_term::selection_remove_trailing_spaces () |
3489 | rxvt_term::selection_remove_trailing_spaces () NOTHROW |
3409 | { |
3490 | { |
3410 | int32_t end_col, end_row; |
3491 | int32_t end_col, end_row; |
3411 | text_t *stp; |
3492 | text_t *stp; |
3412 | |
3493 | |
3413 | end_col = selection.end.col; |
3494 | end_col = selection.end.col; |
… | |
… | |
3451 | /* |
3532 | /* |
3452 | * Double click on button 3 when already selected |
3533 | * Double click on button 3 when already selected |
3453 | * EXT: button 3 double click |
3534 | * EXT: button 3 double click |
3454 | */ |
3535 | */ |
3455 | void |
3536 | void |
3456 | rxvt_term::selection_rotate (int x, int y) |
3537 | rxvt_term::selection_rotate (int x, int y) NOTHROW |
3457 | { |
3538 | { |
3458 | selection.clicks = selection.clicks % 3 + 1; |
3539 | selection.clicks = selection.clicks % 3 + 1; |
3459 | selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); |
3540 | selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); |
3460 | } |
3541 | } |
3461 | |
3542 | |
… | |
… | |
3463 | /* |
3544 | /* |
3464 | * Respond to a request for our current selection |
3545 | * Respond to a request for our current selection |
3465 | * EXT: SelectionRequest |
3546 | * EXT: SelectionRequest |
3466 | */ |
3547 | */ |
3467 | void |
3548 | void |
3468 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) |
3549 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW |
3469 | { |
3550 | { |
3470 | XSelectionEvent ev; |
3551 | XSelectionEvent ev; |
3471 | dDisp; |
|
|
3472 | |
3552 | |
3473 | ev.type = SelectionNotify; |
3553 | ev.type = SelectionNotify; |
3474 | ev.property = None; |
3554 | ev.property = None; |
3475 | ev.display = rq.display; |
3555 | ev.display = rq.display; |
3476 | ev.requestor = rq.requestor; |
3556 | ev.requestor = rq.requestor; |
… | |
… | |
3490 | *target++ = xa[XA_COMPOUND_TEXT]; |
3570 | *target++ = xa[XA_COMPOUND_TEXT]; |
3491 | #if X_HAVE_UTF8_STRING |
3571 | #if X_HAVE_UTF8_STRING |
3492 | *target++ = xa[XA_UTF8_STRING]; |
3572 | *target++ = xa[XA_UTF8_STRING]; |
3493 | #endif |
3573 | #endif |
3494 | |
3574 | |
3495 | XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, |
3575 | XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM, |
3496 | 32, PropModeReplace, |
3576 | 32, PropModeReplace, |
3497 | (unsigned char *)target_list, target - target_list); |
3577 | (unsigned char *)target_list, target - target_list); |
3498 | ev.property = rq.property; |
3578 | ev.property = rq.property; |
3499 | } |
3579 | } |
3500 | #if TODO // TODO |
3580 | #if TODO // TODO |
… | |
… | |
3503 | /* TODO: Handle MULTIPLE */ |
3583 | /* TODO: Handle MULTIPLE */ |
3504 | } |
3584 | } |
3505 | #endif |
3585 | #endif |
3506 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3586 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3507 | { |
3587 | { |
3508 | XChangeProperty (disp, rq.requestor, rq.property, rq.target, |
3588 | XChangeProperty (dpy, rq.requestor, rq.property, rq.target, |
3509 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3589 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3510 | ev.property = rq.property; |
3590 | ev.property = rq.property; |
3511 | } |
3591 | } |
3512 | else if (rq.target == XA_STRING |
3592 | else if (rq.target == XA_STRING |
3513 | || rq.target == xa[XA_TEXT] |
3593 | || rq.target == xa[XA_TEXT] |
… | |
… | |
3537 | style = enc_string; |
3617 | style = enc_string; |
3538 | else if (target == xa[XA_TEXT]) |
3618 | else if (target == xa[XA_TEXT]) |
3539 | style = enc_text; |
3619 | style = enc_text; |
3540 | else if (target == xa[XA_COMPOUND_TEXT]) |
3620 | else if (target == xa[XA_COMPOUND_TEXT]) |
3541 | style = enc_compound_text; |
3621 | style = enc_compound_text; |
3542 | #if ENABLE_FRILLS |
3622 | #if !ENABLE_MINIMAL |
3543 | else if (target == xa[XA_UTF8_STRING]) |
3623 | else if (target == xa[XA_UTF8_STRING]) |
3544 | style = enc_utf8; |
3624 | style = enc_utf8; |
3545 | #endif |
3625 | #endif |
3546 | else |
3626 | else |
3547 | { |
3627 | { |
… | |
… | |
3558 | { |
3638 | { |
3559 | cl = L""; |
3639 | cl = L""; |
3560 | selectlen = 0; |
3640 | selectlen = 0; |
3561 | } |
3641 | } |
3562 | |
3642 | |
3563 | #if ENABLE_FRILLS |
3643 | #if !ENABLE_MINIMAL |
3564 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
3644 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
3565 | // so recode it manually |
3645 | // so recode it manually |
3566 | if (style == enc_utf8) |
3646 | if (style == enc_utf8) |
3567 | { |
3647 | { |
3568 | freect = 1; |
3648 | freect = 1; |
… | |
… | |
3571 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
3651 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
3572 | ct.nitems = strlen ((char *)ct.value); |
3652 | ct.nitems = strlen ((char *)ct.value); |
3573 | } |
3653 | } |
3574 | else |
3654 | else |
3575 | #endif |
3655 | #endif |
3576 | if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3656 | if (XwcTextListToTextProperty (dpy, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3577 | freect = 1; |
3657 | freect = 1; |
3578 | else |
3658 | else |
3579 | { |
3659 | { |
3580 | /* if we failed to convert then send it raw */ |
3660 | /* if we failed to convert then send it raw */ |
3581 | ct.value = (unsigned char *)cl; |
3661 | ct.value = (unsigned char *)cl; |
3582 | ct.nitems = selectlen; |
3662 | ct.nitems = selectlen; |
3583 | ct.encoding = target; |
3663 | ct.encoding = target; |
3584 | } |
3664 | } |
3585 | |
3665 | |
3586 | XChangeProperty (disp, rq.requestor, rq.property, |
3666 | XChangeProperty (dpy, rq.requestor, rq.property, |
3587 | ct.encoding, 8, PropModeReplace, |
3667 | ct.encoding, 8, PropModeReplace, |
3588 | ct.value, (int)ct.nitems); |
3668 | ct.value, (int)ct.nitems); |
3589 | ev.property = rq.property; |
3669 | ev.property = rq.property; |
3590 | |
3670 | |
3591 | if (freect) |
3671 | if (freect) |
3592 | XFree (ct.value); |
3672 | XFree (ct.value); |
3593 | } |
3673 | } |
3594 | |
3674 | |
3595 | XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); |
3675 | XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); |
3596 | } |
|
|
3597 | |
|
|
3598 | /* ------------------------------------------------------------------------- * |
|
|
3599 | * MOUSE ROUTINES * |
|
|
3600 | * ------------------------------------------------------------------------- */ |
|
|
3601 | |
|
|
3602 | /* |
|
|
3603 | * return col/row values corresponding to x/y pixel values |
|
|
3604 | */ |
|
|
3605 | void |
|
|
3606 | rxvt_term::pixel_position (int *x, int *y) |
|
|
3607 | { |
|
|
3608 | *x = Pixel2Col (*x); |
|
|
3609 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
|
|
3610 | *y = Pixel2Row (*y); |
|
|
3611 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
|
|
3612 | } |
3676 | } |
3613 | |
3677 | |
3614 | /* ------------------------------------------------------------------------- */ |
3678 | /* ------------------------------------------------------------------------- */ |
3615 | #ifdef USE_XIM |
3679 | #ifdef USE_XIM |
3616 | void |
3680 | void |
3617 | rxvt_term::im_set_position (XPoint &pos) |
3681 | rxvt_term::im_set_position (XPoint &pos) NOTHROW |
3618 | { |
3682 | { |
3619 | XWindowAttributes xwa; |
3683 | XWindowAttributes xwa; |
3620 | |
3684 | |
3621 | XGetWindowAttributes (display->display, vt, &xwa); |
3685 | XGetWindowAttributes (dpy, vt, &xwa); |
3622 | |
3686 | |
3623 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3687 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3624 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; |
3688 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; |
3625 | } |
3689 | } |
3626 | #endif |
3690 | #endif |
3627 | |
3691 | |
3628 | #if ENABLE_OVERLAY |
3692 | #if ENABLE_OVERLAY |
3629 | void |
3693 | void |
3630 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3694 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) NOTHROW |
3631 | { |
3695 | { |
3632 | if (nrow < 1 || ncol < 1) |
3696 | if (nrow < 1 || ncol < 1) |
3633 | return; |
3697 | return; |
3634 | |
3698 | |
3635 | want_refresh = 1; |
3699 | want_refresh = 1; |
… | |
… | |
3680 | *rp = r; |
3744 | *rp = r; |
3681 | } |
3745 | } |
3682 | } |
3746 | } |
3683 | |
3747 | |
3684 | void |
3748 | void |
3685 | rxvt_term::scr_overlay_off () |
3749 | rxvt_term::scr_overlay_off () NOTHROW |
3686 | { |
3750 | { |
3687 | if (!ov_text) |
3751 | if (!ov_text) |
3688 | return; |
3752 | return; |
3689 | |
3753 | |
3690 | want_refresh = 1; |
3754 | want_refresh = 1; |
… | |
… | |
3698 | delete [] ov_text; ov_text = 0; |
3762 | delete [] ov_text; ov_text = 0; |
3699 | delete [] ov_rend; ov_rend = 0; |
3763 | delete [] ov_rend; ov_rend = 0; |
3700 | } |
3764 | } |
3701 | |
3765 | |
3702 | void |
3766 | void |
3703 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) |
3767 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW |
3704 | { |
3768 | { |
3705 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
3769 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
3706 | return; |
3770 | return; |
3707 | |
3771 | |
3708 | x++, y++; |
3772 | x++, y++; |
… | |
… | |
3710 | ov_text[y][x] = text; |
3774 | ov_text[y][x] = text; |
3711 | ov_rend[y][x] = rend; |
3775 | ov_rend[y][x] = rend; |
3712 | } |
3776 | } |
3713 | |
3777 | |
3714 | void |
3778 | void |
3715 | rxvt_term::scr_overlay_set (int x, int y, const char *s) |
3779 | rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW |
3716 | { |
3780 | { |
3717 | while (*s) |
3781 | while (*s) |
3718 | scr_overlay_set (x++, y, *s++); |
3782 | scr_overlay_set (x++, y, *s++); |
3719 | } |
3783 | } |
3720 | |
3784 | |
3721 | void |
3785 | void |
3722 | rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) |
3786 | rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW |
3723 | { |
3787 | { |
3724 | while (*s) |
3788 | while (*s) |
3725 | { |
3789 | { |
3726 | text_t t = *s++; |
3790 | text_t t = *s++; |
3727 | int width = wcwidth (t); |
3791 | int width = WCWIDTH (t); |
3728 | |
3792 | |
3729 | while (width--) |
3793 | while (width--) |
3730 | { |
3794 | { |
3731 | scr_overlay_set (x++, y, t); |
3795 | scr_overlay_set (x++, y, t); |
3732 | t = NOCHAR; |
3796 | t = NOCHAR; |
3733 | } |
3797 | } |
3734 | } |
3798 | } |
3735 | } |
3799 | } |
3736 | |
3800 | |
3737 | void |
3801 | void |
3738 | rxvt_term::scr_swap_overlay () |
3802 | rxvt_term::scr_swap_overlay () NOTHROW |
3739 | { |
3803 | { |
3740 | if (!ov_text) |
3804 | if (!ov_text) |
3741 | return; |
3805 | return; |
3742 | |
3806 | |
3743 | // swap screen mem with overlay |
3807 | // swap screen mem with overlay |
3744 | for (int y = ov_h; y--; ) |
3808 | for (int y = ov_h; y--; ) |
3745 | { |
3809 | { |
3746 | text_t *t1 = ov_text[y]; |
3810 | text_t *t1 = ov_text[y]; |
3747 | rend_t *r1 = ov_rend[y]; |
3811 | rend_t *r1 = ov_rend[y]; |
3748 | |
3812 | |
3749 | text_t *t2 = ROW(y + ov_y - view_start).t + ov_x; |
3813 | text_t *t2 = ROW(y + ov_y + view_start).t + ov_x; |
3750 | rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x; |
3814 | rend_t *r2 = ROW(y + ov_y + view_start).r + ov_x; |
3751 | |
3815 | |
3752 | for (int x = ov_w; x--; ) |
3816 | for (int x = ov_w; x--; ) |
3753 | { |
3817 | { |
3754 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3818 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3755 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3819 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |