1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.c |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * $Id: screen.C,v 1.9 2003/12/18 02:07:12 pcg Exp $ |
|
|
5 | * |
4 | * |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
5 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
7 | * |
6 | * |
8 | * This program is free software; you can redistribute it and/or modify |
7 | * 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 |
8 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
89 | /* |
88 | /* |
90 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
89 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
91 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
90 | * 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 |
91 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
93 | */ |
92 | */ |
94 | #define drawBuffer (R->TermWin.vt) |
93 | #define drawBuffer TermWin.vt |
95 | |
94 | |
96 | #define CLEAR_ROWS(row, num) \ |
95 | #define CLEAR_ROWS(row, num) \ |
97 | if (R->TermWin.mapped) \ |
96 | if (TermWin.mapped) \ |
98 | XClearArea(R->Xdisplay, drawBuffer, R->TermWin.int_bwidth, \ |
97 | XClearArea (Xdisplay, drawBuffer, TermWin.int_bwidth, \ |
99 | Row2Pixel(row), (unsigned int)R->TermWin.width, \ |
98 | Row2Pixel(row), (unsigned int)TermWin.width, \ |
100 | (unsigned int)Height2Pixel(num), False) |
99 | (unsigned int)Height2Pixel(num), False) |
101 | |
100 | |
102 | #define CLEAR_CHARS(x, y, num) \ |
101 | #define CLEAR_CHARS(x, y, num) \ |
103 | if (R->TermWin.mapped) \ |
102 | if (TermWin.mapped) \ |
104 | XClearArea(R->Xdisplay, drawBuffer, x, y, \ |
103 | XClearArea (Xdisplay, drawBuffer, x, y, \ |
105 | (unsigned int)Width2Pixel(num), \ |
104 | (unsigned int)Width2Pixel(num), \ |
106 | (unsigned int)Height2Pixel(1), False) |
105 | (unsigned int)Height2Pixel(1), False) |
107 | |
106 | |
108 | #define ERASE_ROWS(row, num) \ |
107 | #define ERASE_ROWS(row, num) \ |
109 | XFillRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, \ |
108 | XFillRectangle (Xdisplay, drawBuffer, TermWin.gc, \ |
110 | R->TermWin.int_bwidth, Row2Pixel(row), \ |
109 | TermWin.int_bwidth, Row2Pixel(row), \ |
111 | (unsigned int)R->TermWin.width, \ |
110 | (unsigned int)TermWin.width, \ |
112 | (unsigned int)Height2Pixel(num)) |
111 | (unsigned int)Height2Pixel(num)) |
113 | |
112 | |
114 | /* ------------------------------------------------------------------------- * |
113 | /* ------------------------------------------------------------------------- * |
115 | * SCREEN `COMMON' ROUTINES * |
114 | * SCREEN `COMMON' ROUTINES * |
116 | * ------------------------------------------------------------------------- */ |
115 | * ------------------------------------------------------------------------- */ |
117 | /* Fill part/all of a line with blanks. */ |
116 | /* Fill part/all of a line with blanks. */ |
… | |
… | |
289 | else if (nrow > prev_nrow) |
288 | else if (nrow > prev_nrow) |
290 | { |
289 | { |
291 | /* add rows */ |
290 | /* add rows */ |
292 | scr_reset_realloc (); /* realloc _first_ */ |
291 | scr_reset_realloc (); /* realloc _first_ */ |
293 | |
292 | |
294 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
293 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
295 | |
294 | |
296 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
295 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
297 | |
296 | |
298 | for (p = prev_total_rows; p < total_rows; p++) |
297 | for (p = prev_total_rows; p < total_rows; p++) |
299 | { |
298 | { |
… | |
… | |
447 | /* then so is screen.rend[i] */ |
446 | /* then so is screen.rend[i] */ |
448 | assert(screen.rend[i]); |
447 | assert(screen.rend[i]); |
449 | } |
448 | } |
450 | #endif |
449 | #endif |
451 | |
450 | |
452 | delete talloc; |
451 | delete talloc; talloc = 0; |
453 | delete ralloc; |
452 | delete ralloc; ralloc = 0; |
454 | |
453 | |
455 | free (screen.text); |
454 | free (screen.text); |
456 | free (screen.tlen); |
455 | free (screen.tlen); |
457 | free (screen.rend); |
456 | free (screen.rend); |
458 | free (drawn_text); |
457 | free (drawn_text); |
… | |
… | |
485 | |
484 | |
486 | R->scr_release (); |
485 | R->scr_release (); |
487 | R->prev_nrow = R->prev_ncol = 0; |
486 | R->prev_nrow = R->prev_ncol = 0; |
488 | R->scr_reset (); |
487 | R->scr_reset (); |
489 | |
488 | |
490 | rxvt_scr_clear (aR); |
489 | R->scr_clear (); |
491 | rxvt_scr_refresh (aR_ SLOW_REFRESH); |
490 | R->scr_refresh (SLOW_REFRESH); |
492 | #ifdef RXVT_GRAPHICS |
491 | #ifdef RXVT_GRAPHICS |
493 | rxvt_Gr_reset (aR); |
492 | rxvt_Gr_reset (aR); |
494 | #endif |
493 | #endif |
495 | } |
494 | } |
496 | |
495 | |
… | |
… | |
899 | case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; |
898 | case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; |
900 | case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
899 | case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
901 | } |
900 | } |
902 | |
901 | |
903 | rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); |
902 | rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); |
904 | |
|
|
905 | stp[R->screen.cur.col] = c; |
|
|
906 | srp[R->screen.cur.col] = rend; |
|
|
907 | |
|
|
908 | if (c > 255) |
|
|
909 | { |
|
|
910 | // rely on wcwidth to tell us the character width, at least for non iso-8859-1 |
903 | // rely on wcwidth to tell us the character width, at least for non-ascii |
911 | int width = wcwidth (c); |
904 | int width = c <= 128 ? 1 : wcwidth (c); |
|
|
905 | |
|
|
906 | // width -1 characters (e.g. combining chars) are ignored currently. |
|
|
907 | if (width > 0) |
|
|
908 | do |
912 | |
909 | { |
913 | if (width > 1) |
910 | stp[R->screen.cur.col] = c; |
914 | { |
|
|
915 | while (--width > 0 && R->screen.cur.col < last_col - 1) |
|
|
916 | { |
|
|
917 | |
|
|
918 | srp[R->screen.cur.col] |= RS_wide; |
911 | srp[R->screen.cur.col] = rend; |
919 | |
912 | |
|
|
913 | if (R->screen.cur.col < last_col - 1) |
920 | R->screen.cur.col++; |
914 | R->screen.cur.col++; |
921 | stp[R->screen.cur.col] = NOCHAR; |
915 | else |
922 | srp[R->screen.cur.col] = rend; |
|
|
923 | } |
916 | { |
924 | } |
|
|
925 | } |
|
|
926 | |
|
|
927 | if (R->screen.cur.col < last_col - 1) |
|
|
928 | R->screen.cur.col++; |
|
|
929 | else { |
|
|
930 | R->screen.tlen[row] = last_col; |
917 | R->screen.tlen[row] = last_col; |
931 | if (R->screen.flags & Screen_Autowrap) |
918 | if (R->screen.flags & Screen_Autowrap) |
932 | R->screen.flags |= Screen_WrapNext; |
919 | R->screen.flags |= Screen_WrapNext; |
|
|
920 | break; |
|
|
921 | } |
|
|
922 | |
|
|
923 | c = NOCHAR; |
933 | } |
924 | } |
|
|
925 | while (--width > 0); |
|
|
926 | else |
|
|
927 | 1; /* handle combining character etc. here. */ |
934 | } |
928 | } |
|
|
929 | |
935 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
930 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
936 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
931 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
937 | |
932 | |
938 | /* |
933 | /* |
939 | * If we wrote anywhere in the selected area, kill the selection |
934 | * If we wrote anywhere in the selected area, kill the selection |
940 | * XXX: should we kill the mark too? Possibly, but maybe that |
935 | * XXX: should we kill the mark too? Possibly, but maybe that |
941 | * should be a similar check. |
936 | * should be a similar check. |
… | |
… | |
1211 | * Erase part of whole of the screen |
1206 | * Erase part of whole of the screen |
1212 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1207 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1213 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1208 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1214 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1209 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1215 | */ |
1210 | */ |
1216 | /* EXTPROTO */ |
|
|
1217 | void |
1211 | void |
1218 | rxvt_scr_erase_screen(pR_ int mode) |
1212 | rxvt_term::scr_erase_screen (int mode) |
1219 | { |
1213 | { |
1220 | int num; |
1214 | int num; |
1221 | int32_t row, row_offset; |
1215 | int32_t row, row_offset; |
1222 | rend_t ren; |
1216 | rend_t ren; |
1223 | XGCValues gcvalue; |
1217 | XGCValues gcvalue; |
1224 | |
1218 | |
1225 | R->want_refresh = 1; |
1219 | want_refresh = 1; |
1226 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); |
1220 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row)); |
1227 | ZERO_SCROLLBACK(R); |
1221 | ZERO_SCROLLBACK(this); |
1228 | row_offset = (int32_t)R->TermWin.saveLines; |
1222 | row_offset = (int32_t)TermWin.saveLines; |
1229 | |
1223 | |
1230 | switch (mode) { |
1224 | switch (mode) { |
1231 | case 0: /* erase to end of screen */ |
1225 | case 0: /* erase to end of screen */ |
1232 | rxvt_selection_check(aR_ 1); |
1226 | rxvt_selection_check(this,1); |
1233 | rxvt_scr_erase_line(aR_ 0); |
1227 | rxvt_scr_erase_line(this,0); |
1234 | row = R->screen.cur.row + 1; /* possible OOB */ |
1228 | row = screen.cur.row + 1; /* possible OOB */ |
1235 | num = R->TermWin.nrow - row; |
1229 | num = TermWin.nrow - row; |
1236 | break; |
1230 | break; |
1237 | case 1: /* erase to beginning of screen */ |
1231 | case 1: /* erase to beginning of screen */ |
1238 | rxvt_selection_check(aR_ 3); |
1232 | rxvt_selection_check(this,3); |
1239 | rxvt_scr_erase_line(aR_ 1); |
1233 | rxvt_scr_erase_line(this,1); |
1240 | row = 0; |
1234 | row = 0; |
1241 | num = R->screen.cur.row; |
1235 | num = screen.cur.row; |
1242 | break; |
1236 | break; |
1243 | case 2: /* erase whole screen */ |
1237 | case 2: /* erase whole screen */ |
1244 | rxvt_selection_check(aR_ 3); |
1238 | rxvt_selection_check (this, 3); |
1245 | #ifdef RXVT_GRAPHICS |
1239 | #ifdef RXVT_GRAPHICS |
1246 | rxvt_Gr_ClearScreen(aR); |
1240 | rxvt_Gr_ClearScreen (this); |
1247 | #endif |
1241 | #endif |
1248 | row = 0; |
1242 | row = 0; |
1249 | num = R->TermWin.nrow; |
1243 | num = TermWin.nrow; |
1250 | break; |
1244 | break; |
1251 | default: |
1245 | default: |
1252 | return; |
1246 | return; |
1253 | } |
1247 | } |
1254 | R->refresh_type |= REFRESH_BOUNDS; |
1248 | refresh_type |= REFRESH_BOUNDS; |
1255 | if (R->selection.op && R->current_screen == R->selection.screen |
1249 | if (selection.op && current_screen == selection.screen |
1256 | && ((R->selection.beg.row >= row && R->selection.beg.row <= row + num) |
1250 | && ((selection.beg.row >= row && selection.beg.row <= row + num) |
1257 | || (R->selection.end.row >= row |
1251 | || (selection.end.row >= row |
1258 | && R->selection.end.row <= row + num))) |
1252 | && selection.end.row <= row + num))) |
1259 | CLEAR_SELECTION(R); |
1253 | CLEAR_SELECTION (this); |
1260 | if (row >= R->TermWin.nrow) /* Out Of Bounds */ |
1254 | if (row >= TermWin.nrow) /* Out Of Bounds */ |
1261 | return; |
1255 | return; |
1262 | MIN_IT(num, (R->TermWin.nrow - row)); |
1256 | MIN_IT(num, (TermWin.nrow - row)); |
1263 | if (R->rstyle & (RS_RVid | RS_Uline)) |
1257 | if (rstyle & (RS_RVid | RS_Uline)) |
1264 | ren = (rend_t) ~RS_None; |
1258 | ren = (rend_t) ~RS_None; |
1265 | else if (GET_BASEBG(R->rstyle) == Color_bg) { |
1259 | else if (GET_BASEBG(rstyle) == Color_bg) { |
1266 | ren = DEFAULT_RSTYLE; |
1260 | ren = DEFAULT_RSTYLE; |
1267 | CLEAR_ROWS(row, num); |
1261 | CLEAR_ROWS(row, num); |
1268 | } else { |
1262 | } else { |
1269 | ren = (R->rstyle & (RS_fgMask | RS_bgMask)); |
1263 | ren = (rstyle & (RS_fgMask | RS_bgMask)); |
1270 | gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->rstyle)]; |
1264 | gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)]; |
1271 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1265 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1272 | ERASE_ROWS(row, num); |
1266 | ERASE_ROWS(row, num); |
1273 | gcvalue.foreground = R->PixColors[Color_fg]; |
1267 | gcvalue.foreground = PixColors[Color_fg]; |
1274 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1268 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1275 | } |
1269 | } |
1276 | for (; num--; row++) { |
1270 | for (; num--; row++) { |
1277 | R->scr_blank_screen_mem (R->screen.text, R->screen.rend, |
1271 | scr_blank_screen_mem (screen.text, screen.rend, |
1278 | (unsigned int)(row + row_offset), R->rstyle); |
1272 | (unsigned int)(row + row_offset), rstyle); |
1279 | R->screen.tlen[row + row_offset] = 0; |
1273 | screen.tlen[row + row_offset] = 0; |
1280 | R->scr_blank_line (R->drawn_text[row], R->drawn_rend[row], |
1274 | scr_blank_line (drawn_text[row], drawn_rend[row], |
1281 | (unsigned int)R->TermWin.ncol, ren); |
1275 | (unsigned int)TermWin.ncol, ren); |
1282 | } |
1276 | } |
1283 | } |
1277 | } |
1284 | |
1278 | |
1285 | /* ------------------------------------------------------------------------- */ |
1279 | /* ------------------------------------------------------------------------- */ |
1286 | /* |
1280 | /* |
… | |
… | |
1570 | |
1564 | |
1571 | gcvalue.foreground = R->PixColors[Color_fg]; |
1565 | gcvalue.foreground = R->PixColors[Color_fg]; |
1572 | gcvalue.background = R->PixColors[Color_bg]; |
1566 | gcvalue.background = R->PixColors[Color_bg]; |
1573 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1567 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1574 | &gcvalue); |
1568 | &gcvalue); |
1575 | rxvt_scr_clear(aR); |
1569 | R->scr_clear (); |
1576 | rxvt_scr_touch(aR_ True); |
1570 | R->scr_touch (true); |
1577 | } |
1571 | } |
1578 | } |
1572 | } |
1579 | |
1573 | |
1580 | /* ------------------------------------------------------------------------- */ |
1574 | /* ------------------------------------------------------------------------- */ |
1581 | /* |
1575 | /* |
… | |
… | |
1651 | rxvt_set_font_style(aR); |
1645 | rxvt_set_font_style(aR); |
1652 | } |
1646 | } |
1653 | |
1647 | |
1654 | |
1648 | |
1655 | /* ------------------------------------------------------------------------- * |
1649 | /* ------------------------------------------------------------------------- * |
1656 | * GRAPHICS COLOURS * |
|
|
1657 | * ------------------------------------------------------------------------- */ |
|
|
1658 | |
|
|
1659 | #ifdef RXVT_GRAPHICS |
|
|
1660 | /* EXTPROTO */ |
|
|
1661 | int |
|
|
1662 | rxvt_scr_get_fgcolor(pR) |
|
|
1663 | { |
|
|
1664 | return GET_FGCOLOR(R->rstyle); |
|
|
1665 | } |
|
|
1666 | |
|
|
1667 | /* ------------------------------------------------------------------------- */ |
|
|
1668 | /* EXTPROTO */ |
|
|
1669 | int |
|
|
1670 | rxvt_scr_get_bgcolor(pR) |
|
|
1671 | { |
|
|
1672 | return GET_BGCOLOR(R->rstyle); |
|
|
1673 | } |
|
|
1674 | #endif |
|
|
1675 | |
|
|
1676 | /* ------------------------------------------------------------------------- * |
|
|
1677 | * MAJOR SCREEN MANIPULATION * |
1650 | * MAJOR SCREEN MANIPULATION * |
1678 | * ------------------------------------------------------------------------- */ |
1651 | * ------------------------------------------------------------------------- */ |
|
|
1652 | |
|
|
1653 | /* |
|
|
1654 | * refresh matching text. |
|
|
1655 | */ |
|
|
1656 | bool |
|
|
1657 | rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) |
|
|
1658 | { |
|
|
1659 | bool found = false; |
|
|
1660 | |
|
|
1661 | for (int i = 0; i < TermWin.nrow; i++) |
|
|
1662 | { |
|
|
1663 | int col = 0; |
|
|
1664 | rend_t *drp = drawn_rend [i]; |
|
|
1665 | |
|
|
1666 | for (; col < TermWin.ncol; col++, drp++) |
|
|
1667 | if ((*drp & mask) == value) |
|
|
1668 | { |
|
|
1669 | found = true; |
|
|
1670 | *drp = ~value; |
|
|
1671 | } |
|
|
1672 | } |
|
|
1673 | |
|
|
1674 | return found; |
|
|
1675 | } |
1679 | |
1676 | |
1680 | /* |
1677 | /* |
1681 | * Refresh an area |
1678 | * Refresh an area |
1682 | */ |
1679 | */ |
1683 | enum { |
1680 | enum { |
1684 | PART_BEG = 0, |
1681 | PART_BEG = 0, |
1685 | PART_END, |
1682 | PART_END, |
1686 | RC_COUNT |
1683 | RC_COUNT |
1687 | }; |
1684 | }; |
1688 | |
1685 | |
1689 | /* EXTPROTO */ |
|
|
1690 | void |
1686 | void |
1691 | rxvt_scr_expose(pR_ int x, int y, int width, int height, Bool refresh) |
1687 | rxvt_term::scr_expose (int x, int y, int width, int height, bool refresh) |
1692 | { |
1688 | { |
1693 | int i; |
1689 | int i; |
1694 | row_col_t rc[RC_COUNT]; |
1690 | row_col_t rc[RC_COUNT]; |
1695 | |
1691 | |
1696 | if (R->drawn_text == NULL) /* sanity check */ |
1692 | if (drawn_text == NULL) /* sanity check */ |
1697 | return; |
1693 | return; |
1698 | |
1694 | |
1699 | #ifdef DEBUG_STRICT |
1695 | #ifdef DEBUG_STRICT |
1700 | x = max(x, (int)R->TermWin.int_bwidth); |
1696 | x = max(x, (int)TermWin.int_bwidth); |
1701 | x = min(x, (int)R->TermWin.width); |
1697 | x = min(x, (int)TermWin.width); |
1702 | y = max(y, (int)R->TermWin.int_bwidth); |
1698 | y = max(y, (int)TermWin.int_bwidth); |
1703 | y = min(y, (int)R->TermWin.height); |
1699 | y = min(y, (int)TermWin.height); |
1704 | #endif |
1700 | #endif |
1705 | |
1701 | |
1706 | /* round down */ |
1702 | /* round down */ |
1707 | rc[PART_BEG].col = Pixel2Col(x); |
1703 | rc[PART_BEG].col = Pixel2Col(x); |
1708 | rc[PART_BEG].row = Pixel2Row(y); |
1704 | rc[PART_BEG].row = Pixel2Row(y); |
1709 | /* round up */ |
1705 | /* round up */ |
1710 | rc[PART_END].col = Pixel2Width(x + width + R->TermWin.fwidth - 1); |
1706 | rc[PART_END].col = Pixel2Width(x + width + TermWin.fwidth - 1); |
1711 | rc[PART_END].row = Pixel2Row(y + height + R->TermWin.fheight - 1); |
1707 | rc[PART_END].row = Pixel2Row(y + height + TermWin.fheight - 1); |
1712 | |
1708 | |
1713 | /* sanity checks */ |
1709 | /* sanity checks */ |
1714 | for (i = PART_BEG; i < RC_COUNT; i++) { |
1710 | for (i = PART_BEG; i < RC_COUNT; i++) |
|
|
1711 | { |
1715 | MIN_IT(rc[i].col, R->TermWin.ncol - 1); |
1712 | MIN_IT(rc[i].col, TermWin.ncol - 1); |
1716 | MIN_IT(rc[i].row, R->TermWin.nrow - 1); |
1713 | MIN_IT(rc[i].row, TermWin.nrow - 1); |
1717 | } |
1714 | } |
1718 | |
1715 | |
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)); |
1716 | 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 | |
1717 | |
1721 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1718 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1722 | fill_text (&(R->drawn_text[i][rc[PART_BEG].col]), 0, |
1719 | fill_text (&(drawn_text[i][rc[PART_BEG].col]), 0, |
1723 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1720 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1724 | |
1721 | |
1725 | if (refresh) |
1722 | if (refresh) |
1726 | rxvt_scr_refresh(aR_ SLOW_REFRESH | REFRESH_BOUNDS); |
1723 | scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); |
1727 | } |
1724 | } |
1728 | |
1725 | |
1729 | /* ------------------------------------------------------------------------- */ |
1726 | /* ------------------------------------------------------------------------- */ |
1730 | /* |
1727 | /* |
1731 | * Refresh the entire screen |
1728 | * Refresh the entire screen |
1732 | */ |
1729 | */ |
1733 | /* EXTPROTO */ |
|
|
1734 | void |
1730 | void |
1735 | rxvt_scr_touch(pR_ Bool refresh) |
1731 | rxvt_term::scr_touch (bool refresh) |
1736 | { |
1732 | { |
1737 | rxvt_scr_expose(aR_ 0, 0, R->TermWin.width, R->TermWin.height, refresh); |
1733 | scr_expose (0, 0, TermWin.width, TermWin.height, refresh); |
1738 | } |
1734 | } |
1739 | |
1735 | |
1740 | /* ------------------------------------------------------------------------- */ |
1736 | /* ------------------------------------------------------------------------- */ |
1741 | /* |
1737 | /* |
1742 | * Move the display so that the line represented by scrollbar value Y is at |
1738 | * Move the display so that the line represented by scrollbar value Y is at |
… | |
… | |
1861 | * Refresh the screen |
1857 | * Refresh the screen |
1862 | * R->drawn_text/R->drawn_rend contain the screen information before the update. |
1858 | * R->drawn_text/R->drawn_rend contain the screen information before the update. |
1863 | * R->screen.text/R->screen.rend contain what the screen will change to. |
1859 | * R->screen.text/R->screen.rend contain what the screen will change to. |
1864 | */ |
1860 | */ |
1865 | |
1861 | |
1866 | #if defined (NO_BRIGHTCOLOR) || defined (VERYBOLD) |
|
|
1867 | # define MONO_BOLD(x) ((x) & (RS_Bold|RS_Blink)) |
|
|
1868 | # define MONO_BOLD_FG(x, fg) MONO_BOLD(x) |
|
|
1869 | #else |
|
|
1870 | # define MONO_BOLD(x) \ |
|
|
1871 | (((x) & (RS_Bold | RS_fgMask)) == (RS_Bold | Color_fg)) |
|
|
1872 | # define MONO_BOLD_FG(x, fg) (((x) & RS_Bold) && (fg) == Color_fg) |
|
|
1873 | #endif |
|
|
1874 | |
|
|
1875 | #define FONT_WIDTH(X, Y) \ |
1862 | #define FONT_WIDTH(X, Y) \ |
1876 | (X)->per_char[(Y) - (X)->min_char_or_byte2].width |
1863 | (X)->per_char[(Y) - (X)->min_char_or_byte2].width |
1877 | #define FONT_RBEAR(X, Y) \ |
1864 | #define FONT_RBEAR(X, Y) \ |
1878 | (X)->per_char[(Y) - (X)->min_char_or_byte2].rbearing |
1865 | (X)->per_char[(Y) - (X)->min_char_or_byte2].rbearing |
1879 | #define FONT_LBEAR(X, Y) \ |
1866 | #define FONT_LBEAR(X, Y) \ |
1880 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1867 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1881 | #define IS_FONT_CHAR(X, Y) \ |
1868 | #define IS_FONT_CHAR(X, Y) \ |
1882 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1869 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1883 | |
1870 | |
1884 | /* EXTPROTO */ |
|
|
1885 | void |
1871 | void |
1886 | rxvt_scr_refresh(pR_ unsigned char refresh_type) |
1872 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1887 | { |
1873 | { |
1888 | unsigned char clearfirst, /* first character writes before cell */ |
1874 | unsigned char clearfirst, /* first character writes before cell */ |
1889 | clearlast, /* last character writes beyond cell */ |
1875 | clearlast, /* last character writes beyond cell */ |
1890 | must_clear, /* use draw_string not draw_image_string */ |
1876 | must_clear, /* use draw_string not draw_image_string */ |
1891 | #ifndef NO_BOLDFONT |
|
|
1892 | bfont, /* we've changed font to bold font */ |
|
|
1893 | #endif |
|
|
1894 | rvid, /* reverse video this position */ |
1877 | rvid, /* reverse video this position */ |
1895 | wbyte, /* we're in multibyte */ |
|
|
1896 | showcursor; /* show the cursor */ |
1878 | showcursor; /* show the cursor */ |
1897 | int fore, back; /* desired foreground/background */ |
|
|
1898 | int16_t col, row, /* column/row we're processing */ |
1879 | int16_t col, row, /* column/row we're processing */ |
1899 | ocrow; /* old cursor row */ |
1880 | ocrow; /* old cursor row */ |
1900 | int cursorwidth; |
1881 | int cursorwidth; |
1901 | int i, /* tmp */ |
1882 | int i, /* tmp */ |
1902 | row_offset; /* basic offset in screen structure */ |
1883 | row_offset; /* basic offset in screen structure */ |
… | |
… | |
1904 | rend_t cc1; /* store colours at cursor position(s) */ |
1885 | rend_t cc1; /* store colours at cursor position(s) */ |
1905 | rend_t cc2; /* store colours at cursor position(s) */ |
1886 | rend_t cc2; /* store colours at cursor position(s) */ |
1906 | #endif |
1887 | #endif |
1907 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1888 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1908 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1889 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1909 | char *buffer; /* local copy of R->buffer */ |
|
|
1910 | |
1890 | |
1911 | if (refresh_type == NO_REFRESH || !R->TermWin.mapped) |
1891 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1912 | return; |
1892 | return; |
1913 | |
1893 | |
1914 | /* |
1894 | /* |
1915 | * A: set up vars |
1895 | * A: set up vars |
1916 | */ |
1896 | */ |
1917 | clearfirst = clearlast = must_clear = wbyte = 0; |
1897 | clearfirst = clearlast = must_clear = 0; |
1918 | #ifndef NO_BOLDFONT |
|
|
1919 | bfont = 0; |
|
|
1920 | #endif |
|
|
1921 | |
1898 | |
1922 | if (R->currmaxcol < R->TermWin.ncol) |
1899 | if (currmaxcol < TermWin.ncol) |
1923 | { |
1900 | { |
1924 | R->currmaxcol = R->TermWin.ncol; |
1901 | currmaxcol = TermWin.ncol; |
1925 | R->buffer = (char *)rxvt_realloc (R->buffer, |
1902 | buffer = (char *)rxvt_realloc (buffer, |
1926 | sizeof(char) * (R->currmaxcol + 1) * MB_CUR_MAX); |
1903 | sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); |
1927 | } |
1904 | } |
1928 | |
1905 | |
1929 | buffer = R->buffer; |
|
|
1930 | R->refresh_count = 0; |
1906 | refresh_count = 0; |
1931 | |
1907 | |
1932 | row_offset = R->TermWin.saveLines - R->TermWin.view_start; |
1908 | row_offset = TermWin.saveLines - TermWin.view_start; |
1933 | |
1909 | |
1934 | if ((refresh_type & REFRESH_BOUNDS)) |
1910 | if ((refresh_type & REFRESH_BOUNDS)) |
1935 | { |
1911 | { |
1936 | clearfirst = clearlast = 1; |
1912 | clearfirst = clearlast = 1; |
1937 | R->refresh_type &= ~REFRESH_BOUNDS; |
1913 | refresh_type &= ~REFRESH_BOUNDS; |
1938 | } |
1914 | } |
1939 | |
1915 | |
1940 | #if defined(XPM_BACKGROUND) |
1916 | #if defined(XPM_BACKGROUND) |
1941 | must_clear |= (R->bgPixmap.pixmap != None); |
1917 | must_clear |= (bgPixmap.pixmap != None); |
1942 | #endif |
1918 | #endif |
1943 | #if defined(TRANSPARENT) |
1919 | #if defined(TRANSPARENT) |
1944 | must_clear |= ((R->Options & Opt_transparent) && R->am_transparent); |
1920 | must_clear |= ((Options & Opt_transparent) && am_transparent); |
1945 | #endif |
1921 | #endif |
1946 | ocrow = R->oldcursor.row; /* is there an old outline cursor on screen? */ |
1922 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1947 | |
1923 | |
1948 | /* |
1924 | /* |
1949 | * B: reverse any characters which are selected |
1925 | * B: reverse any characters which are selected |
1950 | */ |
1926 | */ |
1951 | rxvt_scr_reverse_selection(aR); |
1927 | rxvt_scr_reverse_selection (this); |
1952 | |
1928 | |
1953 | /* |
1929 | /* |
1954 | * C: set the cursor character(s) |
1930 | * C: set the cursor character(s) |
1955 | */ |
1931 | */ |
1956 | { |
1932 | { |
1957 | unsigned char setoldcursor; |
1933 | unsigned char setoldcursor; |
1958 | rend_t ccol1, /* Cursor colour */ |
1934 | rend_t ccol1, /* Cursor colour */ |
1959 | ccol2; /* Cursor colour2 */ |
1935 | ccol2; /* Cursor colour2 */ |
1960 | |
1936 | |
1961 | showcursor = (R->screen.flags & Screen_VisibleCursor); |
1937 | showcursor = (screen.flags & Screen_VisibleCursor); |
1962 | cursorwidth = 0; |
1938 | cursorwidth = 0; |
1963 | #ifdef CURSOR_BLINK |
1939 | #ifdef CURSOR_BLINK |
1964 | if (R->hidden_cursor) |
1940 | if (hidden_cursor) |
1965 | showcursor = 0; |
1941 | showcursor = 0; |
1966 | #endif |
1942 | #endif |
1967 | |
1943 | |
1968 | cursorwidth = 0; |
1944 | cursorwidth = 0; |
1969 | |
1945 | |
1970 | if (showcursor) |
1946 | if (showcursor) |
1971 | { |
1947 | { |
1972 | cursorwidth++; |
1948 | cursorwidth++; |
1973 | |
1949 | |
1974 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
1950 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
1975 | [R->screen.cur.col]); |
1951 | [screen.cur.col]); |
1976 | |
1952 | |
1977 | if (showcursor && R->TermWin.focus) |
1953 | if (showcursor && TermWin.focus) |
1978 | { |
1954 | { |
1979 | *srp ^= RS_RVid; |
1955 | *srp ^= RS_RVid; |
1980 | #ifndef NO_CURSORCOLOR |
1956 | #ifndef NO_CURSORCOLOR |
1981 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1957 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1982 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) |
1958 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
1983 | ccol1 = Color_cursor; |
1959 | ccol1 = Color_cursor; |
1984 | else |
1960 | else |
1985 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1961 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1986 | ccol1 = GET_FGCOLOR(R->rstyle); |
1962 | ccol1 = GET_FGCOLOR(rstyle); |
1987 | #else |
1963 | #else |
1988 | ccol1 = Color_fg; |
1964 | ccol1 = Color_fg; |
1989 | #endif |
1965 | #endif |
1990 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor2)) |
1966 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor2)) |
1991 | ccol2 = Color_cursor2; |
1967 | ccol2 = Color_cursor2; |
1992 | else |
1968 | else |
1993 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1969 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1994 | ccol2 = GET_BGCOLOR(R->rstyle); |
1970 | ccol2 = GET_BGCOLOR(rstyle); |
1995 | #else |
1971 | #else |
1996 | ccol2 = Color_bg; |
1972 | ccol2 = Color_bg; |
1997 | #endif |
1973 | #endif |
1998 | *srp = SET_FGCOLOR(*srp, ccol1); |
1974 | *srp = SET_FGCOLOR(*srp, ccol1); |
1999 | *srp = SET_BGCOLOR(*srp, ccol2); |
1975 | *srp = SET_BGCOLOR(*srp, ccol2); |
2000 | #endif |
1976 | #endif |
2001 | } |
1977 | } |
2002 | |
|
|
2003 | while (IS_WIDE (*srp)) |
|
|
2004 | cursorwidth++, srp++; |
|
|
2005 | } |
1978 | } |
2006 | |
1979 | |
2007 | /* make sure no outline cursor is left around */ |
1980 | /* make sure no outline cursor is left around */ |
2008 | setoldcursor = 0; |
1981 | setoldcursor = 0; |
2009 | if (ocrow != -1) { |
1982 | if (ocrow != -1) { |
2010 | if (R->screen.cur.row + R->TermWin.view_start != ocrow |
1983 | if (screen.cur.row + TermWin.view_start != ocrow |
2011 | || R->screen.cur.col != R->oldcursor.col) { |
1984 | || screen.cur.col != oldcursor.col) { |
2012 | if (ocrow < R->TermWin.nrow |
1985 | if (ocrow < TermWin.nrow |
2013 | && R->oldcursor.col < R->TermWin.ncol) { |
1986 | && oldcursor.col < TermWin.ncol) { |
2014 | R->drawn_rend[ocrow][R->oldcursor.col] ^= (RS_RVid | RS_Uline); |
1987 | drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); |
2015 | } |
1988 | } |
2016 | if (R->TermWin.focus || !showcursor) |
1989 | if (TermWin.focus || !showcursor) |
2017 | R->oldcursor.row = -1; |
1990 | oldcursor.row = -1; |
2018 | else |
1991 | else |
2019 | setoldcursor = 1; |
1992 | setoldcursor = 1; |
2020 | } |
1993 | } |
2021 | } else if (!R->TermWin.focus) |
1994 | } else if (!TermWin.focus) |
2022 | setoldcursor = 1; |
1995 | setoldcursor = 1; |
2023 | if (setoldcursor) { |
1996 | if (setoldcursor) { |
2024 | if (R->screen.cur.row + R->TermWin.view_start >= R->TermWin.nrow) |
1997 | if (screen.cur.row + TermWin.view_start >= TermWin.nrow) |
2025 | R->oldcursor.row = -1; |
1998 | oldcursor.row = -1; |
2026 | else { |
1999 | else { |
2027 | R->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; |
2000 | oldcursor.row = screen.cur.row + TermWin.view_start; |
2028 | R->oldcursor.col = R->screen.cur.col; |
2001 | oldcursor.col = screen.cur.col; |
2029 | } |
2002 | } |
2030 | } |
2003 | } |
2031 | } |
2004 | } |
2032 | |
2005 | |
2033 | #ifndef NO_SLOW_LINK_SUPPORT |
2006 | #ifndef NO_SLOW_LINK_SUPPORT |
2034 | /* |
2007 | /* |
2035 | * D: CopyArea pass - very useful for slower links |
2008 | * D: CopyArea pass - very useful for slower links |
2036 | * This has been deliberately kept simple. |
2009 | * This has been deliberately kept simple. |
2037 | */ |
2010 | */ |
2038 | i = R->num_scr; |
2011 | i = num_scr; |
2039 | if (refresh_type == FAST_REFRESH && R->num_scr_allow && i |
2012 | if (refresh_type == FAST_REFRESH && num_scr_allow && i |
2040 | && abs(i) < R->TermWin.nrow && !must_clear) |
2013 | && abs(i) < TermWin.nrow && !must_clear) |
2041 | { |
2014 | { |
2042 | int16_t nits; |
2015 | int16_t nits; |
2043 | int j; |
2016 | int j; |
2044 | rend_t *drp2; |
2017 | rend_t *drp2; |
2045 | text_t *dtp2; |
2018 | text_t *dtp2; |
2046 | int len, wlen; |
2019 | int len, wlen; |
2047 | |
2020 | |
2048 | j = R->TermWin.nrow; |
2021 | j = TermWin.nrow; |
2049 | wlen = len = -1; |
2022 | wlen = len = -1; |
2050 | row = i > 0 ? 0 : j - 1; |
2023 | row = i > 0 ? 0 : j - 1; |
2051 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2024 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2052 | { |
2025 | { |
2053 | if (row + i >= 0 && row + i < R->TermWin.nrow && row + i != ocrow) |
2026 | if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow) |
2054 | { |
2027 | { |
2055 | stp = R->screen.text[row + row_offset]; |
2028 | stp = screen.text[row + row_offset]; |
2056 | srp = R->screen.rend[row + row_offset]; |
2029 | srp = screen.rend[row + row_offset]; |
2057 | dtp = R->drawn_text[row]; |
2030 | dtp = drawn_text[row]; |
2058 | dtp2 = R->drawn_text[row + i]; |
2031 | dtp2 = drawn_text[row + i]; |
2059 | drp = R->drawn_rend[row]; |
2032 | drp = drawn_rend[row]; |
2060 | drp2 = R->drawn_rend[row + i]; |
2033 | drp2 = drawn_rend[row + i]; |
2061 | |
2034 | |
2062 | for (nits = 0, col = R->TermWin.ncol; col--; ) |
2035 | for (nits = 0, col = TermWin.ncol; col--; ) |
2063 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2036 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2064 | nits--; |
2037 | nits--; |
2065 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2038 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2066 | nits++; |
2039 | nits++; |
2067 | |
2040 | |
2068 | if (nits > 8) /* XXX: arbitrary choice */ |
2041 | if (nits > 8) /* XXX: arbitrary choice */ |
2069 | { |
2042 | { |
2070 | for (col = R->TermWin.ncol; col--; ) |
2043 | for (col = TermWin.ncol; col--; ) |
2071 | { |
2044 | { |
2072 | *dtp++ = *dtp2++; |
2045 | *dtp++ = *dtp2++; |
2073 | *drp++ = *drp2++; |
2046 | *drp++ = *drp2++; |
2074 | } |
2047 | } |
2075 | |
2048 | |
… | |
… | |
2084 | if (len != -1) |
2057 | if (len != -1) |
2085 | { |
2058 | { |
2086 | /* also comes here at end if needed because of >= above */ |
2059 | /* also comes here at end if needed because of >= above */ |
2087 | if (wlen < len) |
2060 | if (wlen < len) |
2088 | SWAP_IT(wlen, len, int); |
2061 | SWAP_IT(wlen, len, int); |
|
|
2062 | |
2089 | D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
2063 | 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, |
2064 | XCopyArea (Xdisplay, TermWin.vt, TermWin.vt, |
2091 | R->TermWin.gc, 0, Row2Pixel(len + i), |
2065 | TermWin.gc, 0, Row2Pixel (len + i), |
2092 | (unsigned int)TermWin_TotalWidth(), |
2066 | (unsigned int)TermWin_TotalWidth (), |
2093 | (unsigned int)Height2Pixel(wlen - len + 1), |
2067 | (unsigned int)Height2Pixel (wlen - len + 1), |
2094 | 0, Row2Pixel(len)); |
2068 | 0, Row2Pixel (len)); |
2095 | len = -1; |
2069 | len = -1; |
2096 | } |
2070 | } |
2097 | } |
2071 | } |
2098 | } |
2072 | } |
2099 | #endif |
2073 | #endif |
2100 | |
2074 | |
2101 | /* |
2075 | /* |
2102 | * E: main pass across every character |
2076 | * E: main pass across every character |
2103 | */ |
2077 | */ |
2104 | for (row = 0; row < R->TermWin.nrow; row++) |
2078 | for (row = 0; row < TermWin.nrow; row++) |
2105 | { |
2079 | { |
2106 | stp = R->screen.text[row + row_offset]; |
2080 | stp = screen.text[row + row_offset]; |
2107 | srp = R->screen.rend[row + row_offset]; |
2081 | srp = screen.rend[row + row_offset]; |
2108 | dtp = R->drawn_text[row]; |
2082 | dtp = drawn_text[row]; |
2109 | drp = R->drawn_rend[row]; |
2083 | drp = drawn_rend[row]; |
2110 | |
2084 | |
2111 | /* |
2085 | /* |
2112 | * E2: OK, now the real pass |
2086 | * E2: OK, now the real pass |
2113 | */ |
2087 | */ |
2114 | int ypixel = (int)Row2Pixel(row); |
2088 | int ypixel = (int)Row2Pixel(row); |
2115 | |
2089 | |
2116 | for (col = 0; col < R->TermWin.ncol; col++) |
2090 | for (col = 0; col < TermWin.ncol; col++) |
2117 | { |
2091 | { |
2118 | /* compare new text with old - if exactly the same then continue */ |
2092 | /* compare new text with old - if exactly the same then continue */ |
2119 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2093 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2120 | |
2094 | |
2121 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2095 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
… | |
… | |
2137 | |
2111 | |
2138 | int xpixel = Col2Pixel(col); |
2112 | int xpixel = Col2Pixel(col); |
2139 | |
2113 | |
2140 | // this loop looks very messy, it can probably be optimized |
2114 | // this loop looks very messy, it can probably be optimized |
2141 | // and cleaned a bit by you? |
2115 | // and cleaned a bit by you? |
2142 | for (i = 0; ++col < R->TermWin.ncol; ) |
2116 | for (i = 0; ++col < TermWin.ncol; ) |
2143 | { |
2117 | { |
2144 | if (stp[col] == NOCHAR) |
2118 | if (stp[col] == NOCHAR) |
2145 | { |
2119 | { |
2146 | dtp[col] = stp[col]; |
2120 | dtp[col] = stp[col]; |
2147 | drp[col] = rend; |
2121 | drp[col] = rend; |
… | |
… | |
2151 | i++; |
2125 | i++; |
2152 | |
2126 | |
2153 | continue; |
2127 | continue; |
2154 | } |
2128 | } |
2155 | |
2129 | |
2156 | if (((rend ^ srp[col]) & ~RS_wide) != 0) |
2130 | if (rend != srp[col]) |
2157 | break; |
2131 | break; |
2158 | |
2132 | |
2159 | count++; |
2133 | count++; |
2160 | |
2134 | |
2161 | if (stp[col] != dtp[col] |
2135 | if (stp[col] != dtp[col] |
… | |
… | |
2173 | } |
2147 | } |
2174 | |
2148 | |
2175 | col--; /* went one too far. move back */ |
2149 | col--; /* went one too far. move back */ |
2176 | count -= i; /* dump any matching trailing chars */ |
2150 | count -= i; /* dump any matching trailing chars */ |
2177 | |
2151 | |
2178 | /* |
2152 | /* |
2179 | * Determine the attributes for the string |
2153 | * Determine the attributes for the string |
2180 | */ |
2154 | */ |
2181 | int fid = GET_FONT(rend); |
2155 | int fid = GET_FONT (rend); |
2182 | fore = GET_FGCOLOR(rend); |
2156 | int fore = GET_FGCOLOR (rend); // desired foreground |
2183 | back = GET_BGCOLOR(rend); |
2157 | int back = GET_BGCOLOR (rend); // desired background |
|
|
2158 | |
2184 | rend = GET_ATTR(rend); |
2159 | rend = GET_ATTR (rend); |
2185 | |
2160 | |
2186 | rvid = (rend & RS_RVid) ? 1 : 0; |
2161 | rvid = !!(rend & RS_RVid); |
|
|
2162 | #ifdef TEXT_BLINK |
|
|
2163 | if (rend & RS_Blink) |
|
|
2164 | { |
|
|
2165 | if (!text_blink_ev.active) |
|
|
2166 | { |
|
|
2167 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
2168 | hidden_text = 0; |
|
|
2169 | } |
|
|
2170 | else if (hidden_text) |
|
|
2171 | fore = back; |
|
|
2172 | } |
2187 | #ifdef OPTION_HC |
2173 | #elif OPTION_HC |
2188 | if (!rvid && (rend & RS_Blink)) |
2174 | if (!rvid && (rend & RS_Blink)) |
2189 | { |
2175 | { |
2190 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_HC)) |
2176 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) |
2191 | back = Color_HC; |
2177 | back = Color_HC; |
2192 | else |
2178 | else |
2193 | rvid = !rvid; /* fall back */ |
2179 | rvid = !rvid; /* fall back */ |
2194 | } |
2180 | } |
2195 | #endif |
2181 | #endif |
2196 | if (rvid) |
2182 | if (rvid) |
2197 | { |
2183 | { |
2198 | SWAP_IT(fore, back, int); |
2184 | SWAP_IT(fore, back, int); |
2199 | |
2185 | |
2200 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2186 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2201 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_RV) |
2187 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_RV) |
2202 | # ifndef NO_CURSORCOLOR |
2188 | # ifndef NO_CURSORCOLOR |
2203 | && !ISSET_PIXCOLOR(R, Color_cursor) |
2189 | && !ISSET_PIXCOLOR (this, Color_cursor) |
2204 | # endif |
2190 | # endif |
2205 | ) |
2191 | ) |
2206 | back = Color_RV; |
2192 | back = Color_RV; |
2207 | #endif |
2193 | #endif |
2208 | } |
2194 | } |
2209 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2195 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2210 | else if (rend & RS_Bold) |
2196 | else if (rend & RS_Bold) |
2211 | { |
2197 | { |
|
|
2198 | if (Xdepth > 2) |
2212 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_BD)) |
2199 | if (ISSET_PIXCOLOR (this, Color_BD)) |
2213 | { |
|
|
2214 | fore = Color_BD; |
2200 | fore = Color_BD; |
2215 | # ifndef VERYBOLD |
|
|
2216 | rend &= ~RS_Bold; /* we've taken care of it */ |
|
|
2217 | # endif |
|
|
2218 | } |
2201 | else |
|
|
2202 | fore = Color_White; |
2219 | } |
2203 | } |
2220 | else if (rend & RS_Uline) |
2204 | else if (rend & RS_Uline) |
2221 | { |
2205 | { |
2222 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_UL)) |
2206 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) |
2223 | { |
|
|
2224 | fore = Color_UL; |
2207 | fore = Color_UL; |
2225 | rend &= ~RS_Uline; /* we've taken care of it */ |
|
|
2226 | } |
|
|
2227 | } |
2208 | } |
2228 | #endif |
2209 | #endif |
2229 | |
2210 | |
2230 | /* |
2211 | /* |
2231 | * Actually do the drawing of the string here |
2212 | * Actually do the drawing of the string here |
2232 | */ |
2213 | */ |
2233 | rxvt_font *font = (*R->TermWin.fontset)[fid]; |
2214 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2234 | |
2215 | |
2235 | if (back == Color_bg) |
2216 | if (back == Color_bg) |
2236 | { |
2217 | { |
2237 | if (must_clear) |
2218 | if (must_clear) |
2238 | { |
2219 | { |
… | |
… | |
2241 | { |
2222 | { |
2242 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2223 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2243 | goto nodraw; |
2224 | goto nodraw; |
2244 | } |
2225 | } |
2245 | |
2226 | |
2246 | CLEAR_CHARS(xpixel, ypixel, count); |
2227 | CLEAR_CHARS (xpixel, ypixel, count); |
2247 | nodraw: ; |
2228 | nodraw: ; |
2248 | } |
2229 | } |
2249 | else |
2230 | else |
2250 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2231 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2251 | } |
2232 | } |
2252 | else |
2233 | else |
2253 | font->draw (xpixel, ypixel, text, count, fore, back); |
2234 | font->draw (xpixel, ypixel, text, count, fore, back); |
2254 | |
2235 | |
2255 | if ((rend & RS_Uline) && (font->descent > 1)) |
2236 | if ((rend & RS_Uline) && (font->descent > 1)) |
2256 | XDrawLine(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2237 | XDrawLine(Xdisplay, drawBuffer, TermWin.gc, |
2257 | xpixel, ypixel + font->ascent + 1, |
2238 | xpixel, ypixel + font->ascent + 1, |
2258 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2239 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2259 | } /* for (col....) */ |
2240 | } /* for (col....) */ |
2260 | } /* for (row....) */ |
2241 | } /* for (row....) */ |
2261 | |
2242 | |
2262 | /* |
2243 | /* |
2263 | * G: cleanup cursor and display outline cursor if necessary |
2244 | * G: cleanup cursor and display outline cursor if necessary |
2264 | */ |
2245 | */ |
2265 | if (showcursor) { |
2246 | if (showcursor) { |
2266 | if (R->TermWin.focus) { |
2247 | if (TermWin.focus) { |
2267 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
2248 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
2268 | [R->screen.cur.col]); |
2249 | [screen.cur.col]); |
2269 | *srp ^= RS_RVid; |
2250 | *srp ^= RS_RVid; |
2270 | #ifndef NO_CURSORCOLOR |
2251 | #ifndef NO_CURSORCOLOR |
2271 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2252 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2272 | #endif |
2253 | #endif |
2273 | } else if (R->oldcursor.row >= 0) { |
2254 | } else if (oldcursor.row >= 0) { |
2274 | #ifndef NO_CURSORCOLOR |
2255 | #ifndef NO_CURSORCOLOR |
2275 | unsigned long gcmask; /* Graphics Context mask */ |
2256 | unsigned long gcmask; /* Graphics Context mask */ |
2276 | |
2257 | |
2277 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) { |
2258 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
2278 | XSetForeground (R->Xdisplay, R->TermWin.gc, R->PixColors[Color_cursor]); |
2259 | XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); |
2279 | } |
|
|
2280 | #endif |
2260 | #endif |
2281 | XDrawRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2261 | XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, |
2282 | Col2Pixel(R->oldcursor.col), |
2262 | Col2Pixel(oldcursor.col), |
2283 | Row2Pixel(R->oldcursor.row), |
2263 | Row2Pixel(oldcursor.row), |
2284 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2264 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2285 | (unsigned int)(Height2Pixel(1) - R->TermWin.lineSpace - 1)); |
2265 | (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); |
2286 | } |
2266 | } |
2287 | } |
2267 | } |
2288 | /* |
2268 | |
|
|
2269 | /* |
2289 | * H: cleanup selection |
2270 | * H: cleanup selection |
2290 | */ |
2271 | */ |
2291 | rxvt_scr_reverse_selection(aR); |
2272 | rxvt_scr_reverse_selection (this); |
2292 | |
2273 | |
2293 | /* |
2274 | /* |
2294 | * I: other general cleanup |
2275 | * I: other general cleanup |
2295 | */ |
2276 | */ |
2296 | if (clearfirst && R->TermWin.int_bwidth) |
2277 | if (clearfirst && TermWin.int_bwidth) |
2297 | /* |
2278 | /* |
2298 | * clear the whole screen height, note that width == 0 is treated |
2279 | * clear the whole screen height, note that width == 0 is treated |
2299 | * specially by XClearArea |
2280 | * specially by XClearArea |
2300 | */ |
2281 | */ |
2301 | XClearArea(R->Xdisplay, R->TermWin.vt, 0, 0, |
2282 | XClearArea(Xdisplay, TermWin.vt, 0, 0, |
2302 | (unsigned int)R->TermWin.int_bwidth, |
2283 | (unsigned int)TermWin.int_bwidth, |
2303 | (unsigned int)TermWin_TotalHeight(), False); |
2284 | (unsigned int)TermWin_TotalHeight(), False); |
2304 | if (clearlast && R->TermWin.int_bwidth) |
2285 | if (clearlast && TermWin.int_bwidth) |
2305 | /* |
2286 | /* |
2306 | * clear the whole screen height, note that width == 0 is treated |
2287 | * clear the whole screen height, note that width == 0 is treated |
2307 | * specially by XClearArea |
2288 | * specially by XClearArea |
2308 | */ |
2289 | */ |
2309 | XClearArea(R->Xdisplay, R->TermWin.vt, |
2290 | XClearArea(Xdisplay, TermWin.vt, |
2310 | R->TermWin.width + R->TermWin.int_bwidth, 0, |
2291 | TermWin.width + TermWin.int_bwidth, 0, |
2311 | (unsigned int)R->TermWin.int_bwidth, |
2292 | (unsigned int)TermWin.int_bwidth, |
2312 | (unsigned int)TermWin_TotalHeight(), False); |
2293 | (unsigned int)TermWin_TotalHeight(), False); |
2313 | if (refresh_type & SMOOTH_REFRESH) |
2294 | if (refresh_type & SMOOTH_REFRESH) |
2314 | XSync(R->Xdisplay, False); |
2295 | XSync(Xdisplay, False); |
2315 | |
2296 | |
2316 | R->num_scr = 0; |
2297 | num_scr = 0; |
2317 | R->num_scr_allow = 1; |
2298 | num_scr_allow = 1; |
2318 | R->want_refresh = 0; /* screen is current */ |
2299 | want_refresh = 0; /* screen is current */ |
2319 | } |
2300 | } |
2320 | /* ------------------------------------------------------------------------- */ |
|
|
2321 | |
2301 | |
2322 | /* EXTPROTO */ |
2302 | /* ------------------------------------------------------------------------- */ |
2323 | void |
2303 | void |
2324 | rxvt_scr_clear(pR) |
2304 | rxvt_term::scr_clear() |
2325 | { |
2305 | { |
2326 | if (!R->TermWin.mapped) |
2306 | if (!TermWin.mapped) |
2327 | return; |
2307 | return; |
|
|
2308 | |
2328 | R->num_scr_allow = 0; |
2309 | num_scr_allow = 0; |
2329 | R->want_refresh = 1; |
2310 | want_refresh = 1; |
2330 | #ifdef TRANSPARENT |
2311 | #ifdef TRANSPARENT |
2331 | if ((R->Options & Opt_transparent) && (R->am_pixmap_trans == 0)) { |
2312 | if ((Options & Opt_transparent) && (am_pixmap_trans == 0)) |
2332 | int i; |
2313 | { |
|
|
2314 | int i; |
2333 | |
2315 | |
2334 | if (!(R->Options & Opt_transparent_all)) |
2316 | if (!(Options & Opt_transparent_all)) |
2335 | i = 0; |
2317 | i = 0; |
2336 | else |
2318 | else |
2337 | i = (int)(sizeof(R->TermWin.parent) / sizeof(Window)); |
2319 | i = (int)(sizeof(TermWin.parent) / sizeof(Window)); |
2338 | for (; i--;) |
2320 | |
|
|
2321 | while (i--) |
2339 | if (R->TermWin.parent[i] != None) |
2322 | if (TermWin.parent[i] != None) |
2340 | XClearWindow(R->Xdisplay, R->TermWin.parent[i]); |
2323 | XClearWindow(Xdisplay, TermWin.parent[i]); |
2341 | } |
2324 | } |
2342 | #endif |
2325 | #endif |
|
|
2326 | |
2343 | XClearWindow(R->Xdisplay, R->TermWin.vt); |
2327 | XClearWindow (Xdisplay, TermWin.vt); |
2344 | } |
2328 | } |
2345 | |
2329 | |
2346 | /* ------------------------------------------------------------------------- */ |
2330 | /* ------------------------------------------------------------------------- */ |
2347 | /* INTPROTO */ |
2331 | /* INTPROTO */ |
2348 | void |
2332 | void |
… | |
… | |
2456 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2440 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2457 | { |
2441 | { |
2458 | unsigned int i, j, n; |
2442 | unsigned int i, j, n; |
2459 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2443 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2460 | |
2444 | |
|
|
2445 | #if 0 |
|
|
2446 | /* a paste should act like the user is typing, so check scrollTtyKeypress */ |
|
|
2447 | ZERO_SCROLLBACK (r); |
|
|
2448 | #endif |
|
|
2449 | |
2461 | /* convert normal newline chars into common keyboard Return key sequence */ |
2450 | /* convert normal newline chars into common keyboard Return key sequence */ |
2462 | for (i = 0; i < len; i += PROP_SIZE) |
2451 | for (i = 0; i < len; i += PROP_SIZE) |
2463 | { |
2452 | { |
2464 | n = min (len - i, PROP_SIZE); |
2453 | n = min (len - i, PROP_SIZE); |
2465 | MEMCPY (ds, data + i, n); |
2454 | MEMCPY (ds, data + i, n); |
… | |
… | |
2484 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2473 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2485 | { |
2474 | { |
2486 | long nread = 0; |
2475 | long nread = 0; |
2487 | unsigned long bytes_after; |
2476 | unsigned long bytes_after; |
2488 | XTextProperty ct; |
2477 | XTextProperty ct; |
2489 | int dummy_count; |
|
|
2490 | char **cl; |
|
|
2491 | |
2478 | |
2492 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2479 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2493 | |
2480 | |
2494 | if (prop == None) /* check for failed XConvertSelection */ |
2481 | if (prop == None) /* check for failed XConvertSelection */ |
2495 | { |
2482 | { |
… | |
… | |
2498 | int selnum = R->selection_type & Sel_whereMask; |
2485 | int selnum = R->selection_type & Sel_whereMask; |
2499 | |
2486 | |
2500 | R->selection_type = 0; |
2487 | R->selection_type = 0; |
2501 | if (selnum != Sel_direct) |
2488 | if (selnum != Sel_direct) |
2502 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
2489 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
|
|
2490 | } |
|
|
2491 | |
|
|
2492 | if ((R->selection_type & Sel_UTF8String)) |
|
|
2493 | { |
|
|
2494 | int selnum = R->selection_type & Sel_whereMask; |
|
|
2495 | |
|
|
2496 | R->selection_type = Sel_CompoundText; |
|
|
2497 | if (selnum != Sel_direct) |
|
|
2498 | rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], selnum); |
|
|
2499 | else |
|
|
2500 | R->selection_type = 0; |
2503 | } |
2501 | } |
2504 | |
2502 | |
2505 | return 0; |
2503 | return 0; |
2506 | } |
2504 | } |
2507 | |
2505 | |
… | |
… | |
2542 | nread = -1; /* discount any previous stuff */ |
2540 | nread = -1; /* discount any previous stuff */ |
2543 | break; |
2541 | break; |
2544 | } |
2542 | } |
2545 | |
2543 | |
2546 | nread += ct.nitems; |
2544 | nread += ct.nitems; |
|
|
2545 | |
|
|
2546 | char **cl; |
|
|
2547 | int cr; |
2547 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2548 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2548 | &dummy_count) == Success && cl) |
2549 | &cr) >= 0 && cl) |
2549 | { |
2550 | { |
|
|
2551 | for (int i = 0; i < cr; i++) |
2550 | R->paste ((unsigned char *)cl[0], STRLEN (cl[0])); |
2552 | R->paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
|
|
2553 | |
2551 | XFreeStringList (cl); |
2554 | XFreeStringList (cl); |
2552 | } |
2555 | } |
2553 | else |
2556 | else |
2554 | R->paste (ct.value, ct.nitems); |
2557 | R->paste (ct.value, ct.nitems); |
2555 | |
2558 | |
… | |
… | |
2570 | } |
2573 | } |
2571 | |
2574 | |
2572 | void |
2575 | void |
2573 | rxvt_term::incr_cb (time_watcher &w) |
2576 | rxvt_term::incr_cb (time_watcher &w) |
2574 | { |
2577 | { |
2575 | w.stop (); |
|
|
2576 | selection_wait = Sel_none; |
2578 | selection_wait = Sel_none; |
2577 | |
2579 | |
2578 | rxvt_print_error("data loss: timeout on INCR selection paste"); |
2580 | rxvt_print_error ("data loss: timeout on INCR selection paste"); |
2579 | } |
2581 | } |
2580 | |
2582 | |
2581 | /* |
2583 | /* |
2582 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2584 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2583 | */ |
2585 | */ |
… | |
… | |
2649 | int i; |
2651 | int i; |
2650 | |
2652 | |
2651 | R->selection_request_time = tm; |
2653 | R->selection_request_time = tm; |
2652 | R->selection_wait = Sel_normal; |
2654 | R->selection_wait = Sel_normal; |
2653 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
2655 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
|
|
2656 | #if X_HAVE_UTF8_STRING |
|
|
2657 | R->selection_type = Sel_UTF8String; |
|
|
2658 | if (rxvt_selection_request_other(aR_ R->xa[XA_UTF8_STRING], i)) |
|
|
2659 | return; |
|
|
2660 | #else |
2654 | R->selection_type = Sel_CompoundText; |
2661 | R->selection_type = Sel_CompoundText; |
2655 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2662 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2656 | return; |
2663 | return; |
|
|
2664 | #endif |
2657 | } |
2665 | } |
2658 | } |
2666 | } |
2659 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2667 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2660 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2668 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2661 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
2669 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
… | |
… | |
2793 | { |
2801 | { |
2794 | free (new_selection_text); |
2802 | free (new_selection_text); |
2795 | return; |
2803 | return; |
2796 | } |
2804 | } |
2797 | |
2805 | |
2798 | // due to MB_MAX_CUR, selection wastage is usually high |
2806 | // due to MB_MAX_CUR, selection wastage is usually high, so realloc |
2799 | if (str - (char *)new_selection_text > 1024) |
2807 | if (str - (char *)new_selection_text > 1024) |
2800 | new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); |
2808 | new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); |
2801 | |
2809 | |
2802 | R->selection.len = i; |
2810 | R->selection.len = i; |
|
|
2811 | |
2803 | if (R->selection.text) |
2812 | if (R->selection.text) |
2804 | free (R->selection.text); |
2813 | free (R->selection.text); |
2805 | |
2814 | |
2806 | R->selection.text = new_selection_text; |
2815 | R->selection.text = new_selection_text; |
2807 | |
2816 | |
2808 | XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); |
2817 | XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); |
2809 | if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) |
2818 | if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) |
2810 | rxvt_print_error("can't get primary selection"); |
2819 | rxvt_print_error("can't get primary selection"); |
|
|
2820 | |
|
|
2821 | |
|
|
2822 | { |
|
|
2823 | XTextProperty ct; |
|
|
2824 | char *cl = (char *)R->selection.text; |
|
|
2825 | |
|
|
2826 | if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, XStringStyle, &ct) >= 0) |
|
|
2827 | { |
|
|
2828 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
|
|
2829 | PropModeReplace, ct.value, ct.nitems); |
|
|
2830 | XFree (ct.value); |
|
|
2831 | } |
|
|
2832 | else |
2811 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
2833 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
2812 | PropModeReplace, R->selection.text, (int)R->selection.len); |
2834 | PropModeReplace, R->selection.text, (int)R->selection.len); |
|
|
2835 | } |
|
|
2836 | |
2813 | R->selection_time = tm; |
2837 | R->selection_time = tm; |
2814 | D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); |
2838 | D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); |
2815 | } |
2839 | } |
2816 | |
2840 | |
2817 | /* ------------------------------------------------------------------------- */ |
2841 | /* ------------------------------------------------------------------------- */ |
2818 | /* |
2842 | /* |
2819 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2843 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2820 | * EXT: button 1 press |
2844 | * EXT: button 1 press |
2821 | */ |
2845 | */ |
2822 | /* EXTPROTO */ |
|
|
2823 | void |
2846 | void |
2824 | rxvt_selection_click(pR_ int clicks, int x, int y) |
2847 | rxvt_term::selection_click (int clicks, int x, int y) |
2825 | { |
2848 | { |
2826 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2849 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2827 | |
2850 | |
2828 | clicks = ((clicks - 1) % 3) + 1; |
2851 | clicks = ((clicks - 1) % 3) + 1; |
2829 | R->selection.clicks = clicks; /* save clicks so extend will work */ |
2852 | selection.clicks = clicks; /* save clicks so extend will work */ |
2830 | |
2853 | |
2831 | rxvt_selection_start_colrow(aR_ Pixel2Col(x), Pixel2Row(y)); |
2854 | rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y)); |
|
|
2855 | |
2832 | if (clicks == 2 || clicks == 3) |
2856 | if (clicks == 2 || clicks == 3) |
2833 | rxvt_selection_extend_colrow(aR_ R->selection.mark.col, |
2857 | rxvt_selection_extend_colrow (this, selection.mark.col, |
2834 | R->selection.mark.row |
|
|
2835 | + R->TermWin.view_start, |
2858 | selection.mark.row + TermWin.view_start, |
2836 | 0, /* button 3 */ |
2859 | 0, /* button 3 */ |
2837 | 1, /* button press */ |
2860 | 1, /* button press */ |
2838 | 0); /* click change */ |
2861 | 0); /* click change */ |
2839 | } |
2862 | } |
2840 | |
2863 | |
2841 | /* ------------------------------------------------------------------------- */ |
2864 | /* ------------------------------------------------------------------------- */ |
2842 | /* |
2865 | /* |
2843 | * Mark a selection at the specified col/row |
2866 | * Mark a selection at the specified col/row |
… | |
… | |
2953 | * EXT: button 3 press; button 1 or 3 drag |
2976 | * EXT: button 3 press; button 1 or 3 drag |
2954 | * flag == 0 ==> button 1 |
2977 | * flag == 0 ==> button 1 |
2955 | * flag == 1 ==> button 3 press |
2978 | * flag == 1 ==> button 3 press |
2956 | * flag == 2 ==> button 3 motion |
2979 | * flag == 2 ==> button 3 motion |
2957 | */ |
2980 | */ |
2958 | /* EXTPROTO */ |
|
|
2959 | void |
2981 | void |
2960 | rxvt_selection_extend(pR_ int x, int y, int flag) |
2982 | rxvt_term::selection_extend (int x, int y, int flag) |
2961 | { |
2983 | { |
2962 | int col, row; |
2984 | int col, row; |
2963 | |
2985 | |
2964 | col = Pixel2Col(x); |
2986 | col = Pixel2Col(x); |
2965 | row = Pixel2Row(y); |
2987 | row = Pixel2Row(y); |
2966 | MAX_IT(row, 0); |
2988 | MAX_IT(row, 0); |
2967 | MIN_IT(row, (int)R->TermWin.nrow - 1); |
2989 | MIN_IT(row, (int)TermWin.nrow - 1); |
2968 | MAX_IT(col, 0); |
2990 | MAX_IT(col, 0); |
2969 | MIN_IT(col, (int)R->TermWin.ncol); |
2991 | MIN_IT(col, (int)TermWin.ncol); |
|
|
2992 | |
2970 | #ifndef NO_NEW_SELECTION |
2993 | #ifndef NO_NEW_SELECTION |
2971 | /* |
2994 | /* |
2972 | * If we're selecting characters (single click) then we must check first |
2995 | * 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 |
2996 | * 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 |
2997 | * 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. |
2998 | * be _past_ a character for it to be selected. |
2976 | */ |
2999 | */ |
2977 | if (R->selection_style != OLD_SELECT) { |
3000 | if (selection_style != OLD_SELECT) |
|
|
3001 | { |
2978 | if (((R->selection.clicks % 3) == 1) && !flag |
3002 | if (((selection.clicks % 3) == 1) && !flag |
2979 | && (col == R->selection.mark.col |
3003 | && (col == selection.mark.col |
2980 | && (row == R->selection.mark.row + R->TermWin.view_start))) { |
3004 | && (row == selection.mark.row + TermWin.view_start))) |
|
|
3005 | { |
2981 | /* select nothing */ |
3006 | /* select nothing */ |
2982 | R->selection.beg.row = R->selection.end.row = 0; |
3007 | selection.beg.row = selection.end.row = 0; |
2983 | R->selection.beg.col = R->selection.end.col = 0; |
3008 | selection.beg.col = selection.end.col = 0; |
2984 | R->selection.clicks = 4; |
3009 | selection.clicks = 4; |
2985 | R->want_refresh = 1; |
3010 | want_refresh = 1; |
2986 | D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); |
3011 | D_SELECT((stderr, "rxvt_selection_extend() selection.clicks = 4")); |
2987 | return; |
3012 | return; |
2988 | } |
3013 | } |
2989 | } |
3014 | } |
2990 | #endif |
3015 | #endif |
2991 | if (R->selection.clicks == 4) |
3016 | if (selection.clicks == 4) |
2992 | R->selection.clicks = 1; |
3017 | selection.clicks = 1; |
|
|
3018 | |
2993 | rxvt_selection_extend_colrow(aR_ col, row, !!flag, /* ? button 3 */ |
3019 | rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */ |
2994 | flag == 1 ? 1 : 0, /* ? button press */ |
3020 | flag == 1 ? 1 : 0, /* ? button press */ |
2995 | 0); /* no click change */ |
3021 | 0); /* no click change */ |
2996 | } |
3022 | } |
2997 | |
3023 | |
2998 | /* ------------------------------------------------------------------------- */ |
3024 | /* ------------------------------------------------------------------------- */ |
2999 | /* |
3025 | /* |
3000 | * Extend the selection to the specified col/row |
3026 | * Extend the selection to the specified col/row |
… | |
… | |
3254 | /* ------------------------------------------------------------------------- */ |
3280 | /* ------------------------------------------------------------------------- */ |
3255 | /* |
3281 | /* |
3256 | * Double click on button 3 when already selected |
3282 | * Double click on button 3 when already selected |
3257 | * EXT: button 3 double click |
3283 | * EXT: button 3 double click |
3258 | */ |
3284 | */ |
3259 | /* EXTPROTO */ |
|
|
3260 | void |
3285 | void |
3261 | rxvt_selection_rotate(pR_ int x, int y) |
3286 | rxvt_term::selection_rotate (int x, int y) |
3262 | { |
3287 | { |
3263 | R->selection.clicks = R->selection.clicks % 3 + 1; |
3288 | selection.clicks = selection.clicks % 3 + 1; |
3264 | rxvt_selection_extend_colrow(aR_ Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3289 | rxvt_selection_extend_colrow (this, Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3265 | } |
3290 | } |
3266 | |
3291 | |
3267 | /* ------------------------------------------------------------------------- */ |
3292 | /* ------------------------------------------------------------------------- */ |
3268 | /* |
3293 | /* |
3269 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3294 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3270 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
3295 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
3271 | * the X11 protocol. |
3296 | * the X11 protocol. |
3272 | */ |
3297 | */ |
3273 | typedef CARD32 Atom32; |
3298 | typedef CARD32 Atom32; |
3274 | |
3299 | |
3275 | /* ------------------------------------------------------------------------- */ |
3300 | /* ------------------------------------------------------------------------- */ |
3276 | /* |
3301 | /* |
3277 | * Respond to a request for our current selection |
3302 | * Respond to a request for our current selection |
3278 | * EXT: SelectionRequest |
3303 | * EXT: SelectionRequest |
… | |
… | |
3280 | /* EXTPROTO */ |
3305 | /* EXTPROTO */ |
3281 | void |
3306 | void |
3282 | rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) |
3307 | rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) |
3283 | { |
3308 | { |
3284 | XSelectionEvent ev; |
3309 | XSelectionEvent ev; |
3285 | #ifdef USE_XIM |
|
|
3286 | Atom32 target_list[4]; |
|
|
3287 | #else |
|
|
3288 | Atom32 target_list[3]; |
|
|
3289 | #endif |
|
|
3290 | Atom target; |
|
|
3291 | XTextProperty ct; |
3310 | XTextProperty ct; |
3292 | XICCEncodingStyle style; |
3311 | XICCEncodingStyle style; |
3293 | char *cl[2], dummy[1]; |
3312 | Atom target; |
3294 | |
3313 | |
3295 | ev.type = SelectionNotify; |
3314 | ev.type = SelectionNotify; |
3296 | ev.property = None; |
3315 | ev.property = None; |
3297 | ev.display = rq->display; |
3316 | ev.display = rq->display; |
3298 | ev.requestor = rq->requestor; |
3317 | ev.requestor = rq->requestor; |
3299 | ev.selection = rq->selection; |
3318 | ev.selection = rq->selection; |
3300 | ev.target = rq->target; |
3319 | ev.target = rq->target; |
3301 | ev.time = rq->time; |
3320 | ev.time = rq->time; |
3302 | |
3321 | |
3303 | if (rq->target == R->xa[XA_TARGETS]) { |
3322 | if (rq->target == R->xa[XA_TARGETS]) { |
|
|
3323 | Atom32 target_list[5]; |
|
|
3324 | Atom32 *target = target_list; |
|
|
3325 | |
3304 | target_list[0] = (Atom32) R->xa[XA_TARGETS]; |
3326 | *target++ = (Atom32) R->xa[XA_TARGETS]; |
3305 | target_list[1] = (Atom32) XA_STRING; |
3327 | *target++ = (Atom32) XA_STRING; |
3306 | target_list[2] = (Atom32) R->xa[XA_TEXT]; |
3328 | *target++ = (Atom32) R->xa[XA_TEXT]; |
3307 | #ifdef USE_XIM |
|
|
3308 | target_list[3] = (Atom32) R->xa[XA_COMPOUND_TEXT]; |
3329 | *target++ = (Atom32) R->xa[XA_COMPOUND_TEXT]; |
|
|
3330 | #if X_HAVE_UTF8_STRING |
|
|
3331 | *target++ = (Atom32) R->xa[XA_UTF8_STRING]; |
3309 | #endif |
3332 | #endif |
3310 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, |
3333 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, |
3311 | (8 * sizeof(target_list[0])), PropModeReplace, |
3334 | (8 * sizeof(target_list[0])), PropModeReplace, |
3312 | (unsigned char *)target_list, |
3335 | (unsigned char *)target_list, |
3313 | (sizeof(target_list) / sizeof(target_list[0]))); |
3336 | target - target_list); |
3314 | ev.property = rq->property; |
3337 | ev.property = rq->property; |
3315 | } else if (rq->target == R->xa[XA_MULTIPLE]) { |
3338 | } else if (rq->target == R->xa[XA_MULTIPLE]) { |
3316 | /* TODO: Handle MULTIPLE */ |
3339 | /* TODO: Handle MULTIPLE */ |
3317 | } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { |
3340 | } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { |
3318 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, |
3341 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, |
3319 | (8 * sizeof(Time)), PropModeReplace, |
3342 | (8 * sizeof(Time)), PropModeReplace, |
3320 | (unsigned char *)&R->selection_time, 1); |
3343 | (unsigned char *)&R->selection_time, 1); |
3321 | ev.property = rq->property; |
3344 | ev.property = rq->property; |
3322 | } else if (rq->target == XA_STRING |
3345 | } else if (rq->target == XA_STRING |
|
|
3346 | || rq->target == R->xa[XA_TEXT] |
3323 | || rq->target == R->xa[XA_COMPOUND_TEXT] |
3347 | || rq->target == R->xa[XA_COMPOUND_TEXT] |
3324 | || rq->target == R->xa[XA_TEXT]) { |
3348 | || rq->target == R->xa[XA_UTF8_STRING] |
3325 | #ifdef USE_XIM |
3349 | ) { |
3326 | short freect = 0; |
3350 | short freect = 0; |
3327 | #endif |
|
|
3328 | int selectlen; |
3351 | int selectlen; |
|
|
3352 | char *cl; |
3329 | |
3353 | |
3330 | #ifdef USE_XIM |
3354 | target = rq->target; |
|
|
3355 | |
3331 | if (rq->target != XA_STRING) { |
3356 | if (target == XA_STRING) |
|
|
3357 | // we actually don't do XA_STRING, but who cares, as i18n clients |
|
|
3358 | // will ask for another format anyways. |
|
|
3359 | style = XStringStyle; |
|
|
3360 | else if (target == R->xa[XA_TEXT]) |
|
|
3361 | style = XTextStyle; |
|
|
3362 | else if (target == R->xa[XA_COMPOUND_TEXT]) |
|
|
3363 | style = XCompoundTextStyle; |
|
|
3364 | #if X_HAVE_UTF8_STRING |
|
|
3365 | else if (target == R->xa[XA_UTF8_STRING]) |
|
|
3366 | style = XUTF8StringStyle; |
|
|
3367 | #endif |
|
|
3368 | else |
|
|
3369 | { |
3332 | target = R->xa[XA_COMPOUND_TEXT]; |
3370 | target = R->xa[XA_COMPOUND_TEXT]; |
3333 | style = (rq->target == R->xa[XA_COMPOUND_TEXT]) |
|
|
3334 | ? XCompoundTextStyle : XStdICCTextStyle; |
|
|
3335 | } else |
|
|
3336 | #endif |
|
|
3337 | { |
|
|
3338 | target = XA_STRING; |
|
|
3339 | style = XStringStyle; |
3371 | style = XCompoundTextStyle; |
3340 | } |
3372 | } |
|
|
3373 | |
3341 | if (R->selection.text) { |
3374 | if (R->selection.text) { |
3342 | cl[0] = (char *)R->selection.text; |
3375 | cl = (char *)R->selection.text; |
3343 | selectlen = R->selection.len; |
3376 | selectlen = R->selection.len; |
3344 | } else { |
3377 | } else { |
3345 | cl[0] = dummy; |
3378 | cl = ""; |
3346 | *dummy = '\0'; |
|
|
3347 | selectlen = 0; |
3379 | selectlen = 0; |
3348 | } |
3380 | } |
3349 | #ifdef USE_XIM |
3381 | |
3350 | if (XmbTextListToTextProperty(R->Xdisplay, cl, 1, style, &ct) |
3382 | if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, style, &ct) >= 0) |
3351 | == Success) /* if we failed to convert then send it raw */ |
|
|
3352 | freect = 1; |
3383 | freect = 1; |
3353 | else |
3384 | else |
3354 | #endif |
|
|
3355 | { |
3385 | { |
|
|
3386 | /* if we failed to convert then send it raw */ |
3356 | ct.value = (unsigned char *)cl[0]; |
3387 | ct.value = (unsigned char *)cl; |
3357 | ct.nitems = selectlen; |
3388 | ct.nitems = selectlen; |
3358 | } |
3389 | } |
|
|
3390 | |
3359 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, |
3391 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, |
3360 | target, 8, PropModeReplace, |
3392 | target, 8, PropModeReplace, |
3361 | ct.value, (int)ct.nitems); |
3393 | ct.value, (int)ct.nitems); |
3362 | ev.property = rq->property; |
3394 | ev.property = rq->property; |
3363 | #ifdef USE_XIM |
3395 | |
3364 | if (freect) |
3396 | if (freect) |
3365 | XFree(ct.value); |
3397 | XFree (ct.value); |
3366 | #endif |
|
|
3367 | } |
3398 | } |
3368 | XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); |
3399 | XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); |
3369 | } |
3400 | } |
3370 | |
3401 | |
3371 | /* ------------------------------------------------------------------------- * |
3402 | /* ------------------------------------------------------------------------- * |
… | |
… | |
3373 | * ------------------------------------------------------------------------- */ |
3404 | * ------------------------------------------------------------------------- */ |
3374 | |
3405 | |
3375 | /* |
3406 | /* |
3376 | * return col/row values corresponding to x/y pixel values |
3407 | * return col/row values corresponding to x/y pixel values |
3377 | */ |
3408 | */ |
3378 | /* EXTPROTO */ |
|
|
3379 | void |
3409 | void |
3380 | rxvt_pixel_position(pR_ int *x, int *y) |
3410 | rxvt_term::pixel_position (int *x, int *y) |
3381 | { |
3411 | { |
3382 | *x = Pixel2Col(*x); |
3412 | *x = Pixel2Col(*x); |
3383 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3413 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3384 | *y = Pixel2Row(*y); |
3414 | *y = Pixel2Row(*y); |
3385 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3415 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3386 | } |
3416 | } |
|
|
3417 | |
3387 | /* ------------------------------------------------------------------------- */ |
3418 | /* ------------------------------------------------------------------------- */ |
3388 | #ifdef USE_XIM |
3419 | #ifdef USE_XIM |
3389 | /* EXTPROTO */ |
|
|
3390 | void |
3420 | void |
3391 | rxvt_setPosition(pR_ XPoint *pos) |
3421 | rxvt_term::set_position (XPoint *pos) |
3392 | { |
3422 | { |
3393 | XWindowAttributes xwa; |
3423 | XWindowAttributes xwa; |
3394 | |
3424 | |
3395 | XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &xwa); |
3425 | XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa); |
3396 | pos->x = Col2Pixel(R->screen.cur.col) + xwa.x; |
3426 | pos->x = Col2Pixel (screen.cur.col) + xwa.x; |
3397 | pos->y = Height2Pixel((R->screen.cur.row + 1)) + xwa.y |
3427 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3398 | - R->TermWin.lineSpace; |
|
|
3399 | } |
3428 | } |
|
|
3429 | |
3400 | #endif |
3430 | #endif |
3401 | /* ------------------------------------------------------------------------- */ |
3431 | /* ------------------------------------------------------------------------- */ |
3402 | |
3432 | |
3403 | /* ------------------------------------------------------------------------- * |
3433 | /* ------------------------------------------------------------------------- * |
3404 | * DEBUG ROUTINES * |
3434 | * DEBUG ROUTINES * |