ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.10 by pcg, Thu Dec 18 08:06:46 2003 UTC vs.
Revision 1.19 by pcg, Thu Jan 29 23:26:01 2004 UTC

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 $
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 */
1217void 1211void
1218rxvt_scr_erase_screen(pR_ int mode) 1212rxvt_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 */
1661int
1662rxvt_scr_get_fgcolor(pR)
1663{
1664 return GET_FGCOLOR(R->rstyle);
1665}
1666
1667/* ------------------------------------------------------------------------- */
1668/* EXTPROTO */
1669int
1670rxvt_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 */
1656bool
1657rxvt_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 */
1683enum { 1680enum {
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 */
1690void 1686void
1691rxvt_scr_expose(pR_ int x, int y, int width, int height, Bool refresh) 1687rxvt_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 */
1734void 1730void
1735rxvt_scr_touch(pR_ Bool refresh) 1731rxvt_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 */
1885void 1871void
1886rxvt_scr_refresh(pR_ unsigned char refresh_type) 1872rxvt_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);
2247nodraw: ; 2228nodraw: ;
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/* ------------------------------------------------------------------------- */
2323void 2303void
2324rxvt_scr_clear(pR) 2304rxvt_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 */
2348void 2332void
2489rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) 2473rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop)
2490{ 2474{
2491 long nread = 0; 2475 long nread = 0;
2492 unsigned long bytes_after; 2476 unsigned long bytes_after;
2493 XTextProperty ct; 2477 XTextProperty ct;
2494 int dummy_count;
2495 char **cl;
2496 2478
2497 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));
2498 2480
2499 if (prop == None) /* check for failed XConvertSelection */ 2481 if (prop == None) /* check for failed XConvertSelection */
2500 { 2482 {
2503 int selnum = R->selection_type & Sel_whereMask; 2485 int selnum = R->selection_type & Sel_whereMask;
2504 2486
2505 R->selection_type = 0; 2487 R->selection_type = 0;
2506 if (selnum != Sel_direct) 2488 if (selnum != Sel_direct)
2507 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;
2508 } 2501 }
2509 2502
2510 return 0; 2503 return 0;
2511 } 2504 }
2512 2505
2547 nread = -1; /* discount any previous stuff */ 2540 nread = -1; /* discount any previous stuff */
2548 break; 2541 break;
2549 } 2542 }
2550 2543
2551 nread += ct.nitems; 2544 nread += ct.nitems;
2545
2546 char **cl;
2547 int cr;
2552 if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, 2548 if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl,
2553 &dummy_count) == Success && cl) 2549 &cr) >= 0 && cl)
2554 { 2550 {
2551 for (int i = 0; i < cr; i++)
2555 R->paste ((unsigned char *)cl[0], STRLEN (cl[0])); 2552 R->paste ((unsigned char *)cl[i], STRLEN (cl[i]));
2553
2556 XFreeStringList (cl); 2554 XFreeStringList (cl);
2557 } 2555 }
2558 else 2556 else
2559 R->paste (ct.value, ct.nitems); 2557 R->paste (ct.value, ct.nitems);
2560 2558
2575} 2573}
2576 2574
2577void 2575void
2578rxvt_term::incr_cb (time_watcher &w) 2576rxvt_term::incr_cb (time_watcher &w)
2579{ 2577{
2580 w.stop ();
2581 selection_wait = Sel_none; 2578 selection_wait = Sel_none;
2582 2579
2583 rxvt_print_error("data loss: timeout on INCR selection paste"); 2580 rxvt_print_error ("data loss: timeout on INCR selection paste");
2584} 2581}
2585 2582
2586/* 2583/*
2587 * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> 2584 * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za>
2588 */ 2585 */
2654 int i; 2651 int i;
2655 2652
2656 R->selection_request_time = tm; 2653 R->selection_request_time = tm;
2657 R->selection_wait = Sel_normal; 2654 R->selection_wait = Sel_normal;
2658 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
2659 R->selection_type = Sel_CompoundText; 2661 R->selection_type = Sel_CompoundText;
2660 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))
2661 return; 2663 return;
2664#endif
2662 } 2665 }
2663 } 2666 }
2664 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() */
2665 D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); 2668 D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0"));
2666 rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); 2669 rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False);
2798 { 2801 {
2799 free (new_selection_text); 2802 free (new_selection_text);
2800 return; 2803 return;
2801 } 2804 }
2802 2805
2803 // due to MB_MAX_CUR, selection wastage is usually high 2806 // due to MB_MAX_CUR, selection wastage is usually high, so realloc
2804 if (str - (char *)new_selection_text > 1024) 2807 if (str - (char *)new_selection_text > 1024)
2805 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);
2806 2809
2807 R->selection.len = i; 2810 R->selection.len = i;
2811
2808 if (R->selection.text) 2812 if (R->selection.text)
2809 free (R->selection.text); 2813 free (R->selection.text);
2810 2814
2811 R->selection.text = new_selection_text; 2815 R->selection.text = new_selection_text;
2812 2816
2813 XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); 2817 XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm);
2814 if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) 2818 if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt)
2815 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
2816 XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, 2833 XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8,
2817 PropModeReplace, R->selection.text, (int)R->selection.len); 2834 PropModeReplace, R->selection.text, (int)R->selection.len);
2835 }
2836
2818 R->selection_time = tm; 2837 R->selection_time = tm;
2819 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));
2820} 2839}
2821 2840
2822/* ------------------------------------------------------------------------- */ 2841/* ------------------------------------------------------------------------- */
2823/* 2842/*
2824 * 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
2825 * EXT: button 1 press 2844 * EXT: button 1 press
2826 */ 2845 */
2827/* EXTPROTO */
2828void 2846void
2829rxvt_selection_click(pR_ int clicks, int x, int y) 2847rxvt_term::selection_click (int clicks, int x, int y)
2830{ 2848{
2831 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));
2832 2850
2833 clicks = ((clicks - 1) % 3) + 1; 2851 clicks = ((clicks - 1) % 3) + 1;
2834 R->selection.clicks = clicks; /* save clicks so extend will work */ 2852 selection.clicks = clicks; /* save clicks so extend will work */
2835 2853
2836 rxvt_selection_start_colrow(aR_ Pixel2Col(x), Pixel2Row(y)); 2854 rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y));
2855
2837 if (clicks == 2 || clicks == 3) 2856 if (clicks == 2 || clicks == 3)
2838 rxvt_selection_extend_colrow(aR_ R->selection.mark.col, 2857 rxvt_selection_extend_colrow (this, selection.mark.col,
2839 R->selection.mark.row
2840 + R->TermWin.view_start, 2858 selection.mark.row + TermWin.view_start,
2841 0, /* button 3 */ 2859 0, /* button 3 */
2842 1, /* button press */ 2860 1, /* button press */
2843 0); /* click change */ 2861 0); /* click change */
2844} 2862}
2845 2863
2846/* ------------------------------------------------------------------------- */ 2864/* ------------------------------------------------------------------------- */
2847/* 2865/*
2848 * Mark a selection at the specified col/row 2866 * Mark a selection at the specified col/row
2958 * EXT: button 3 press; button 1 or 3 drag 2976 * EXT: button 3 press; button 1 or 3 drag
2959 * flag == 0 ==> button 1 2977 * flag == 0 ==> button 1
2960 * flag == 1 ==> button 3 press 2978 * flag == 1 ==> button 3 press
2961 * flag == 2 ==> button 3 motion 2979 * flag == 2 ==> button 3 motion
2962 */ 2980 */
2963/* EXTPROTO */
2964void 2981void
2965rxvt_selection_extend(pR_ int x, int y, int flag) 2982rxvt_term::selection_extend (int x, int y, int flag)
2966{ 2983{
2967 int col, row; 2984 int col, row;
2968 2985
2969 col = Pixel2Col(x); 2986 col = Pixel2Col(x);
2970 row = Pixel2Row(y); 2987 row = Pixel2Row(y);
2971 MAX_IT(row, 0); 2988 MAX_IT(row, 0);
2972 MIN_IT(row, (int)R->TermWin.nrow - 1); 2989 MIN_IT(row, (int)TermWin.nrow - 1);
2973 MAX_IT(col, 0); 2990 MAX_IT(col, 0);
2974 MIN_IT(col, (int)R->TermWin.ncol); 2991 MIN_IT(col, (int)TermWin.ncol);
2992
2975#ifndef NO_NEW_SELECTION 2993#ifndef NO_NEW_SELECTION
2976/* 2994 /*
2977 * 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
2978 * 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
2979 * 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
2980 * be _past_ a character for it to be selected. 2998 * be _past_ a character for it to be selected.
2981 */ 2999 */
2982 if (R->selection_style != OLD_SELECT) { 3000 if (selection_style != OLD_SELECT)
3001 {
2983 if (((R->selection.clicks % 3) == 1) && !flag 3002 if (((selection.clicks % 3) == 1) && !flag
2984 && (col == R->selection.mark.col 3003 && (col == selection.mark.col
2985 && (row == R->selection.mark.row + R->TermWin.view_start))) { 3004 && (row == selection.mark.row + TermWin.view_start)))
3005 {
2986 /* select nothing */ 3006 /* select nothing */
2987 R->selection.beg.row = R->selection.end.row = 0; 3007 selection.beg.row = selection.end.row = 0;
2988 R->selection.beg.col = R->selection.end.col = 0; 3008 selection.beg.col = selection.end.col = 0;
2989 R->selection.clicks = 4; 3009 selection.clicks = 4;
2990 R->want_refresh = 1; 3010 want_refresh = 1;
2991 D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); 3011 D_SELECT((stderr, "rxvt_selection_extend() selection.clicks = 4"));
2992 return; 3012 return;
2993 } 3013 }
2994 } 3014 }
2995#endif 3015#endif
2996 if (R->selection.clicks == 4) 3016 if (selection.clicks == 4)
2997 R->selection.clicks = 1; 3017 selection.clicks = 1;
3018
2998 rxvt_selection_extend_colrow(aR_ col, row, !!flag, /* ? button 3 */ 3019 rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */
2999 flag == 1 ? 1 : 0, /* ? button press */ 3020 flag == 1 ? 1 : 0, /* ? button press */
3000 0); /* no click change */ 3021 0); /* no click change */
3001} 3022}
3002 3023
3003/* ------------------------------------------------------------------------- */ 3024/* ------------------------------------------------------------------------- */
3004/* 3025/*
3005 * Extend the selection to the specified col/row 3026 * Extend the selection to the specified col/row
3259/* ------------------------------------------------------------------------- */ 3280/* ------------------------------------------------------------------------- */
3260/* 3281/*
3261 * Double click on button 3 when already selected 3282 * Double click on button 3 when already selected
3262 * EXT: button 3 double click 3283 * EXT: button 3 double click
3263 */ 3284 */
3264/* EXTPROTO */
3265void 3285void
3266rxvt_selection_rotate(pR_ int x, int y) 3286rxvt_term::selection_rotate (int x, int y)
3267{ 3287{
3268 R->selection.clicks = R->selection.clicks % 3 + 1; 3288 selection.clicks = selection.clicks % 3 + 1;
3269 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);
3270} 3290}
3271 3291
3272/* ------------------------------------------------------------------------- */ 3292/* ------------------------------------------------------------------------- */
3273/* 3293/*
3274 * 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
3275 * 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
3276 * the X11 protocol. 3296 * the X11 protocol.
3277 */ 3297 */
3278typedef CARD32 Atom32; 3298typedef CARD32 Atom32;
3279 3299
3280/* ------------------------------------------------------------------------- */ 3300/* ------------------------------------------------------------------------- */
3281/* 3301/*
3282 * Respond to a request for our current selection 3302 * Respond to a request for our current selection
3283 * EXT: SelectionRequest 3303 * EXT: SelectionRequest
3285/* EXTPROTO */ 3305/* EXTPROTO */
3286void 3306void
3287rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) 3307rxvt_selection_send(pR_ const XSelectionRequestEvent *rq)
3288{ 3308{
3289 XSelectionEvent ev; 3309 XSelectionEvent ev;
3290#ifdef USE_XIM
3291 Atom32 target_list[4];
3292#else
3293 Atom32 target_list[3];
3294#endif
3295 Atom target;
3296 XTextProperty ct; 3310 XTextProperty ct;
3297 XICCEncodingStyle style; 3311 XICCEncodingStyle style;
3298 char *cl[2], dummy[1]; 3312 Atom target;
3299 3313
3300 ev.type = SelectionNotify; 3314 ev.type = SelectionNotify;
3301 ev.property = None; 3315 ev.property = None;
3302 ev.display = rq->display; 3316 ev.display = rq->display;
3303 ev.requestor = rq->requestor; 3317 ev.requestor = rq->requestor;
3304 ev.selection = rq->selection; 3318 ev.selection = rq->selection;
3305 ev.target = rq->target; 3319 ev.target = rq->target;
3306 ev.time = rq->time; 3320 ev.time = rq->time;
3307 3321
3308 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
3309 target_list[0] = (Atom32) R->xa[XA_TARGETS]; 3326 *target++ = (Atom32) R->xa[XA_TARGETS];
3310 target_list[1] = (Atom32) XA_STRING; 3327 *target++ = (Atom32) XA_STRING;
3311 target_list[2] = (Atom32) R->xa[XA_TEXT]; 3328 *target++ = (Atom32) R->xa[XA_TEXT];
3312#ifdef USE_XIM
3313 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];
3314#endif 3332#endif
3315 XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, 3333 XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM,
3316 (8 * sizeof(target_list[0])), PropModeReplace, 3334 (8 * sizeof(target_list[0])), PropModeReplace,
3317 (unsigned char *)target_list, 3335 (unsigned char *)target_list,
3318 (sizeof(target_list) / sizeof(target_list[0]))); 3336 target - target_list);
3319 ev.property = rq->property; 3337 ev.property = rq->property;
3320 } else if (rq->target == R->xa[XA_MULTIPLE]) { 3338 } else if (rq->target == R->xa[XA_MULTIPLE]) {
3321 /* TODO: Handle MULTIPLE */ 3339 /* TODO: Handle MULTIPLE */
3322 } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { 3340 } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) {
3323 XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, 3341 XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER,
3324 (8 * sizeof(Time)), PropModeReplace, 3342 (8 * sizeof(Time)), PropModeReplace,
3325 (unsigned char *)&R->selection_time, 1); 3343 (unsigned char *)&R->selection_time, 1);
3326 ev.property = rq->property; 3344 ev.property = rq->property;
3327 } else if (rq->target == XA_STRING 3345 } else if (rq->target == XA_STRING
3346 || rq->target == R->xa[XA_TEXT]
3328 || rq->target == R->xa[XA_COMPOUND_TEXT] 3347 || rq->target == R->xa[XA_COMPOUND_TEXT]
3329 || rq->target == R->xa[XA_TEXT]) { 3348 || rq->target == R->xa[XA_UTF8_STRING]
3330#ifdef USE_XIM 3349 ) {
3331 short freect = 0; 3350 short freect = 0;
3332#endif
3333 int selectlen; 3351 int selectlen;
3352 char *cl;
3334 3353
3335#ifdef USE_XIM 3354 target = rq->target;
3355
3336 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 {
3337 target = R->xa[XA_COMPOUND_TEXT]; 3370 target = R->xa[XA_COMPOUND_TEXT];
3338 style = (rq->target == R->xa[XA_COMPOUND_TEXT])
3339 ? XCompoundTextStyle : XStdICCTextStyle;
3340 } else
3341#endif
3342 {
3343 target = XA_STRING;
3344 style = XStringStyle; 3371 style = XCompoundTextStyle;
3345 } 3372 }
3373
3346 if (R->selection.text) { 3374 if (R->selection.text) {
3347 cl[0] = (char *)R->selection.text; 3375 cl = (char *)R->selection.text;
3348 selectlen = R->selection.len; 3376 selectlen = R->selection.len;
3349 } else { 3377 } else {
3350 cl[0] = dummy; 3378 cl = "";
3351 *dummy = '\0';
3352 selectlen = 0; 3379 selectlen = 0;
3353 } 3380 }
3354#ifdef USE_XIM 3381
3355 if (XmbTextListToTextProperty(R->Xdisplay, cl, 1, style, &ct) 3382 if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, style, &ct) >= 0)
3356 == Success) /* if we failed to convert then send it raw */
3357 freect = 1; 3383 freect = 1;
3358 else 3384 else
3359#endif
3360 { 3385 {
3386 /* if we failed to convert then send it raw */
3361 ct.value = (unsigned char *)cl[0]; 3387 ct.value = (unsigned char *)cl;
3362 ct.nitems = selectlen; 3388 ct.nitems = selectlen;
3363 } 3389 }
3390
3364 XChangeProperty(R->Xdisplay, rq->requestor, rq->property, 3391 XChangeProperty(R->Xdisplay, rq->requestor, rq->property,
3365 target, 8, PropModeReplace, 3392 target, 8, PropModeReplace,
3366 ct.value, (int)ct.nitems); 3393 ct.value, (int)ct.nitems);
3367 ev.property = rq->property; 3394 ev.property = rq->property;
3368#ifdef USE_XIM 3395
3369 if (freect) 3396 if (freect)
3370 XFree(ct.value); 3397 XFree (ct.value);
3371#endif
3372 } 3398 }
3373 XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); 3399 XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev);
3374} 3400}
3375 3401
3376/* ------------------------------------------------------------------------- * 3402/* ------------------------------------------------------------------------- *
3378 * ------------------------------------------------------------------------- */ 3404 * ------------------------------------------------------------------------- */
3379 3405
3380/* 3406/*
3381 * return col/row values corresponding to x/y pixel values 3407 * return col/row values corresponding to x/y pixel values
3382 */ 3408 */
3383/* EXTPROTO */
3384void 3409void
3385rxvt_pixel_position(pR_ int *x, int *y) 3410rxvt_term::pixel_position (int *x, int *y)
3386{ 3411{
3387 *x = Pixel2Col(*x); 3412 *x = Pixel2Col(*x);
3388/* 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); */
3389 *y = Pixel2Row(*y); 3414 *y = Pixel2Row(*y);
3390/* 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); */
3391} 3416}
3417
3392/* ------------------------------------------------------------------------- */ 3418/* ------------------------------------------------------------------------- */
3393#ifdef USE_XIM 3419#ifdef USE_XIM
3394/* EXTPROTO */
3395void 3420void
3396rxvt_setPosition(pR_ XPoint *pos) 3421rxvt_term::set_position (XPoint *pos)
3397{ 3422{
3398 XWindowAttributes xwa; 3423 XWindowAttributes xwa;
3399 3424
3400 XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &xwa); 3425 XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa);
3401 pos->x = Col2Pixel(R->screen.cur.col) + xwa.x; 3426 pos->x = Col2Pixel (screen.cur.col) + xwa.x;
3402 pos->y = Height2Pixel((R->screen.cur.row + 1)) + xwa.y 3427 pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace;
3403 - R->TermWin.lineSpace;
3404} 3428}
3429
3405#endif 3430#endif
3406/* ------------------------------------------------------------------------- */ 3431/* ------------------------------------------------------------------------- */
3407 3432
3408/* ------------------------------------------------------------------------- * 3433/* ------------------------------------------------------------------------- *
3409 * DEBUG ROUTINES * 3434 * DEBUG ROUTINES *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines