1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
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-2004 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
7 | * |
7 | * |
… | |
… | |
29 | #include "rxvt.h" /* NECESSARY */ |
29 | #include "rxvt.h" /* NECESSARY */ |
30 | #include "screen.intpro" /* PROTOS for internal routines */ |
30 | #include "screen.intpro" /* PROTOS for internal routines */ |
31 | |
31 | |
32 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
32 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
33 | |
33 | |
34 | #include <stdint.h> |
34 | #include <inttypes.h> |
35 | #include <wchar.h> |
35 | #include <wchar.h> |
36 | |
36 | |
37 | #include "salloc.C" // HACK, should be a seperate compile! |
37 | #include "salloc.C" // HACK, should be a seperate compile! |
38 | |
38 | |
39 | inline void fill_text (text_t *start, text_t value, int len) |
39 | inline void fill_text (text_t *start, text_t value, int len) |
… | |
… | |
48 | |
48 | |
49 | /* ------------------------------------------------------------------------- * |
49 | /* ------------------------------------------------------------------------- * |
50 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
50 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
51 | * ------------------------------------------------------------------------- */ |
51 | * ------------------------------------------------------------------------- */ |
52 | #define ZERO_SCROLLBACK() \ |
52 | #define ZERO_SCROLLBACK() \ |
53 | if ((Options & Opt_scrollTtyOutput) == Opt_scrollTtyOutput) \ |
53 | if (Options & Opt_scrollTtyOutput) \ |
54 | TermWin.view_start = 0 |
54 | TermWin.view_start = 0 |
55 | #define CLEAR_SELECTION() \ |
55 | #define CLEAR_SELECTION() \ |
56 | selection.beg.row = selection.beg.col \ |
56 | selection.beg.row = selection.beg.col \ |
57 | = selection.end.row = selection.end.col = 0 |
57 | = selection.end.row = selection.end.col = 0 |
58 | #define CLEAR_ALL_SELECTION() \ |
58 | #define CLEAR_ALL_SELECTION() \ |
59 | selection.beg.row = selection.beg.col \ |
59 | selection.beg.row = selection.beg.col \ |
60 | = selection.mark.row = selection.mark.col \ |
60 | = selection.mark.row = selection.mark.col \ |
61 | = selection.end.row = selection.end.col = 0 |
61 | = selection.end.row = selection.end.col = 0 |
62 | |
62 | |
63 | #define ROW_AND_COL_IS_AFTER(A, B, C, D) \ |
63 | #define ROW_AND_COL_IS_AFTER(A, B, C, D) \ |
64 | (((A) > (C)) || (((A) == (C)) && ((B) > (D)))) |
64 | (((A) > (C)) || (((A) == (C)) && ((B) > (D)))) |
65 | #define ROW_AND_COL_IS_BEFORE(A, B, C, D) \ |
65 | #define ROW_AND_COL_IS_BEFORE(A, B, C, D) \ |
66 | (((A) < (C)) || (((A) == (C)) && ((B) < (D)))) |
66 | (((A) < (C)) || (((A) == (C)) && ((B) < (D)))) |
67 | #define ROW_AND_COL_IN_ROW_AFTER(A, B, C, D) \ |
67 | #define ROW_AND_COL_IN_ROW_AFTER(A, B, C, D) \ |
68 | (((A) == (C)) && ((B) > (D))) |
68 | (((A) == (C)) && ((B) > (D))) |
69 | #define ROW_AND_COL_IN_ROW_AT_OR_AFTER(A, B, C, D) \ |
69 | #define ROW_AND_COL_IN_ROW_AT_OR_AFTER(A, B, C, D) \ |
70 | (((A) == (C)) && ((B) >= (D))) |
70 | (((A) == (C)) && ((B) >= (D))) |
71 | #define ROW_AND_COL_IN_ROW_BEFORE(A, B, C, D) \ |
71 | #define ROW_AND_COL_IN_ROW_BEFORE(A, B, C, D) \ |
72 | (((A) == (C)) && ((B) < (D))) |
72 | (((A) == (C)) && ((B) < (D))) |
73 | #define ROW_AND_COL_IN_ROW_AT_OR_BEFORE(A, B, C, D) \ |
73 | #define ROW_AND_COL_IN_ROW_AT_OR_BEFORE(A, B, C, D) \ |
74 | (((A) == (C)) && ((B) <= (D))) |
74 | (((A) == (C)) && ((B) <= (D))) |
75 | |
75 | |
76 | /* these must be row_col_t */ |
76 | /* these must be row_col_t */ |
77 | #define ROWCOL_IS_AFTER(X, Y) \ |
77 | #define ROWCOL_IS_AFTER(X, Y) \ |
78 | ROW_AND_COL_IS_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
78 | ROW_AND_COL_IS_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
79 | #define ROWCOL_IS_BEFORE(X, Y) \ |
79 | #define ROWCOL_IS_BEFORE(X, Y) \ |
80 | ROW_AND_COL_IS_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
80 | ROW_AND_COL_IS_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
81 | #define ROWCOL_IN_ROW_AFTER(X, Y) \ |
81 | #define ROWCOL_IN_ROW_AFTER(X, Y) \ |
82 | ROW_AND_COL_IN_ROW_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
82 | ROW_AND_COL_IN_ROW_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
83 | #define ROWCOL_IN_ROW_BEFORE(X, Y) \ |
83 | #define ROWCOL_IN_ROW_BEFORE(X, Y) \ |
84 | ROW_AND_COL_IN_ROW_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
84 | ROW_AND_COL_IN_ROW_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
85 | #define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ |
85 | #define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ |
86 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
86 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
87 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
87 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
88 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
88 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
89 | |
89 | |
90 | /* |
90 | /* |
91 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
91 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
92 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
92 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
93 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
93 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
94 | */ |
94 | */ |
95 | #define drawBuffer TermWin.vt |
95 | #define drawBuffer TermWin.vt |
96 | |
96 | |
97 | #define CLEAR_ROWS(row, num) \ |
97 | #define CLEAR_ROWS(row, num) \ |
98 | if (TermWin.mapped) \ |
98 | if (TermWin.mapped) \ |
99 | XClearArea (display->display, drawBuffer, TermWin.int_bwidth, \ |
99 | XClearArea (display->display, drawBuffer, 0, \ |
100 | Row2Pixel (row), (unsigned int)TermWin.width, \ |
100 | Row2Pixel (row), (unsigned int)TermWin.width, \ |
101 | (unsigned int)Height2Pixel (num), False) |
101 | (unsigned int)Height2Pixel (num), False) |
102 | |
102 | |
103 | #define CLEAR_CHARS(x, y, num) \ |
103 | #define CLEAR_CHARS(x, y, num) \ |
104 | if (TermWin.mapped) \ |
104 | if (TermWin.mapped) \ |
105 | XClearArea (display->display, drawBuffer, x, y, \ |
105 | XClearArea (display->display, drawBuffer, x, y, \ |
106 | (unsigned int)Width2Pixel (num), \ |
106 | (unsigned int)Width2Pixel (num), \ |
107 | (unsigned int)Height2Pixel (1), False) |
107 | (unsigned int)Height2Pixel (1), False) |
108 | |
108 | |
109 | #define ERASE_ROWS(row, num) \ |
109 | #define ERASE_ROWS(row, num) \ |
110 | XFillRectangle (display->display, drawBuffer, TermWin.gc, \ |
110 | XFillRectangle (display->display, drawBuffer, TermWin.gc, \ |
111 | TermWin.int_bwidth, Row2Pixel (row), \ |
111 | 0, Row2Pixel (row), \ |
112 | (unsigned int)TermWin.width, \ |
112 | (unsigned int)TermWin.width, \ |
113 | (unsigned int)Height2Pixel (num)) |
113 | (unsigned int)Height2Pixel (num)) |
114 | |
114 | |
115 | /* ------------------------------------------------------------------------- * |
115 | /* ------------------------------------------------------------------------- * |
116 | * SCREEN `COMMON' ROUTINES * |
116 | * SCREEN `COMMON' ROUTINES * |
117 | * ------------------------------------------------------------------------- */ |
117 | * ------------------------------------------------------------------------- */ |
118 | /* Fill part/all of a line with blanks. */ |
118 | /* Fill part/all of a line with blanks. */ |
119 | void |
119 | void |
120 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
120 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
121 | { |
121 | { |
122 | efs &= ~RS_baseattrMask; |
122 | efs &= ~RS_baseattrMask; |
123 | efs = SET_FONT (efs, TermWin.fontset->find_font (' ')); |
123 | efs = SET_FONT (efs, TermWin.ascii_map [' ' - 0x20]); |
124 | |
124 | |
125 | while (width--) |
125 | while (width--) |
126 | { |
126 | { |
127 | *et++ = ' '; |
127 | *et++ = ' '; |
128 | *er++ = efs; |
128 | *er++ = efs; |
… | |
… | |
172 | nrow = TermWin.nrow; |
172 | nrow = TermWin.nrow; |
173 | |
173 | |
174 | if (ncol == prev_ncol && nrow == prev_nrow) |
174 | if (ncol == prev_ncol && nrow == prev_nrow) |
175 | return; |
175 | return; |
176 | |
176 | |
|
|
177 | // we need at least two lines for wrapping to work correctly |
|
|
178 | if (nrow + TermWin.saveLines < 2) |
|
|
179 | { |
|
|
180 | TermWin.saveLines++; |
|
|
181 | prev_nrow--; |
|
|
182 | TermWin.nscrolled++; |
|
|
183 | } |
|
|
184 | |
177 | want_refresh = 1; |
185 | want_refresh = 1; |
178 | |
186 | |
|
|
187 | prev_total_rows = prev_nrow + TermWin.saveLines; |
179 | total_rows = nrow + TermWin.saveLines; |
188 | total_rows = nrow + TermWin.saveLines; |
180 | prev_total_rows = prev_nrow + TermWin.saveLines; |
|
|
181 | |
189 | |
182 | screen.tscroll = 0; |
190 | screen.tscroll = 0; |
183 | screen.bscroll = nrow - 1; |
191 | screen.bscroll = nrow - 1; |
184 | |
192 | |
185 | if (!talloc) |
193 | if (!talloc) |
186 | { |
194 | { |
187 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
195 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
188 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
196 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
189 | } |
197 | } |
190 | |
198 | |
191 | if (prev_nrow == 0) |
199 | if (!screen.text) |
192 | { |
200 | { |
193 | /* |
201 | /* |
194 | * first time called so just malloc everything : don't rely on realloc |
202 | * first time called so just malloc everything: don't rely on realloc |
195 | * Note: this is still needed so that all the scrollback lines are NULL |
203 | * Note: this is still needed so that all the scrollback lines are NULL |
196 | */ |
204 | */ |
197 | screen.text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
205 | screen.text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
198 | buf_text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
206 | buf_text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
199 | drawn_text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); |
207 | drawn_text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); |
… | |
… | |
256 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
264 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
257 | |
265 | |
258 | for (p = nrow; p < prev_nrow; p++) |
266 | for (p = nrow; p < prev_nrow; p++) |
259 | { |
267 | { |
260 | q = p + TermWin.saveLines; |
268 | q = p + TermWin.saveLines; |
|
|
269 | |
261 | if (screen.text[q]) |
270 | if (screen.text[q]) |
262 | { |
271 | { |
263 | #ifdef DEBUG_STRICT |
272 | #ifdef DEBUG_STRICT |
264 | assert (screen.rend[q]); |
273 | assert (screen.rend[q]); |
265 | #endif |
274 | #endif |
266 | talloc->free (screen.text[q]); |
275 | talloc->free (screen.text[q]); |
267 | ralloc->free (screen.rend[q]); |
276 | ralloc->free (screen.rend[q]); |
268 | } |
277 | } |
|
|
278 | |
269 | if (swap.text[p]) |
279 | if (swap.text[p]) |
270 | { |
280 | { |
271 | #ifdef DEBUG_STRICT |
281 | #ifdef DEBUG_STRICT |
272 | assert (swap.rend[p]); |
282 | assert (swap.rend[p]); |
273 | #endif |
283 | #endif |
274 | talloc->free (swap.text[p]); |
284 | talloc->free (swap.text[p]); |
275 | ralloc->free (swap.rend[p]); |
285 | ralloc->free (swap.rend[p]); |
276 | } |
286 | } |
|
|
287 | |
277 | #ifdef DEBUG_STRICT |
288 | #ifdef DEBUG_STRICT |
278 | assert (drawn_text[p] && drawn_rend[p]); |
289 | assert (drawn_text[p] && drawn_rend[p]); |
279 | #endif |
290 | #endif |
280 | talloc->free (drawn_text[p]); |
291 | talloc->free (drawn_text[p]); |
281 | ralloc->free (drawn_rend[p]); |
292 | ralloc->free (drawn_rend[p]); |
… | |
… | |
311 | swap.tlen[p] = 0; |
322 | swap.tlen[p] = 0; |
312 | swap.text[p] = NULL; |
323 | swap.text[p] = NULL; |
313 | swap.rend[p] = NULL; |
324 | swap.rend[p] = NULL; |
314 | drawn_text[p] = NULL; |
325 | drawn_text[p] = NULL; |
315 | drawn_rend[p] = NULL; |
326 | drawn_rend[p] = NULL; |
316 | scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); |
327 | scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); |
317 | scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); |
328 | scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); |
318 | } |
329 | } |
319 | |
330 | |
320 | if (k > 0) |
331 | if (k > 0) |
321 | { |
332 | { |
… | |
… | |
336 | } |
347 | } |
337 | |
348 | |
338 | /* resize columns */ |
349 | /* resize columns */ |
339 | if (ncol != prev_ncol) |
350 | if (ncol != prev_ncol) |
340 | { |
351 | { |
341 | int common = min (prev_ncol, ncol); |
|
|
342 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
352 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
343 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
353 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
344 | |
354 | |
345 | for (p = 0; p < total_rows; p++) |
355 | for (p = 0; p < total_rows; p++) |
346 | { |
356 | { |
347 | if (screen.text[p]) |
357 | if (screen.text[p]) |
348 | { |
358 | { |
349 | text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t; |
359 | screen.text[p] = (text_t *)ta->alloc (screen.text[p], prev_ncol * sizeof (text_t)); |
350 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, screen.rend[p], common * sizeof (rend_t)); screen.rend[p] = r; |
360 | screen.rend[p] = (rend_t *)ra->alloc (screen.rend[p], prev_ncol * sizeof (rend_t)); |
351 | |
361 | |
352 | MIN_IT (screen.tlen[p], (int16_t)ncol); |
362 | MIN_IT (screen.tlen[p], (int16_t)ncol); |
353 | |
363 | |
354 | if (ncol > prev_ncol) |
364 | if (ncol > prev_ncol) |
355 | scr_blank_line (& (screen.text[p][prev_ncol]), |
365 | scr_blank_line (&screen.text[p][prev_ncol], |
356 | & (screen.rend[p][prev_ncol]), |
366 | &screen.rend[p][prev_ncol], |
357 | ncol - prev_ncol, |
367 | ncol - prev_ncol, setrstyle); |
358 | setrstyle); |
|
|
359 | } |
368 | } |
360 | } |
369 | } |
361 | |
370 | |
362 | for (p = 0; p < nrow; p++) |
371 | for (p = 0; p < nrow; p++) |
363 | { |
372 | { |
364 | text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t; |
373 | drawn_text[p] = (text_t *)ta->alloc (drawn_text[p], prev_ncol * sizeof (text_t)); |
365 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, drawn_rend[p], common * sizeof (rend_t)); drawn_rend[p] = r; |
374 | drawn_rend[p] = (rend_t *)ra->alloc (drawn_rend[p], prev_ncol * sizeof (rend_t)); |
366 | |
375 | |
367 | if (ncol > prev_ncol) |
376 | if (ncol > prev_ncol) |
368 | scr_blank_line (& (drawn_text[p][prev_ncol]), |
377 | scr_blank_line (&drawn_text[p][prev_ncol], |
369 | & (drawn_rend[p][prev_ncol]), |
378 | &drawn_rend[p][prev_ncol], |
370 | ncol - prev_ncol, setrstyle); |
379 | ncol - prev_ncol, setrstyle); |
371 | |
380 | |
372 | if (swap.text[p]) |
381 | if (swap.text[p]) |
373 | { |
382 | { |
374 | text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t; |
383 | swap.text[p] = (text_t *)ta->alloc (swap.text[p], prev_ncol * sizeof (text_t)); |
375 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, swap.rend[p], common * sizeof (rend_t)); swap.rend[p] = r; |
384 | swap.rend[p] = (rend_t *)ra->alloc (swap.rend[p], prev_ncol * sizeof (rend_t)); |
376 | |
385 | |
377 | MIN_IT (swap.tlen[p], (int16_t)ncol); |
386 | MIN_IT (swap.tlen[p], (int16_t)ncol); |
378 | |
387 | |
379 | if (ncol > prev_ncol) |
388 | if (ncol > prev_ncol) |
380 | scr_blank_line (& (swap.text[p][prev_ncol]), |
389 | scr_blank_line (&swap.text[p][prev_ncol], |
381 | & (swap.rend[p][prev_ncol]), |
390 | &swap.rend[p][prev_ncol], |
382 | ncol - prev_ncol, setrstyle); |
391 | ncol - prev_ncol, setrstyle); |
383 | } |
392 | } |
384 | |
393 | |
385 | } |
394 | } |
386 | |
395 | |
… | |
… | |
476 | |
485 | |
477 | scr_release (); |
486 | scr_release (); |
478 | prev_nrow = prev_ncol = 0; |
487 | prev_nrow = prev_ncol = 0; |
479 | scr_reset (); |
488 | scr_reset (); |
480 | |
489 | |
481 | scr_clear (); |
490 | scr_clear (true); |
482 | scr_refresh (SLOW_REFRESH); |
491 | scr_refresh (SLOW_REFRESH); |
483 | } |
492 | } |
484 | |
493 | |
485 | /* ------------------------------------------------------------------------- * |
494 | /* ------------------------------------------------------------------------- * |
486 | * PROCESS SCREEN COMMANDS * |
495 | * PROCESS SCREEN COMMANDS * |
… | |
… | |
511 | s->s_cur.col = s->cur.col; |
520 | s->s_cur.col = s->cur.col; |
512 | s->s_rstyle = rstyle; |
521 | s->s_rstyle = rstyle; |
513 | s->s_charset = s->charset; |
522 | s->s_charset = s->charset; |
514 | s->s_charset_char = charsets[s->charset]; |
523 | s->s_charset_char = charsets[s->charset]; |
515 | break; |
524 | break; |
|
|
525 | |
516 | case RESTORE: |
526 | case RESTORE: |
517 | want_refresh = 1; |
527 | want_refresh = 1; |
518 | s->cur.row = s->s_cur.row; |
528 | s->cur.row = s->s_cur.row; |
519 | s->cur.col = s->s_cur.col; |
529 | s->cur.col = s->s_cur.col; |
520 | s->flags &= ~Screen_WrapNext; |
530 | s->flags &= ~Screen_WrapNext; |
… | |
… | |
703 | if (j > 0) |
713 | if (j > 0) |
704 | { |
714 | { |
705 | /* A: scroll up */ |
715 | /* A: scroll up */ |
706 | |
716 | |
707 | /* A1: Copy lines that will get clobbered by the rotation */ |
717 | /* A1: Copy lines that will get clobbered by the rotation */ |
|
|
718 | memcpy (buf_text, screen.text + row1, count * sizeof (text_t *)); |
|
|
719 | memcpy (buf_rend, screen.rend + row1, count * sizeof (rend_t *)); |
|
|
720 | |
|
|
721 | /* A2: Rotate lines */ |
|
|
722 | i = row2 - row1 - count + 1; |
|
|
723 | memmove (screen.tlen + row1, screen.tlen + row1 + count, i * sizeof (int16_t)); |
|
|
724 | memmove (screen.text + row1, screen.text + row1 + count, i * sizeof (text_t *)); |
|
|
725 | memmove (screen.rend + row1, screen.rend + row1 + count, i * sizeof (rend_t *)); |
|
|
726 | |
|
|
727 | j = row2 - count + 1, i = count; |
|
|
728 | } |
|
|
729 | else /* if (j < 0) */ |
|
|
730 | { |
|
|
731 | /* B: scroll down */ |
|
|
732 | |
|
|
733 | /* B1: Copy lines that will get clobbered by the rotation */ |
708 | for (i = 0, j = row1; i < count; i++, j++) |
734 | for (i = 0, j = row2; i < count; i++, j--) |
709 | { |
735 | { |
710 | buf_text[i] = screen.text[j]; |
736 | buf_text[i] = screen.text[j]; |
711 | buf_rend[i] = screen.rend[j]; |
737 | buf_rend[i] = screen.rend[j]; |
712 | } |
738 | } |
|
|
739 | |
713 | /* A2: Rotate lines */ |
740 | /* B2: Rotate lines */ |
714 | for (j = row1, i = j + count; i <= row2; i++, j++) |
741 | for (j = row2, i = j - count; i >= row1; i--, j--) |
715 | { |
742 | { |
716 | screen.tlen[j] = screen.tlen[i]; |
743 | screen.tlen[j] = screen.tlen[i]; |
717 | screen.text[j] = screen.text[i]; |
744 | screen.text[j] = screen.text[i]; |
718 | screen.rend[j] = screen.rend[i]; |
745 | screen.rend[j] = screen.rend[i]; |
719 | } |
746 | } |
720 | j = row2 - count + 1, i = count; |
|
|
721 | } |
|
|
722 | else /* if (j < 0) */ |
|
|
723 | { |
|
|
724 | /* B: scroll down */ |
|
|
725 | |
747 | |
726 | /* B1: Copy lines that will get clobbered by the rotation */ |
|
|
727 | for (i = 0, j = row2; i < count; i++, j--) |
|
|
728 | { |
|
|
729 | buf_text[i] = screen.text[j]; |
|
|
730 | buf_rend[i] = screen.rend[j]; |
|
|
731 | } |
|
|
732 | /* B2: Rotate lines */ |
|
|
733 | for (j = row2, i = j - count; i >= row1; i--, j--) |
|
|
734 | { |
|
|
735 | screen.tlen[j] = screen.tlen[i]; |
|
|
736 | screen.text[j] = screen.text[i]; |
|
|
737 | screen.rend[j] = screen.rend[i]; |
|
|
738 | } |
|
|
739 | j = row1, i = count; |
748 | j = row1, i = count; |
740 | count = -count; |
749 | count = -count; |
741 | } |
750 | } |
742 | |
751 | |
743 | /* C: Resurrect lines */ |
752 | /* C: Resurrect lines */ |
|
|
753 | memset (screen.tlen + j, 0, i * sizeof (int16_t)); |
|
|
754 | memcpy (screen.text + j, buf_text, i * sizeof (text_t *)); |
|
|
755 | memcpy (screen.rend + j, buf_rend, i * sizeof (text_t *)); |
|
|
756 | if (!spec) /* line length may not equal TermWin.ncol */ |
744 | for (; i--; j++) |
757 | for (; i--; j++) |
745 | { |
|
|
746 | screen.tlen[j] = 0; |
|
|
747 | screen.text[j] = buf_text[i]; |
|
|
748 | screen.rend[j] = buf_rend[i]; |
|
|
749 | |
|
|
750 | if (!spec) /* line length may not equal TermWin.ncol */ |
|
|
751 | scr_blank_screen_mem (screen.text, screen.rend, |
758 | scr_blank_screen_mem (screen.text, screen.rend, (unsigned int)j, rstyle); |
752 | (unsigned int)j, rstyle); |
|
|
753 | } |
|
|
754 | |
759 | |
755 | return count; |
760 | return count; |
756 | } |
761 | } |
757 | |
762 | |
758 | /* ------------------------------------------------------------------------- */ |
763 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
776 | |
781 | |
777 | D_SCREEN ((stderr, "rxvt_scr_add_lines (%d,%d)", nlines, len)); |
782 | D_SCREEN ((stderr, "rxvt_scr_add_lines (%d,%d)", nlines, len)); |
778 | ZERO_SCROLLBACK (); |
783 | ZERO_SCROLLBACK (); |
779 | if (nlines > 0) |
784 | if (nlines > 0) |
780 | { |
785 | { |
781 | nlines += (screen.cur.row - screen.bscroll); |
786 | nlines += screen.cur.row - screen.bscroll; |
782 | if ((nlines > 0) |
787 | if ((nlines > 0) |
783 | && (screen.tscroll == 0) |
788 | && (screen.tscroll == 0) |
784 | && (screen.bscroll == (TermWin.nrow - 1))) |
789 | && (screen.bscroll == (TermWin.nrow - 1))) |
785 | { |
790 | { |
786 | /* _at least_ this many lines need to be scrolled */ |
791 | /* _at least_ this many lines need to be scrolled */ |
787 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines, 0); |
792 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines, 0); |
788 | screen.cur.row -= nlines; |
793 | screen.cur.row -= nlines; |
789 | } |
794 | } |
790 | } |
795 | } |
|
|
796 | |
791 | #ifdef DEBUG_STRICT |
797 | #ifdef DEBUG_STRICT |
792 | assert (screen.cur.col < last_col); |
798 | assert (screen.cur.col < last_col); |
793 | assert ((screen.cur.row < TermWin.nrow) |
799 | assert ((screen.cur.row < TermWin.nrow) |
794 | && (screen.cur.row >= - (int32_t)TermWin.nscrolled)); |
800 | && (screen.cur.row >= - (int32_t)TermWin.nscrolled)); |
795 | #else /* drive with your eyes closed */ |
801 | #else /* drive with your eyes closed */ |
796 | MIN_IT (screen.cur.col, last_col - 1); |
802 | MIN_IT (screen.cur.col, last_col - 1); |
797 | MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); |
803 | MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); |
798 | MAX_IT (screen.cur.row, - (int32_t)TermWin.nscrolled); |
804 | MAX_IT (screen.cur.row, - (int32_t)TermWin.nscrolled); |
799 | #endif |
805 | #endif |
… | |
… | |
810 | c = *str++; |
816 | c = *str++; |
811 | |
817 | |
812 | if (c < 0x20) |
818 | if (c < 0x20) |
813 | switch (c) |
819 | switch (c) |
814 | { |
820 | { |
815 | case '\t': |
821 | case C0_HT: |
816 | scr_tab (1); |
822 | scr_tab (1); |
817 | continue; |
823 | continue; |
818 | |
824 | |
819 | case '\n': |
825 | case C0_LF: |
820 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
826 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
821 | MAX_IT (screen.tlen[row], screen.cur.col); |
827 | MAX_IT (screen.tlen[row], screen.cur.col); |
822 | |
828 | |
823 | screen.flags &= ~Screen_WrapNext; |
829 | screen.flags &= ~Screen_WrapNext; |
824 | |
830 | |
… | |
… | |
829 | |
835 | |
830 | stp = screen.text[row]; /* _must_ refresh */ |
836 | stp = screen.text[row]; /* _must_ refresh */ |
831 | srp = screen.rend[row]; /* _must_ refresh */ |
837 | srp = screen.rend[row]; /* _must_ refresh */ |
832 | continue; |
838 | continue; |
833 | |
839 | |
834 | case '\r': |
840 | case C0_CR: |
835 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
841 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
836 | MAX_IT (screen.tlen[row], screen.cur.col); |
842 | MAX_IT (screen.tlen[row], screen.cur.col); |
837 | |
843 | |
838 | screen.flags &= ~Screen_WrapNext; |
844 | screen.flags &= ~Screen_WrapNext; |
839 | screen.cur.col = 0; |
845 | screen.cur.col = 0; |
… | |
… | |
866 | scr_insdel_chars (1, INSERT); |
872 | scr_insdel_chars (1, INSERT); |
867 | |
873 | |
868 | // rely on wcwidth to tell us the character width, at least for non-latin1 |
874 | // rely on wcwidth to tell us the character width, at least for non-latin1 |
869 | // do wcwidth before further replacements, as wcwidth says that line-drawing |
875 | // do wcwidth before further replacements, as wcwidth says that line-drawing |
870 | // characters have width -1 (DOH!) on GNU/Linux sometimes. |
876 | // characters have width -1 (DOH!) on GNU/Linux sometimes. |
871 | int width = c < 256 ? 1 : wcwidth (c); |
877 | int width = c < 0x100 ? 1 : wcwidth (c); |
872 | |
878 | |
873 | if (charsets[screen.charset] == '0') // DEC SPECIAL |
879 | if (charsets[screen.charset] == '0') // DEC SPECIAL |
874 | { |
880 | { |
875 | // vt100 special graphics and line drawing |
881 | // vt100 special graphics and line drawing |
876 | static uint16_t vt100_0[32] = { // 5f .. 7e |
882 | static uint16_t vt100_0[32] = { // 5f .. 7e |
… | |
… | |
885 | c = vt100_0[c - 0x5f]; |
891 | c = vt100_0[c - 0x5f]; |
886 | width = 1; |
892 | width = 1; |
887 | } |
893 | } |
888 | } |
894 | } |
889 | |
895 | |
890 | if (width > 0) |
896 | if (width != 0) |
891 | { |
897 | { |
892 | #if !UNICODE_3 && ENABLE_COMBINING |
898 | #if !UNICODE_3 && ENABLE_COMBINING |
893 | // trim characters we can't store directly :( |
899 | // trim characters we can't store directly :( |
894 | if (c >= 0x10000) |
900 | if (c >= 0x10000) |
895 | c = rxvt_composite.compose (c); // map to lower 16 bits |
901 | c = rxvt_composite.compose (c); // map to lower 16 bits |
896 | #endif |
902 | #endif |
897 | rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c)); |
903 | bool bold = (Options & Opt_realBold) && ((rstyle & RS_Bold) != 0); |
|
|
904 | rend_t rend = SET_FONT (rstyle, |
|
|
905 | c > 0x7f || bold || c < 0x20 |
|
|
906 | ? TermWin.fontset->find_font (c, bold) |
|
|
907 | : TermWin.ascii_map [c - 0x20]); |
898 | |
908 | |
899 | do |
909 | do |
900 | { |
910 | { |
901 | stp[screen.cur.col] = c; |
911 | stp[screen.cur.col] = c; |
902 | srp[screen.cur.col] = rend; |
912 | srp[screen.cur.col] = rend; |
… | |
… | |
987 | */ |
997 | */ |
988 | void |
998 | void |
989 | rxvt_term::scr_backspace () |
999 | rxvt_term::scr_backspace () |
990 | { |
1000 | { |
991 | want_refresh = 1; |
1001 | want_refresh = 1; |
|
|
1002 | |
992 | if (screen.cur.col == 0) |
1003 | if (screen.cur.col == 0) |
993 | { |
1004 | { |
994 | if (screen.cur.row > 0) |
1005 | if (screen.cur.row > 0) |
995 | { |
1006 | { |
996 | #ifdef TERMCAP_HAS_BW |
1007 | #ifdef TERMCAP_HAS_BW |
… | |
… | |
1001 | |
1012 | |
1002 | } |
1013 | } |
1003 | } |
1014 | } |
1004 | else if ((screen.flags & Screen_WrapNext) == 0) |
1015 | else if ((screen.flags & Screen_WrapNext) == 0) |
1005 | scr_gotorc (0, -1, RELATIVE); |
1016 | scr_gotorc (0, -1, RELATIVE); |
|
|
1017 | |
1006 | screen.flags &= ~Screen_WrapNext; |
1018 | screen.flags &= ~Screen_WrapNext; |
1007 | } |
1019 | } |
1008 | |
1020 | |
1009 | /* ------------------------------------------------------------------------- */ |
1021 | /* ------------------------------------------------------------------------- */ |
1010 | /* |
1022 | /* |
… | |
… | |
1114 | want_refresh = 1; |
1126 | want_refresh = 1; |
1115 | ZERO_SCROLLBACK (); |
1127 | ZERO_SCROLLBACK (); |
1116 | |
1128 | |
1117 | D_SCREEN ((stderr, "rxvt_scr_gotorc (r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col)); |
1129 | D_SCREEN ((stderr, "rxvt_scr_gotorc (r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col)); |
1118 | |
1130 | |
1119 | screen.cur.col = ((relative & C_RELATIVE) ? (screen.cur.col + col) |
1131 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1120 | : col); |
|
|
1121 | MAX_IT (screen.cur.col, 0); |
1132 | MAX_IT (screen.cur.col, 0); |
1122 | MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); |
1133 | MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); |
1123 | |
1134 | |
1124 | screen.flags &= ~Screen_WrapNext; |
1135 | screen.flags &= ~Screen_WrapNext; |
1125 | if (relative & R_RELATIVE) |
1136 | if (relative & R_RELATIVE) |
… | |
… | |
1164 | * direction should be UP or DN |
1175 | * direction should be UP or DN |
1165 | */ |
1176 | */ |
1166 | void |
1177 | void |
1167 | rxvt_term::scr_index (enum page_dirn direction) |
1178 | rxvt_term::scr_index (enum page_dirn direction) |
1168 | { |
1179 | { |
1169 | int dirn; |
1180 | int dirn; |
1170 | |
1181 | |
1171 | want_refresh = 1; |
1182 | want_refresh = 1; |
1172 | dirn = ((direction == UP) ? 1 : -1); |
1183 | dirn = ((direction == UP) ? 1 : -1); |
1173 | D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn)); |
1184 | D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn)); |
1174 | |
1185 | |
… | |
… | |
1234 | default: |
1245 | default: |
1235 | return; |
1246 | return; |
1236 | } |
1247 | } |
1237 | |
1248 | |
1238 | if (screen.text[row]) |
1249 | if (screen.text[row]) |
1239 | scr_blank_line (& (screen.text[row][col]), |
1250 | scr_blank_line (&screen.text[row][col], &screen.rend[row][col], num, rstyle); |
1240 | & (screen.rend[row][col]), num, rstyle); |
|
|
1241 | else |
1251 | else |
1242 | scr_blank_screen_mem (screen.text, screen.rend, row, rstyle); |
1252 | scr_blank_screen_mem (screen.text, screen.rend, row, rstyle); |
1243 | } |
1253 | } |
1244 | |
1254 | |
1245 | /* ------------------------------------------------------------------------- */ |
1255 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1283 | break; |
1293 | break; |
1284 | default: |
1294 | default: |
1285 | return; |
1295 | return; |
1286 | } |
1296 | } |
1287 | |
1297 | |
1288 | refresh_type |= REFRESH_BOUNDS; |
|
|
1289 | |
|
|
1290 | if (selection.op && current_screen == selection.screen |
1298 | if (selection.op && current_screen == selection.screen |
1291 | && ((selection.beg.row >= row && selection.beg.row <= row + num) |
1299 | && ((selection.beg.row >= row && selection.beg.row <= row + num) |
1292 | || (selection.end.row >= row |
1300 | || (selection.end.row >= row |
1293 | && selection.end.row <= row + num))) |
1301 | && selection.end.row <= row + num))) |
1294 | CLEAR_SELECTION (); |
1302 | CLEAR_SELECTION (); |
… | |
… | |
1517 | */ |
1525 | */ |
1518 | void |
1526 | void |
1519 | rxvt_term::scr_cursor_visible (int mode) |
1527 | rxvt_term::scr_cursor_visible (int mode) |
1520 | { |
1528 | { |
1521 | want_refresh = 1; |
1529 | want_refresh = 1; |
|
|
1530 | |
1522 | if (mode) |
1531 | if (mode) |
1523 | screen.flags |= Screen_VisibleCursor; |
1532 | screen.flags |= Screen_VisibleCursor; |
1524 | else |
1533 | else |
1525 | screen.flags &= ~Screen_VisibleCursor; |
1534 | screen.flags &= ~Screen_VisibleCursor; |
1526 | } |
1535 | } |
… | |
… | |
1740 | row_col_t rc[RC_COUNT]; |
1749 | row_col_t rc[RC_COUNT]; |
1741 | |
1750 | |
1742 | if (drawn_text == NULL) /* sanity check */ |
1751 | if (drawn_text == NULL) /* sanity check */ |
1743 | return; |
1752 | return; |
1744 | |
1753 | |
|
|
1754 | #ifndef NO_SLOW_LINK_SUPPORT |
|
|
1755 | if (refresh_type == FAST_REFRESH && !display->is_local) |
|
|
1756 | { |
|
|
1757 | y = 0; |
|
|
1758 | height = TermWin.height; |
|
|
1759 | } |
|
|
1760 | #endif |
|
|
1761 | |
1745 | #ifdef DEBUG_STRICT |
1762 | #ifdef DEBUG_STRICT |
1746 | x = max (x, (int)TermWin.int_bwidth); |
1763 | x = max (x, 0); |
1747 | x = min (x, (int)TermWin.width); |
1764 | x = min (x, (int)TermWin.width); |
1748 | y = max (y, (int)TermWin.int_bwidth); |
1765 | y = max (y, 0); |
1749 | y = min (y, (int)TermWin.height); |
1766 | y = min (y, (int)TermWin.height); |
1750 | #endif |
1767 | #endif |
1751 | |
1768 | |
1752 | /* round down */ |
1769 | /* round down */ |
1753 | rc[PART_BEG].col = Pixel2Col (x); |
1770 | rc[PART_BEG].col = Pixel2Col (x); |
… | |
… | |
1764 | } |
1781 | } |
1765 | |
1782 | |
1766 | D_SCREEN ((stderr, "rxvt_scr_expose (x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)- (c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); |
1783 | D_SCREEN ((stderr, "rxvt_scr_expose (x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)- (c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); |
1767 | |
1784 | |
1768 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1785 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1769 | fill_text (& (drawn_text[i][rc[PART_BEG].col]), 0, |
1786 | fill_text (&drawn_text[i][rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1770 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
|
|
1771 | |
1787 | |
1772 | if (refresh) |
1788 | if (refresh) |
1773 | scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); |
1789 | scr_refresh (SLOW_REFRESH); |
1774 | } |
1790 | } |
1775 | |
1791 | |
1776 | /* ------------------------------------------------------------------------- */ |
1792 | /* ------------------------------------------------------------------------- */ |
1777 | /* |
1793 | /* |
1778 | * Refresh the entire screen |
1794 | * Refresh the entire screen |
… | |
… | |
1813 | * direction should be UP or DN |
1829 | * direction should be UP or DN |
1814 | */ |
1830 | */ |
1815 | int |
1831 | int |
1816 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1832 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1817 | { |
1833 | { |
1818 | int n; |
1834 | int n; |
1819 | uint16_t oldviewstart; |
1835 | uint16_t oldviewstart; |
1820 | |
1836 | |
1821 | D_SCREEN ((stderr, "rxvt_scr_page (%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start)); |
1837 | D_SCREEN ((stderr, "rxvt_scr_page (%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start)); |
1822 | #ifdef DEBUG_STRICT |
1838 | #ifdef DEBUG_STRICT |
1823 | assert ((nlines >= 0) && (nlines <= TermWin.nrow)); |
1839 | assert ((nlines >= 0) && (nlines <= TermWin.nrow)); |
1824 | #endif |
1840 | #endif |
… | |
… | |
1842 | if (TermWin.view_start != oldviewstart) |
1858 | if (TermWin.view_start != oldviewstart) |
1843 | { |
1859 | { |
1844 | want_refresh = 1; |
1860 | want_refresh = 1; |
1845 | num_scr -= (TermWin.view_start - oldviewstart); |
1861 | num_scr -= (TermWin.view_start - oldviewstart); |
1846 | } |
1862 | } |
|
|
1863 | |
1847 | return (int) (TermWin.view_start - oldviewstart); |
1864 | return (int) (TermWin.view_start - oldviewstart); |
1848 | } |
1865 | } |
1849 | |
1866 | |
1850 | /* ------------------------------------------------------------------------- */ |
1867 | /* ------------------------------------------------------------------------- */ |
1851 | void |
1868 | void |
… | |
… | |
1919 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1936 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1920 | |
1937 | |
1921 | void |
1938 | void |
1922 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1939 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1923 | { |
1940 | { |
1924 | unsigned char clearfirst, /* first character writes before cell */ |
|
|
1925 | clearlast, /* last character writes beyond cell */ |
|
|
1926 | must_clear, /* use draw_string not draw_image_string */ |
1941 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1927 | rvid, /* reverse video this position */ |
1942 | rvid, /* reverse video this position */ |
1928 | showcursor; /* show the cursor */ |
1943 | showcursor; /* show the cursor */ |
1929 | int16_t col, row, /* column/row we're processing */ |
1944 | int16_t col, row, /* column/row we're processing */ |
1930 | ocrow; /* old cursor row */ |
1945 | ocrow; /* old cursor row */ |
1931 | int i, /* tmp */ |
1946 | int i, /* tmp */ |
… | |
… | |
1940 | return; |
1955 | return; |
1941 | |
1956 | |
1942 | /* |
1957 | /* |
1943 | * A: set up vars |
1958 | * A: set up vars |
1944 | */ |
1959 | */ |
1945 | clearfirst = clearlast = must_clear = 0; |
1960 | must_clear = 0; |
1946 | |
1961 | |
1947 | refresh_count = 0; |
1962 | refresh_count = 0; |
1948 | |
1963 | |
1949 | row_offset = TermWin.saveLines - TermWin.view_start; |
1964 | row_offset = TermWin.saveLines - TermWin.view_start; |
1950 | |
|
|
1951 | if ((refresh_type & REFRESH_BOUNDS)) |
|
|
1952 | { |
|
|
1953 | clearfirst = clearlast = 1; |
|
|
1954 | refresh_type &= ~REFRESH_BOUNDS; |
|
|
1955 | } |
|
|
1956 | |
1965 | |
1957 | #ifdef XPM_BACKGROUND |
1966 | #ifdef XPM_BACKGROUND |
1958 | must_clear |= (bgPixmap.pixmap != None); |
1967 | must_clear |= (bgPixmap.pixmap != None); |
1959 | #endif |
1968 | #endif |
1960 | #ifdef TRANSPARENT |
1969 | #ifdef TRANSPARENT |
… | |
… | |
2048 | /* |
2057 | /* |
2049 | * D: CopyArea pass - very useful for slower links |
2058 | * D: CopyArea pass - very useful for slower links |
2050 | * This has been deliberately kept simple. |
2059 | * This has been deliberately kept simple. |
2051 | */ |
2060 | */ |
2052 | i = num_scr; |
2061 | i = num_scr; |
|
|
2062 | if (!display->is_local |
2053 | if (refresh_type == FAST_REFRESH && num_scr_allow && i |
2063 | && refresh_type == FAST_REFRESH && num_scr_allow && i |
2054 | && abs (i) < TermWin.nrow && !must_clear) |
2064 | && abs (i) < TermWin.nrow && !must_clear) |
2055 | { |
2065 | { |
2056 | int16_t nits; |
2066 | int16_t nits; |
2057 | int j; |
2067 | int j; |
2058 | rend_t *drp2; |
2068 | rend_t *drp2; |
… | |
… | |
2200 | rend = GET_ATTR (rend); |
2210 | rend = GET_ATTR (rend); |
2201 | |
2211 | |
2202 | rvid = !!(rend & RS_RVid); |
2212 | rvid = !!(rend & RS_RVid); |
2203 | |
2213 | |
2204 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2214 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2205 | if (rend & RS_Bold && fore == Color_fg) |
2215 | if (rend & RS_Bold && fore == Color_fg && !(Options & Opt_realBold)) |
2206 | { |
2216 | { |
2207 | if (ISSET_PIXCOLOR (Color_BD)) |
2217 | if (ISSET_PIXCOLOR (Color_BD)) |
2208 | fore = Color_BD; |
2218 | fore = Color_BD; |
2209 | else |
2219 | else |
2210 | rvid = !rvid; |
2220 | rvid = !rvid; |
… | |
… | |
2228 | back = Color_RV; |
2238 | back = Color_RV; |
2229 | #endif |
2239 | #endif |
2230 | } |
2240 | } |
2231 | |
2241 | |
2232 | #ifdef TEXT_BLINK |
2242 | #ifdef TEXT_BLINK |
2233 | if (rend & RS_Blink && back == Color_bg) |
2243 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
2234 | { |
2244 | { |
2235 | if (!text_blink_ev.active) |
2245 | if (!text_blink_ev.active) |
2236 | { |
2246 | { |
2237 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
2247 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
2238 | hidden_text = 0; |
2248 | hidden_text = 0; |
… | |
… | |
2268 | font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, Color_bg); |
2278 | font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, Color_bg); |
2269 | } |
2279 | } |
2270 | else |
2280 | else |
2271 | font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back); |
2281 | font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back); |
2272 | |
2282 | |
2273 | if ((rend & RS_Uline) && (font->descent > 1)) |
2283 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2274 | XDrawLine (display->display, drawBuffer, TermWin.gc, |
2284 | XDrawLine (display->display, drawBuffer, TermWin.gc, |
2275 | xpixel, ypixel + font->ascent + 1, |
2285 | xpixel, ypixel + font->ascent + 1, |
2276 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2286 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2277 | } /* for (col....) */ |
2287 | } /* for (col....) */ |
2278 | } /* for (row....) */ |
2288 | } /* for (row....) */ |
… | |
… | |
2313 | /* |
2323 | /* |
2314 | * H: cleanup selection |
2324 | * H: cleanup selection |
2315 | */ |
2325 | */ |
2316 | scr_reverse_selection (); |
2326 | scr_reverse_selection (); |
2317 | |
2327 | |
2318 | /* |
|
|
2319 | * I: other general cleanup |
|
|
2320 | */ |
|
|
2321 | if (clearfirst && TermWin.int_bwidth) |
|
|
2322 | /* |
|
|
2323 | * clear the whole screen height, note that width == 0 is treated |
|
|
2324 | * specially by XClearArea |
|
|
2325 | */ |
|
|
2326 | XClearArea (display->display, TermWin.vt, 0, 0, |
|
|
2327 | (unsigned int)TermWin.int_bwidth, |
|
|
2328 | (unsigned int)TermWin_TotalHeight (), False); |
|
|
2329 | |
|
|
2330 | if (clearlast && TermWin.int_bwidth) |
|
|
2331 | /* |
|
|
2332 | * clear the whole screen height, note that width == 0 is treated |
|
|
2333 | * specially by XClearArea |
|
|
2334 | */ |
|
|
2335 | XClearArea (display->display, TermWin.vt, |
|
|
2336 | TermWin.width + TermWin.int_bwidth, 0, |
|
|
2337 | (unsigned int)TermWin.int_bwidth, |
|
|
2338 | (unsigned int)TermWin_TotalHeight (), False); |
|
|
2339 | |
|
|
2340 | if (refresh_type & SMOOTH_REFRESH) |
2328 | if (refresh_type & SMOOTH_REFRESH) |
2341 | XSync (display->display, False); |
2329 | XFlush (display->display); |
2342 | |
2330 | |
2343 | num_scr = 0; |
2331 | num_scr = 0; |
2344 | num_scr_allow = 1; |
2332 | num_scr_allow = 1; |
2345 | want_refresh = 0; /* screen is current */ |
2333 | want_refresh = 0; /* screen is current */ |
2346 | } |
2334 | } |
… | |
… | |
2517 | { |
2505 | { |
2518 | n = min (len - i, PROP_SIZE); |
2506 | n = min (len - i, PROP_SIZE); |
2519 | MEMCPY (ds, data + i, n); |
2507 | MEMCPY (ds, data + i, n); |
2520 | |
2508 | |
2521 | for (j = 0; j < n; j++) |
2509 | for (j = 0; j < n; j++) |
2522 | if (ds[j] == '\n') |
2510 | if (ds[j] == C0_LF) |
2523 | ds[j] = '\r'; |
2511 | ds[j] = C0_CR; |
2524 | |
2512 | |
2525 | tt_write (ds, (int)n); |
2513 | tt_write (ds, (int)n); |
2526 | } |
2514 | } |
2527 | |
2515 | |
2528 | free (ds); |
2516 | free (ds); |
… | |
… | |
2577 | break; |
2565 | break; |
2578 | |
2566 | |
2579 | if (ct.encoding == 0) |
2567 | if (ct.encoding == 0) |
2580 | { |
2568 | { |
2581 | D_SELECT ((stderr, "rxvt_selection_paste: property didn't exist!")); |
2569 | D_SELECT ((stderr, "rxvt_selection_paste: property didn't exist!")); |
|
|
2570 | break; |
|
|
2571 | } |
|
|
2572 | else if (ct.encoding == xa[XA_INCR]) |
|
|
2573 | { |
|
|
2574 | // INCR selection, start handshake |
|
|
2575 | XDeleteProperty (display->display, win, prop); |
|
|
2576 | selection_wait = Sel_incr; |
|
|
2577 | incr_ev.start (NOW + 10); |
2582 | break; |
2578 | break; |
2583 | } |
2579 | } |
2584 | |
2580 | |
2585 | if (ct.value == NULL) |
2581 | if (ct.value == NULL) |
2586 | { |
2582 | { |
… | |
… | |
2609 | |
2605 | |
2610 | nread += ct.nitems; |
2606 | nread += ct.nitems; |
2611 | |
2607 | |
2612 | char **cl; |
2608 | char **cl; |
2613 | int cr; |
2609 | int cr; |
2614 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, |
2610 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 && cl) |
2615 | &cr) >= 0 && cl) |
|
|
2616 | { |
2611 | { |
2617 | for (int i = 0; i < cr; i++) |
2612 | for (int i = 0; i < cr; i++) |
2618 | paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
2613 | paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
2619 | |
2614 | |
2620 | XFreeStringList (cl); |
2615 | XFreeStringList (cl); |
… | |
… | |
2650 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2645 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2651 | */ |
2646 | */ |
2652 | void |
2647 | void |
2653 | rxvt_term::selection_property (Window win, Atom prop) |
2648 | rxvt_term::selection_property (Window win, Atom prop) |
2654 | { |
2649 | { |
2655 | int reget_time = 0; |
2650 | if (prop == None || selection_wait != Sel_incr) |
2656 | |
|
|
2657 | if (prop == None) |
|
|
2658 | return; |
2651 | return; |
2659 | |
2652 | |
2660 | D_SELECT ((stderr, "rxvt_selection_property (%08lx, %lu)", win, (unsigned long)prop)); |
|
|
2661 | if (selection_wait == Sel_normal) |
|
|
2662 | { |
|
|
2663 | int a, afmt; |
|
|
2664 | Atom atype; |
|
|
2665 | unsigned long bytes_after, nitems; |
|
|
2666 | unsigned char *s = NULL; |
|
|
2667 | |
|
|
2668 | a = XGetWindowProperty (display->display, win, prop, 0L, 1L, False, |
|
|
2669 | xa[XA_INCR], &atype, &afmt, &nitems, |
|
|
2670 | &bytes_after, &s); |
|
|
2671 | if (s) |
|
|
2672 | XFree (s); |
|
|
2673 | if (a != Success) |
|
|
2674 | return; |
|
|
2675 | |
|
|
2676 | #ifndef __CYGWIN32__ |
|
|
2677 | if (atype == xa[XA_INCR]) |
|
|
2678 | { /* start an INCR transfer */ |
|
|
2679 | D_SELECT ((stderr, "rxvt_selection_property: INCR: starting transfer")); |
|
|
2680 | XDeleteProperty (display->display, win, prop); |
|
|
2681 | XFlush (display->display); |
|
|
2682 | reget_time = 1; |
|
|
2683 | selection_wait = Sel_incr; |
|
|
2684 | } |
|
|
2685 | #endif |
|
|
2686 | |
|
|
2687 | } |
|
|
2688 | else if (selection_wait == Sel_incr) |
|
|
2689 | { |
|
|
2690 | reget_time = 1; |
|
|
2691 | |
|
|
2692 | if (selection_paste (win, prop, True) == -1) |
2653 | if (selection_paste (win, prop, 1) > 0) |
2693 | { |
|
|
2694 | D_SELECT ((stderr, "rxvt_selection_property: INCR: clean end")); |
|
|
2695 | selection_wait = Sel_none; |
|
|
2696 | incr_ev.stop (); |
|
|
2697 | } |
|
|
2698 | } |
|
|
2699 | if (reget_time) /* received more data so reget time */ |
|
|
2700 | incr_ev.start (NOW + 10); |
2654 | incr_ev.start (NOW + 10); |
|
|
2655 | else |
|
|
2656 | { |
|
|
2657 | selection_wait = Sel_none; |
|
|
2658 | incr_ev.stop (); |
|
|
2659 | } |
2701 | } |
2660 | } |
2702 | |
2661 | |
2703 | /* ------------------------------------------------------------------------- */ |
2662 | /* ------------------------------------------------------------------------- */ |
2704 | /* |
2663 | /* |
2705 | * Request the current selection: |
2664 | * Request the current selection: |
… | |
… | |
2879 | else |
2838 | else |
2880 | new_selection_text[ofs++] = *t++; |
2839 | new_selection_text[ofs++] = *t++; |
2881 | } |
2840 | } |
2882 | |
2841 | |
2883 | if (screen.tlen[row] != -1 && row != end_row) |
2842 | if (screen.tlen[row] != -1 && row != end_row) |
2884 | new_selection_text[ofs++] = L'\n'; |
2843 | new_selection_text[ofs++] = C0_LF; |
2885 | } |
2844 | } |
2886 | |
2845 | |
2887 | if (end_col != selection.end.col) |
2846 | if (end_col != selection.end.col) |
2888 | new_selection_text[ofs++] = L'\n'; |
2847 | new_selection_text[ofs++] = C0_LF; |
2889 | |
2848 | |
2890 | new_selection_text[ofs] = 0; |
2849 | new_selection_text[ofs] = 0; |
2891 | |
2850 | |
2892 | if (ofs == 0) |
2851 | if (ofs == 0) |
2893 | { |
2852 | { |
… | |
… | |
3120 | * Extend the selection to the specified col/row |
3079 | * Extend the selection to the specified col/row |
3121 | */ |
3080 | */ |
3122 | void |
3081 | void |
3123 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) |
3082 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) |
3124 | { |
3083 | { |
3125 | int16_t ncol = TermWin.ncol; |
3084 | int16_t ncol = TermWin.ncol; |
3126 | int end_col; |
3085 | int end_col; |
3127 | row_col_t pos; |
3086 | row_col_t pos; |
3128 | enum { |
3087 | enum { |
3129 | LEFT, RIGHT |
3088 | LEFT, RIGHT |
3130 | } closeto = RIGHT; |
3089 | } closeto = RIGHT; |
3131 | |
3090 | |
3132 | D_SELECT ((stderr, "rxvt_selection_extend_colrow (c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, selection.clicks, selection.op)); |
3091 | D_SELECT ((stderr, "rxvt_selection_extend_colrow (c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, selection.clicks, selection.op)); |
… | |
… | |
3410 | (8 * sizeof (target_list[0])), PropModeReplace, |
3369 | (8 * sizeof (target_list[0])), PropModeReplace, |
3411 | (unsigned char *)target_list, |
3370 | (unsigned char *)target_list, |
3412 | target - target_list); |
3371 | target - target_list); |
3413 | ev.property = rq.property; |
3372 | ev.property = rq.property; |
3414 | } |
3373 | } |
|
|
3374 | #if TODO // TODO |
3415 | else if (rq.target == xa[XA_MULTIPLE]) |
3375 | else if (rq.target == xa[XA_MULTIPLE]) |
3416 | { |
3376 | { |
3417 | /* TODO: Handle MULTIPLE */ |
3377 | /* TODO: Handle MULTIPLE */ |
3418 | } |
3378 | } |
|
|
3379 | #endif |
3419 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3380 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3420 | { |
3381 | { |
3421 | XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER, |
3382 | XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER, |
3422 | (8 * sizeof (Time)), PropModeReplace, |
3383 | (8 * sizeof (Time)), PropModeReplace, |
3423 | (unsigned char *)&selection_time, 1); |
3384 | (unsigned char *)&selection_time, 1); |
… | |
… | |
3515 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3476 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3516 | } |
3477 | } |
3517 | |
3478 | |
3518 | #endif |
3479 | #endif |
3519 | /* ------------------------------------------------------------------------- */ |
3480 | /* ------------------------------------------------------------------------- */ |
3520 | |
|
|
3521 | /* ------------------------------------------------------------------------- * |
|
|
3522 | * DEBUG ROUTINES * |
|
|
3523 | * ------------------------------------------------------------------------- */ |
|
|
3524 | #if 0 |
|
|
3525 | void |
|
|
3526 | rxvt_debug_colors (void) |
|
|
3527 | { |
|
|
3528 | int color; |
|
|
3529 | const char *name[] = |
|
|
3530 | { |
|
|
3531 | "fg", "bg", |
|
|
3532 | "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white" |
|
|
3533 | }; |
|
|
3534 | |
|
|
3535 | fprintf (stderr, "Color ( "); |
|
|
3536 | if (rstyle & RS_RVid) |
|
|
3537 | fprintf (stderr, "rvid "); |
|
|
3538 | if (rstyle & RS_Bold) |
|
|
3539 | fprintf (stderr, "bold "); |
|
|
3540 | if (rstyle & RS_Blink) |
|
|
3541 | fprintf (stderr, "blink "); |
|
|
3542 | if (rstyle & RS_Uline) |
|
|
3543 | fprintf (stderr, "uline "); |
|
|
3544 | fprintf (stderr, "): "); |
|
|
3545 | |
|
|
3546 | color = GET_FGCOLOR (rstyle); |
|
|
3547 | #ifndef NO_BRIGHTCOLOR |
|
|
3548 | if (color >= minBrightCOLOR && color <= maxBrightCOLOR) |
|
|
3549 | { |
|
|
3550 | color -= (minBrightCOLOR - minCOLOR); |
|
|
3551 | fprintf (stderr, "bright "); |
|
|
3552 | } |
|
|
3553 | #endif |
|
|
3554 | fprintf (stderr, "%s on ", name[color]); |
|
|
3555 | |
|
|
3556 | color = GET_BGCOLOR (rstyle); |
|
|
3557 | #ifndef NO_BRIGHTCOLOR |
|
|
3558 | if (color >= minBrightCOLOR && color <= maxBrightCOLOR) |
|
|
3559 | { |
|
|
3560 | color -= (minBrightCOLOR - minCOLOR); |
|
|
3561 | fprintf (stderr, "bright "); |
|
|
3562 | } |
|
|
3563 | #endif |
|
|
3564 | fprintf (stderr, "%s\n", name[color]); |
|
|
3565 | } |
|
|
3566 | #endif |
|
|