1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.c |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * $Id: screen.C,v 1.8 2003/12/17 09:00:35 pcg Exp $ |
4 | * $Id: screen.C,v 1.16 2004/01/16 22:11:09 pcg Exp $ |
5 | * |
5 | * |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
89 | /* |
89 | /* |
90 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
90 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
91 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
91 | * 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 |
92 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
93 | */ |
93 | */ |
94 | #define drawBuffer (R->TermWin.vt) |
94 | #define drawBuffer TermWin.vt |
95 | |
95 | |
96 | #define CLEAR_ROWS(row, num) \ |
96 | #define CLEAR_ROWS(row, num) \ |
97 | if (R->TermWin.mapped) \ |
97 | if (TermWin.mapped) \ |
98 | XClearArea(R->Xdisplay, drawBuffer, R->TermWin.int_bwidth, \ |
98 | XClearArea (Xdisplay, drawBuffer, TermWin.int_bwidth, \ |
99 | Row2Pixel(row), (unsigned int)R->TermWin.width, \ |
99 | Row2Pixel(row), (unsigned int)TermWin.width, \ |
100 | (unsigned int)Height2Pixel(num), False) |
100 | (unsigned int)Height2Pixel(num), False) |
101 | |
101 | |
102 | #define CLEAR_CHARS(x, y, num) \ |
102 | #define CLEAR_CHARS(x, y, num) \ |
103 | if (R->TermWin.mapped) \ |
103 | if (TermWin.mapped) \ |
104 | XClearArea(R->Xdisplay, drawBuffer, x, y, \ |
104 | XClearArea (Xdisplay, drawBuffer, x, y, \ |
105 | (unsigned int)Width2Pixel(num), \ |
105 | (unsigned int)Width2Pixel(num), \ |
106 | (unsigned int)Height2Pixel(1), False) |
106 | (unsigned int)Height2Pixel(1), False) |
107 | |
107 | |
108 | #define ERASE_ROWS(row, num) \ |
108 | #define ERASE_ROWS(row, num) \ |
109 | XFillRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, \ |
109 | XFillRectangle (Xdisplay, drawBuffer, TermWin.gc, \ |
110 | R->TermWin.int_bwidth, Row2Pixel(row), \ |
110 | TermWin.int_bwidth, Row2Pixel(row), \ |
111 | (unsigned int)R->TermWin.width, \ |
111 | (unsigned int)TermWin.width, \ |
112 | (unsigned int)Height2Pixel(num)) |
112 | (unsigned int)Height2Pixel(num)) |
113 | |
113 | |
114 | /* ------------------------------------------------------------------------- * |
114 | /* ------------------------------------------------------------------------- * |
115 | * SCREEN `COMMON' ROUTINES * |
115 | * SCREEN `COMMON' ROUTINES * |
116 | * ------------------------------------------------------------------------- */ |
116 | * ------------------------------------------------------------------------- */ |
117 | /* Fill part/all of a line with blanks. */ |
117 | /* Fill part/all of a line with blanks. */ |
… | |
… | |
227 | #if NSCREENS |
227 | #if NSCREENS |
228 | swap.flags = Screen_DefaultFlags; |
228 | swap.flags = Screen_DefaultFlags; |
229 | swap.cur.row = swap.cur.col = 0; |
229 | swap.cur.row = swap.cur.col = 0; |
230 | swap.charset = 0; |
230 | swap.charset = 0; |
231 | current_screen = SECONDARY; |
231 | current_screen = SECONDARY; |
232 | rxvt_scr_cursor(aR_ SAVE); |
232 | rxvt_scr_cursor (this, SAVE); |
233 | current_screen = PRIMARY; |
233 | current_screen = PRIMARY; |
234 | #endif |
234 | #endif |
235 | |
235 | |
236 | selection.text = NULL; |
236 | selection.text = NULL; |
237 | selection.len = 0; |
237 | selection.len = 0; |
… | |
… | |
289 | else if (nrow > prev_nrow) |
289 | else if (nrow > prev_nrow) |
290 | { |
290 | { |
291 | /* add rows */ |
291 | /* add rows */ |
292 | scr_reset_realloc (); /* realloc _first_ */ |
292 | scr_reset_realloc (); /* realloc _first_ */ |
293 | |
293 | |
294 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
294 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
295 | |
295 | |
296 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
296 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
297 | |
297 | |
298 | for (p = prev_total_rows; p < total_rows; p++) |
298 | for (p = prev_total_rows; p < total_rows; p++) |
299 | { |
299 | { |
… | |
… | |
447 | /* then so is screen.rend[i] */ |
447 | /* then so is screen.rend[i] */ |
448 | assert(screen.rend[i]); |
448 | assert(screen.rend[i]); |
449 | } |
449 | } |
450 | #endif |
450 | #endif |
451 | |
451 | |
452 | delete talloc; |
452 | delete talloc; talloc = 0; |
453 | delete ralloc; |
453 | delete ralloc; ralloc = 0; |
454 | |
454 | |
455 | free (screen.text); |
455 | free (screen.text); |
456 | free (screen.tlen); |
456 | free (screen.tlen); |
457 | free (screen.rend); |
457 | free (screen.rend); |
458 | free (drawn_text); |
458 | free (drawn_text); |
… | |
… | |
485 | |
485 | |
486 | R->scr_release (); |
486 | R->scr_release (); |
487 | R->prev_nrow = R->prev_ncol = 0; |
487 | R->prev_nrow = R->prev_ncol = 0; |
488 | R->scr_reset (); |
488 | R->scr_reset (); |
489 | |
489 | |
490 | rxvt_scr_clear (aR); |
490 | R->scr_clear (); |
491 | rxvt_scr_refresh (aR_ SLOW_REFRESH); |
491 | R->scr_refresh (SLOW_REFRESH); |
492 | #ifdef RXVT_GRAPHICS |
492 | #ifdef RXVT_GRAPHICS |
493 | rxvt_Gr_reset (aR); |
493 | rxvt_Gr_reset (aR); |
494 | #endif |
494 | #endif |
495 | } |
495 | } |
496 | |
496 | |
… | |
… | |
899 | case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; |
899 | case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; |
900 | case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
900 | case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
901 | } |
901 | } |
902 | |
902 | |
903 | rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); |
903 | rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); |
|
|
904 | // rely on wcwidth to tell us the character width, at least for non-ascii |
|
|
905 | int width = c <= 128 ? 1 : wcwidth (c); |
904 | |
906 | |
905 | stp[R->screen.cur.col] = c; |
907 | // width 0 characters (e.g. combining chars) are ignored. your problem, really |
906 | srp[R->screen.cur.col] = rend; |
908 | while (width-- > 0) |
907 | |
|
|
908 | if (c > 255) |
|
|
909 | { |
909 | { |
910 | // rely on wcwidth to tell us the character width, at least for non iso-8859-1 |
910 | stp[R->screen.cur.col] = c; |
911 | int width = wcwidth (c); |
911 | srp[R->screen.cur.col] = rend; |
|
|
912 | |
|
|
913 | if (R->screen.cur.col < last_col - 1) |
|
|
914 | R->screen.cur.col++; |
912 | |
915 | else |
913 | if (width > 1) |
|
|
914 | { |
916 | { |
915 | while (--width > 0 && R->screen.cur.col < last_col - 1) |
917 | R->screen.tlen[row] = last_col; |
|
|
918 | if (R->screen.flags & Screen_Autowrap) |
|
|
919 | R->screen.flags |= Screen_WrapNext; |
916 | { |
920 | break; |
917 | |
|
|
918 | srp[R->screen.cur.col] |= RS_wide; |
|
|
919 | |
|
|
920 | R->screen.cur.col++; |
|
|
921 | stp[R->screen.cur.col] = NOCHAR; |
|
|
922 | srp[R->screen.cur.col] = rend; |
|
|
923 | } |
|
|
924 | } |
921 | } |
|
|
922 | |
|
|
923 | c = NOCHAR; |
925 | } |
924 | } |
926 | |
|
|
927 | if (R->screen.cur.col < last_col - 1) |
|
|
928 | R->screen.cur.col++; |
|
|
929 | else { |
|
|
930 | R->screen.tlen[row] = last_col; |
|
|
931 | if (R->screen.flags & Screen_Autowrap) |
|
|
932 | R->screen.flags |= Screen_WrapNext; |
|
|
933 | } |
|
|
934 | } |
925 | } |
935 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
926 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
936 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
927 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
937 | |
928 | |
938 | /* |
929 | /* |
… | |
… | |
1211 | * Erase part of whole of the screen |
1202 | * Erase part of whole of the screen |
1212 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1203 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1213 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1204 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1214 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1205 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1215 | */ |
1206 | */ |
1216 | /* EXTPROTO */ |
|
|
1217 | void |
1207 | void |
1218 | rxvt_scr_erase_screen(pR_ int mode) |
1208 | rxvt_term::scr_erase_screen (int mode) |
1219 | { |
1209 | { |
1220 | int num; |
1210 | int num; |
1221 | int32_t row, row_offset; |
1211 | int32_t row, row_offset; |
1222 | rend_t ren; |
1212 | rend_t ren; |
1223 | XGCValues gcvalue; |
1213 | XGCValues gcvalue; |
1224 | |
1214 | |
1225 | R->want_refresh = 1; |
1215 | want_refresh = 1; |
1226 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); |
1216 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row)); |
1227 | ZERO_SCROLLBACK(R); |
1217 | ZERO_SCROLLBACK(this); |
1228 | row_offset = (int32_t)R->TermWin.saveLines; |
1218 | row_offset = (int32_t)TermWin.saveLines; |
1229 | |
1219 | |
1230 | switch (mode) { |
1220 | switch (mode) { |
1231 | case 0: /* erase to end of screen */ |
1221 | case 0: /* erase to end of screen */ |
1232 | rxvt_selection_check(aR_ 1); |
1222 | rxvt_selection_check(this,1); |
1233 | rxvt_scr_erase_line(aR_ 0); |
1223 | rxvt_scr_erase_line(this,0); |
1234 | row = R->screen.cur.row + 1; /* possible OOB */ |
1224 | row = screen.cur.row + 1; /* possible OOB */ |
1235 | num = R->TermWin.nrow - row; |
1225 | num = TermWin.nrow - row; |
1236 | break; |
1226 | break; |
1237 | case 1: /* erase to beginning of screen */ |
1227 | case 1: /* erase to beginning of screen */ |
1238 | rxvt_selection_check(aR_ 3); |
1228 | rxvt_selection_check(this,3); |
1239 | rxvt_scr_erase_line(aR_ 1); |
1229 | rxvt_scr_erase_line(this,1); |
1240 | row = 0; |
1230 | row = 0; |
1241 | num = R->screen.cur.row; |
1231 | num = screen.cur.row; |
1242 | break; |
1232 | break; |
1243 | case 2: /* erase whole screen */ |
1233 | case 2: /* erase whole screen */ |
1244 | rxvt_selection_check(aR_ 3); |
1234 | rxvt_selection_check (this, 3); |
1245 | #ifdef RXVT_GRAPHICS |
1235 | #ifdef RXVT_GRAPHICS |
1246 | rxvt_Gr_ClearScreen(aR); |
1236 | rxvt_Gr_ClearScreen (this); |
1247 | #endif |
1237 | #endif |
1248 | row = 0; |
1238 | row = 0; |
1249 | num = R->TermWin.nrow; |
1239 | num = TermWin.nrow; |
1250 | break; |
1240 | break; |
1251 | default: |
1241 | default: |
1252 | return; |
1242 | return; |
1253 | } |
1243 | } |
1254 | R->refresh_type |= REFRESH_BOUNDS; |
1244 | refresh_type |= REFRESH_BOUNDS; |
1255 | if (R->selection.op && R->current_screen == R->selection.screen |
1245 | if (selection.op && current_screen == selection.screen |
1256 | && ((R->selection.beg.row >= row && R->selection.beg.row <= row + num) |
1246 | && ((selection.beg.row >= row && selection.beg.row <= row + num) |
1257 | || (R->selection.end.row >= row |
1247 | || (selection.end.row >= row |
1258 | && R->selection.end.row <= row + num))) |
1248 | && selection.end.row <= row + num))) |
1259 | CLEAR_SELECTION(R); |
1249 | CLEAR_SELECTION (this); |
1260 | if (row >= R->TermWin.nrow) /* Out Of Bounds */ |
1250 | if (row >= TermWin.nrow) /* Out Of Bounds */ |
1261 | return; |
1251 | return; |
1262 | MIN_IT(num, (R->TermWin.nrow - row)); |
1252 | MIN_IT(num, (TermWin.nrow - row)); |
1263 | if (R->rstyle & (RS_RVid | RS_Uline)) |
1253 | if (rstyle & (RS_RVid | RS_Uline)) |
1264 | ren = (rend_t) ~RS_None; |
1254 | ren = (rend_t) ~RS_None; |
1265 | else if (GET_BASEBG(R->rstyle) == Color_bg) { |
1255 | else if (GET_BASEBG(rstyle) == Color_bg) { |
1266 | ren = DEFAULT_RSTYLE; |
1256 | ren = DEFAULT_RSTYLE; |
1267 | CLEAR_ROWS(row, num); |
1257 | CLEAR_ROWS(row, num); |
1268 | } else { |
1258 | } else { |
1269 | ren = (R->rstyle & (RS_fgMask | RS_bgMask)); |
1259 | ren = (rstyle & (RS_fgMask | RS_bgMask)); |
1270 | gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->rstyle)]; |
1260 | gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)]; |
1271 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1261 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1272 | ERASE_ROWS(row, num); |
1262 | ERASE_ROWS(row, num); |
1273 | gcvalue.foreground = R->PixColors[Color_fg]; |
1263 | gcvalue.foreground = PixColors[Color_fg]; |
1274 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1264 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1275 | } |
1265 | } |
1276 | for (; num--; row++) { |
1266 | for (; num--; row++) { |
1277 | R->scr_blank_screen_mem (R->screen.text, R->screen.rend, |
1267 | scr_blank_screen_mem (screen.text, screen.rend, |
1278 | (unsigned int)(row + row_offset), R->rstyle); |
1268 | (unsigned int)(row + row_offset), rstyle); |
1279 | R->screen.tlen[row + row_offset] = 0; |
1269 | screen.tlen[row + row_offset] = 0; |
1280 | R->scr_blank_line (R->drawn_text[row], R->drawn_rend[row], |
1270 | scr_blank_line (drawn_text[row], drawn_rend[row], |
1281 | (unsigned int)R->TermWin.ncol, ren); |
1271 | (unsigned int)TermWin.ncol, ren); |
1282 | } |
1272 | } |
1283 | } |
1273 | } |
1284 | |
1274 | |
1285 | /* ------------------------------------------------------------------------- */ |
1275 | /* ------------------------------------------------------------------------- */ |
1286 | /* |
1276 | /* |
… | |
… | |
1570 | |
1560 | |
1571 | gcvalue.foreground = R->PixColors[Color_fg]; |
1561 | gcvalue.foreground = R->PixColors[Color_fg]; |
1572 | gcvalue.background = R->PixColors[Color_bg]; |
1562 | gcvalue.background = R->PixColors[Color_bg]; |
1573 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1563 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1574 | &gcvalue); |
1564 | &gcvalue); |
1575 | rxvt_scr_clear(aR); |
1565 | R->scr_clear (); |
1576 | rxvt_scr_touch(aR_ True); |
1566 | R->scr_touch (true); |
1577 | } |
1567 | } |
1578 | } |
1568 | } |
1579 | |
1569 | |
1580 | /* ------------------------------------------------------------------------- */ |
1570 | /* ------------------------------------------------------------------------- */ |
1581 | /* |
1571 | /* |
… | |
… | |
1684 | PART_BEG = 0, |
1674 | PART_BEG = 0, |
1685 | PART_END, |
1675 | PART_END, |
1686 | RC_COUNT |
1676 | RC_COUNT |
1687 | }; |
1677 | }; |
1688 | |
1678 | |
1689 | /* EXTPROTO */ |
|
|
1690 | void |
1679 | void |
1691 | rxvt_scr_expose(pR_ int x, int y, int width, int height, Bool refresh) |
1680 | rxvt_term::scr_expose (int x, int y, int width, int height, bool refresh) |
1692 | { |
1681 | { |
1693 | int i; |
1682 | int i; |
1694 | row_col_t rc[RC_COUNT]; |
1683 | row_col_t rc[RC_COUNT]; |
1695 | |
1684 | |
1696 | if (R->drawn_text == NULL) /* sanity check */ |
1685 | if (drawn_text == NULL) /* sanity check */ |
1697 | return; |
1686 | return; |
1698 | |
1687 | |
1699 | #ifdef DEBUG_STRICT |
1688 | #ifdef DEBUG_STRICT |
1700 | x = max(x, (int)R->TermWin.int_bwidth); |
1689 | x = max(x, (int)TermWin.int_bwidth); |
1701 | x = min(x, (int)R->TermWin.width); |
1690 | x = min(x, (int)TermWin.width); |
1702 | y = max(y, (int)R->TermWin.int_bwidth); |
1691 | y = max(y, (int)TermWin.int_bwidth); |
1703 | y = min(y, (int)R->TermWin.height); |
1692 | y = min(y, (int)TermWin.height); |
1704 | #endif |
1693 | #endif |
1705 | |
1694 | |
1706 | /* round down */ |
1695 | /* round down */ |
1707 | rc[PART_BEG].col = Pixel2Col(x); |
1696 | rc[PART_BEG].col = Pixel2Col(x); |
1708 | rc[PART_BEG].row = Pixel2Row(y); |
1697 | rc[PART_BEG].row = Pixel2Row(y); |
1709 | /* round up */ |
1698 | /* round up */ |
1710 | rc[PART_END].col = Pixel2Width(x + width + R->TermWin.fwidth - 1); |
1699 | rc[PART_END].col = Pixel2Width(x + width + TermWin.fwidth - 1); |
1711 | rc[PART_END].row = Pixel2Row(y + height + R->TermWin.fheight - 1); |
1700 | rc[PART_END].row = Pixel2Row(y + height + TermWin.fheight - 1); |
1712 | |
1701 | |
1713 | /* sanity checks */ |
1702 | /* sanity checks */ |
1714 | for (i = PART_BEG; i < RC_COUNT; i++) { |
1703 | for (i = PART_BEG; i < RC_COUNT; i++) |
|
|
1704 | { |
1715 | MIN_IT(rc[i].col, R->TermWin.ncol - 1); |
1705 | MIN_IT(rc[i].col, TermWin.ncol - 1); |
1716 | MIN_IT(rc[i].row, R->TermWin.nrow - 1); |
1706 | MIN_IT(rc[i].row, TermWin.nrow - 1); |
1717 | } |
1707 | } |
1718 | |
1708 | |
1719 | 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)); |
1709 | 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)); |
1720 | |
1710 | |
1721 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1711 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1722 | fill_text (&(R->drawn_text[i][rc[PART_BEG].col]), 0, |
1712 | fill_text (&(drawn_text[i][rc[PART_BEG].col]), 0, |
1723 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1713 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1724 | |
1714 | |
1725 | if (refresh) |
1715 | if (refresh) |
1726 | rxvt_scr_refresh(aR_ SLOW_REFRESH | REFRESH_BOUNDS); |
1716 | scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); |
1727 | } |
1717 | } |
1728 | |
1718 | |
1729 | /* ------------------------------------------------------------------------- */ |
1719 | /* ------------------------------------------------------------------------- */ |
1730 | /* |
1720 | /* |
1731 | * Refresh the entire screen |
1721 | * Refresh the entire screen |
1732 | */ |
1722 | */ |
1733 | /* EXTPROTO */ |
|
|
1734 | void |
1723 | void |
1735 | rxvt_scr_touch(pR_ Bool refresh) |
1724 | rxvt_term::scr_touch (bool refresh) |
1736 | { |
1725 | { |
1737 | rxvt_scr_expose(aR_ 0, 0, R->TermWin.width, R->TermWin.height, refresh); |
1726 | scr_expose (0, 0, TermWin.width, TermWin.height, refresh); |
1738 | } |
1727 | } |
1739 | |
1728 | |
1740 | /* ------------------------------------------------------------------------- */ |
1729 | /* ------------------------------------------------------------------------- */ |
1741 | /* |
1730 | /* |
1742 | * Move the display so that the line represented by scrollbar value Y is at |
1731 | * Move the display so that the line represented by scrollbar value Y is at |
… | |
… | |
1879 | #define FONT_LBEAR(X, Y) \ |
1868 | #define FONT_LBEAR(X, Y) \ |
1880 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1869 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1881 | #define IS_FONT_CHAR(X, Y) \ |
1870 | #define IS_FONT_CHAR(X, Y) \ |
1882 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1871 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1883 | |
1872 | |
1884 | /* EXTPROTO */ |
|
|
1885 | void |
1873 | void |
1886 | rxvt_scr_refresh(pR_ unsigned char refresh_type) |
1874 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1887 | { |
1875 | { |
1888 | unsigned char clearfirst, /* first character writes before cell */ |
1876 | unsigned char clearfirst, /* first character writes before cell */ |
1889 | clearlast, /* last character writes beyond cell */ |
1877 | clearlast, /* last character writes beyond cell */ |
1890 | must_clear, /* use draw_string not draw_image_string */ |
1878 | must_clear, /* use draw_string not draw_image_string */ |
1891 | #ifndef NO_BOLDFONT |
1879 | #ifndef NO_BOLDFONT |
… | |
… | |
1904 | rend_t cc1; /* store colours at cursor position(s) */ |
1892 | rend_t cc1; /* store colours at cursor position(s) */ |
1905 | rend_t cc2; /* store colours at cursor position(s) */ |
1893 | rend_t cc2; /* store colours at cursor position(s) */ |
1906 | #endif |
1894 | #endif |
1907 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1895 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1908 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1896 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1909 | char *buffer; /* local copy of R->buffer */ |
|
|
1910 | |
1897 | |
1911 | if (refresh_type == NO_REFRESH || !R->TermWin.mapped) |
1898 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1912 | return; |
1899 | return; |
1913 | |
1900 | |
1914 | /* |
1901 | /* |
1915 | * A: set up vars |
1902 | * A: set up vars |
1916 | */ |
1903 | */ |
1917 | clearfirst = clearlast = must_clear = wbyte = 0; |
1904 | clearfirst = clearlast = must_clear = wbyte = 0; |
1918 | #ifndef NO_BOLDFONT |
1905 | #ifndef NO_BOLDFONT |
1919 | bfont = 0; |
1906 | bfont = 0; |
1920 | #endif |
1907 | #endif |
1921 | |
1908 | |
1922 | if (R->currmaxcol < R->TermWin.ncol) |
1909 | if (currmaxcol < TermWin.ncol) |
1923 | { |
1910 | { |
1924 | R->currmaxcol = R->TermWin.ncol; |
1911 | currmaxcol = TermWin.ncol; |
1925 | R->buffer = (char *)rxvt_realloc (R->buffer, |
1912 | buffer = (char *)rxvt_realloc (buffer, |
1926 | sizeof(char) * (R->currmaxcol + 1) * MB_CUR_MAX); |
1913 | sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); |
1927 | } |
1914 | } |
1928 | |
1915 | |
1929 | buffer = R->buffer; |
|
|
1930 | R->refresh_count = 0; |
1916 | refresh_count = 0; |
1931 | |
1917 | |
1932 | row_offset = R->TermWin.saveLines - R->TermWin.view_start; |
1918 | row_offset = TermWin.saveLines - TermWin.view_start; |
1933 | |
1919 | |
1934 | if ((refresh_type & REFRESH_BOUNDS)) |
1920 | if ((refresh_type & REFRESH_BOUNDS)) |
1935 | { |
1921 | { |
1936 | clearfirst = clearlast = 1; |
1922 | clearfirst = clearlast = 1; |
1937 | R->refresh_type &= ~REFRESH_BOUNDS; |
1923 | refresh_type &= ~REFRESH_BOUNDS; |
1938 | } |
1924 | } |
1939 | |
1925 | |
1940 | #if defined(XPM_BACKGROUND) |
1926 | #if defined(XPM_BACKGROUND) |
1941 | must_clear |= (R->bgPixmap.pixmap != None); |
1927 | must_clear |= (bgPixmap.pixmap != None); |
1942 | #endif |
1928 | #endif |
1943 | #if defined(TRANSPARENT) |
1929 | #if defined(TRANSPARENT) |
1944 | must_clear |= ((R->Options & Opt_transparent) && R->am_transparent); |
1930 | must_clear |= ((Options & Opt_transparent) && am_transparent); |
1945 | #endif |
1931 | #endif |
1946 | ocrow = R->oldcursor.row; /* is there an old outline cursor on screen? */ |
1932 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1947 | |
1933 | |
1948 | /* |
1934 | /* |
1949 | * B: reverse any characters which are selected |
1935 | * B: reverse any characters which are selected |
1950 | */ |
1936 | */ |
1951 | rxvt_scr_reverse_selection(aR); |
1937 | rxvt_scr_reverse_selection (this); |
1952 | |
1938 | |
1953 | /* |
1939 | /* |
1954 | * C: set the cursor character(s) |
1940 | * C: set the cursor character(s) |
1955 | */ |
1941 | */ |
1956 | { |
1942 | { |
1957 | unsigned char setoldcursor; |
1943 | unsigned char setoldcursor; |
1958 | rend_t ccol1, /* Cursor colour */ |
1944 | rend_t ccol1, /* Cursor colour */ |
1959 | ccol2; /* Cursor colour2 */ |
1945 | ccol2; /* Cursor colour2 */ |
1960 | |
1946 | |
1961 | showcursor = (R->screen.flags & Screen_VisibleCursor); |
1947 | showcursor = (screen.flags & Screen_VisibleCursor); |
1962 | cursorwidth = 0; |
1948 | cursorwidth = 0; |
1963 | #ifdef CURSOR_BLINK |
1949 | #ifdef CURSOR_BLINK |
1964 | if (R->hidden_cursor) |
1950 | if (hidden_cursor) |
1965 | showcursor = 0; |
1951 | showcursor = 0; |
1966 | #endif |
1952 | #endif |
1967 | |
1953 | |
1968 | cursorwidth = 0; |
1954 | cursorwidth = 0; |
1969 | |
1955 | |
1970 | if (showcursor) |
1956 | if (showcursor) |
1971 | { |
1957 | { |
1972 | cursorwidth++; |
1958 | cursorwidth++; |
1973 | |
1959 | |
1974 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
1960 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
1975 | [R->screen.cur.col]); |
1961 | [screen.cur.col]); |
1976 | |
1962 | |
1977 | if (showcursor && R->TermWin.focus) |
1963 | if (showcursor && TermWin.focus) |
1978 | { |
1964 | { |
1979 | *srp ^= RS_RVid; |
1965 | *srp ^= RS_RVid; |
1980 | #ifndef NO_CURSORCOLOR |
1966 | #ifndef NO_CURSORCOLOR |
1981 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1967 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1982 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) |
1968 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
1983 | ccol1 = Color_cursor; |
1969 | ccol1 = Color_cursor; |
1984 | else |
1970 | else |
1985 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1971 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1986 | ccol1 = GET_FGCOLOR(R->rstyle); |
1972 | ccol1 = GET_FGCOLOR(rstyle); |
1987 | #else |
1973 | #else |
1988 | ccol1 = Color_fg; |
1974 | ccol1 = Color_fg; |
1989 | #endif |
1975 | #endif |
1990 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor2)) |
1976 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor2)) |
1991 | ccol2 = Color_cursor2; |
1977 | ccol2 = Color_cursor2; |
1992 | else |
1978 | else |
1993 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1979 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1994 | ccol2 = GET_BGCOLOR(R->rstyle); |
1980 | ccol2 = GET_BGCOLOR(rstyle); |
1995 | #else |
1981 | #else |
1996 | ccol2 = Color_bg; |
1982 | ccol2 = Color_bg; |
1997 | #endif |
1983 | #endif |
1998 | *srp = SET_FGCOLOR(*srp, ccol1); |
1984 | *srp = SET_FGCOLOR(*srp, ccol1); |
1999 | *srp = SET_BGCOLOR(*srp, ccol2); |
1985 | *srp = SET_BGCOLOR(*srp, ccol2); |
… | |
… | |
2005 | } |
1991 | } |
2006 | |
1992 | |
2007 | /* make sure no outline cursor is left around */ |
1993 | /* make sure no outline cursor is left around */ |
2008 | setoldcursor = 0; |
1994 | setoldcursor = 0; |
2009 | if (ocrow != -1) { |
1995 | if (ocrow != -1) { |
2010 | if (R->screen.cur.row + R->TermWin.view_start != ocrow |
1996 | if (screen.cur.row + TermWin.view_start != ocrow |
2011 | || R->screen.cur.col != R->oldcursor.col) { |
1997 | || screen.cur.col != oldcursor.col) { |
2012 | if (ocrow < R->TermWin.nrow |
1998 | if (ocrow < TermWin.nrow |
2013 | && R->oldcursor.col < R->TermWin.ncol) { |
1999 | && oldcursor.col < TermWin.ncol) { |
2014 | R->drawn_rend[ocrow][R->oldcursor.col] ^= (RS_RVid | RS_Uline); |
2000 | drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); |
2015 | } |
2001 | } |
2016 | if (R->TermWin.focus || !showcursor) |
2002 | if (TermWin.focus || !showcursor) |
2017 | R->oldcursor.row = -1; |
2003 | oldcursor.row = -1; |
2018 | else |
2004 | else |
2019 | setoldcursor = 1; |
2005 | setoldcursor = 1; |
2020 | } |
2006 | } |
2021 | } else if (!R->TermWin.focus) |
2007 | } else if (!TermWin.focus) |
2022 | setoldcursor = 1; |
2008 | setoldcursor = 1; |
2023 | if (setoldcursor) { |
2009 | if (setoldcursor) { |
2024 | if (R->screen.cur.row + R->TermWin.view_start >= R->TermWin.nrow) |
2010 | if (screen.cur.row + TermWin.view_start >= TermWin.nrow) |
2025 | R->oldcursor.row = -1; |
2011 | oldcursor.row = -1; |
2026 | else { |
2012 | else { |
2027 | R->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; |
2013 | oldcursor.row = screen.cur.row + TermWin.view_start; |
2028 | R->oldcursor.col = R->screen.cur.col; |
2014 | oldcursor.col = screen.cur.col; |
2029 | } |
2015 | } |
2030 | } |
2016 | } |
2031 | } |
2017 | } |
2032 | |
2018 | |
2033 | #ifndef NO_SLOW_LINK_SUPPORT |
2019 | #ifndef NO_SLOW_LINK_SUPPORT |
2034 | /* |
2020 | /* |
2035 | * D: CopyArea pass - very useful for slower links |
2021 | * D: CopyArea pass - very useful for slower links |
2036 | * This has been deliberately kept simple. |
2022 | * This has been deliberately kept simple. |
2037 | */ |
2023 | */ |
2038 | i = R->num_scr; |
2024 | i = num_scr; |
2039 | if (refresh_type == FAST_REFRESH && R->num_scr_allow && i |
2025 | if (refresh_type == FAST_REFRESH && num_scr_allow && i |
2040 | && abs(i) < R->TermWin.nrow && !must_clear) |
2026 | && abs(i) < TermWin.nrow && !must_clear) |
2041 | { |
2027 | { |
2042 | int16_t nits; |
2028 | int16_t nits; |
2043 | int j; |
2029 | int j; |
2044 | rend_t *drp2; |
2030 | rend_t *drp2; |
2045 | text_t *dtp2; |
2031 | text_t *dtp2; |
2046 | int len, wlen; |
2032 | int len, wlen; |
2047 | |
2033 | |
2048 | j = R->TermWin.nrow; |
2034 | j = TermWin.nrow; |
2049 | wlen = len = -1; |
2035 | wlen = len = -1; |
2050 | row = i > 0 ? 0 : j - 1; |
2036 | row = i > 0 ? 0 : j - 1; |
2051 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2037 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2052 | { |
2038 | { |
2053 | if (row + i >= 0 && row + i < R->TermWin.nrow && row + i != ocrow) |
2039 | if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow) |
2054 | { |
2040 | { |
2055 | stp = R->screen.text[row + row_offset]; |
2041 | stp = screen.text[row + row_offset]; |
2056 | srp = R->screen.rend[row + row_offset]; |
2042 | srp = screen.rend[row + row_offset]; |
2057 | dtp = R->drawn_text[row]; |
2043 | dtp = drawn_text[row]; |
2058 | dtp2 = R->drawn_text[row + i]; |
2044 | dtp2 = drawn_text[row + i]; |
2059 | drp = R->drawn_rend[row]; |
2045 | drp = drawn_rend[row]; |
2060 | drp2 = R->drawn_rend[row + i]; |
2046 | drp2 = drawn_rend[row + i]; |
2061 | |
2047 | |
2062 | for (nits = 0, col = R->TermWin.ncol; col--; ) |
2048 | for (nits = 0, col = TermWin.ncol; col--; ) |
2063 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2049 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2064 | nits--; |
2050 | nits--; |
2065 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2051 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2066 | nits++; |
2052 | nits++; |
2067 | |
2053 | |
2068 | if (nits > 8) /* XXX: arbitrary choice */ |
2054 | if (nits > 8) /* XXX: arbitrary choice */ |
2069 | { |
2055 | { |
2070 | for (col = R->TermWin.ncol; col--; ) |
2056 | for (col = TermWin.ncol; col--; ) |
2071 | { |
2057 | { |
2072 | *dtp++ = *dtp2++; |
2058 | *dtp++ = *dtp2++; |
2073 | *drp++ = *drp2++; |
2059 | *drp++ = *drp2++; |
2074 | } |
2060 | } |
2075 | |
2061 | |
… | |
… | |
2084 | if (len != -1) |
2070 | if (len != -1) |
2085 | { |
2071 | { |
2086 | /* also comes here at end if needed because of >= above */ |
2072 | /* also comes here at end if needed because of >= above */ |
2087 | if (wlen < len) |
2073 | if (wlen < len) |
2088 | SWAP_IT(wlen, len, int); |
2074 | SWAP_IT(wlen, len, int); |
|
|
2075 | |
2089 | D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
2076 | D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
2090 | XCopyArea(R->Xdisplay, R->TermWin.vt, R->TermWin.vt, |
2077 | XCopyArea (Xdisplay, TermWin.vt, TermWin.vt, |
2091 | R->TermWin.gc, 0, Row2Pixel(len + i), |
2078 | TermWin.gc, 0, Row2Pixel (len + i), |
2092 | (unsigned int)TermWin_TotalWidth(), |
2079 | (unsigned int)TermWin_TotalWidth (), |
2093 | (unsigned int)Height2Pixel(wlen - len + 1), |
2080 | (unsigned int)Height2Pixel (wlen - len + 1), |
2094 | 0, Row2Pixel(len)); |
2081 | 0, Row2Pixel (len)); |
2095 | len = -1; |
2082 | len = -1; |
2096 | } |
2083 | } |
2097 | } |
2084 | } |
2098 | } |
2085 | } |
2099 | #endif |
2086 | #endif |
2100 | |
2087 | |
2101 | /* |
2088 | /* |
2102 | * E: main pass across every character |
2089 | * E: main pass across every character |
2103 | */ |
2090 | */ |
2104 | for (row = 0; row < R->TermWin.nrow; row++) |
2091 | for (row = 0; row < TermWin.nrow; row++) |
2105 | { |
2092 | { |
2106 | stp = R->screen.text[row + row_offset]; |
2093 | stp = screen.text[row + row_offset]; |
2107 | srp = R->screen.rend[row + row_offset]; |
2094 | srp = screen.rend[row + row_offset]; |
2108 | dtp = R->drawn_text[row]; |
2095 | dtp = drawn_text[row]; |
2109 | drp = R->drawn_rend[row]; |
2096 | drp = drawn_rend[row]; |
2110 | |
2097 | |
2111 | /* |
2098 | /* |
2112 | * E2: OK, now the real pass |
2099 | * E2: OK, now the real pass |
2113 | */ |
2100 | */ |
2114 | int ypixel = (int)Row2Pixel(row); |
2101 | int ypixel = (int)Row2Pixel(row); |
2115 | |
2102 | |
2116 | for (col = 0; col < R->TermWin.ncol; col++) |
2103 | for (col = 0; col < TermWin.ncol; col++) |
2117 | { |
2104 | { |
2118 | /* compare new text with old - if exactly the same then continue */ |
2105 | /* compare new text with old - if exactly the same then continue */ |
2119 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2106 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2120 | |
2107 | |
2121 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2108 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
… | |
… | |
2137 | |
2124 | |
2138 | int xpixel = Col2Pixel(col); |
2125 | int xpixel = Col2Pixel(col); |
2139 | |
2126 | |
2140 | // this loop looks very messy, it can probably be optimized |
2127 | // this loop looks very messy, it can probably be optimized |
2141 | // and cleaned a bit by you? |
2128 | // and cleaned a bit by you? |
2142 | for (i = 0; ++col < R->TermWin.ncol; ) |
2129 | for (i = 0; ++col < TermWin.ncol; ) |
2143 | { |
2130 | { |
2144 | if (stp[col] == NOCHAR) |
2131 | if (stp[col] == NOCHAR) |
2145 | { |
2132 | { |
2146 | dtp[col] = stp[col]; |
2133 | dtp[col] = stp[col]; |
2147 | drp[col] = rend; |
2134 | drp[col] = rend; |
… | |
… | |
2173 | } |
2160 | } |
2174 | |
2161 | |
2175 | col--; /* went one too far. move back */ |
2162 | col--; /* went one too far. move back */ |
2176 | count -= i; /* dump any matching trailing chars */ |
2163 | count -= i; /* dump any matching trailing chars */ |
2177 | |
2164 | |
2178 | /* |
2165 | /* |
2179 | * Determine the attributes for the string |
2166 | * Determine the attributes for the string |
2180 | */ |
2167 | */ |
2181 | int fid = GET_FONT(rend); |
2168 | int fid = GET_FONT(rend); |
2182 | fore = GET_FGCOLOR(rend); |
2169 | fore = GET_FGCOLOR(rend); |
2183 | back = GET_BGCOLOR(rend); |
2170 | back = GET_BGCOLOR(rend); |
2184 | rend = GET_ATTR(rend); |
2171 | rend = GET_ATTR(rend); |
2185 | |
2172 | |
2186 | rvid = (rend & RS_RVid) ? 1 : 0; |
2173 | rvid = (rend & RS_RVid) ? 1 : 0; |
2187 | #ifdef OPTION_HC |
2174 | #ifdef OPTION_HC |
2188 | if (!rvid && (rend & RS_Blink)) |
2175 | if (!rvid && (rend & RS_Blink)) |
2189 | { |
2176 | { |
2190 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_HC)) |
2177 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) |
2191 | back = Color_HC; |
2178 | back = Color_HC; |
2192 | else |
2179 | else |
2193 | rvid = !rvid; /* fall back */ |
2180 | rvid = !rvid; /* fall back */ |
2194 | } |
2181 | } |
2195 | #endif |
2182 | #endif |
2196 | if (rvid) |
2183 | if (rvid) |
2197 | { |
2184 | { |
2198 | SWAP_IT(fore, back, int); |
2185 | SWAP_IT(fore, back, int); |
2199 | |
2186 | |
2200 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2187 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2201 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_RV) |
2188 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_RV) |
2202 | # ifndef NO_CURSORCOLOR |
2189 | # ifndef NO_CURSORCOLOR |
2203 | && !ISSET_PIXCOLOR(R, Color_cursor) |
2190 | && !ISSET_PIXCOLOR (this, Color_cursor) |
2204 | # endif |
2191 | # endif |
2205 | ) |
2192 | ) |
2206 | back = Color_RV; |
2193 | back = Color_RV; |
2207 | #endif |
2194 | #endif |
2208 | } |
2195 | } |
2209 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2196 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2210 | else if (rend & RS_Bold) |
2197 | else if (rend & RS_Bold) |
2211 | { |
2198 | { |
2212 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_BD)) |
2199 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD)) |
2213 | { |
2200 | { |
2214 | fore = Color_BD; |
2201 | fore = Color_BD; |
2215 | # ifndef VERYBOLD |
2202 | # ifndef VERYBOLD |
2216 | rend &= ~RS_Bold; /* we've taken care of it */ |
2203 | rend &= ~RS_Bold; /* we've taken care of it */ |
2217 | # endif |
2204 | # endif |
2218 | } |
2205 | } |
2219 | } |
2206 | } |
2220 | else if (rend & RS_Uline) |
2207 | else if (rend & RS_Uline) |
2221 | { |
2208 | { |
2222 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_UL)) |
2209 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) |
2223 | { |
2210 | { |
2224 | fore = Color_UL; |
2211 | fore = Color_UL; |
2225 | rend &= ~RS_Uline; /* we've taken care of it */ |
2212 | rend &= ~RS_Uline; /* we've taken care of it */ |
2226 | } |
2213 | } |
2227 | } |
2214 | } |
2228 | #endif |
2215 | #endif |
2229 | |
2216 | |
2230 | /* |
2217 | /* |
2231 | * Actually do the drawing of the string here |
2218 | * Actually do the drawing of the string here |
2232 | */ |
2219 | */ |
2233 | rxvt_font *font = (*R->TermWin.fontset)[fid]; |
2220 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2234 | |
2221 | |
2235 | if (back == Color_bg) |
2222 | if (back == Color_bg) |
2236 | { |
2223 | { |
2237 | if (must_clear) |
2224 | if (must_clear) |
2238 | { |
2225 | { |
… | |
… | |
2241 | { |
2228 | { |
2242 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2229 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2243 | goto nodraw; |
2230 | goto nodraw; |
2244 | } |
2231 | } |
2245 | |
2232 | |
2246 | CLEAR_CHARS(xpixel, ypixel, count); |
2233 | CLEAR_CHARS (xpixel, ypixel, count); |
2247 | nodraw: ; |
2234 | nodraw: ; |
2248 | } |
2235 | } |
2249 | else |
2236 | else |
2250 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2237 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2251 | } |
2238 | } |
2252 | else |
2239 | else |
2253 | font->draw (xpixel, ypixel, text, count, fore, back); |
2240 | font->draw (xpixel, ypixel, text, count, fore, back); |
2254 | |
2241 | |
2255 | if ((rend & RS_Uline) && (font->descent > 1)) |
2242 | if ((rend & RS_Uline) && (font->descent > 1)) |
2256 | XDrawLine(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2243 | XDrawLine(Xdisplay, drawBuffer, TermWin.gc, |
2257 | xpixel, ypixel + font->ascent + 1, |
2244 | xpixel, ypixel + font->ascent + 1, |
2258 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2245 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2259 | } /* for (col....) */ |
2246 | } /* for (col....) */ |
2260 | } /* for (row....) */ |
2247 | } /* for (row....) */ |
2261 | |
2248 | |
2262 | /* |
2249 | /* |
2263 | * G: cleanup cursor and display outline cursor if necessary |
2250 | * G: cleanup cursor and display outline cursor if necessary |
2264 | */ |
2251 | */ |
2265 | if (showcursor) { |
2252 | if (showcursor) { |
2266 | if (R->TermWin.focus) { |
2253 | if (TermWin.focus) { |
2267 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
2254 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
2268 | [R->screen.cur.col]); |
2255 | [screen.cur.col]); |
2269 | *srp ^= RS_RVid; |
2256 | *srp ^= RS_RVid; |
2270 | #ifndef NO_CURSORCOLOR |
2257 | #ifndef NO_CURSORCOLOR |
2271 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2258 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2272 | #endif |
2259 | #endif |
2273 | } else if (R->oldcursor.row >= 0) { |
2260 | } else if (oldcursor.row >= 0) { |
2274 | #ifndef NO_CURSORCOLOR |
2261 | #ifndef NO_CURSORCOLOR |
2275 | unsigned long gcmask; /* Graphics Context mask */ |
2262 | unsigned long gcmask; /* Graphics Context mask */ |
2276 | |
2263 | |
2277 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) { |
2264 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
2278 | XSetForeground (R->Xdisplay, R->TermWin.gc, R->PixColors[Color_cursor]); |
2265 | XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); |
2279 | } |
|
|
2280 | #endif |
2266 | #endif |
2281 | XDrawRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2267 | XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, |
2282 | Col2Pixel(R->oldcursor.col), |
2268 | Col2Pixel(oldcursor.col), |
2283 | Row2Pixel(R->oldcursor.row), |
2269 | Row2Pixel(oldcursor.row), |
2284 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2270 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2285 | (unsigned int)(Height2Pixel(1) - R->TermWin.lineSpace - 1)); |
2271 | (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); |
2286 | } |
2272 | } |
2287 | } |
2273 | } |
2288 | /* |
2274 | |
|
|
2275 | /* |
2289 | * H: cleanup selection |
2276 | * H: cleanup selection |
2290 | */ |
2277 | */ |
2291 | rxvt_scr_reverse_selection(aR); |
2278 | rxvt_scr_reverse_selection (this); |
2292 | |
2279 | |
2293 | /* |
2280 | /* |
2294 | * I: other general cleanup |
2281 | * I: other general cleanup |
2295 | */ |
2282 | */ |
2296 | if (clearfirst && R->TermWin.int_bwidth) |
2283 | if (clearfirst && TermWin.int_bwidth) |
2297 | /* |
2284 | /* |
2298 | * clear the whole screen height, note that width == 0 is treated |
2285 | * clear the whole screen height, note that width == 0 is treated |
2299 | * specially by XClearArea |
2286 | * specially by XClearArea |
2300 | */ |
2287 | */ |
2301 | XClearArea(R->Xdisplay, R->TermWin.vt, 0, 0, |
2288 | XClearArea(Xdisplay, TermWin.vt, 0, 0, |
2302 | (unsigned int)R->TermWin.int_bwidth, |
2289 | (unsigned int)TermWin.int_bwidth, |
2303 | (unsigned int)TermWin_TotalHeight(), False); |
2290 | (unsigned int)TermWin_TotalHeight(), False); |
2304 | if (clearlast && R->TermWin.int_bwidth) |
2291 | if (clearlast && TermWin.int_bwidth) |
2305 | /* |
2292 | /* |
2306 | * clear the whole screen height, note that width == 0 is treated |
2293 | * clear the whole screen height, note that width == 0 is treated |
2307 | * specially by XClearArea |
2294 | * specially by XClearArea |
2308 | */ |
2295 | */ |
2309 | XClearArea(R->Xdisplay, R->TermWin.vt, |
2296 | XClearArea(Xdisplay, TermWin.vt, |
2310 | R->TermWin.width + R->TermWin.int_bwidth, 0, |
2297 | TermWin.width + TermWin.int_bwidth, 0, |
2311 | (unsigned int)R->TermWin.int_bwidth, |
2298 | (unsigned int)TermWin.int_bwidth, |
2312 | (unsigned int)TermWin_TotalHeight(), False); |
2299 | (unsigned int)TermWin_TotalHeight(), False); |
2313 | if (refresh_type & SMOOTH_REFRESH) |
2300 | if (refresh_type & SMOOTH_REFRESH) |
2314 | XSync(R->Xdisplay, False); |
2301 | XSync(Xdisplay, False); |
2315 | |
2302 | |
2316 | R->num_scr = 0; |
2303 | num_scr = 0; |
2317 | R->num_scr_allow = 1; |
2304 | num_scr_allow = 1; |
2318 | R->want_refresh = 0; /* screen is current */ |
2305 | want_refresh = 0; /* screen is current */ |
2319 | } |
2306 | } |
2320 | /* ------------------------------------------------------------------------- */ |
|
|
2321 | |
2307 | |
2322 | /* EXTPROTO */ |
2308 | /* ------------------------------------------------------------------------- */ |
2323 | void |
2309 | void |
2324 | rxvt_scr_clear(pR) |
2310 | rxvt_term::scr_clear() |
2325 | { |
2311 | { |
2326 | if (!R->TermWin.mapped) |
2312 | if (!TermWin.mapped) |
2327 | return; |
2313 | return; |
|
|
2314 | |
2328 | R->num_scr_allow = 0; |
2315 | num_scr_allow = 0; |
2329 | R->want_refresh = 1; |
2316 | want_refresh = 1; |
2330 | #ifdef TRANSPARENT |
2317 | #ifdef TRANSPARENT |
2331 | if ((R->Options & Opt_transparent) && (R->am_pixmap_trans == 0)) { |
2318 | if ((Options & Opt_transparent) && (am_pixmap_trans == 0)) |
2332 | int i; |
2319 | { |
|
|
2320 | int i; |
2333 | |
2321 | |
2334 | if (!(R->Options & Opt_transparent_all)) |
2322 | if (!(Options & Opt_transparent_all)) |
2335 | i = 0; |
2323 | i = 0; |
2336 | else |
2324 | else |
2337 | i = (int)(sizeof(R->TermWin.parent) / sizeof(Window)); |
2325 | i = (int)(sizeof(TermWin.parent) / sizeof(Window)); |
2338 | for (; i--;) |
2326 | |
|
|
2327 | while (i--) |
2339 | if (R->TermWin.parent[i] != None) |
2328 | if (TermWin.parent[i] != None) |
2340 | XClearWindow(R->Xdisplay, R->TermWin.parent[i]); |
2329 | XClearWindow(Xdisplay, TermWin.parent[i]); |
2341 | } |
2330 | } |
2342 | #endif |
2331 | #endif |
|
|
2332 | |
2343 | XClearWindow(R->Xdisplay, R->TermWin.vt); |
2333 | XClearWindow (Xdisplay, TermWin.vt); |
2344 | } |
2334 | } |
2345 | |
2335 | |
2346 | /* ------------------------------------------------------------------------- */ |
2336 | /* ------------------------------------------------------------------------- */ |
2347 | /* INTPROTO */ |
2337 | /* INTPROTO */ |
2348 | void |
2338 | void |
… | |
… | |
2456 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2446 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2457 | { |
2447 | { |
2458 | unsigned int i, j, n; |
2448 | unsigned int i, j, n; |
2459 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2449 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2460 | |
2450 | |
|
|
2451 | #if 0 |
|
|
2452 | /* a paste should act like the user is typing, so check scrollTtyKeypress */ |
|
|
2453 | ZERO_SCROLLBACK (r); |
|
|
2454 | #endif |
|
|
2455 | |
2461 | /* convert normal newline chars into common keyboard Return key sequence */ |
2456 | /* convert normal newline chars into common keyboard Return key sequence */ |
2462 | for (i = 0; i < len; i += PROP_SIZE) |
2457 | for (i = 0; i < len; i += PROP_SIZE) |
2463 | { |
2458 | { |
2464 | n = min (len - i, PROP_SIZE); |
2459 | n = min (len - i, PROP_SIZE); |
2465 | MEMCPY (ds, data + i, n); |
2460 | MEMCPY (ds, data + i, n); |
… | |
… | |
2570 | } |
2565 | } |
2571 | |
2566 | |
2572 | void |
2567 | void |
2573 | rxvt_term::incr_cb (time_watcher &w) |
2568 | rxvt_term::incr_cb (time_watcher &w) |
2574 | { |
2569 | { |
2575 | w.stop (); |
|
|
2576 | selection_wait = Sel_none; |
2570 | selection_wait = Sel_none; |
2577 | |
2571 | |
2578 | rxvt_print_error("data loss: timeout on INCR selection paste"); |
2572 | rxvt_print_error ("data loss: timeout on INCR selection paste"); |
2579 | } |
2573 | } |
2580 | |
2574 | |
2581 | /* |
2575 | /* |
2582 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2576 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2583 | */ |
2577 | */ |
… | |
… | |
2817 | /* ------------------------------------------------------------------------- */ |
2811 | /* ------------------------------------------------------------------------- */ |
2818 | /* |
2812 | /* |
2819 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2813 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2820 | * EXT: button 1 press |
2814 | * EXT: button 1 press |
2821 | */ |
2815 | */ |
2822 | /* EXTPROTO */ |
|
|
2823 | void |
2816 | void |
2824 | rxvt_selection_click(pR_ int clicks, int x, int y) |
2817 | rxvt_term::selection_click (int clicks, int x, int y) |
2825 | { |
2818 | { |
2826 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2819 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2827 | |
2820 | |
2828 | clicks = ((clicks - 1) % 3) + 1; |
2821 | clicks = ((clicks - 1) % 3) + 1; |
2829 | R->selection.clicks = clicks; /* save clicks so extend will work */ |
2822 | selection.clicks = clicks; /* save clicks so extend will work */ |
2830 | |
2823 | |
2831 | rxvt_selection_start_colrow(aR_ Pixel2Col(x), Pixel2Row(y)); |
2824 | rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y)); |
|
|
2825 | |
2832 | if (clicks == 2 || clicks == 3) |
2826 | if (clicks == 2 || clicks == 3) |
2833 | rxvt_selection_extend_colrow(aR_ R->selection.mark.col, |
2827 | rxvt_selection_extend_colrow (this, selection.mark.col, |
2834 | R->selection.mark.row |
|
|
2835 | + R->TermWin.view_start, |
2828 | selection.mark.row + TermWin.view_start, |
2836 | 0, /* button 3 */ |
2829 | 0, /* button 3 */ |
2837 | 1, /* button press */ |
2830 | 1, /* button press */ |
2838 | 0); /* click change */ |
2831 | 0); /* click change */ |
2839 | } |
2832 | } |
2840 | |
2833 | |
2841 | /* ------------------------------------------------------------------------- */ |
2834 | /* ------------------------------------------------------------------------- */ |
2842 | /* |
2835 | /* |
2843 | * Mark a selection at the specified col/row |
2836 | * Mark a selection at the specified col/row |
… | |
… | |
2953 | * EXT: button 3 press; button 1 or 3 drag |
2946 | * EXT: button 3 press; button 1 or 3 drag |
2954 | * flag == 0 ==> button 1 |
2947 | * flag == 0 ==> button 1 |
2955 | * flag == 1 ==> button 3 press |
2948 | * flag == 1 ==> button 3 press |
2956 | * flag == 2 ==> button 3 motion |
2949 | * flag == 2 ==> button 3 motion |
2957 | */ |
2950 | */ |
2958 | /* EXTPROTO */ |
|
|
2959 | void |
2951 | void |
2960 | rxvt_selection_extend(pR_ int x, int y, int flag) |
2952 | rxvt_term::selection_extend (int x, int y, int flag) |
2961 | { |
2953 | { |
2962 | int col, row; |
2954 | int col, row; |
2963 | |
2955 | |
2964 | col = Pixel2Col(x); |
2956 | col = Pixel2Col(x); |
2965 | row = Pixel2Row(y); |
2957 | row = Pixel2Row(y); |
2966 | MAX_IT(row, 0); |
2958 | MAX_IT(row, 0); |
2967 | MIN_IT(row, (int)R->TermWin.nrow - 1); |
2959 | MIN_IT(row, (int)TermWin.nrow - 1); |
2968 | MAX_IT(col, 0); |
2960 | MAX_IT(col, 0); |
2969 | MIN_IT(col, (int)R->TermWin.ncol); |
2961 | MIN_IT(col, (int)TermWin.ncol); |
|
|
2962 | |
2970 | #ifndef NO_NEW_SELECTION |
2963 | #ifndef NO_NEW_SELECTION |
2971 | /* |
2964 | /* |
2972 | * If we're selecting characters (single click) then we must check first |
2965 | * If we're selecting characters (single click) then we must check first |
2973 | * if we are at the same place as the original mark. If we are then |
2966 | * if we are at the same place as the original mark. If we are then |
2974 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
2967 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
2975 | * be _past_ a character for it to be selected. |
2968 | * be _past_ a character for it to be selected. |
2976 | */ |
2969 | */ |
2977 | if (R->selection_style != OLD_SELECT) { |
2970 | if (selection_style != OLD_SELECT) |
|
|
2971 | { |
2978 | if (((R->selection.clicks % 3) == 1) && !flag |
2972 | if (((selection.clicks % 3) == 1) && !flag |
2979 | && (col == R->selection.mark.col |
2973 | && (col == selection.mark.col |
2980 | && (row == R->selection.mark.row + R->TermWin.view_start))) { |
2974 | && (row == selection.mark.row + TermWin.view_start))) |
|
|
2975 | { |
2981 | /* select nothing */ |
2976 | /* select nothing */ |
2982 | R->selection.beg.row = R->selection.end.row = 0; |
2977 | selection.beg.row = selection.end.row = 0; |
2983 | R->selection.beg.col = R->selection.end.col = 0; |
2978 | selection.beg.col = selection.end.col = 0; |
2984 | R->selection.clicks = 4; |
2979 | selection.clicks = 4; |
2985 | R->want_refresh = 1; |
2980 | want_refresh = 1; |
2986 | D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); |
2981 | D_SELECT((stderr, "rxvt_selection_extend() selection.clicks = 4")); |
2987 | return; |
2982 | return; |
2988 | } |
2983 | } |
2989 | } |
2984 | } |
2990 | #endif |
2985 | #endif |
2991 | if (R->selection.clicks == 4) |
2986 | if (selection.clicks == 4) |
2992 | R->selection.clicks = 1; |
2987 | selection.clicks = 1; |
|
|
2988 | |
2993 | rxvt_selection_extend_colrow(aR_ col, row, !!flag, /* ? button 3 */ |
2989 | rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */ |
2994 | flag == 1 ? 1 : 0, /* ? button press */ |
2990 | flag == 1 ? 1 : 0, /* ? button press */ |
2995 | 0); /* no click change */ |
2991 | 0); /* no click change */ |
2996 | } |
2992 | } |
2997 | |
2993 | |
2998 | /* ------------------------------------------------------------------------- */ |
2994 | /* ------------------------------------------------------------------------- */ |
2999 | /* |
2995 | /* |
3000 | * Extend the selection to the specified col/row |
2996 | * Extend the selection to the specified col/row |
… | |
… | |
3254 | /* ------------------------------------------------------------------------- */ |
3250 | /* ------------------------------------------------------------------------- */ |
3255 | /* |
3251 | /* |
3256 | * Double click on button 3 when already selected |
3252 | * Double click on button 3 when already selected |
3257 | * EXT: button 3 double click |
3253 | * EXT: button 3 double click |
3258 | */ |
3254 | */ |
3259 | /* EXTPROTO */ |
|
|
3260 | void |
3255 | void |
3261 | rxvt_selection_rotate(pR_ int x, int y) |
3256 | rxvt_term::selection_rotate (int x, int y) |
3262 | { |
3257 | { |
3263 | R->selection.clicks = R->selection.clicks % 3 + 1; |
3258 | selection.clicks = selection.clicks % 3 + 1; |
3264 | rxvt_selection_extend_colrow(aR_ Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3259 | rxvt_selection_extend_colrow (this, Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3265 | } |
3260 | } |
3266 | |
3261 | |
3267 | /* ------------------------------------------------------------------------- */ |
3262 | /* ------------------------------------------------------------------------- */ |
3268 | /* |
3263 | /* |
3269 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3264 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
… | |
… | |
3373 | * ------------------------------------------------------------------------- */ |
3368 | * ------------------------------------------------------------------------- */ |
3374 | |
3369 | |
3375 | /* |
3370 | /* |
3376 | * return col/row values corresponding to x/y pixel values |
3371 | * return col/row values corresponding to x/y pixel values |
3377 | */ |
3372 | */ |
3378 | /* EXTPROTO */ |
|
|
3379 | void |
3373 | void |
3380 | rxvt_pixel_position(pR_ int *x, int *y) |
3374 | rxvt_term::pixel_position (int *x, int *y) |
3381 | { |
3375 | { |
3382 | *x = Pixel2Col(*x); |
3376 | *x = Pixel2Col(*x); |
3383 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3377 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3384 | *y = Pixel2Row(*y); |
3378 | *y = Pixel2Row(*y); |
3385 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3379 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3386 | } |
3380 | } |
|
|
3381 | |
3387 | /* ------------------------------------------------------------------------- */ |
3382 | /* ------------------------------------------------------------------------- */ |
3388 | #ifdef USE_XIM |
3383 | #ifdef USE_XIM |
3389 | /* EXTPROTO */ |
|
|
3390 | void |
3384 | void |
3391 | rxvt_setPosition(pR_ XPoint *pos) |
3385 | rxvt_term::set_position (XPoint *pos) |
3392 | { |
3386 | { |
3393 | XWindowAttributes xwa; |
3387 | XWindowAttributes xwa; |
3394 | |
3388 | |
3395 | XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &xwa); |
3389 | XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa); |
3396 | pos->x = Col2Pixel(R->screen.cur.col) + xwa.x; |
3390 | pos->x = Col2Pixel (screen.cur.col) + xwa.x; |
3397 | pos->y = Height2Pixel((R->screen.cur.row + 1)) + xwa.y |
3391 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3398 | - R->TermWin.lineSpace; |
|
|
3399 | } |
3392 | } |
|
|
3393 | |
3400 | #endif |
3394 | #endif |
3401 | /* ------------------------------------------------------------------------- */ |
3395 | /* ------------------------------------------------------------------------- */ |
3402 | |
3396 | |
3403 | /* ------------------------------------------------------------------------- * |
3397 | /* ------------------------------------------------------------------------- * |
3404 | * DEBUG ROUTINES * |
3398 | * DEBUG ROUTINES * |