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.415 by root, Mon May 28 14:25:16 2012 UTC vs.
Revision 1.457 by sf-exg, Tue Jun 21 12:03:56 2016 UTC

2 * File: screen.C 2 * File: screen.C
3 *---------------------------------------------------------------------------* 3 *---------------------------------------------------------------------------*
4 * 4 *
5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> 5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com>
6 * Copyright (c) 2003-2007 Marc Lehmann <schmorp@schmorp.de> 6 * Copyright (c) 2003-2007 Marc Lehmann <schmorp@schmorp.de>
7 * Copyright (c) 2015 Emanuele Giaquinta <e.giaquinta@glauco.it>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * 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 10 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version. 12 * (at your option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27#include "../config.h" /* NECESSARY */ 28#include "../config.h" /* NECESSARY */
28#include "rxvt.h" /* NECESSARY */ 29#include "rxvt.h" /* NECESSARY */
29#include "rxvtperl.h" /* NECESSARY */ 30#include "rxvtperl.h" /* NECESSARY */
30 31
31#include <inttypes.h> 32#include <inttypes.h>
32
33#include "salloc.C" // HACK, should be a separate compile!
34 33
35static inline void 34static inline void
36fill_text (text_t *start, text_t value, int len) 35fill_text (text_t *start, text_t value, int len)
37{ 36{
38 while (len--) 37 while (len--)
152 l.r[col] = rend; 151 l.r[col] = rend;
153 col++; 152 col++;
154 } while (col < ncol && l.t[col] == NOCHAR); 153 } while (col < ncol && l.t[col] == NOCHAR);
155} 154}
156 155
156// set the rendition of a single wide character beginning at the given column
157void
158rxvt_term::scr_set_char_rend (line_t &l, int col, rend_t rend)
159{
160 do {
161 l.r[col] = rend;
162 col++;
163 } while (col < ncol && l.t[col] == NOCHAR);
164}
165
157/* ------------------------------------------------------------------------- * 166/* ------------------------------------------------------------------------- *
158 * SCREEN INITIALISATION * 167 * SCREEN INITIALISATION *
159 * ------------------------------------------------------------------------- */ 168 * ------------------------------------------------------------------------- */
160 169
161void 170void
162rxvt_term::scr_alloc () 171rxvt_term::scr_alloc () NOTHROW
163{ 172{
164 int tsize = sizeof (text_t) * ncol; 173 int tsize = sizeof (text_t) * ncol;
165 int rsize = sizeof (rend_t) * ncol; 174 int rsize = sizeof (rend_t) * ncol;
166 175
167 // we assume that rend_t size is a sufficient alignment 176 // we assume that rend_t size is a sufficient alignment
168 // factor for tetx_t and line_t values, and we only 177 // factor for text_t and line_t values, and we only
169 // need to adjust tsize. 178 // need to adjust tsize.
170 tsize = (tsize + sizeof (rend_t) - 1); 179 tsize = (tsize + sizeof (rend_t) - 1);
171 tsize -= tsize % sizeof (rend_t); 180 tsize -= tsize % sizeof (rend_t);
172 181
173 int all_rows = total_rows + nrow + nrow; 182 int all_rows = total_rows + nrow + nrow;
174 183
175 chunk_size = (sizeof (line_t) + rsize + tsize) * all_rows; 184 chunk_size = (sizeof (line_t) + rsize + tsize) * all_rows;
176 chunk = rxvt_malloc (chunk_size); 185 chunk = chunk_alloc (chunk_size, 0);
177 186
178 char *base = (char *)chunk + sizeof (line_t) * all_rows; 187 char *base = (char *)chunk + sizeof (line_t) * all_rows;
179 188
180 for (int row = 0; row < all_rows; ++row) 189 for (int row = 0; row < all_rows; ++row)
181 { 190 {
191 swap_buf = drawn_buf + nrow; 200 swap_buf = drawn_buf + nrow;
192 row_buf = swap_buf + nrow; 201 row_buf = swap_buf + nrow;
193} 202}
194 203
195void 204void
205rxvt_term::copy_line (line_t &dst, line_t &src)
206{
207 scr_blank_screen_mem (dst, DEFAULT_RSTYLE);
208 dst.l = min (src.l, ncol);
209 memcpy (dst.t, src.t, sizeof (text_t) * dst.l);
210 memcpy (dst.r, src.r, sizeof (rend_t) * dst.l);
211 dst.f = src.f;
212}
213
214void ecb_cold
196rxvt_term::scr_reset () 215rxvt_term::scr_reset ()
197{ 216{
198#if ENABLE_OVERLAY 217#if ENABLE_OVERLAY
199 scr_overlay_off (); 218 scr_overlay_off ();
200#endif 219#endif
227 246
228 screen.tscroll = 0; 247 screen.tscroll = 0;
229 screen.bscroll = nrow - 1; 248 screen.bscroll = nrow - 1;
230 249
231 void *prev_chunk = chunk; 250 void *prev_chunk = chunk;
251 size_t prev_chunk_size = chunk_size;
232 line_t *prev_drawn_buf = drawn_buf; 252 line_t *prev_drawn_buf = drawn_buf;
233 line_t *prev_swap_buf = swap_buf; 253 line_t *prev_swap_buf = swap_buf;
234 line_t *prev_row_buf = row_buf; 254 line_t *prev_row_buf = row_buf;
235 255
236 int common_col = min (prev_ncol, ncol);
237
238 scr_alloc (); 256 scr_alloc ();
239 257
240 if (!prev_row_buf) 258 if (!prev_row_buf)
241 { 259 {
242 /*
243 * first time called so just malloc everything: don't rely on realloc
244 */
245 top_row = 0; 260 top_row = 0;
246 term_start = 0; 261 term_start = 0;
247 262
248 memset (charsets, 'B', sizeof (charsets)); 263 memset (charsets, 'B', sizeof (charsets));
249 rstyle = DEFAULT_RSTYLE; 264 rstyle = DEFAULT_RSTYLE;
274 { 289 {
275 /* 290 /*
276 * add or delete rows as appropriate 291 * add or delete rows as appropriate
277 */ 292 */
278 293
294 int common_col = min (prev_ncol, ncol);
295
279 for (int row = min (nrow, prev_nrow); row--; ) 296 for (int row = min (nrow, prev_nrow); row--; )
280 { 297 {
281 scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); 298 scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE);
282 scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE);
283
284 memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col); 299 memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col);
285 memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col); 300 memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col);
286 memcpy (swap_buf [row].t, prev_swap_buf [row].t, sizeof (text_t) * common_col); 301
287 memcpy (swap_buf [row].r, prev_swap_buf [row].r, sizeof (rend_t) * common_col); 302 copy_line (swap_buf [row], prev_swap_buf [row]);
288 } 303 }
289 304
290 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row 305 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row
291 int pend = MOD (term_start + top_row , prev_total_rows); 306 int pend = MOD (term_start + top_row , prev_total_rows);
292 int q = total_rows; // rewrapped row 307 int q = total_rows; // rewrapped row
387 for (int row = min (nrow, prev_nrow); row--; ) 402 for (int row = min (nrow, prev_nrow); row--; )
388 { 403 {
389 line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)]; 404 line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)];
390 line_t &dst = row_buf [row]; 405 line_t &dst = row_buf [row];
391 406
392 scr_blank_screen_mem (dst, DEFAULT_RSTYLE); 407 copy_line (dst, src);
393
394 memcpy (dst.t, src.t, sizeof (text_t) * common_col);
395 memcpy (dst.r, src.r, sizeof (rend_t) * common_col);
396 } 408 }
397 409
398 for (int row = prev_nrow; row < nrow; row++) 410 for (int row = prev_nrow; row < nrow; row++)
399 scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); 411 scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
400 412
410 if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); 422 if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE);
411 if (!swap_buf [row].valid ()) scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); 423 if (!swap_buf [row].valid ()) scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE);
412 if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); 424 if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE);
413 } 425 }
414 426
415 free (prev_chunk); 427 chunk_free (prev_chunk, prev_chunk_size);
416 428
417 free (tabs); 429 free (tabs);
418 tabs = (char *)rxvt_malloc (ncol); 430 tabs = (char *)rxvt_malloc (ncol);
419 431
420 for (int col = ncol; col--; ) 432 for (int col = ncol; col--; )
428 tt_winch (); 440 tt_winch ();
429 441
430 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 442 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
431} 443}
432 444
433/* ------------------------------------------------------------------------- */ 445void ecb_cold
434/*
435 * Free everything. That way malloc debugging can find leakage.
436 */
437void
438rxvt_term::scr_release () NOTHROW 446rxvt_term::scr_release () NOTHROW
439{ 447{
440 free (chunk); 448 chunk_free (chunk, chunk_size);
449 chunk = 0;
450 row_buf = 0;
451
441 free (tabs); 452 free (tabs);
453 tabs = 0;
442} 454}
443 455
444/* ------------------------------------------------------------------------- */ 456/* ------------------------------------------------------------------------- */
445/* 457/*
446 * Hard/Soft reset 458 * Hard/Soft reset
447 */ 459 */
448void 460void ecb_cold
449rxvt_term::scr_poweron () 461rxvt_term::scr_poweron ()
450{ 462{
451 scr_release (); 463 scr_release ();
452 464
453 row_buf = 0;
454 tabs = 0;
455 prev_nrow = prev_ncol = 0; 465 prev_nrow = prev_ncol = 0;
456 rvideo_mode = false; 466 rvideo_mode = false;
457 scr_soft_reset (); 467 scr_soft_reset ();
458 scr_reset (); 468 scr_reset ();
459 469
460 scr_clear (true); 470 scr_clear (true);
461 scr_refresh (); 471 scr_refresh ();
462} 472}
463 473
464void 474void ecb_cold
465rxvt_term::scr_soft_reset () NOTHROW 475rxvt_term::scr_soft_reset () NOTHROW
466{ 476{
467 /* only affects modes, nothing drastic such as clearing the screen */ 477 /* only affects modes, nothing drastic such as clearing the screen */
468#if ENABLE_OVERLAY 478#if ENABLE_OVERLAY
469 scr_overlay_off (); 479 scr_overlay_off ();
605 * Change the colour for following text 615 * Change the colour for following text
606 */ 616 */
607void 617void
608rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW 618rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW
609{ 619{
610 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) 620 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR24))
611 color = fgbg; 621 color = fgbg;
612 622
613 if (fgbg == Color_fg) 623 if (fgbg == Color_fg)
614 rstyle = SET_FGCOLOR (rstyle, color); 624 rstyle = SET_FGCOLOR (rstyle, color);
615 else 625 else
635/* 645/*
636 * Scroll text between <row1> and <row2> inclusive, by <count> lines 646 * Scroll text between <row1> and <row2> inclusive, by <count> lines
637 * count positive ==> scroll up 647 * count positive ==> scroll up
638 * count negative ==> scroll down 648 * count negative ==> scroll down
639 */ 649 */
640int 650int ecb_hot
641rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW 651rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW
642{ 652{
643 if (count == 0 || (row1 > row2)) 653 if (count == 0 || (row1 > row2))
644 return 0; 654 return 0;
645 655
706 716
707 // finally move the view window, if desired 717 // finally move the view window, if desired
708 if (option (Opt_scrollWithBuffer) 718 if (option (Opt_scrollWithBuffer)
709 && view_start != 0 719 && view_start != 0
710 && view_start != -saveLines) 720 && view_start != -saveLines)
711 scr_page (UP, count); 721 scr_page (count);
712 722
713 if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) 723 if (SHOULD_INVOKE (HOOK_SCROLL_BACK))
714 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); 724 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END));
715 } 725 }
716 else 726 else
779 789
780/* ------------------------------------------------------------------------- */ 790/* ------------------------------------------------------------------------- */
781/* 791/*
782 * Add text given in <str> of length <len> to screen struct 792 * Add text given in <str> of length <len> to screen struct
783 */ 793 */
784void 794void ecb_hot
785rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW 795rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
786{ 796{
787 if (len <= 0) /* sanity */ 797 if (len <= 0) /* sanity */
788 return; 798 return;
789 799
1002 } 1012 }
1003 else if (screen.cur.row > 0 1013 else if (screen.cur.row > 0
1004 && ROW(screen.cur.row - 1).is_longer ()) 1014 && ROW(screen.cur.row - 1).is_longer ())
1005 { 1015 {
1006 linep = &ROW(screen.cur.row - 1); 1016 linep = &ROW(screen.cur.row - 1);
1007 tp = line->t + ncol - 1; 1017 tp = linep->t + ncol - 1;
1008 rp = line->r + ncol - 1; 1018 rp = linep->r + ncol - 1;
1009 } 1019 }
1010 else 1020 else
1011 continue; 1021 continue;
1012 1022
1013 linep->touch (); 1023 linep->touch ();
1139 * XTERM_SEQ: ESC 6 1149 * XTERM_SEQ: ESC 6
1140 * Move cursor left in row. If we're at the left boundary, shift everything 1150 * Move cursor left in row. If we're at the left boundary, shift everything
1141 * in that row right. Clear left column. 1151 * in that row right. Clear left column.
1142 */ 1152 */
1143#if !ENABLE_MINIMAL 1153#if !ENABLE_MINIMAL
1144void 1154void ecb_cold
1145rxvt_term::scr_backindex () NOTHROW 1155rxvt_term::scr_backindex () NOTHROW
1146{ 1156{
1147 if (screen.cur.col > 0) 1157 if (screen.cur.col > 0)
1148 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); 1158 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
1149 else 1159 else
1156 * XTERM_SEQ: ESC 9 1166 * XTERM_SEQ: ESC 9
1157 * Move cursor right in row. If we're at the right boundary, shift everything 1167 * Move cursor right in row. If we're at the right boundary, shift everything
1158 * in that row left. Clear right column. 1168 * in that row left. Clear right column.
1159 */ 1169 */
1160#if !ENABLE_MINIMAL 1170#if !ENABLE_MINIMAL
1161void 1171void ecb_cold
1162rxvt_term::scr_forwardindex () NOTHROW 1172rxvt_term::scr_forwardindex () NOTHROW
1163{ 1173{
1164 if (screen.cur.col < ncol - 1) 1174 if (screen.cur.col < ncol - 1)
1165 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1175 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1166 else 1176 else
1231 * direction should be UP or DN 1241 * direction should be UP or DN
1232 */ 1242 */
1233void 1243void
1234rxvt_term::scr_index (enum page_dirn direction) NOTHROW 1244rxvt_term::scr_index (enum page_dirn direction) NOTHROW
1235{ 1245{
1236 int dirn;
1237
1238 want_refresh = 1; 1246 want_refresh = 1;
1239 ZERO_SCROLLBACK (); 1247 ZERO_SCROLLBACK ();
1240 1248
1241 dirn = ((direction == UP) ? 1 : -1);
1242
1243 screen.flags &= ~Screen_WrapNext; 1249 screen.flags &= ~Screen_WrapNext;
1244 1250
1245 if ((screen.cur.row == screen.bscroll && direction == UP) 1251 if ((screen.cur.row == screen.bscroll && direction == UP)
1246 || (screen.cur.row == screen.tscroll && direction == DN)) 1252 || (screen.cur.row == screen.tscroll && direction == DN))
1247 scr_scroll_text (screen.tscroll, screen.bscroll, dirn); 1253 scr_scroll_text (screen.tscroll, screen.bscroll, direction);
1248 else 1254 else
1249 screen.cur.row += dirn; 1255 screen.cur.row += direction;
1250 1256
1251 clamp_it (screen.cur.row, 0, nrow - 1); 1257 clamp_it (screen.cur.row, 0, nrow - 1);
1252 selection_check (0); 1258 selection_check (0);
1253} 1259}
1254 1260
1417/* ------------------------------------------------------------------------- */ 1423/* ------------------------------------------------------------------------- */
1418/* 1424/*
1419 * Fill the screen with `E's 1425 * Fill the screen with `E's
1420 * XTERM_SEQ: Screen Alignment Test: ESC # 8 1426 * XTERM_SEQ: Screen Alignment Test: ESC # 8
1421 */ 1427 */
1422void 1428void ecb_cold
1423rxvt_term::scr_E () NOTHROW 1429rxvt_term::scr_E () NOTHROW
1424{ 1430{
1425 rend_t fs; 1431 rend_t fs;
1426 1432
1427 want_refresh = 1; 1433 want_refresh = 1;
1591/* ------------------------------------------------------------------------- */ 1597/* ------------------------------------------------------------------------- */
1592/* 1598/*
1593 * Set the scrolling region 1599 * Set the scrolling region
1594 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r 1600 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r
1595 */ 1601 */
1596void 1602void ecb_cold
1597rxvt_term::scr_scroll_region (int top, int bot) NOTHROW 1603rxvt_term::scr_scroll_region (int top, int bot) NOTHROW
1598{ 1604{
1599 max_it (top, 0); 1605 max_it (top, 0);
1600 min_it (bot, nrow - 1); 1606 min_it (bot, nrow - 1);
1601 1607
1611/* 1617/*
1612 * Make the cursor visible/invisible 1618 * Make the cursor visible/invisible
1613 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h 1619 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h
1614 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l 1620 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l
1615 */ 1621 */
1616void 1622void ecb_cold
1617rxvt_term::scr_cursor_visible (int mode) NOTHROW 1623rxvt_term::scr_cursor_visible (int mode) NOTHROW
1618{ 1624{
1619 want_refresh = 1; 1625 want_refresh = 1;
1620 1626
1621 if (mode) 1627 if (mode)
1628/* 1634/*
1629 * Set/unset automatic wrapping 1635 * Set/unset automatic wrapping
1630 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h 1636 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h
1631 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l 1637 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l
1632 */ 1638 */
1633void 1639void ecb_cold
1634rxvt_term::scr_autowrap (int mode) NOTHROW 1640rxvt_term::scr_autowrap (int mode) NOTHROW
1635{ 1641{
1636 if (mode) 1642 if (mode)
1637 screen.flags |= Screen_Autowrap; 1643 screen.flags |= Screen_Autowrap;
1638 else 1644 else
1647 * Relative mode: line numbers are relative to top margin of scrolling region 1653 * Relative mode: line numbers are relative to top margin of scrolling region
1648 * and the cursor cannot be moved outside. 1654 * and the cursor cannot be moved outside.
1649 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h 1655 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h
1650 * XTERM_SEQ: Set Relative: ESC [ ? 6 l 1656 * XTERM_SEQ: Set Relative: ESC [ ? 6 l
1651 */ 1657 */
1652void 1658void ecb_cold
1653rxvt_term::scr_relative_origin (int mode) NOTHROW 1659rxvt_term::scr_relative_origin (int mode) NOTHROW
1654{ 1660{
1655 if (mode) 1661 if (mode)
1656 screen.flags |= Screen_Relative; 1662 screen.flags |= Screen_Relative;
1657 else 1663 else
1664/* 1670/*
1665 * Set insert/replace mode 1671 * Set insert/replace mode
1666 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h 1672 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h
1667 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l 1673 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l
1668 */ 1674 */
1669void 1675void ecb_cold
1670rxvt_term::scr_insert_mode (int mode) NOTHROW 1676rxvt_term::scr_insert_mode (int mode) NOTHROW
1671{ 1677{
1672 if (mode) 1678 if (mode)
1673 screen.flags |= Screen_Insert; 1679 screen.flags |= Screen_Insert;
1674 else 1680 else
1680 * Set/Unset tabs 1686 * Set/Unset tabs
1681 * XTERM_SEQ: Set tab at current column : ESC H 1687 * XTERM_SEQ: Set tab at current column : ESC H
1682 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g 1688 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g
1683 * XTERM_SEQ: Clear all tabs : ESC [ 3 g 1689 * XTERM_SEQ: Clear all tabs : ESC [ 3 g
1684 */ 1690 */
1685void 1691void ecb_cold
1686rxvt_term::scr_set_tab (int mode) NOTHROW 1692rxvt_term::scr_set_tab (int mode) NOTHROW
1687{ 1693{
1688 if (mode < 0) 1694 if (mode < 0)
1689 memset (tabs, 0, ncol); 1695 memset (tabs, 0, ncol);
1690 else if (screen.cur.col < ncol) 1696 else if (screen.cur.col < ncol)
1709 if (rvideo_state != on) 1715 if (rvideo_state != on)
1710 { 1716 {
1711 rvideo_state = on; 1717 rvideo_state = on;
1712 1718
1713 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1719 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1714#ifdef HAVE_BG_PIXMAP 1720#ifdef HAVE_IMG
1715 if (bg_pixmap == None) 1721 if (bg_img == 0)
1716#endif 1722#endif
1717 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 1723 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
1718 1724
1719 XGCValues gcvalue; 1725 XGCValues gcvalue;
1720 gcvalue.foreground = pix_colors[Color_fg]; 1726 gcvalue.foreground = pix_colors[Color_fg];
1729/* ------------------------------------------------------------------------- */ 1735/* ------------------------------------------------------------------------- */
1730/* 1736/*
1731 * Report current cursor position 1737 * Report current cursor position
1732 * XTERM_SEQ: Report position: ESC [ 6 n 1738 * XTERM_SEQ: Report position: ESC [ 6 n
1733 */ 1739 */
1734void 1740void ecb_cold
1735rxvt_term::scr_report_position () NOTHROW 1741rxvt_term::scr_report_position () NOTHROW
1736{ 1742{
1737 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); 1743 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1);
1738} 1744}
1739 1745
1742 * ------------------------------------------------------------------------- */ 1748 * ------------------------------------------------------------------------- */
1743 1749
1744/* 1750/*
1745 * Set font style 1751 * Set font style
1746 */ 1752 */
1747void 1753void ecb_cold
1748rxvt_term::set_font_style () NOTHROW 1754rxvt_term::set_font_style () NOTHROW
1749{ 1755{
1750#if 0 1756#if 0
1751 switch (charsets [screen.charset]) 1757 switch (charsets [screen.charset])
1752 { 1758 {
1774 * XTERM_SEQ: Invoke G0 character set: CTRL-O 1780 * XTERM_SEQ: Invoke G0 character set: CTRL-O
1775 * XTERM_SEQ: Invoke G1 character set: CTRL-N 1781 * XTERM_SEQ: Invoke G1 character set: CTRL-N
1776 * XTERM_SEQ: Invoke G2 character set: ESC N 1782 * XTERM_SEQ: Invoke G2 character set: ESC N
1777 * XTERM_SEQ: Invoke G3 character set: ESC O 1783 * XTERM_SEQ: Invoke G3 character set: ESC O
1778 */ 1784 */
1779void 1785void ecb_cold
1780rxvt_term::scr_charset_choose (int set) NOTHROW 1786rxvt_term::scr_charset_choose (int set) NOTHROW
1781{ 1787{
1782 screen.charset = set; 1788 screen.charset = set;
1783 set_font_style (); 1789 set_font_style ();
1784} 1790}
1805 * ------------------------------------------------------------------------- */ 1811 * ------------------------------------------------------------------------- */
1806 1812
1807/* 1813/*
1808 * refresh matching text. 1814 * refresh matching text.
1809 */ 1815 */
1810bool 1816bool ecb_cold
1811rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW 1817rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW
1812{ 1818{
1813 bool found = false; 1819 bool found = false;
1814 1820
1815 for (int i = 0; i < nrow; i++) 1821 for (int i = 0; i < nrow; i++)
1834 PART_BEG = 0, 1840 PART_BEG = 0,
1835 PART_END, 1841 PART_END,
1836 RC_COUNT 1842 RC_COUNT
1837}; 1843};
1838 1844
1839void 1845void ecb_hot
1840rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) NOTHROW 1846rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) NOTHROW
1841{ 1847{
1842 int i; 1848 int i;
1843 row_col_t rc[RC_COUNT]; 1849 row_col_t rc[RC_COUNT];
1844 1850
1892 * the top of the screen 1898 * the top of the screen
1893 */ 1899 */
1894void 1900void
1895rxvt_term::scr_move_to (int y, int len) NOTHROW 1901rxvt_term::scr_move_to (int y, int len) NOTHROW
1896{ 1902{
1897 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); 1903 // lerp (y, 0, len, top_row, nrow - 1)
1904 scr_changeview (top_row + (nrow - 1 - top_row) * y / len);
1898} 1905}
1899 1906
1900/* ------------------------------------------------------------------------- */ 1907/* ------------------------------------------------------------------------- */
1901/* 1908/*
1902 * Page the screen up/down nlines 1909 * Page the screen up/down nlines
1903 * direction should be UP or DN 1910 * direction should be UP or DN
1904 */ 1911 */
1905bool 1912bool
1906rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW 1913rxvt_term::scr_page (int nlines) NOTHROW
1907{ 1914{
1908 int new_view_start =
1909 direction == UP ? view_start - nlines
1910 : view_start + nlines;
1911
1912 return scr_changeview (new_view_start); 1915 return scr_changeview (view_start - nlines);
1913} 1916}
1914 1917
1915bool 1918bool
1916rxvt_term::scr_changeview (int new_view_start) NOTHROW 1919rxvt_term::scr_changeview (int new_view_start) NOTHROW
1917{ 1920{
1970 HOOK_INVOKE ((this, HOOK_BELL, DT_END)); 1973 HOOK_INVOKE ((this, HOOK_BELL, DT_END));
1971#endif 1974#endif
1972} 1975}
1973 1976
1974/* ------------------------------------------------------------------------- */ 1977/* ------------------------------------------------------------------------- */
1975void 1978void ecb_cold
1976rxvt_term::scr_printscreen (int fullhist) NOTHROW 1979rxvt_term::scr_printscreen (int fullhist) NOTHROW
1977{ 1980{
1978#ifdef PRINTPIPE 1981#ifdef PRINTPIPE
1979 int nrows, row_start; 1982 int nrows, row_start;
1980 FILE *fd = popen_printer (); 1983 FILE *fd = popen_printer ();
2029/* 2032/*
2030 * Refresh the screen 2033 * Refresh the screen
2031 * drawn_text/drawn_rend contain the screen information before the update. 2034 * drawn_text/drawn_rend contain the screen information before the update.
2032 * screen.text/screen.rend contain what the screen will change to. 2035 * screen.text/screen.rend contain what the screen will change to.
2033 */ 2036 */
2034void 2037void ecb_hot
2035rxvt_term::scr_refresh () NOTHROW 2038rxvt_term::scr_refresh () NOTHROW
2036{ 2039{
2037 int16_t col, row, /* column/row we're processing */ 2040 int16_t col, row, /* column/row we're processing */
2038 ocrow; /* old cursor row */ 2041 ocrow; /* old cursor row */
2039 int i; /* tmp */ 2042 int i; /* tmp */
2040#ifndef NO_CURSORCOLOR
2041 rend_t cc1; /* store colours at cursor position (s) */
2042#endif
2043 rend_t *crp; // cursor rendition pointer
2044 rend_t ccol1, /* Cursor colour */ 2043 rend_t ccol1, /* Cursor colour */
2045 ccol2; /* Cursor colour2 */ 2044 ccol2; /* Cursor colour2 */
2045 rend_t cur_rend;
2046 int cur_col;
2047 int cursorwidth;
2046 2048
2047 want_refresh = 0; /* screen is current */ 2049 want_refresh = 0; /* screen is current */
2048 2050
2049 if (refresh_type == NO_REFRESH || !mapped) 2051 if (refresh_type == NO_REFRESH || !mapped)
2050 return; 2052 return;
2054 */ 2056 */
2055 refresh_count = 0; 2057 refresh_count = 0;
2056 2058
2057 unsigned int old_screen_flags = screen.flags; 2059 unsigned int old_screen_flags = screen.flags;
2058 bool have_bg = 0; 2060 bool have_bg = 0;
2059#ifdef HAVE_BG_PIXMAP 2061#ifdef HAVE_IMG
2060 have_bg = bg_pixmap != None; 2062 have_bg = bg_img != 0;
2061#endif 2063#endif
2062 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2064 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
2063 2065
2064 /* 2066 /*
2065 * B: reverse any characters which are selected 2067 * B: reverse any characters which are selected
2075 2077
2076 /* 2078 /*
2077 * C: set the cursor character (s) 2079 * C: set the cursor character (s)
2078 */ 2080 */
2079 { 2081 {
2080 bool setoldcursor;
2081
2082#ifdef CURSOR_BLINK 2082#ifdef CURSOR_BLINK
2083 if (hidden_cursor) 2083 if (hidden_cursor)
2084 showcursor = 0; 2084 showcursor = 0;
2085#endif 2085#endif
2086 2086
2089 int col = screen.cur.col; 2089 int col = screen.cur.col;
2090 2090
2091 while (col && ROW(screen.cur.row).t[col] == NOCHAR) 2091 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2092 col--; 2092 col--;
2093 2093
2094 cursorwidth = 1;
2095 while (col + cursorwidth < ncol
2096 && ROW(screen.cur.row).t[col + cursorwidth] == NOCHAR)
2097 cursorwidth++;
2098
2094 crp = &ROW(screen.cur.row).r[col]; 2099 cur_rend = ROW(screen.cur.row).r[col];
2100 cur_col = col;
2095 2101
2096#ifndef NO_CURSORCOLOR 2102#ifndef NO_CURSORCOLOR
2097 cc1 = *crp & (RS_fgMask | RS_bgMask);
2098 if (ISSET_PIXCOLOR (Color_cursor)) 2103 if (ISSET_PIXCOLOR (Color_cursor))
2099 ccol1 = Color_cursor; 2104 ccol1 = Color_cursor;
2100 else 2105 else
2101#endif 2106#endif
2102#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2107#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2114 ccol2 = bgcolor_of (rstyle); 2119 ccol2 = bgcolor_of (rstyle);
2115#else 2120#else
2116 ccol2 = Color_bg; 2121 ccol2 = Color_bg;
2117#endif 2122#endif
2118 2123
2119 if (focus) 2124 if (focus && cursor_type == 0)
2120 { 2125 {
2121 if (option (Opt_cursorUnderline)) 2126 rend_t rend = cur_rend;
2122 *crp ^= RS_Uline; 2127
2123 else
2124 {
2125 *crp ^= RS_RVid; 2128 rend ^= RS_RVid;
2126 *crp = SET_FGCOLOR (*crp, ccol1); 2129 rend = SET_FGCOLOR (rend, ccol1);
2127 *crp = SET_BGCOLOR (*crp, ccol2); 2130 rend = SET_BGCOLOR (rend, ccol2);
2128 } 2131
2132 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend);
2129 } 2133 }
2130 } 2134 }
2131 2135
2132 /* make sure no outline cursor is left around */ 2136 /* make sure no outline cursor is left around */
2133 setoldcursor = 0; 2137 if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol)
2134 if (ocrow != -1) 2138 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2139
2140 // save the current cursor coordinates if the cursor is visible
2141 // and either the window is unfocused or the cursor style is
2142 // underline or vertical bar, so as to clear the outline cursor in
2143 // the next refresh if the cursor moves or becomes invisible
2144 if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow)
2135 { 2145 {
2136 if (screen.cur.row - view_start != ocrow 2146 oldcursor.row = screen.cur.row - view_start;
2137 || screen.cur.col != oldcursor.col) 2147 oldcursor.col = screen.cur.col;
2138 {
2139 if (ocrow < nrow
2140 && oldcursor.col < ncol)
2141 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2142
2143 if (focus || !showcursor)
2144 oldcursor.row = -1;
2145 else
2146 setoldcursor = 1;
2147 }
2148 } 2148 }
2149 else if (!focus) 2149 else
2150 setoldcursor = 1;
2151
2152 if (setoldcursor)
2153 {
2154 if (screen.cur.row - view_start >= nrow)
2155 oldcursor.row = -1; 2150 oldcursor.row = -1;
2156 else
2157 {
2158 oldcursor.row = screen.cur.row - view_start;
2159 oldcursor.col = screen.cur.col;
2160 }
2161 }
2162 } 2151 }
2163 2152
2164#ifndef NO_SLOW_LINK_SUPPORT 2153#ifndef NO_SLOW_LINK_SUPPORT
2165 /* 2154 /*
2166 * D: CopyArea pass - very useful for slower links 2155 * D: CopyArea pass - very useful for slower links
2247 int ypixel = (int)Row2Pixel (row); 2236 int ypixel = (int)Row2Pixel (row);
2248 2237
2249 for (col = 0; col < ncol; col++) 2238 for (col = 0; col < ncol; col++)
2250 { 2239 {
2251 /* compare new text with old - if exactly the same then continue */ 2240 /* compare new text with old - if exactly the same then continue */
2252 if (stp[col] == dtp[col] /* Must match characters to skip. */ 2241 if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col]))
2253 && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */
2254 || (stp[col] == ' ' /* space w/ no background change */
2255 && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col]))))
2256 continue; 2242 continue;
2257 2243
2258 // redraw one or more characters 2244 // redraw one or more characters
2259 2245
2260 // seek to the beginning of wide characters 2246 // seek to the beginning of wide characters
2432 else 2418 else
2433 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2419 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2434 2420
2435 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) 2421 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back))
2436 { 2422 {
2423 if (showcursor && focus && row == screen.cur.row
2424 && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth))
2425 XSetForeground (dpy, gc, pix_colors[ccol1]);
2426 else
2437#if ENABLE_FRILLS 2427#if ENABLE_FRILLS
2438 if (ISSET_PIXCOLOR (Color_underline)) 2428 if (ISSET_PIXCOLOR (Color_underline))
2439 XSetForeground (dpy, gc, pix_colors[Color_underline]); 2429 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2440 else 2430 else
2441#endif 2431#endif
2453 */ 2443 */
2454 if (showcursor) 2444 if (showcursor)
2455 { 2445 {
2456 if (focus) 2446 if (focus)
2457 { 2447 {
2458 if (option (Opt_cursorUnderline)) 2448 if (cursor_type == 0)
2459 *crp ^= RS_Uline; 2449 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend);
2460 else 2450 else if (oldcursor.row >= 0)
2461 { 2451 {
2462 *crp ^= RS_RVid; 2452 XSetForeground (dpy, gc, pix_colors[ccol1]);
2463#ifndef NO_CURSORCOLOR 2453 if (cursor_type == 1)
2464 *crp = (*crp & ~ (RS_fgMask | RS_bgMask)) | cc1; 2454 XFillRectangle (dpy, vt, gc,
2465#endif 2455 Col2Pixel (cur_col),
2456 Row2Pixel (oldcursor.row + 1) - 2,
2457 Width2Pixel (1),
2458 2);
2459 else
2460 XFillRectangle (dpy, vt, gc,
2461 Col2Pixel (cur_col),
2462 Row2Pixel (oldcursor.row),
2463 2,
2464 Height2Pixel (1));
2466 } 2465 }
2467 } 2466 }
2468 else if (oldcursor.row >= 0) 2467 else if (oldcursor.row >= 0)
2469 { 2468 {
2470 int cursorwidth = 1;
2471 int col = oldcursor.col;
2472
2473 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2474 col--;
2475
2476 while (col + cursorwidth < ncol
2477 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2478 cursorwidth++;
2479
2480#ifndef NO_CURSORCOLOR
2481 if (ISSET_PIXCOLOR (Color_cursor))
2482 XSetForeground (dpy, gc, pix_colors[Color_cursor]);
2483 else
2484#endif
2485 XSetForeground (dpy, gc, pix_colors[ccol1]); 2469 XSetForeground (dpy, gc, pix_colors[ccol1]);
2486 2470
2487 XDrawRectangle (dpy, vt, gc, 2471 XDrawRectangle (dpy, vt, gc,
2488 Col2Pixel (col), 2472 Col2Pixel (cur_col),
2489 Row2Pixel (oldcursor.row), 2473 Row2Pixel (oldcursor.row),
2490 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2474 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2491 (unsigned int) (Height2Pixel (1) - 1)); 2475 (unsigned int) (Height2Pixel (1) - 1));
2492 } 2476 }
2493 } 2477 }
2505 screen.flags = old_screen_flags; 2489 screen.flags = old_screen_flags;
2506 num_scr = 0; 2490 num_scr = 0;
2507 num_scr_allow = 1; 2491 num_scr_allow = 1;
2508} 2492}
2509 2493
2510void 2494void ecb_cold
2511rxvt_term::scr_remap_chars (line_t &l) NOTHROW 2495rxvt_term::scr_remap_chars (line_t &l) NOTHROW
2512{ 2496{
2513 if (!l.valid ()) 2497 if (!l.valid ())
2514 return; 2498 return;
2515 2499
2517 2501
2518 for (int i = ncol; i--; ) 2502 for (int i = ncol; i--; )
2519 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); 2503 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i]));
2520} 2504}
2521 2505
2522void 2506void ecb_cold
2523rxvt_term::scr_remap_chars () NOTHROW 2507rxvt_term::scr_remap_chars () NOTHROW
2524{ 2508{
2525 for (int i = total_rows; i--; ) 2509 for (int i = total_rows; i--; )
2526 scr_remap_chars (row_buf [i]); 2510 scr_remap_chars (row_buf [i]);
2527 2511
2530 scr_remap_chars (drawn_buf [i]); 2514 scr_remap_chars (drawn_buf [i]);
2531 scr_remap_chars (swap_buf [i]); 2515 scr_remap_chars (swap_buf [i]);
2532 } 2516 }
2533} 2517}
2534 2518
2535void 2519void ecb_cold
2536rxvt_term::scr_recolour (bool refresh) NOTHROW 2520rxvt_term::scr_recolor (bool refresh) NOTHROW
2537{ 2521{
2538 bool transparent = false; 2522 bool transparent = false;
2539 2523
2540#ifdef HAVE_BG_PIXMAP 2524#ifdef HAVE_IMG
2541 if (bg_pixmap != None) 2525 if (bg_img != 0)
2542 { 2526 {
2543# ifdef ENABLE_TRANSPARENCY 2527# if ENABLE_TRANSPARENCY
2544 if (bg_flags & BG_IS_TRANSPARENT) 2528 if (bg_flags & BG_IS_TRANSPARENT)
2545 { 2529 {
2546 XSetWindowBackgroundPixmap (dpy, parent, bg_pixmap); 2530 XSetWindowBackgroundPixmap (dpy, parent, bg_img->pm);
2547 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); 2531 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2548 2532
2549 transparent = true; 2533 transparent = true;
2550 } 2534 }
2551 else 2535 else
2552# endif 2536# endif
2553 { 2537 {
2554 XSetWindowBackground (dpy, parent, pix_colors[Color_border]); 2538 XSetWindowBackground (dpy, parent, pix_colors[Color_border]);
2555 XSetWindowBackgroundPixmap (dpy, vt, bg_pixmap); 2539 XSetWindowBackgroundPixmap (dpy, vt, bg_img->pm);
2556 } 2540 }
2557 } 2541 }
2558 else 2542 else
2559#endif 2543#endif
2560 { 2544 {
2562 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 2546 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2563 } 2547 }
2564 2548
2565 XClearWindow (dpy, parent); 2549 XClearWindow (dpy, parent);
2566 2550
2567 if (scrollBar.win) 2551 if (scrollBar.state && scrollBar.win)
2568 { 2552 {
2569 if (transparent) 2553 if (transparent)
2570 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); 2554 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2571 else 2555 else
2572 XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); 2556 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]);
2573 scrollBar.state = SB_STATE_IDLE; 2557 scrollBar.state = SB_STATE_IDLE;
2574 scrollBar.show (0); 2558 scrollBar.show (0);
2575 } 2559 }
2576 2560
2577 if (refresh) 2561 if (refresh)
2643 for (rend_t *srp = ROW(row).r; col < end_col; col++) 2627 for (rend_t *srp = ROW(row).r; col < end_col; col++)
2644 srp[col] ^= rstyle; 2628 srp[col] ^= rstyle;
2645} 2629}
2646 2630
2647/* ------------------------------------------------------------------------- */ 2631/* ------------------------------------------------------------------------- */
2648void 2632void ecb_hot
2649rxvt_term::scr_reverse_selection () NOTHROW 2633rxvt_term::scr_reverse_selection () NOTHROW
2650{ 2634{
2651 if (selection.op 2635 if (selection.op
2652 && current_screen == selection.screen 2636 && current_screen == selection.screen
2653 && selection.end.row >= view_start) 2637 && selection.end.row >= view_start)
2694 || (check_more == 1 2678 || (check_more == 1
2695 && current_screen == selection.screen 2679 && current_screen == selection.screen
2696 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) 2680 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg)
2697 && ROWCOL_IS_BEFORE (screen.cur, selection.end))) 2681 && ROWCOL_IS_BEFORE (screen.cur, selection.end)))
2698 CLEAR_ALL_SELECTION (); 2682 CLEAR_ALL_SELECTION ();
2683}
2684
2685void
2686rxvt_term::selection_changed () NOTHROW
2687{
2688 line_t &r1 = ROW (selection.beg.row);
2689 while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR)
2690 ++selection.beg.col;
2691
2692 line_t &r2 = ROW (selection.end.row);
2693 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR)
2694 ++selection.end.col;
2695
2696 want_refresh = 1;
2699} 2697}
2700 2698
2701/* ------------------------------------------------------------------------- */ 2699/* ------------------------------------------------------------------------- */
2702/* 2700/*
2703 * Paste a selection direct to the command fd 2701 * Paste a selection direct to the command fd
2944/* ------------------------------------------------------------------------- */ 2942/* ------------------------------------------------------------------------- */
2945/* 2943/*
2946 * Mark or select text based upon number of clicks: 1, 2, or 3 2944 * Mark or select text based upon number of clicks: 1, 2, or 3
2947 * EXT: button 1 press 2945 * EXT: button 1 press
2948 */ 2946 */
2949void 2947void ecb_cold
2950rxvt_term::selection_click (int clicks, int x, int y) NOTHROW 2948rxvt_term::selection_click (int clicks, int x, int y) NOTHROW
2951{ 2949{
2952 clicks = ((clicks - 1) % 3) + 1; 2950 clicks = ((clicks - 1) % 3) + 1;
2953 selection.clicks = clicks; /* save clicks so extend will work */ 2951 selection.clicks = clicks; /* save clicks so extend will work */
2954 2952
2973 2971
2974/* ------------------------------------------------------------------------- */ 2972/* ------------------------------------------------------------------------- */
2975/* 2973/*
2976 * Mark a selection at the specified col/row 2974 * Mark a selection at the specified col/row
2977 */ 2975 */
2978void 2976void ecb_cold
2979rxvt_term::selection_start_colrow (int col, int row) NOTHROW 2977rxvt_term::selection_start_colrow (int col, int row) NOTHROW
2980{ 2978{
2981 want_refresh = 1; 2979 want_refresh = 1;
2982 2980
2983 selection.mark.row = row + view_start; 2981 selection.mark.row = row + view_start;
3006 * Word select: select text for 2 clicks 3004 * Word select: select text for 2 clicks
3007 * We now only find out the boundary in one direction 3005 * We now only find out the boundary in one direction
3008 */ 3006 */
3009 3007
3010/* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ 3008/* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */
3011#define DELIMIT_TEXT(x) \ 3009#define DELIMIT_TEXT(x) \
3012 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) 3010 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x)))
3013#define DELIMIT_REND(x) 1 3011#define DELIMIT_REND(x) 1
3014 3012
3015void 3013void ecb_cold
3016rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW 3014rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW
3017{ 3015{
3018 int col, row, dirnadd, tcol, trow, w1, w2; 3016 int col, row, dirnadd, tcol, trow, w1, w2;
3019 row_col_t bound; 3017 row_col_t bound;
3020 text_t *stp; 3018 text_t *stp;
3094 * EXT: button 3 press; button 1 or 3 drag 3092 * EXT: button 3 press; button 1 or 3 drag
3095 * flag == 0 ==> button 1 3093 * flag == 0 ==> button 1
3096 * flag == 1 ==> button 3 press 3094 * flag == 1 ==> button 3 press
3097 * flag == 2 ==> button 3 motion 3095 * flag == 2 ==> button 3 motion
3098 */ 3096 */
3099void 3097void ecb_cold
3100rxvt_term::selection_extend (int x, int y, int flag) NOTHROW 3098rxvt_term::selection_extend (int x, int y, int flag) NOTHROW
3101{ 3099{
3102 int col = clamp (Pixel2Col (x), 0, ncol); 3100 int col = clamp (Pixel2Col (x), 0, ncol);
3103 int row = clamp (Pixel2Row (y), 0, nrow - 1); 3101 int row = clamp (Pixel2Row (y), 0, nrow - 1);
3104 3102
3130 3128
3131/* ------------------------------------------------------------------------- */ 3129/* ------------------------------------------------------------------------- */
3132/* 3130/*
3133 * Extend the selection to the specified col/row 3131 * Extend the selection to the specified col/row
3134 */ 3132 */
3135void 3133void ecb_cold
3136rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW 3134rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW
3137{ 3135{
3138 row_col_t pos; 3136 row_col_t pos;
3139 enum { 3137 enum {
3140 LEFT, RIGHT 3138 LEFT, RIGHT
3141 } closeto = RIGHT; 3139 } closeto = RIGHT;
3142
3143 want_refresh = 1;
3144 3140
3145 switch (selection.op) 3141 switch (selection.op)
3146 { 3142 {
3147 case SELECTION_INIT: 3143 case SELECTION_INIT:
3148 CLEAR_SELECTION (); 3144 CLEAR_SELECTION ();
3328 3324
3329#if !ENABLE_MINIMAL 3325#if !ENABLE_MINIMAL
3330 if (selection.rect && selection.beg.col > selection.end.col) 3326 if (selection.rect && selection.beg.col > selection.end.col)
3331 ::swap (selection.beg.col, selection.end.col); 3327 ::swap (selection.beg.col, selection.end.col);
3332#endif 3328#endif
3329
3330 selection_changed ();
3333} 3331}
3334 3332
3335#if !ENABLE_MINIMAL 3333#if !ENABLE_MINIMAL
3336void 3334void ecb_cold
3337rxvt_term::selection_remove_trailing_spaces () NOTHROW 3335rxvt_term::selection_remove_trailing_spaces () NOTHROW
3338{ 3336{
3339 int32_t end_col, end_row; 3337 int32_t end_col, end_row;
3340 text_t *stp; 3338 text_t *stp;
3341 3339
3379/* ------------------------------------------------------------------------- */ 3377/* ------------------------------------------------------------------------- */
3380/* 3378/*
3381 * Double click on button 3 when already selected 3379 * Double click on button 3 when already selected
3382 * EXT: button 3 double click 3380 * EXT: button 3 double click
3383 */ 3381 */
3384void 3382void ecb_cold
3385rxvt_term::selection_rotate (int x, int y) NOTHROW 3383rxvt_term::selection_rotate (int x, int y) NOTHROW
3386{ 3384{
3387 selection.clicks = selection.clicks % 3 + 1; 3385 selection.clicks = selection.clicks % 3 + 1;
3388 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); 3386 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1);
3389} 3387}
3391/* ------------------------------------------------------------------------- */ 3389/* ------------------------------------------------------------------------- */
3392/* 3390/*
3393 * Respond to a request for our current selection 3391 * Respond to a request for our current selection
3394 * EXT: SelectionRequest 3392 * EXT: SelectionRequest
3395 */ 3393 */
3396void 3394void ecb_cold
3397rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW 3395rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW
3398{ 3396{
3399 Atom property = rq.property == None ? rq.target : rq.property; 3397 Atom property = rq.property == None ? rq.target : rq.property;
3400 XSelectionEvent ev; 3398 XSelectionEvent ev;
3401 3399
3534 3532
3535 XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); 3533 XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev);
3536} 3534}
3537 3535
3538/* ------------------------------------------------------------------------- */ 3536/* ------------------------------------------------------------------------- */
3539#ifdef USE_XIM 3537#if USE_XIM
3540void 3538void ecb_cold
3541rxvt_term::im_set_position (XPoint &pos) NOTHROW 3539rxvt_term::im_set_position (XPoint &pos) NOTHROW
3542{ 3540{
3543 XWindowAttributes xwa; 3541 XWindowAttributes xwa;
3544 3542
3545 XGetWindowAttributes (dpy, vt, &xwa); 3543 XGetWindowAttributes (dpy, vt, &xwa);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines