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 | * |
… | |
… | |
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 | * ------------------------------------------------------------------------- */ |
… | |
… | |
189 | } |
189 | } |
190 | |
190 | |
191 | if (prev_nrow == 0) |
191 | if (prev_nrow == 0) |
192 | { |
192 | { |
193 | /* |
193 | /* |
194 | * first time called so just malloc everything : don't rely on realloc |
194 | * 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 |
195 | * Note: this is still needed so that all the scrollback lines are NULL |
196 | */ |
196 | */ |
197 | screen.text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
197 | screen.text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
198 | buf_text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
198 | buf_text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
199 | drawn_text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); |
199 | drawn_text = (text_t **)rxvt_calloc (nrow, sizeof (text_t *)); |
… | |
… | |
256 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
256 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
257 | |
257 | |
258 | for (p = nrow; p < prev_nrow; p++) |
258 | for (p = nrow; p < prev_nrow; p++) |
259 | { |
259 | { |
260 | q = p + TermWin.saveLines; |
260 | q = p + TermWin.saveLines; |
|
|
261 | |
261 | if (screen.text[q]) |
262 | if (screen.text[q]) |
262 | { |
263 | { |
263 | #ifdef DEBUG_STRICT |
264 | #ifdef DEBUG_STRICT |
264 | assert (screen.rend[q]); |
265 | assert (screen.rend[q]); |
265 | #endif |
266 | #endif |
266 | talloc->free (screen.text[q]); |
267 | talloc->free (screen.text[q]); |
267 | ralloc->free (screen.rend[q]); |
268 | ralloc->free (screen.rend[q]); |
268 | } |
269 | } |
|
|
270 | |
269 | if (swap.text[p]) |
271 | if (swap.text[p]) |
270 | { |
272 | { |
271 | #ifdef DEBUG_STRICT |
273 | #ifdef DEBUG_STRICT |
272 | assert (swap.rend[p]); |
274 | assert (swap.rend[p]); |
273 | #endif |
275 | #endif |
274 | talloc->free (swap.text[p]); |
276 | talloc->free (swap.text[p]); |
275 | ralloc->free (swap.rend[p]); |
277 | ralloc->free (swap.rend[p]); |
276 | } |
278 | } |
|
|
279 | |
277 | #ifdef DEBUG_STRICT |
280 | #ifdef DEBUG_STRICT |
278 | assert (drawn_text[p] && drawn_rend[p]); |
281 | assert (drawn_text[p] && drawn_rend[p]); |
279 | #endif |
282 | #endif |
280 | talloc->free (drawn_text[p]); |
283 | talloc->free (drawn_text[p]); |
281 | ralloc->free (drawn_rend[p]); |
284 | ralloc->free (drawn_rend[p]); |
… | |
… | |
311 | swap.tlen[p] = 0; |
314 | swap.tlen[p] = 0; |
312 | swap.text[p] = NULL; |
315 | swap.text[p] = NULL; |
313 | swap.rend[p] = NULL; |
316 | swap.rend[p] = NULL; |
314 | drawn_text[p] = NULL; |
317 | drawn_text[p] = NULL; |
315 | drawn_rend[p] = NULL; |
318 | drawn_rend[p] = NULL; |
316 | scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); |
319 | scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); |
317 | scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); |
320 | scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); |
318 | } |
321 | } |
319 | |
322 | |
320 | if (k > 0) |
323 | if (k > 0) |
321 | { |
324 | { |
… | |
… | |
336 | } |
339 | } |
337 | |
340 | |
338 | /* resize columns */ |
341 | /* resize columns */ |
339 | if (ncol != prev_ncol) |
342 | if (ncol != prev_ncol) |
340 | { |
343 | { |
341 | int common = min (prev_ncol, ncol); |
|
|
342 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
344 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
343 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
345 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
344 | |
346 | |
345 | for (p = 0; p < total_rows; p++) |
347 | for (p = 0; p < total_rows; p++) |
346 | { |
348 | { |
347 | if (screen.text[p]) |
349 | if (screen.text[p]) |
348 | { |
350 | { |
349 | text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t; |
351 | 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; |
352 | screen.rend[p] = (rend_t *)ra->alloc (screen.rend[p], prev_ncol * sizeof (rend_t)); |
351 | |
353 | |
352 | MIN_IT (screen.tlen[p], (int16_t)ncol); |
354 | MIN_IT (screen.tlen[p], (int16_t)ncol); |
353 | |
355 | |
354 | if (ncol > prev_ncol) |
356 | if (ncol > prev_ncol) |
355 | scr_blank_line (& (screen.text[p][prev_ncol]), |
357 | scr_blank_line (&screen.text[p][prev_ncol], |
356 | & (screen.rend[p][prev_ncol]), |
358 | &screen.rend[p][prev_ncol], |
357 | ncol - prev_ncol, |
359 | ncol - prev_ncol, setrstyle); |
358 | setrstyle); |
|
|
359 | } |
360 | } |
360 | } |
361 | } |
361 | |
362 | |
362 | for (p = 0; p < nrow; p++) |
363 | for (p = 0; p < nrow; p++) |
363 | { |
364 | { |
364 | text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t; |
365 | 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; |
366 | drawn_rend[p] = (rend_t *)ra->alloc (drawn_rend[p], prev_ncol * sizeof (rend_t)); |
366 | |
367 | |
367 | if (ncol > prev_ncol) |
368 | if (ncol > prev_ncol) |
368 | scr_blank_line (& (drawn_text[p][prev_ncol]), |
369 | scr_blank_line (&drawn_text[p][prev_ncol], |
369 | & (drawn_rend[p][prev_ncol]), |
370 | &drawn_rend[p][prev_ncol], |
370 | ncol - prev_ncol, setrstyle); |
371 | ncol - prev_ncol, setrstyle); |
371 | |
372 | |
372 | if (swap.text[p]) |
373 | if (swap.text[p]) |
373 | { |
374 | { |
374 | text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t; |
375 | 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; |
376 | swap.rend[p] = (rend_t *)ra->alloc (swap.rend[p], prev_ncol * sizeof (rend_t)); |
376 | |
377 | |
377 | MIN_IT (swap.tlen[p], (int16_t)ncol); |
378 | MIN_IT (swap.tlen[p], (int16_t)ncol); |
378 | |
379 | |
379 | if (ncol > prev_ncol) |
380 | if (ncol > prev_ncol) |
380 | scr_blank_line (& (swap.text[p][prev_ncol]), |
381 | scr_blank_line (&swap.text[p][prev_ncol], |
381 | & (swap.rend[p][prev_ncol]), |
382 | &swap.rend[p][prev_ncol], |
382 | ncol - prev_ncol, setrstyle); |
383 | ncol - prev_ncol, setrstyle); |
383 | } |
384 | } |
384 | |
385 | |
385 | } |
386 | } |
386 | |
387 | |
… | |
… | |
476 | |
477 | |
477 | scr_release (); |
478 | scr_release (); |
478 | prev_nrow = prev_ncol = 0; |
479 | prev_nrow = prev_ncol = 0; |
479 | scr_reset (); |
480 | scr_reset (); |
480 | |
481 | |
481 | scr_clear (); |
482 | scr_clear (true); |
482 | scr_refresh (SLOW_REFRESH); |
483 | scr_refresh (SLOW_REFRESH); |
483 | } |
484 | } |
484 | |
485 | |
485 | /* ------------------------------------------------------------------------- * |
486 | /* ------------------------------------------------------------------------- * |
486 | * PROCESS SCREEN COMMANDS * |
487 | * PROCESS SCREEN COMMANDS * |
… | |
… | |
511 | s->s_cur.col = s->cur.col; |
512 | s->s_cur.col = s->cur.col; |
512 | s->s_rstyle = rstyle; |
513 | s->s_rstyle = rstyle; |
513 | s->s_charset = s->charset; |
514 | s->s_charset = s->charset; |
514 | s->s_charset_char = charsets[s->charset]; |
515 | s->s_charset_char = charsets[s->charset]; |
515 | break; |
516 | break; |
|
|
517 | |
516 | case RESTORE: |
518 | case RESTORE: |
517 | want_refresh = 1; |
519 | want_refresh = 1; |
518 | s->cur.row = s->s_cur.row; |
520 | s->cur.row = s->s_cur.row; |
519 | s->cur.col = s->s_cur.col; |
521 | s->cur.col = s->s_cur.col; |
520 | s->flags &= ~Screen_WrapNext; |
522 | s->flags &= ~Screen_WrapNext; |
… | |
… | |
708 | for (i = 0, j = row1; i < count; i++, j++) |
710 | for (i = 0, j = row1; i < count; i++, j++) |
709 | { |
711 | { |
710 | buf_text[i] = screen.text[j]; |
712 | buf_text[i] = screen.text[j]; |
711 | buf_rend[i] = screen.rend[j]; |
713 | buf_rend[i] = screen.rend[j]; |
712 | } |
714 | } |
|
|
715 | |
713 | /* A2: Rotate lines */ |
716 | /* A2: Rotate lines */ |
714 | for (j = row1, i = j + count; i <= row2; i++, j++) |
717 | for (j = row1, i = j + count; i <= row2; i++, j++) |
715 | { |
718 | { |
716 | screen.tlen[j] = screen.tlen[i]; |
719 | screen.tlen[j] = screen.tlen[i]; |
717 | screen.text[j] = screen.text[i]; |
720 | screen.text[j] = screen.text[i]; |
718 | screen.rend[j] = screen.rend[i]; |
721 | screen.rend[j] = screen.rend[i]; |
719 | } |
722 | } |
|
|
723 | |
720 | j = row2 - count + 1, i = count; |
724 | j = row2 - count + 1, i = count; |
721 | } |
725 | } |
722 | else /* if (j < 0) */ |
726 | else /* if (j < 0) */ |
723 | { |
727 | { |
724 | /* B: scroll down */ |
728 | /* B: scroll down */ |
… | |
… | |
727 | for (i = 0, j = row2; i < count; i++, j--) |
731 | for (i = 0, j = row2; i < count; i++, j--) |
728 | { |
732 | { |
729 | buf_text[i] = screen.text[j]; |
733 | buf_text[i] = screen.text[j]; |
730 | buf_rend[i] = screen.rend[j]; |
734 | buf_rend[i] = screen.rend[j]; |
731 | } |
735 | } |
|
|
736 | |
732 | /* B2: Rotate lines */ |
737 | /* B2: Rotate lines */ |
733 | for (j = row2, i = j - count; i >= row1; i--, j--) |
738 | for (j = row2, i = j - count; i >= row1; i--, j--) |
734 | { |
739 | { |
735 | screen.tlen[j] = screen.tlen[i]; |
740 | screen.tlen[j] = screen.tlen[i]; |
736 | screen.text[j] = screen.text[i]; |
741 | screen.text[j] = screen.text[i]; |
737 | screen.rend[j] = screen.rend[i]; |
742 | screen.rend[j] = screen.rend[i]; |
738 | } |
743 | } |
|
|
744 | |
739 | j = row1, i = count; |
745 | j = row1, i = count; |
740 | count = -count; |
746 | count = -count; |
741 | } |
747 | } |
742 | |
748 | |
743 | /* C: Resurrect lines */ |
749 | /* C: Resurrect lines */ |
… | |
… | |
746 | screen.tlen[j] = 0; |
752 | screen.tlen[j] = 0; |
747 | screen.text[j] = buf_text[i]; |
753 | screen.text[j] = buf_text[i]; |
748 | screen.rend[j] = buf_rend[i]; |
754 | screen.rend[j] = buf_rend[i]; |
749 | |
755 | |
750 | if (!spec) /* line length may not equal TermWin.ncol */ |
756 | if (!spec) /* line length may not equal TermWin.ncol */ |
751 | scr_blank_screen_mem (screen.text, screen.rend, |
757 | scr_blank_screen_mem (screen.text, screen.rend, (unsigned int)j, rstyle); |
752 | (unsigned int)j, rstyle); |
|
|
753 | } |
758 | } |
754 | |
759 | |
755 | return count; |
760 | return count; |
756 | } |
761 | } |
757 | |
762 | |
… | |
… | |
810 | c = *str++; |
815 | c = *str++; |
811 | |
816 | |
812 | if (c < 0x20) |
817 | if (c < 0x20) |
813 | switch (c) |
818 | switch (c) |
814 | { |
819 | { |
815 | case '\t': |
820 | case C0_HT: |
816 | scr_tab (1); |
821 | scr_tab (1); |
817 | continue; |
822 | continue; |
818 | |
823 | |
819 | case '\n': |
824 | case C0_LF: |
820 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
825 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
821 | MAX_IT (screen.tlen[row], screen.cur.col); |
826 | MAX_IT (screen.tlen[row], screen.cur.col); |
822 | |
827 | |
823 | screen.flags &= ~Screen_WrapNext; |
828 | screen.flags &= ~Screen_WrapNext; |
824 | |
829 | |
… | |
… | |
829 | |
834 | |
830 | stp = screen.text[row]; /* _must_ refresh */ |
835 | stp = screen.text[row]; /* _must_ refresh */ |
831 | srp = screen.rend[row]; /* _must_ refresh */ |
836 | srp = screen.rend[row]; /* _must_ refresh */ |
832 | continue; |
837 | continue; |
833 | |
838 | |
834 | case '\r': |
839 | case C0_CR: |
835 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
840 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
836 | MAX_IT (screen.tlen[row], screen.cur.col); |
841 | MAX_IT (screen.tlen[row], screen.cur.col); |
837 | |
842 | |
838 | screen.flags &= ~Screen_WrapNext; |
843 | screen.flags &= ~Screen_WrapNext; |
839 | screen.cur.col = 0; |
844 | screen.cur.col = 0; |
… | |
… | |
885 | c = vt100_0[c - 0x5f]; |
890 | c = vt100_0[c - 0x5f]; |
886 | width = 1; |
891 | width = 1; |
887 | } |
892 | } |
888 | } |
893 | } |
889 | |
894 | |
890 | if (width > 0) |
895 | if (width != 0) |
891 | { |
896 | { |
892 | #if !UNICODE_3 && ENABLE_COMBINING |
897 | #if !UNICODE_3 && ENABLE_COMBINING |
893 | // trim characters we can't store directly :( |
898 | // trim characters we can't store directly :( |
894 | if (c >= 0x10000) |
899 | if (c >= 0x10000) |
895 | c = rxvt_composite.compose (c); // map to lower 16 bits |
900 | c = rxvt_composite.compose (c); // map to lower 16 bits |
896 | #endif |
901 | #endif |
|
|
902 | bool bold = (Options & Opt_realBold) && ((rstyle & RS_Bold) != 0); |
897 | rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c)); |
903 | rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c, bold)); |
898 | |
904 | |
899 | do |
905 | do |
900 | { |
906 | { |
901 | stp[screen.cur.col] = c; |
907 | stp[screen.cur.col] = c; |
902 | srp[screen.cur.col] = rend; |
908 | srp[screen.cur.col] = rend; |
… | |
… | |
987 | */ |
993 | */ |
988 | void |
994 | void |
989 | rxvt_term::scr_backspace () |
995 | rxvt_term::scr_backspace () |
990 | { |
996 | { |
991 | want_refresh = 1; |
997 | want_refresh = 1; |
|
|
998 | |
992 | if (screen.cur.col == 0) |
999 | if (screen.cur.col == 0) |
993 | { |
1000 | { |
994 | if (screen.cur.row > 0) |
1001 | if (screen.cur.row > 0) |
995 | { |
1002 | { |
996 | #ifdef TERMCAP_HAS_BW |
1003 | #ifdef TERMCAP_HAS_BW |
… | |
… | |
1001 | |
1008 | |
1002 | } |
1009 | } |
1003 | } |
1010 | } |
1004 | else if ((screen.flags & Screen_WrapNext) == 0) |
1011 | else if ((screen.flags & Screen_WrapNext) == 0) |
1005 | scr_gotorc (0, -1, RELATIVE); |
1012 | scr_gotorc (0, -1, RELATIVE); |
|
|
1013 | |
1006 | screen.flags &= ~Screen_WrapNext; |
1014 | screen.flags &= ~Screen_WrapNext; |
1007 | } |
1015 | } |
1008 | |
1016 | |
1009 | /* ------------------------------------------------------------------------- */ |
1017 | /* ------------------------------------------------------------------------- */ |
1010 | /* |
1018 | /* |
… | |
… | |
1114 | want_refresh = 1; |
1122 | want_refresh = 1; |
1115 | ZERO_SCROLLBACK (); |
1123 | ZERO_SCROLLBACK (); |
1116 | |
1124 | |
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)); |
1125 | 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 | |
1126 | |
1119 | screen.cur.col = ((relative & C_RELATIVE) ? (screen.cur.col + col) |
1127 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1120 | : col); |
|
|
1121 | MAX_IT (screen.cur.col, 0); |
1128 | MAX_IT (screen.cur.col, 0); |
1122 | MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); |
1129 | MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); |
1123 | |
1130 | |
1124 | screen.flags &= ~Screen_WrapNext; |
1131 | screen.flags &= ~Screen_WrapNext; |
1125 | if (relative & R_RELATIVE) |
1132 | if (relative & R_RELATIVE) |
… | |
… | |
1164 | * direction should be UP or DN |
1171 | * direction should be UP or DN |
1165 | */ |
1172 | */ |
1166 | void |
1173 | void |
1167 | rxvt_term::scr_index (enum page_dirn direction) |
1174 | rxvt_term::scr_index (enum page_dirn direction) |
1168 | { |
1175 | { |
1169 | int dirn; |
1176 | int dirn; |
1170 | |
1177 | |
1171 | want_refresh = 1; |
1178 | want_refresh = 1; |
1172 | dirn = ((direction == UP) ? 1 : -1); |
1179 | dirn = ((direction == UP) ? 1 : -1); |
1173 | D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn)); |
1180 | D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn)); |
1174 | |
1181 | |
… | |
… | |
1234 | default: |
1241 | default: |
1235 | return; |
1242 | return; |
1236 | } |
1243 | } |
1237 | |
1244 | |
1238 | if (screen.text[row]) |
1245 | if (screen.text[row]) |
1239 | scr_blank_line (& (screen.text[row][col]), |
1246 | scr_blank_line (&screen.text[row][col], &screen.rend[row][col], num, rstyle); |
1240 | & (screen.rend[row][col]), num, rstyle); |
|
|
1241 | else |
1247 | else |
1242 | scr_blank_screen_mem (screen.text, screen.rend, row, rstyle); |
1248 | scr_blank_screen_mem (screen.text, screen.rend, row, rstyle); |
1243 | } |
1249 | } |
1244 | |
1250 | |
1245 | /* ------------------------------------------------------------------------- */ |
1251 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1517 | */ |
1523 | */ |
1518 | void |
1524 | void |
1519 | rxvt_term::scr_cursor_visible (int mode) |
1525 | rxvt_term::scr_cursor_visible (int mode) |
1520 | { |
1526 | { |
1521 | want_refresh = 1; |
1527 | want_refresh = 1; |
|
|
1528 | |
1522 | if (mode) |
1529 | if (mode) |
1523 | screen.flags |= Screen_VisibleCursor; |
1530 | screen.flags |= Screen_VisibleCursor; |
1524 | else |
1531 | else |
1525 | screen.flags &= ~Screen_VisibleCursor; |
1532 | screen.flags &= ~Screen_VisibleCursor; |
1526 | } |
1533 | } |
… | |
… | |
1741 | |
1748 | |
1742 | if (drawn_text == NULL) /* sanity check */ |
1749 | if (drawn_text == NULL) /* sanity check */ |
1743 | return; |
1750 | return; |
1744 | |
1751 | |
1745 | #ifdef DEBUG_STRICT |
1752 | #ifdef DEBUG_STRICT |
1746 | x = max (x, (int)TermWin.int_bwidth); |
1753 | x = max (x, 0); |
1747 | x = min (x, (int)TermWin.width); |
1754 | x = min (x, (int)TermWin.width); |
1748 | y = max (y, (int)TermWin.int_bwidth); |
1755 | y = max (y, 0); |
1749 | y = min (y, (int)TermWin.height); |
1756 | y = min (y, (int)TermWin.height); |
1750 | #endif |
1757 | #endif |
1751 | |
1758 | |
1752 | /* round down */ |
1759 | /* round down */ |
1753 | rc[PART_BEG].col = Pixel2Col (x); |
1760 | rc[PART_BEG].col = Pixel2Col (x); |
… | |
… | |
1764 | } |
1771 | } |
1765 | |
1772 | |
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)); |
1773 | 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 | |
1774 | |
1768 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1775 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1769 | fill_text (& (drawn_text[i][rc[PART_BEG].col]), 0, |
1776 | 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 | |
1777 | |
1772 | if (refresh) |
1778 | if (refresh) |
1773 | scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); |
1779 | scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); |
1774 | } |
1780 | } |
1775 | |
1781 | |
… | |
… | |
1842 | if (TermWin.view_start != oldviewstart) |
1848 | if (TermWin.view_start != oldviewstart) |
1843 | { |
1849 | { |
1844 | want_refresh = 1; |
1850 | want_refresh = 1; |
1845 | num_scr -= (TermWin.view_start - oldviewstart); |
1851 | num_scr -= (TermWin.view_start - oldviewstart); |
1846 | } |
1852 | } |
|
|
1853 | |
1847 | return (int) (TermWin.view_start - oldviewstart); |
1854 | return (int) (TermWin.view_start - oldviewstart); |
1848 | } |
1855 | } |
1849 | |
1856 | |
1850 | /* ------------------------------------------------------------------------- */ |
1857 | /* ------------------------------------------------------------------------- */ |
1851 | void |
1858 | void |
… | |
… | |
2200 | rend = GET_ATTR (rend); |
2207 | rend = GET_ATTR (rend); |
2201 | |
2208 | |
2202 | rvid = !!(rend & RS_RVid); |
2209 | rvid = !!(rend & RS_RVid); |
2203 | |
2210 | |
2204 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2211 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2205 | if (rend & RS_Bold && fore == Color_fg) |
2212 | if (rend & RS_Bold && fore == Color_fg && !(Options & Opt_realBold)) |
2206 | { |
2213 | { |
2207 | if (ISSET_PIXCOLOR (Color_BD)) |
2214 | if (ISSET_PIXCOLOR (Color_BD)) |
2208 | fore = Color_BD; |
2215 | fore = Color_BD; |
2209 | else |
2216 | else |
2210 | rvid = !rvid; |
2217 | rvid = !rvid; |
… | |
… | |
2316 | scr_reverse_selection (); |
2323 | scr_reverse_selection (); |
2317 | |
2324 | |
2318 | /* |
2325 | /* |
2319 | * I: other general cleanup |
2326 | * I: other general cleanup |
2320 | */ |
2327 | */ |
|
|
2328 | #if 0 |
2321 | if (clearfirst && TermWin.int_bwidth) |
2329 | if (clearfirst && TermWin.int_bwidth) |
2322 | /* |
2330 | /* |
2323 | * clear the whole screen height, note that width == 0 is treated |
2331 | * clear the whole screen height, note that width == 0 is treated |
2324 | * specially by XClearArea |
2332 | * specially by XClearArea |
2325 | */ |
2333 | */ |
… | |
… | |
2334 | */ |
2342 | */ |
2335 | XClearArea (display->display, TermWin.vt, |
2343 | XClearArea (display->display, TermWin.vt, |
2336 | TermWin.width + TermWin.int_bwidth, 0, |
2344 | TermWin.width + TermWin.int_bwidth, 0, |
2337 | (unsigned int)TermWin.int_bwidth, |
2345 | (unsigned int)TermWin.int_bwidth, |
2338 | (unsigned int)TermWin_TotalHeight (), False); |
2346 | (unsigned int)TermWin_TotalHeight (), False); |
|
|
2347 | #endif |
2339 | |
2348 | |
2340 | if (refresh_type & SMOOTH_REFRESH) |
2349 | if (refresh_type & SMOOTH_REFRESH) |
2341 | XSync (display->display, False); |
2350 | XSync (display->display, False); |
2342 | |
2351 | |
2343 | num_scr = 0; |
2352 | num_scr = 0; |
… | |
… | |
2517 | { |
2526 | { |
2518 | n = min (len - i, PROP_SIZE); |
2527 | n = min (len - i, PROP_SIZE); |
2519 | MEMCPY (ds, data + i, n); |
2528 | MEMCPY (ds, data + i, n); |
2520 | |
2529 | |
2521 | for (j = 0; j < n; j++) |
2530 | for (j = 0; j < n; j++) |
2522 | if (ds[j] == '\n') |
2531 | if (ds[j] == C0_LF) |
2523 | ds[j] = '\r'; |
2532 | ds[j] = C0_CR; |
2524 | |
2533 | |
2525 | tt_write (ds, (int)n); |
2534 | tt_write (ds, (int)n); |
2526 | } |
2535 | } |
2527 | |
2536 | |
2528 | free (ds); |
2537 | free (ds); |
… | |
… | |
2609 | |
2618 | |
2610 | nread += ct.nitems; |
2619 | nread += ct.nitems; |
2611 | |
2620 | |
2612 | char **cl; |
2621 | char **cl; |
2613 | int cr; |
2622 | int cr; |
2614 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, |
2623 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 && cl) |
2615 | &cr) >= 0 && cl) |
|
|
2616 | { |
2624 | { |
2617 | for (int i = 0; i < cr; i++) |
2625 | for (int i = 0; i < cr; i++) |
2618 | paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
2626 | paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
2619 | |
2627 | |
2620 | XFreeStringList (cl); |
2628 | XFreeStringList (cl); |
… | |
… | |
2879 | else |
2887 | else |
2880 | new_selection_text[ofs++] = *t++; |
2888 | new_selection_text[ofs++] = *t++; |
2881 | } |
2889 | } |
2882 | |
2890 | |
2883 | if (screen.tlen[row] != -1 && row != end_row) |
2891 | if (screen.tlen[row] != -1 && row != end_row) |
2884 | new_selection_text[ofs++] = L'\n'; |
2892 | new_selection_text[ofs++] = C0_LF; |
2885 | } |
2893 | } |
2886 | |
2894 | |
2887 | if (end_col != selection.end.col) |
2895 | if (end_col != selection.end.col) |
2888 | new_selection_text[ofs++] = L'\n'; |
2896 | new_selection_text[ofs++] = C0_LF; |
2889 | |
2897 | |
2890 | new_selection_text[ofs] = 0; |
2898 | new_selection_text[ofs] = 0; |
2891 | |
2899 | |
2892 | if (ofs == 0) |
2900 | if (ofs == 0) |
2893 | { |
2901 | { |
… | |
… | |
3120 | * Extend the selection to the specified col/row |
3128 | * Extend the selection to the specified col/row |
3121 | */ |
3129 | */ |
3122 | void |
3130 | void |
3123 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) |
3131 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) |
3124 | { |
3132 | { |
3125 | int16_t ncol = TermWin.ncol; |
3133 | int16_t ncol = TermWin.ncol; |
3126 | int end_col; |
3134 | int end_col; |
3127 | row_col_t pos; |
3135 | row_col_t pos; |
3128 | enum { |
3136 | enum { |
3129 | LEFT, RIGHT |
3137 | LEFT, RIGHT |
3130 | } closeto = RIGHT; |
3138 | } closeto = RIGHT; |
3131 | |
3139 | |
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)); |
3140 | 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)); |
… | |
… | |
3515 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3523 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3516 | } |
3524 | } |
3517 | |
3525 | |
3518 | #endif |
3526 | #endif |
3519 | /* ------------------------------------------------------------------------- */ |
3527 | /* ------------------------------------------------------------------------- */ |
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 |
|
|