1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.c |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * $Id: screen.C,v 1.10 2003/12/18 08:06:46 pcg Exp $ |
4 | * $Id: screen.C,v 1.12 2003/12/18 14:11:47 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. */ |
… | |
… | |
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 | |
… | |
… | |
1211 | * Erase part of whole of the screen |
1211 | * Erase part of whole of the screen |
1212 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1212 | * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J |
1213 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1213 | * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J |
1214 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1214 | * XTERM_SEQ: Clear whole screen : ESC [ 2 J |
1215 | */ |
1215 | */ |
1216 | /* EXTPROTO */ |
|
|
1217 | void |
1216 | void |
1218 | rxvt_scr_erase_screen(pR_ int mode) |
1217 | rxvt_term::scr_erase_screen (int mode) |
1219 | { |
1218 | { |
1220 | int num; |
1219 | int num; |
1221 | int32_t row, row_offset; |
1220 | int32_t row, row_offset; |
1222 | rend_t ren; |
1221 | rend_t ren; |
1223 | XGCValues gcvalue; |
1222 | XGCValues gcvalue; |
1224 | |
1223 | |
1225 | R->want_refresh = 1; |
1224 | want_refresh = 1; |
1226 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); |
1225 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row)); |
1227 | ZERO_SCROLLBACK(R); |
1226 | ZERO_SCROLLBACK(this); |
1228 | row_offset = (int32_t)R->TermWin.saveLines; |
1227 | row_offset = (int32_t)TermWin.saveLines; |
1229 | |
1228 | |
1230 | switch (mode) { |
1229 | switch (mode) { |
1231 | case 0: /* erase to end of screen */ |
1230 | case 0: /* erase to end of screen */ |
1232 | rxvt_selection_check(aR_ 1); |
1231 | rxvt_selection_check(this,1); |
1233 | rxvt_scr_erase_line(aR_ 0); |
1232 | rxvt_scr_erase_line(this,0); |
1234 | row = R->screen.cur.row + 1; /* possible OOB */ |
1233 | row = screen.cur.row + 1; /* possible OOB */ |
1235 | num = R->TermWin.nrow - row; |
1234 | num = TermWin.nrow - row; |
1236 | break; |
1235 | break; |
1237 | case 1: /* erase to beginning of screen */ |
1236 | case 1: /* erase to beginning of screen */ |
1238 | rxvt_selection_check(aR_ 3); |
1237 | rxvt_selection_check(this,3); |
1239 | rxvt_scr_erase_line(aR_ 1); |
1238 | rxvt_scr_erase_line(this,1); |
1240 | row = 0; |
1239 | row = 0; |
1241 | num = R->screen.cur.row; |
1240 | num = screen.cur.row; |
1242 | break; |
1241 | break; |
1243 | case 2: /* erase whole screen */ |
1242 | case 2: /* erase whole screen */ |
1244 | rxvt_selection_check(aR_ 3); |
1243 | rxvt_selection_check (this, 3); |
1245 | #ifdef RXVT_GRAPHICS |
1244 | #ifdef RXVT_GRAPHICS |
1246 | rxvt_Gr_ClearScreen(aR); |
1245 | rxvt_Gr_ClearScreen (this); |
1247 | #endif |
1246 | #endif |
1248 | row = 0; |
1247 | row = 0; |
1249 | num = R->TermWin.nrow; |
1248 | num = TermWin.nrow; |
1250 | break; |
1249 | break; |
1251 | default: |
1250 | default: |
1252 | return; |
1251 | return; |
1253 | } |
1252 | } |
1254 | R->refresh_type |= REFRESH_BOUNDS; |
1253 | refresh_type |= REFRESH_BOUNDS; |
1255 | if (R->selection.op && R->current_screen == R->selection.screen |
1254 | if (selection.op && current_screen == selection.screen |
1256 | && ((R->selection.beg.row >= row && R->selection.beg.row <= row + num) |
1255 | && ((selection.beg.row >= row && selection.beg.row <= row + num) |
1257 | || (R->selection.end.row >= row |
1256 | || (selection.end.row >= row |
1258 | && R->selection.end.row <= row + num))) |
1257 | && selection.end.row <= row + num))) |
1259 | CLEAR_SELECTION(R); |
1258 | CLEAR_SELECTION (this); |
1260 | if (row >= R->TermWin.nrow) /* Out Of Bounds */ |
1259 | if (row >= TermWin.nrow) /* Out Of Bounds */ |
1261 | return; |
1260 | return; |
1262 | MIN_IT(num, (R->TermWin.nrow - row)); |
1261 | MIN_IT(num, (TermWin.nrow - row)); |
1263 | if (R->rstyle & (RS_RVid | RS_Uline)) |
1262 | if (rstyle & (RS_RVid | RS_Uline)) |
1264 | ren = (rend_t) ~RS_None; |
1263 | ren = (rend_t) ~RS_None; |
1265 | else if (GET_BASEBG(R->rstyle) == Color_bg) { |
1264 | else if (GET_BASEBG(rstyle) == Color_bg) { |
1266 | ren = DEFAULT_RSTYLE; |
1265 | ren = DEFAULT_RSTYLE; |
1267 | CLEAR_ROWS(row, num); |
1266 | CLEAR_ROWS(row, num); |
1268 | } else { |
1267 | } else { |
1269 | ren = (R->rstyle & (RS_fgMask | RS_bgMask)); |
1268 | ren = (rstyle & (RS_fgMask | RS_bgMask)); |
1270 | gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->rstyle)]; |
1269 | gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)]; |
1271 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1270 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1272 | ERASE_ROWS(row, num); |
1271 | ERASE_ROWS(row, num); |
1273 | gcvalue.foreground = R->PixColors[Color_fg]; |
1272 | gcvalue.foreground = PixColors[Color_fg]; |
1274 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1273 | XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); |
1275 | } |
1274 | } |
1276 | for (; num--; row++) { |
1275 | for (; num--; row++) { |
1277 | R->scr_blank_screen_mem (R->screen.text, R->screen.rend, |
1276 | scr_blank_screen_mem (screen.text, screen.rend, |
1278 | (unsigned int)(row + row_offset), R->rstyle); |
1277 | (unsigned int)(row + row_offset), rstyle); |
1279 | R->screen.tlen[row + row_offset] = 0; |
1278 | screen.tlen[row + row_offset] = 0; |
1280 | R->scr_blank_line (R->drawn_text[row], R->drawn_rend[row], |
1279 | scr_blank_line (drawn_text[row], drawn_rend[row], |
1281 | (unsigned int)R->TermWin.ncol, ren); |
1280 | (unsigned int)TermWin.ncol, ren); |
1282 | } |
1281 | } |
1283 | } |
1282 | } |
1284 | |
1283 | |
1285 | /* ------------------------------------------------------------------------- */ |
1284 | /* ------------------------------------------------------------------------- */ |
1286 | /* |
1285 | /* |
… | |
… | |
1570 | |
1569 | |
1571 | gcvalue.foreground = R->PixColors[Color_fg]; |
1570 | gcvalue.foreground = R->PixColors[Color_fg]; |
1572 | gcvalue.background = R->PixColors[Color_bg]; |
1571 | gcvalue.background = R->PixColors[Color_bg]; |
1573 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1572 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, |
1574 | &gcvalue); |
1573 | &gcvalue); |
1575 | rxvt_scr_clear(aR); |
1574 | R->scr_clear (); |
1576 | rxvt_scr_touch(aR_ True); |
1575 | R->scr_touch (true); |
1577 | } |
1576 | } |
1578 | } |
1577 | } |
1579 | |
1578 | |
1580 | /* ------------------------------------------------------------------------- */ |
1579 | /* ------------------------------------------------------------------------- */ |
1581 | /* |
1580 | /* |
… | |
… | |
1684 | PART_BEG = 0, |
1683 | PART_BEG = 0, |
1685 | PART_END, |
1684 | PART_END, |
1686 | RC_COUNT |
1685 | RC_COUNT |
1687 | }; |
1686 | }; |
1688 | |
1687 | |
1689 | /* EXTPROTO */ |
|
|
1690 | void |
1688 | void |
1691 | rxvt_scr_expose(pR_ int x, int y, int width, int height, Bool refresh) |
1689 | rxvt_term::scr_expose (int x, int y, int width, int height, bool refresh) |
1692 | { |
1690 | { |
1693 | int i; |
1691 | int i; |
1694 | row_col_t rc[RC_COUNT]; |
1692 | row_col_t rc[RC_COUNT]; |
1695 | |
1693 | |
1696 | if (R->drawn_text == NULL) /* sanity check */ |
1694 | if (drawn_text == NULL) /* sanity check */ |
1697 | return; |
1695 | return; |
1698 | |
1696 | |
1699 | #ifdef DEBUG_STRICT |
1697 | #ifdef DEBUG_STRICT |
1700 | x = max(x, (int)R->TermWin.int_bwidth); |
1698 | x = max(x, (int)TermWin.int_bwidth); |
1701 | x = min(x, (int)R->TermWin.width); |
1699 | x = min(x, (int)TermWin.width); |
1702 | y = max(y, (int)R->TermWin.int_bwidth); |
1700 | y = max(y, (int)TermWin.int_bwidth); |
1703 | y = min(y, (int)R->TermWin.height); |
1701 | y = min(y, (int)TermWin.height); |
1704 | #endif |
1702 | #endif |
1705 | |
1703 | |
1706 | /* round down */ |
1704 | /* round down */ |
1707 | rc[PART_BEG].col = Pixel2Col(x); |
1705 | rc[PART_BEG].col = Pixel2Col(x); |
1708 | rc[PART_BEG].row = Pixel2Row(y); |
1706 | rc[PART_BEG].row = Pixel2Row(y); |
1709 | /* round up */ |
1707 | /* round up */ |
1710 | rc[PART_END].col = Pixel2Width(x + width + R->TermWin.fwidth - 1); |
1708 | rc[PART_END].col = Pixel2Width(x + width + TermWin.fwidth - 1); |
1711 | rc[PART_END].row = Pixel2Row(y + height + R->TermWin.fheight - 1); |
1709 | rc[PART_END].row = Pixel2Row(y + height + TermWin.fheight - 1); |
1712 | |
1710 | |
1713 | /* sanity checks */ |
1711 | /* sanity checks */ |
1714 | for (i = PART_BEG; i < RC_COUNT; i++) { |
1712 | for (i = PART_BEG; i < RC_COUNT; i++) |
|
|
1713 | { |
1715 | MIN_IT(rc[i].col, R->TermWin.ncol - 1); |
1714 | MIN_IT(rc[i].col, TermWin.ncol - 1); |
1716 | MIN_IT(rc[i].row, R->TermWin.nrow - 1); |
1715 | MIN_IT(rc[i].row, TermWin.nrow - 1); |
1717 | } |
1716 | } |
1718 | |
1717 | |
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)); |
1718 | 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 | |
1719 | |
1721 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1720 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1722 | fill_text (&(R->drawn_text[i][rc[PART_BEG].col]), 0, |
1721 | fill_text (&(drawn_text[i][rc[PART_BEG].col]), 0, |
1723 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1722 | (rc[PART_END].col - rc[PART_BEG].col + 1)); |
1724 | |
1723 | |
1725 | if (refresh) |
1724 | if (refresh) |
1726 | rxvt_scr_refresh(aR_ SLOW_REFRESH | REFRESH_BOUNDS); |
1725 | scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); |
1727 | } |
1726 | } |
1728 | |
1727 | |
1729 | /* ------------------------------------------------------------------------- */ |
1728 | /* ------------------------------------------------------------------------- */ |
1730 | /* |
1729 | /* |
1731 | * Refresh the entire screen |
1730 | * Refresh the entire screen |
1732 | */ |
1731 | */ |
1733 | /* EXTPROTO */ |
|
|
1734 | void |
1732 | void |
1735 | rxvt_scr_touch(pR_ Bool refresh) |
1733 | rxvt_term::scr_touch (bool refresh) |
1736 | { |
1734 | { |
1737 | rxvt_scr_expose(aR_ 0, 0, R->TermWin.width, R->TermWin.height, refresh); |
1735 | scr_expose (0, 0, TermWin.width, TermWin.height, refresh); |
1738 | } |
1736 | } |
1739 | |
1737 | |
1740 | /* ------------------------------------------------------------------------- */ |
1738 | /* ------------------------------------------------------------------------- */ |
1741 | /* |
1739 | /* |
1742 | * Move the display so that the line represented by scrollbar value Y is at |
1740 | * Move the display so that the line represented by scrollbar value Y is at |
… | |
… | |
1879 | #define FONT_LBEAR(X, Y) \ |
1877 | #define FONT_LBEAR(X, Y) \ |
1880 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1878 | (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing |
1881 | #define IS_FONT_CHAR(X, Y) \ |
1879 | #define IS_FONT_CHAR(X, Y) \ |
1882 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1880 | ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) |
1883 | |
1881 | |
1884 | /* EXTPROTO */ |
|
|
1885 | void |
1882 | void |
1886 | rxvt_scr_refresh(pR_ unsigned char refresh_type) |
1883 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1887 | { |
1884 | { |
1888 | unsigned char clearfirst, /* first character writes before cell */ |
1885 | unsigned char clearfirst, /* first character writes before cell */ |
1889 | clearlast, /* last character writes beyond cell */ |
1886 | clearlast, /* last character writes beyond cell */ |
1890 | must_clear, /* use draw_string not draw_image_string */ |
1887 | must_clear, /* use draw_string not draw_image_string */ |
1891 | #ifndef NO_BOLDFONT |
1888 | #ifndef NO_BOLDFONT |
… | |
… | |
1904 | rend_t cc1; /* store colours at cursor position(s) */ |
1901 | rend_t cc1; /* store colours at cursor position(s) */ |
1905 | rend_t cc2; /* store colours at cursor position(s) */ |
1902 | rend_t cc2; /* store colours at cursor position(s) */ |
1906 | #endif |
1903 | #endif |
1907 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1904 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1908 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1905 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1909 | char *buffer; /* local copy of R->buffer */ |
|
|
1910 | |
1906 | |
1911 | if (refresh_type == NO_REFRESH || !R->TermWin.mapped) |
1907 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1912 | return; |
1908 | return; |
1913 | |
1909 | |
1914 | /* |
1910 | /* |
1915 | * A: set up vars |
1911 | * A: set up vars |
1916 | */ |
1912 | */ |
1917 | clearfirst = clearlast = must_clear = wbyte = 0; |
1913 | clearfirst = clearlast = must_clear = wbyte = 0; |
1918 | #ifndef NO_BOLDFONT |
1914 | #ifndef NO_BOLDFONT |
1919 | bfont = 0; |
1915 | bfont = 0; |
1920 | #endif |
1916 | #endif |
1921 | |
1917 | |
1922 | if (R->currmaxcol < R->TermWin.ncol) |
1918 | if (currmaxcol < TermWin.ncol) |
1923 | { |
1919 | { |
1924 | R->currmaxcol = R->TermWin.ncol; |
1920 | currmaxcol = TermWin.ncol; |
1925 | R->buffer = (char *)rxvt_realloc (R->buffer, |
1921 | buffer = (char *)rxvt_realloc (buffer, |
1926 | sizeof(char) * (R->currmaxcol + 1) * MB_CUR_MAX); |
1922 | sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); |
1927 | } |
1923 | } |
1928 | |
1924 | |
1929 | buffer = R->buffer; |
|
|
1930 | R->refresh_count = 0; |
1925 | refresh_count = 0; |
1931 | |
1926 | |
1932 | row_offset = R->TermWin.saveLines - R->TermWin.view_start; |
1927 | row_offset = TermWin.saveLines - TermWin.view_start; |
1933 | |
1928 | |
1934 | if ((refresh_type & REFRESH_BOUNDS)) |
1929 | if ((refresh_type & REFRESH_BOUNDS)) |
1935 | { |
1930 | { |
1936 | clearfirst = clearlast = 1; |
1931 | clearfirst = clearlast = 1; |
1937 | R->refresh_type &= ~REFRESH_BOUNDS; |
1932 | refresh_type &= ~REFRESH_BOUNDS; |
1938 | } |
1933 | } |
1939 | |
1934 | |
1940 | #if defined(XPM_BACKGROUND) |
1935 | #if defined(XPM_BACKGROUND) |
1941 | must_clear |= (R->bgPixmap.pixmap != None); |
1936 | must_clear |= (bgPixmap.pixmap != None); |
1942 | #endif |
1937 | #endif |
1943 | #if defined(TRANSPARENT) |
1938 | #if defined(TRANSPARENT) |
1944 | must_clear |= ((R->Options & Opt_transparent) && R->am_transparent); |
1939 | must_clear |= ((Options & Opt_transparent) && am_transparent); |
1945 | #endif |
1940 | #endif |
1946 | ocrow = R->oldcursor.row; /* is there an old outline cursor on screen? */ |
1941 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1947 | |
1942 | |
1948 | /* |
1943 | /* |
1949 | * B: reverse any characters which are selected |
1944 | * B: reverse any characters which are selected |
1950 | */ |
1945 | */ |
1951 | rxvt_scr_reverse_selection(aR); |
1946 | rxvt_scr_reverse_selection (this); |
1952 | |
1947 | |
1953 | /* |
1948 | /* |
1954 | * C: set the cursor character(s) |
1949 | * C: set the cursor character(s) |
1955 | */ |
1950 | */ |
1956 | { |
1951 | { |
1957 | unsigned char setoldcursor; |
1952 | unsigned char setoldcursor; |
1958 | rend_t ccol1, /* Cursor colour */ |
1953 | rend_t ccol1, /* Cursor colour */ |
1959 | ccol2; /* Cursor colour2 */ |
1954 | ccol2; /* Cursor colour2 */ |
1960 | |
1955 | |
1961 | showcursor = (R->screen.flags & Screen_VisibleCursor); |
1956 | showcursor = (screen.flags & Screen_VisibleCursor); |
1962 | cursorwidth = 0; |
1957 | cursorwidth = 0; |
1963 | #ifdef CURSOR_BLINK |
1958 | #ifdef CURSOR_BLINK |
1964 | if (R->hidden_cursor) |
1959 | if (hidden_cursor) |
1965 | showcursor = 0; |
1960 | showcursor = 0; |
1966 | #endif |
1961 | #endif |
1967 | |
1962 | |
1968 | cursorwidth = 0; |
1963 | cursorwidth = 0; |
1969 | |
1964 | |
1970 | if (showcursor) |
1965 | if (showcursor) |
1971 | { |
1966 | { |
1972 | cursorwidth++; |
1967 | cursorwidth++; |
1973 | |
1968 | |
1974 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
1969 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
1975 | [R->screen.cur.col]); |
1970 | [screen.cur.col]); |
1976 | |
1971 | |
1977 | if (showcursor && R->TermWin.focus) |
1972 | if (showcursor && TermWin.focus) |
1978 | { |
1973 | { |
1979 | *srp ^= RS_RVid; |
1974 | *srp ^= RS_RVid; |
1980 | #ifndef NO_CURSORCOLOR |
1975 | #ifndef NO_CURSORCOLOR |
1981 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1976 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
1982 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) |
1977 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
1983 | ccol1 = Color_cursor; |
1978 | ccol1 = Color_cursor; |
1984 | else |
1979 | else |
1985 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1980 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1986 | ccol1 = GET_FGCOLOR(R->rstyle); |
1981 | ccol1 = GET_FGCOLOR(rstyle); |
1987 | #else |
1982 | #else |
1988 | ccol1 = Color_fg; |
1983 | ccol1 = Color_fg; |
1989 | #endif |
1984 | #endif |
1990 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor2)) |
1985 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor2)) |
1991 | ccol2 = Color_cursor2; |
1986 | ccol2 = Color_cursor2; |
1992 | else |
1987 | else |
1993 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1988 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1994 | ccol2 = GET_BGCOLOR(R->rstyle); |
1989 | ccol2 = GET_BGCOLOR(rstyle); |
1995 | #else |
1990 | #else |
1996 | ccol2 = Color_bg; |
1991 | ccol2 = Color_bg; |
1997 | #endif |
1992 | #endif |
1998 | *srp = SET_FGCOLOR(*srp, ccol1); |
1993 | *srp = SET_FGCOLOR(*srp, ccol1); |
1999 | *srp = SET_BGCOLOR(*srp, ccol2); |
1994 | *srp = SET_BGCOLOR(*srp, ccol2); |
… | |
… | |
2005 | } |
2000 | } |
2006 | |
2001 | |
2007 | /* make sure no outline cursor is left around */ |
2002 | /* make sure no outline cursor is left around */ |
2008 | setoldcursor = 0; |
2003 | setoldcursor = 0; |
2009 | if (ocrow != -1) { |
2004 | if (ocrow != -1) { |
2010 | if (R->screen.cur.row + R->TermWin.view_start != ocrow |
2005 | if (screen.cur.row + TermWin.view_start != ocrow |
2011 | || R->screen.cur.col != R->oldcursor.col) { |
2006 | || screen.cur.col != oldcursor.col) { |
2012 | if (ocrow < R->TermWin.nrow |
2007 | if (ocrow < TermWin.nrow |
2013 | && R->oldcursor.col < R->TermWin.ncol) { |
2008 | && oldcursor.col < TermWin.ncol) { |
2014 | R->drawn_rend[ocrow][R->oldcursor.col] ^= (RS_RVid | RS_Uline); |
2009 | drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); |
2015 | } |
2010 | } |
2016 | if (R->TermWin.focus || !showcursor) |
2011 | if (TermWin.focus || !showcursor) |
2017 | R->oldcursor.row = -1; |
2012 | oldcursor.row = -1; |
2018 | else |
2013 | else |
2019 | setoldcursor = 1; |
2014 | setoldcursor = 1; |
2020 | } |
2015 | } |
2021 | } else if (!R->TermWin.focus) |
2016 | } else if (!TermWin.focus) |
2022 | setoldcursor = 1; |
2017 | setoldcursor = 1; |
2023 | if (setoldcursor) { |
2018 | if (setoldcursor) { |
2024 | if (R->screen.cur.row + R->TermWin.view_start >= R->TermWin.nrow) |
2019 | if (screen.cur.row + TermWin.view_start >= TermWin.nrow) |
2025 | R->oldcursor.row = -1; |
2020 | oldcursor.row = -1; |
2026 | else { |
2021 | else { |
2027 | R->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; |
2022 | oldcursor.row = screen.cur.row + TermWin.view_start; |
2028 | R->oldcursor.col = R->screen.cur.col; |
2023 | oldcursor.col = screen.cur.col; |
2029 | } |
2024 | } |
2030 | } |
2025 | } |
2031 | } |
2026 | } |
2032 | |
2027 | |
2033 | #ifndef NO_SLOW_LINK_SUPPORT |
2028 | #ifndef NO_SLOW_LINK_SUPPORT |
2034 | /* |
2029 | /* |
2035 | * D: CopyArea pass - very useful for slower links |
2030 | * D: CopyArea pass - very useful for slower links |
2036 | * This has been deliberately kept simple. |
2031 | * This has been deliberately kept simple. |
2037 | */ |
2032 | */ |
2038 | i = R->num_scr; |
2033 | i = num_scr; |
2039 | if (refresh_type == FAST_REFRESH && R->num_scr_allow && i |
2034 | if (refresh_type == FAST_REFRESH && num_scr_allow && i |
2040 | && abs(i) < R->TermWin.nrow && !must_clear) |
2035 | && abs(i) < TermWin.nrow && !must_clear) |
2041 | { |
2036 | { |
2042 | int16_t nits; |
2037 | int16_t nits; |
2043 | int j; |
2038 | int j; |
2044 | rend_t *drp2; |
2039 | rend_t *drp2; |
2045 | text_t *dtp2; |
2040 | text_t *dtp2; |
2046 | int len, wlen; |
2041 | int len, wlen; |
2047 | |
2042 | |
2048 | j = R->TermWin.nrow; |
2043 | j = TermWin.nrow; |
2049 | wlen = len = -1; |
2044 | wlen = len = -1; |
2050 | row = i > 0 ? 0 : j - 1; |
2045 | row = i > 0 ? 0 : j - 1; |
2051 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2046 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2052 | { |
2047 | { |
2053 | if (row + i >= 0 && row + i < R->TermWin.nrow && row + i != ocrow) |
2048 | if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow) |
2054 | { |
2049 | { |
2055 | stp = R->screen.text[row + row_offset]; |
2050 | stp = screen.text[row + row_offset]; |
2056 | srp = R->screen.rend[row + row_offset]; |
2051 | srp = screen.rend[row + row_offset]; |
2057 | dtp = R->drawn_text[row]; |
2052 | dtp = drawn_text[row]; |
2058 | dtp2 = R->drawn_text[row + i]; |
2053 | dtp2 = drawn_text[row + i]; |
2059 | drp = R->drawn_rend[row]; |
2054 | drp = drawn_rend[row]; |
2060 | drp2 = R->drawn_rend[row + i]; |
2055 | drp2 = drawn_rend[row + i]; |
2061 | |
2056 | |
2062 | for (nits = 0, col = R->TermWin.ncol; col--; ) |
2057 | for (nits = 0, col = TermWin.ncol; col--; ) |
2063 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2058 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2064 | nits--; |
2059 | nits--; |
2065 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2060 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2066 | nits++; |
2061 | nits++; |
2067 | |
2062 | |
2068 | if (nits > 8) /* XXX: arbitrary choice */ |
2063 | if (nits > 8) /* XXX: arbitrary choice */ |
2069 | { |
2064 | { |
2070 | for (col = R->TermWin.ncol; col--; ) |
2065 | for (col = TermWin.ncol; col--; ) |
2071 | { |
2066 | { |
2072 | *dtp++ = *dtp2++; |
2067 | *dtp++ = *dtp2++; |
2073 | *drp++ = *drp2++; |
2068 | *drp++ = *drp2++; |
2074 | } |
2069 | } |
2075 | |
2070 | |
… | |
… | |
2084 | if (len != -1) |
2079 | if (len != -1) |
2085 | { |
2080 | { |
2086 | /* also comes here at end if needed because of >= above */ |
2081 | /* also comes here at end if needed because of >= above */ |
2087 | if (wlen < len) |
2082 | if (wlen < len) |
2088 | SWAP_IT(wlen, len, int); |
2083 | SWAP_IT(wlen, len, int); |
|
|
2084 | |
2089 | D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
2085 | 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, |
2086 | XCopyArea (Xdisplay, TermWin.vt, TermWin.vt, |
2091 | R->TermWin.gc, 0, Row2Pixel(len + i), |
2087 | TermWin.gc, 0, Row2Pixel (len + i), |
2092 | (unsigned int)TermWin_TotalWidth(), |
2088 | (unsigned int)TermWin_TotalWidth (), |
2093 | (unsigned int)Height2Pixel(wlen - len + 1), |
2089 | (unsigned int)Height2Pixel (wlen - len + 1), |
2094 | 0, Row2Pixel(len)); |
2090 | 0, Row2Pixel (len)); |
2095 | len = -1; |
2091 | len = -1; |
2096 | } |
2092 | } |
2097 | } |
2093 | } |
2098 | } |
2094 | } |
2099 | #endif |
2095 | #endif |
2100 | |
2096 | |
2101 | /* |
2097 | /* |
2102 | * E: main pass across every character |
2098 | * E: main pass across every character |
2103 | */ |
2099 | */ |
2104 | for (row = 0; row < R->TermWin.nrow; row++) |
2100 | for (row = 0; row < TermWin.nrow; row++) |
2105 | { |
2101 | { |
2106 | stp = R->screen.text[row + row_offset]; |
2102 | stp = screen.text[row + row_offset]; |
2107 | srp = R->screen.rend[row + row_offset]; |
2103 | srp = screen.rend[row + row_offset]; |
2108 | dtp = R->drawn_text[row]; |
2104 | dtp = drawn_text[row]; |
2109 | drp = R->drawn_rend[row]; |
2105 | drp = drawn_rend[row]; |
2110 | |
2106 | |
2111 | /* |
2107 | /* |
2112 | * E2: OK, now the real pass |
2108 | * E2: OK, now the real pass |
2113 | */ |
2109 | */ |
2114 | int ypixel = (int)Row2Pixel(row); |
2110 | int ypixel = (int)Row2Pixel(row); |
2115 | |
2111 | |
2116 | for (col = 0; col < R->TermWin.ncol; col++) |
2112 | for (col = 0; col < TermWin.ncol; col++) |
2117 | { |
2113 | { |
2118 | /* compare new text with old - if exactly the same then continue */ |
2114 | /* compare new text with old - if exactly the same then continue */ |
2119 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2115 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2120 | |
2116 | |
2121 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2117 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
… | |
… | |
2137 | |
2133 | |
2138 | int xpixel = Col2Pixel(col); |
2134 | int xpixel = Col2Pixel(col); |
2139 | |
2135 | |
2140 | // this loop looks very messy, it can probably be optimized |
2136 | // this loop looks very messy, it can probably be optimized |
2141 | // and cleaned a bit by you? |
2137 | // and cleaned a bit by you? |
2142 | for (i = 0; ++col < R->TermWin.ncol; ) |
2138 | for (i = 0; ++col < TermWin.ncol; ) |
2143 | { |
2139 | { |
2144 | if (stp[col] == NOCHAR) |
2140 | if (stp[col] == NOCHAR) |
2145 | { |
2141 | { |
2146 | dtp[col] = stp[col]; |
2142 | dtp[col] = stp[col]; |
2147 | drp[col] = rend; |
2143 | drp[col] = rend; |
… | |
… | |
2173 | } |
2169 | } |
2174 | |
2170 | |
2175 | col--; /* went one too far. move back */ |
2171 | col--; /* went one too far. move back */ |
2176 | count -= i; /* dump any matching trailing chars */ |
2172 | count -= i; /* dump any matching trailing chars */ |
2177 | |
2173 | |
2178 | /* |
2174 | /* |
2179 | * Determine the attributes for the string |
2175 | * Determine the attributes for the string |
2180 | */ |
2176 | */ |
2181 | int fid = GET_FONT(rend); |
2177 | int fid = GET_FONT(rend); |
2182 | fore = GET_FGCOLOR(rend); |
2178 | fore = GET_FGCOLOR(rend); |
2183 | back = GET_BGCOLOR(rend); |
2179 | back = GET_BGCOLOR(rend); |
2184 | rend = GET_ATTR(rend); |
2180 | rend = GET_ATTR(rend); |
2185 | |
2181 | |
2186 | rvid = (rend & RS_RVid) ? 1 : 0; |
2182 | rvid = (rend & RS_RVid) ? 1 : 0; |
2187 | #ifdef OPTION_HC |
2183 | #ifdef OPTION_HC |
2188 | if (!rvid && (rend & RS_Blink)) |
2184 | if (!rvid && (rend & RS_Blink)) |
2189 | { |
2185 | { |
2190 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_HC)) |
2186 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) |
2191 | back = Color_HC; |
2187 | back = Color_HC; |
2192 | else |
2188 | else |
2193 | rvid = !rvid; /* fall back */ |
2189 | rvid = !rvid; /* fall back */ |
2194 | } |
2190 | } |
2195 | #endif |
2191 | #endif |
2196 | if (rvid) |
2192 | if (rvid) |
2197 | { |
2193 | { |
2198 | SWAP_IT(fore, back, int); |
2194 | SWAP_IT(fore, back, int); |
2199 | |
2195 | |
2200 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2196 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2201 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_RV) |
2197 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_RV) |
2202 | # ifndef NO_CURSORCOLOR |
2198 | # ifndef NO_CURSORCOLOR |
2203 | && !ISSET_PIXCOLOR(R, Color_cursor) |
2199 | && !ISSET_PIXCOLOR (this, Color_cursor) |
2204 | # endif |
2200 | # endif |
2205 | ) |
2201 | ) |
2206 | back = Color_RV; |
2202 | back = Color_RV; |
2207 | #endif |
2203 | #endif |
2208 | } |
2204 | } |
2209 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2205 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2210 | else if (rend & RS_Bold) |
2206 | else if (rend & RS_Bold) |
2211 | { |
2207 | { |
2212 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_BD)) |
2208 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD)) |
2213 | { |
2209 | { |
2214 | fore = Color_BD; |
2210 | fore = Color_BD; |
2215 | # ifndef VERYBOLD |
2211 | # ifndef VERYBOLD |
2216 | rend &= ~RS_Bold; /* we've taken care of it */ |
2212 | rend &= ~RS_Bold; /* we've taken care of it */ |
2217 | # endif |
2213 | # endif |
2218 | } |
2214 | } |
2219 | } |
2215 | } |
2220 | else if (rend & RS_Uline) |
2216 | else if (rend & RS_Uline) |
2221 | { |
2217 | { |
2222 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_UL)) |
2218 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) |
2223 | { |
2219 | { |
2224 | fore = Color_UL; |
2220 | fore = Color_UL; |
2225 | rend &= ~RS_Uline; /* we've taken care of it */ |
2221 | rend &= ~RS_Uline; /* we've taken care of it */ |
2226 | } |
2222 | } |
2227 | } |
2223 | } |
2228 | #endif |
2224 | #endif |
2229 | |
2225 | |
2230 | /* |
2226 | /* |
2231 | * Actually do the drawing of the string here |
2227 | * Actually do the drawing of the string here |
2232 | */ |
2228 | */ |
2233 | rxvt_font *font = (*R->TermWin.fontset)[fid]; |
2229 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2234 | |
2230 | |
2235 | if (back == Color_bg) |
2231 | if (back == Color_bg) |
2236 | { |
2232 | { |
2237 | if (must_clear) |
2233 | if (must_clear) |
2238 | { |
2234 | { |
… | |
… | |
2241 | { |
2237 | { |
2242 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2238 | font->draw (xpixel, ypixel, text, count, fore, -1); |
2243 | goto nodraw; |
2239 | goto nodraw; |
2244 | } |
2240 | } |
2245 | |
2241 | |
2246 | CLEAR_CHARS(xpixel, ypixel, count); |
2242 | CLEAR_CHARS (xpixel, ypixel, count); |
2247 | nodraw: ; |
2243 | nodraw: ; |
2248 | } |
2244 | } |
2249 | else |
2245 | else |
2250 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2246 | font->draw (xpixel, ypixel, text, count, fore, Color_bg); |
2251 | } |
2247 | } |
2252 | else |
2248 | else |
2253 | font->draw (xpixel, ypixel, text, count, fore, back); |
2249 | font->draw (xpixel, ypixel, text, count, fore, back); |
2254 | |
2250 | |
2255 | if ((rend & RS_Uline) && (font->descent > 1)) |
2251 | if ((rend & RS_Uline) && (font->descent > 1)) |
2256 | XDrawLine(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2252 | XDrawLine(Xdisplay, drawBuffer, TermWin.gc, |
2257 | xpixel, ypixel + font->ascent + 1, |
2253 | xpixel, ypixel + font->ascent + 1, |
2258 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2254 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2259 | } /* for (col....) */ |
2255 | } /* for (col....) */ |
2260 | } /* for (row....) */ |
2256 | } /* for (row....) */ |
2261 | |
2257 | |
2262 | /* |
2258 | /* |
2263 | * G: cleanup cursor and display outline cursor if necessary |
2259 | * G: cleanup cursor and display outline cursor if necessary |
2264 | */ |
2260 | */ |
2265 | if (showcursor) { |
2261 | if (showcursor) { |
2266 | if (R->TermWin.focus) { |
2262 | if (TermWin.focus) { |
2267 | srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] |
2263 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
2268 | [R->screen.cur.col]); |
2264 | [screen.cur.col]); |
2269 | *srp ^= RS_RVid; |
2265 | *srp ^= RS_RVid; |
2270 | #ifndef NO_CURSORCOLOR |
2266 | #ifndef NO_CURSORCOLOR |
2271 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2267 | *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; |
2272 | #endif |
2268 | #endif |
2273 | } else if (R->oldcursor.row >= 0) { |
2269 | } else if (oldcursor.row >= 0) { |
2274 | #ifndef NO_CURSORCOLOR |
2270 | #ifndef NO_CURSORCOLOR |
2275 | unsigned long gcmask; /* Graphics Context mask */ |
2271 | unsigned long gcmask; /* Graphics Context mask */ |
2276 | |
2272 | |
2277 | if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) { |
2273 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) |
2278 | XSetForeground (R->Xdisplay, R->TermWin.gc, R->PixColors[Color_cursor]); |
2274 | XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); |
2279 | } |
|
|
2280 | #endif |
2275 | #endif |
2281 | XDrawRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, |
2276 | XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, |
2282 | Col2Pixel(R->oldcursor.col), |
2277 | Col2Pixel(oldcursor.col), |
2283 | Row2Pixel(R->oldcursor.row), |
2278 | Row2Pixel(oldcursor.row), |
2284 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2279 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2285 | (unsigned int)(Height2Pixel(1) - R->TermWin.lineSpace - 1)); |
2280 | (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); |
2286 | } |
2281 | } |
2287 | } |
2282 | } |
2288 | /* |
2283 | |
|
|
2284 | /* |
2289 | * H: cleanup selection |
2285 | * H: cleanup selection |
2290 | */ |
2286 | */ |
2291 | rxvt_scr_reverse_selection(aR); |
2287 | rxvt_scr_reverse_selection (this); |
2292 | |
2288 | |
2293 | /* |
2289 | /* |
2294 | * I: other general cleanup |
2290 | * I: other general cleanup |
2295 | */ |
2291 | */ |
2296 | if (clearfirst && R->TermWin.int_bwidth) |
2292 | if (clearfirst && TermWin.int_bwidth) |
2297 | /* |
2293 | /* |
2298 | * clear the whole screen height, note that width == 0 is treated |
2294 | * clear the whole screen height, note that width == 0 is treated |
2299 | * specially by XClearArea |
2295 | * specially by XClearArea |
2300 | */ |
2296 | */ |
2301 | XClearArea(R->Xdisplay, R->TermWin.vt, 0, 0, |
2297 | XClearArea(Xdisplay, TermWin.vt, 0, 0, |
2302 | (unsigned int)R->TermWin.int_bwidth, |
2298 | (unsigned int)TermWin.int_bwidth, |
2303 | (unsigned int)TermWin_TotalHeight(), False); |
2299 | (unsigned int)TermWin_TotalHeight(), False); |
2304 | if (clearlast && R->TermWin.int_bwidth) |
2300 | if (clearlast && TermWin.int_bwidth) |
2305 | /* |
2301 | /* |
2306 | * clear the whole screen height, note that width == 0 is treated |
2302 | * clear the whole screen height, note that width == 0 is treated |
2307 | * specially by XClearArea |
2303 | * specially by XClearArea |
2308 | */ |
2304 | */ |
2309 | XClearArea(R->Xdisplay, R->TermWin.vt, |
2305 | XClearArea(Xdisplay, TermWin.vt, |
2310 | R->TermWin.width + R->TermWin.int_bwidth, 0, |
2306 | TermWin.width + TermWin.int_bwidth, 0, |
2311 | (unsigned int)R->TermWin.int_bwidth, |
2307 | (unsigned int)TermWin.int_bwidth, |
2312 | (unsigned int)TermWin_TotalHeight(), False); |
2308 | (unsigned int)TermWin_TotalHeight(), False); |
2313 | if (refresh_type & SMOOTH_REFRESH) |
2309 | if (refresh_type & SMOOTH_REFRESH) |
2314 | XSync(R->Xdisplay, False); |
2310 | XSync(Xdisplay, False); |
2315 | |
2311 | |
2316 | R->num_scr = 0; |
2312 | num_scr = 0; |
2317 | R->num_scr_allow = 1; |
2313 | num_scr_allow = 1; |
2318 | R->want_refresh = 0; /* screen is current */ |
2314 | want_refresh = 0; /* screen is current */ |
2319 | } |
2315 | } |
2320 | /* ------------------------------------------------------------------------- */ |
|
|
2321 | |
2316 | |
2322 | /* EXTPROTO */ |
2317 | /* ------------------------------------------------------------------------- */ |
2323 | void |
2318 | void |
2324 | rxvt_scr_clear(pR) |
2319 | rxvt_term::scr_clear() |
2325 | { |
2320 | { |
2326 | if (!R->TermWin.mapped) |
2321 | if (!TermWin.mapped) |
2327 | return; |
2322 | return; |
|
|
2323 | |
2328 | R->num_scr_allow = 0; |
2324 | num_scr_allow = 0; |
2329 | R->want_refresh = 1; |
2325 | want_refresh = 1; |
2330 | #ifdef TRANSPARENT |
2326 | #ifdef TRANSPARENT |
2331 | if ((R->Options & Opt_transparent) && (R->am_pixmap_trans == 0)) { |
2327 | if ((Options & Opt_transparent) && (am_pixmap_trans == 0)) |
2332 | int i; |
2328 | { |
|
|
2329 | int i; |
2333 | |
2330 | |
2334 | if (!(R->Options & Opt_transparent_all)) |
2331 | if (!(Options & Opt_transparent_all)) |
2335 | i = 0; |
2332 | i = 0; |
2336 | else |
2333 | else |
2337 | i = (int)(sizeof(R->TermWin.parent) / sizeof(Window)); |
2334 | i = (int)(sizeof(TermWin.parent) / sizeof(Window)); |
2338 | for (; i--;) |
2335 | |
|
|
2336 | while (i--) |
2339 | if (R->TermWin.parent[i] != None) |
2337 | if (TermWin.parent[i] != None) |
2340 | XClearWindow(R->Xdisplay, R->TermWin.parent[i]); |
2338 | XClearWindow(Xdisplay, TermWin.parent[i]); |
2341 | } |
2339 | } |
2342 | #endif |
2340 | #endif |
|
|
2341 | |
2343 | XClearWindow(R->Xdisplay, R->TermWin.vt); |
2342 | XClearWindow (Xdisplay, TermWin.vt); |
2344 | } |
2343 | } |
2345 | |
2344 | |
2346 | /* ------------------------------------------------------------------------- */ |
2345 | /* ------------------------------------------------------------------------- */ |
2347 | /* INTPROTO */ |
2346 | /* INTPROTO */ |
2348 | void |
2347 | void |
… | |
… | |
2822 | /* ------------------------------------------------------------------------- */ |
2821 | /* ------------------------------------------------------------------------- */ |
2823 | /* |
2822 | /* |
2824 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2823 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2825 | * EXT: button 1 press |
2824 | * EXT: button 1 press |
2826 | */ |
2825 | */ |
2827 | /* EXTPROTO */ |
|
|
2828 | void |
2826 | void |
2829 | rxvt_selection_click(pR_ int clicks, int x, int y) |
2827 | rxvt_term::selection_click (int clicks, int x, int y) |
2830 | { |
2828 | { |
2831 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2829 | D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); |
2832 | |
2830 | |
2833 | clicks = ((clicks - 1) % 3) + 1; |
2831 | clicks = ((clicks - 1) % 3) + 1; |
2834 | R->selection.clicks = clicks; /* save clicks so extend will work */ |
2832 | selection.clicks = clicks; /* save clicks so extend will work */ |
2835 | |
2833 | |
2836 | rxvt_selection_start_colrow(aR_ Pixel2Col(x), Pixel2Row(y)); |
2834 | rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y)); |
|
|
2835 | |
2837 | if (clicks == 2 || clicks == 3) |
2836 | if (clicks == 2 || clicks == 3) |
2838 | rxvt_selection_extend_colrow(aR_ R->selection.mark.col, |
2837 | rxvt_selection_extend_colrow (this, selection.mark.col, |
2839 | R->selection.mark.row |
|
|
2840 | + R->TermWin.view_start, |
2838 | selection.mark.row + TermWin.view_start, |
2841 | 0, /* button 3 */ |
2839 | 0, /* button 3 */ |
2842 | 1, /* button press */ |
2840 | 1, /* button press */ |
2843 | 0); /* click change */ |
2841 | 0); /* click change */ |
2844 | } |
2842 | } |
2845 | |
2843 | |
2846 | /* ------------------------------------------------------------------------- */ |
2844 | /* ------------------------------------------------------------------------- */ |
2847 | /* |
2845 | /* |
2848 | * Mark a selection at the specified col/row |
2846 | * Mark a selection at the specified col/row |
… | |
… | |
2958 | * EXT: button 3 press; button 1 or 3 drag |
2956 | * EXT: button 3 press; button 1 or 3 drag |
2959 | * flag == 0 ==> button 1 |
2957 | * flag == 0 ==> button 1 |
2960 | * flag == 1 ==> button 3 press |
2958 | * flag == 1 ==> button 3 press |
2961 | * flag == 2 ==> button 3 motion |
2959 | * flag == 2 ==> button 3 motion |
2962 | */ |
2960 | */ |
2963 | /* EXTPROTO */ |
|
|
2964 | void |
2961 | void |
2965 | rxvt_selection_extend(pR_ int x, int y, int flag) |
2962 | rxvt_term::selection_extend (int x, int y, int flag) |
2966 | { |
2963 | { |
2967 | int col, row; |
2964 | int col, row; |
2968 | |
2965 | |
2969 | col = Pixel2Col(x); |
2966 | col = Pixel2Col(x); |
2970 | row = Pixel2Row(y); |
2967 | row = Pixel2Row(y); |
2971 | MAX_IT(row, 0); |
2968 | MAX_IT(row, 0); |
2972 | MIN_IT(row, (int)R->TermWin.nrow - 1); |
2969 | MIN_IT(row, (int)TermWin.nrow - 1); |
2973 | MAX_IT(col, 0); |
2970 | MAX_IT(col, 0); |
2974 | MIN_IT(col, (int)R->TermWin.ncol); |
2971 | MIN_IT(col, (int)TermWin.ncol); |
|
|
2972 | |
2975 | #ifndef NO_NEW_SELECTION |
2973 | #ifndef NO_NEW_SELECTION |
2976 | /* |
2974 | /* |
2977 | * If we're selecting characters (single click) then we must check first |
2975 | * If we're selecting characters (single click) then we must check first |
2978 | * if we are at the same place as the original mark. If we are then |
2976 | * if we are at the same place as the original mark. If we are then |
2979 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
2977 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
2980 | * be _past_ a character for it to be selected. |
2978 | * be _past_ a character for it to be selected. |
2981 | */ |
2979 | */ |
2982 | if (R->selection_style != OLD_SELECT) { |
2980 | if (selection_style != OLD_SELECT) |
|
|
2981 | { |
2983 | if (((R->selection.clicks % 3) == 1) && !flag |
2982 | if (((selection.clicks % 3) == 1) && !flag |
2984 | && (col == R->selection.mark.col |
2983 | && (col == selection.mark.col |
2985 | && (row == R->selection.mark.row + R->TermWin.view_start))) { |
2984 | && (row == selection.mark.row + TermWin.view_start))) |
|
|
2985 | { |
2986 | /* select nothing */ |
2986 | /* select nothing */ |
2987 | R->selection.beg.row = R->selection.end.row = 0; |
2987 | selection.beg.row = selection.end.row = 0; |
2988 | R->selection.beg.col = R->selection.end.col = 0; |
2988 | selection.beg.col = selection.end.col = 0; |
2989 | R->selection.clicks = 4; |
2989 | selection.clicks = 4; |
2990 | R->want_refresh = 1; |
2990 | want_refresh = 1; |
2991 | D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); |
2991 | D_SELECT((stderr, "rxvt_selection_extend() selection.clicks = 4")); |
2992 | return; |
2992 | return; |
2993 | } |
2993 | } |
2994 | } |
2994 | } |
2995 | #endif |
2995 | #endif |
2996 | if (R->selection.clicks == 4) |
2996 | if (selection.clicks == 4) |
2997 | R->selection.clicks = 1; |
2997 | selection.clicks = 1; |
|
|
2998 | |
2998 | rxvt_selection_extend_colrow(aR_ col, row, !!flag, /* ? button 3 */ |
2999 | rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */ |
2999 | flag == 1 ? 1 : 0, /* ? button press */ |
3000 | flag == 1 ? 1 : 0, /* ? button press */ |
3000 | 0); /* no click change */ |
3001 | 0); /* no click change */ |
3001 | } |
3002 | } |
3002 | |
3003 | |
3003 | /* ------------------------------------------------------------------------- */ |
3004 | /* ------------------------------------------------------------------------- */ |
3004 | /* |
3005 | /* |
3005 | * Extend the selection to the specified col/row |
3006 | * Extend the selection to the specified col/row |
… | |
… | |
3259 | /* ------------------------------------------------------------------------- */ |
3260 | /* ------------------------------------------------------------------------- */ |
3260 | /* |
3261 | /* |
3261 | * Double click on button 3 when already selected |
3262 | * Double click on button 3 when already selected |
3262 | * EXT: button 3 double click |
3263 | * EXT: button 3 double click |
3263 | */ |
3264 | */ |
3264 | /* EXTPROTO */ |
|
|
3265 | void |
3265 | void |
3266 | rxvt_selection_rotate(pR_ int x, int y) |
3266 | rxvt_term::selection_rotate (int x, int y) |
3267 | { |
3267 | { |
3268 | R->selection.clicks = R->selection.clicks % 3 + 1; |
3268 | selection.clicks = selection.clicks % 3 + 1; |
3269 | rxvt_selection_extend_colrow(aR_ Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3269 | rxvt_selection_extend_colrow (this, Pixel2Col(x), Pixel2Row(y), 1, 0, 1); |
3270 | } |
3270 | } |
3271 | |
3271 | |
3272 | /* ------------------------------------------------------------------------- */ |
3272 | /* ------------------------------------------------------------------------- */ |
3273 | /* |
3273 | /* |
3274 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3274 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
… | |
… | |
3378 | * ------------------------------------------------------------------------- */ |
3378 | * ------------------------------------------------------------------------- */ |
3379 | |
3379 | |
3380 | /* |
3380 | /* |
3381 | * return col/row values corresponding to x/y pixel values |
3381 | * return col/row values corresponding to x/y pixel values |
3382 | */ |
3382 | */ |
3383 | /* EXTPROTO */ |
|
|
3384 | void |
3383 | void |
3385 | rxvt_pixel_position(pR_ int *x, int *y) |
3384 | rxvt_term::pixel_position (int *x, int *y) |
3386 | { |
3385 | { |
3387 | *x = Pixel2Col(*x); |
3386 | *x = Pixel2Col(*x); |
3388 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3387 | /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ |
3389 | *y = Pixel2Row(*y); |
3388 | *y = Pixel2Row(*y); |
3390 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3389 | /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ |
3391 | } |
3390 | } |
|
|
3391 | |
3392 | /* ------------------------------------------------------------------------- */ |
3392 | /* ------------------------------------------------------------------------- */ |
3393 | #ifdef USE_XIM |
3393 | #ifdef USE_XIM |
3394 | /* EXTPROTO */ |
|
|
3395 | void |
3394 | void |
3396 | rxvt_setPosition(pR_ XPoint *pos) |
3395 | rxvt_term::set_position (XPoint *pos) |
3397 | { |
3396 | { |
3398 | XWindowAttributes xwa; |
3397 | XWindowAttributes xwa; |
3399 | |
3398 | |
3400 | XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &xwa); |
3399 | XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa); |
3401 | pos->x = Col2Pixel(R->screen.cur.col) + xwa.x; |
3400 | pos->x = Col2Pixel (screen.cur.col) + xwa.x; |
3402 | pos->y = Height2Pixel((R->screen.cur.row + 1)) + xwa.y |
3401 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3403 | - R->TermWin.lineSpace; |
|
|
3404 | } |
3402 | } |
|
|
3403 | |
3405 | #endif |
3404 | #endif |
3406 | /* ------------------------------------------------------------------------- */ |
3405 | /* ------------------------------------------------------------------------- */ |
3407 | |
3406 | |
3408 | /* ------------------------------------------------------------------------- * |
3407 | /* ------------------------------------------------------------------------- * |
3409 | * DEBUG ROUTINES * |
3408 | * DEBUG ROUTINES * |