--- rxvt-unicode/src/screen.C 2006/02/17 14:30:51 1.259 +++ rxvt-unicode/src/screen.C 2008/07/15 16:41:22 1.308 @@ -1,9 +1,9 @@ -/*--------------------------------*-C-*--------------------------------------* +/*---------------------------------------------------------------------------* * File: screen.C *---------------------------------------------------------------------------* * * Copyright (c) 1997-2001 Geoff Wing - * Copyright (c) 2003-2006 Marc Lehmann + * Copyright (c) 2003-2007 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,13 +28,11 @@ #include "rxvt.h" /* NECESSARY */ #include "rxvtperl.h" /* NECESSARY */ -#include /* get the typedef for CARD32 */ - #include #include "salloc.C" // HACK, should be a seperate compile! -inline void fill_text (text_t *start, text_t value, int len) +static inline void fill_text (text_t *start, text_t value, int len) { while (len--) *start++ = value; @@ -49,7 +47,7 @@ * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * * ------------------------------------------------------------------------- */ #define ZERO_SCROLLBACK() \ - if (OPTION (Opt_scrollTtyOutput)) \ + if (option (Opt_scrollTtyOutput)) \ view_start = 0 #define CLEAR_SELECTION() \ selection.beg.row = selection.beg.col \ @@ -87,30 +85,14 @@ ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) /* - * CLEAR_ROWS : clear rows starting from row * CLEAR_CHARS: clear chars starting from pixel position - * ERASE_ROWS : set rows starting from row to the foreground colour */ -#define drawBuffer vt - -#define CLEAR_ROWS(row, num) \ - if (mapped) \ - XClearArea (dpy, drawBuffer, 0, \ - Row2Pixel (row), (unsigned int)width, \ - (unsigned int)Height2Pixel (num), False) - #define CLEAR_CHARS(x, y, num) \ - if (mapped) \ - XClearArea (dpy, drawBuffer, x, y, \ + if (mapped) \ + XClearArea (dpy, vt, x, y, \ (unsigned int)Width2Pixel (num), \ (unsigned int)Height2Pixel (1), False) -#define ERASE_ROWS(row, num) \ - XFillRectangle (dpy, drawBuffer, gc, \ - 0, Row2Pixel (row), \ - (unsigned int)width, \ - (unsigned int)Height2Pixel (num)) - /* ------------------------------------------------------------------------- * * SCREEN `COMMON' ROUTINES * * ------------------------------------------------------------------------- */ @@ -163,6 +145,7 @@ scr_overlay_off (); #endif + rvideo_mode = false; view_start = 0; num_scr = 0; @@ -239,7 +222,6 @@ selection.op = SELECTION_CLEAR; selection.screen = PRIMARY; selection.clicks = 0; - rvideo_state = rvideo_mode = false; } else { @@ -278,7 +260,7 @@ line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); - + int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row int pend = MOD (term_start + top_row , prev_total_rows); int q = total_rows; // rewrapped row @@ -332,7 +314,7 @@ // see below for cursor adjustment rationale if (p == ocur.row) screen.cur.row = q - (total_rows - nrow); - + // fill a single destination line while (lofs < llen && qcol < ncol) { @@ -368,7 +350,7 @@ term_start = total_rows - nrow; top_row = q - term_start; - + // make sure all terminal lines exist while (top_row > 0) scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); @@ -376,7 +358,7 @@ else { // if no scrollback exists (yet), wing, instead of wrap - + for (int row = min (nrow, prev_nrow); row--; ) { line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; @@ -409,9 +391,9 @@ prev_nrow = nrow; prev_ncol = ncol; - tabs = (char *)rxvt_malloc (ncol * sizeof (char)); + tabs = (char *)rxvt_malloc (ncol); - for (int col = ncol; col--; ) + for (int col = ncol; --col; ) tabs [col] = col % TABSIZE == 0; if (current_screen != PRIMARY) @@ -512,7 +494,7 @@ void rxvt_term::scr_swap_screen () { - if (!OPTION (Opt_secondaryScreen)) + if (!option (Opt_secondaryScreen)) return; for (int i = prev_nrow; i--; ) @@ -544,7 +526,7 @@ int i = current_screen; current_screen = scrn; scrn = i; #if NSCREENS - if (OPTION (Opt_secondaryScreen)) + if (option (Opt_secondaryScreen)) { num_scr = 0; @@ -557,7 +539,7 @@ } else #endif - if (OPTION (Opt_secondaryScroll)) + if (option (Opt_secondaryScroll)) scr_scroll_text (0, prev_nrow - 1, prev_nrow); } @@ -600,14 +582,14 @@ */ void rxvt_term::scr_rendition (int set, int style) NOTHROW - { - if (set) - rstyle |= style; - else if (style == ~RS_None) - rstyle = DEFAULT_RSTYLE; - else - rstyle &= ~style; - } +{ + if (set) + rstyle |= style; + else if (style == ~RS_None) + rstyle = DEFAULT_RSTYLE; + else + rstyle &= ~style; +} /* ------------------------------------------------------------------------- */ /* @@ -626,7 +608,7 @@ if (count > 0 && row1 == 0 - && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) + && (current_screen == PRIMARY || option (Opt_secondaryScroll))) { top_row = max (top_row - count, -saveLines); @@ -668,7 +650,7 @@ ::swap (l1, l2); l2.touch (); } - + // move and/or clear selection, if any if (selection.op && current_screen == selection.screen) { @@ -686,7 +668,7 @@ } // finally move the view window, if desired - if (OPTION (Opt_scrollWithBuffer) + if (option (Opt_scrollWithBuffer) && view_start != 0 && view_start != -saveLines) scr_page (UP, count); @@ -714,7 +696,7 @@ selection.beg.row -= count; selection.end.row -= count; selection.mark.row -= count; - + selection_check (0); } } @@ -836,7 +818,7 @@ if (screen.flags & Screen_WrapNext) { scr_do_wrap (); - + line->l = ncol; line->is_longer (1); @@ -1015,23 +997,20 @@ void rxvt_term::scr_backspace () NOTHROW { - want_refresh = 1; - if (screen.cur.col == 0) { if (screen.cur.row > 0) { #ifdef TERMCAP_HAS_BW screen.cur.col = ncol - 1; - screen.cur.row--; - return; + --screen.cur.row; + + want_refresh = 1; #endif } } - else if (!(screen.flags & Screen_WrapNext)) + else scr_gotorc (0, -1, RELATIVE); - - screen.flags &= ~Screen_WrapNext; } /* ------------------------------------------------------------------------- */ @@ -1064,7 +1043,7 @@ if (!--count) break; } - else + else ht &= l.t[i] == ' ' && RS_SAME (l.r[i], base_rend); @@ -1073,7 +1052,7 @@ // store horizontal tab commands as characters inside the text // buffer so they can be selected and pasted. - if (ht && OPTION (Opt_pastableTabs)) + if (ht && option (Opt_pastableTabs)) { base_rend = SET_FONT (base_rend, 0); @@ -1190,7 +1169,8 @@ else { if (screen.flags & Screen_Relative) - { /* relative origin mode */ + { + /* relative origin mode */ screen.cur.row = row + screen.tscroll; min_it (screen.cur.row, screen.bscroll); } @@ -1233,6 +1213,7 @@ * XTERM_SEQ: Clear line to right: ESC [ 0 K * XTERM_SEQ: Clear line to left : ESC [ 1 K * XTERM_SEQ: Clear whole line : ESC [ 2 K + * extension: clear to right unless wrapped: ESC [ 3 K */ void rxvt_term::scr_erase_line (int mode) NOTHROW @@ -1251,21 +1232,31 @@ switch (mode) { + case 3: + if (screen.flags & Screen_WrapNext) + return; + + /* fall through */ + case 0: /* erase to end of line */ col = screen.cur.col; num = ncol - col; min_it (line.l, col); + if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) CLEAR_SELECTION (); break; + case 1: /* erase to beginning of line */ col = 0; num = screen.cur.col + 1; + if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur) || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur)) CLEAR_SELECTION (); break; + case 2: /* erase whole line */ col = 0; num = ncol; @@ -1333,19 +1324,28 @@ min_it (num, nrow - row); + /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */ if (rstyle & (RS_RVid | RS_Uline)) ren = (rend_t) ~RS_None; else if (GET_BASEBG (rstyle) == Color_bg) { ren = DEFAULT_RSTYLE; - CLEAR_ROWS (row, num); + + if (mapped) + XClearArea (dpy, vt, 0, + Row2Pixel (row), (unsigned int)width, + (unsigned int)Height2Pixel (num), False); } else { ren = rstyle & (RS_fgMask | RS_bgMask); + gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; XChangeGC (dpy, gc, GCForeground, &gcvalue); - ERASE_ROWS (row, num); + XFillRectangle (dpy, vt, gc, + 0, Row2Pixel (row), + (unsigned int)width, + (unsigned int)Height2Pixel (num)); gcvalue.foreground = pix_colors[Color_fg]; XChangeGC (dpy, gc, GCForeground, &gcvalue); } @@ -1476,7 +1476,8 @@ || (selection.end.col + count >= ncol)) CLEAR_SELECTION (); else - { /* shift selection */ + { + /* shift selection */ selection.beg.col += count; selection.mark.col += count; /* XXX: yes? */ selection.end.col += count; @@ -1625,7 +1626,7 @@ rxvt_term::scr_set_tab (int mode) NOTHROW { if (mode < 0) - memset (tabs, 0, ncol * sizeof (char)); + memset (tabs, 0, ncol); else if (screen.cur.col < ncol) tabs [screen.cur.col] = !!mode; } @@ -1650,12 +1651,9 @@ rvideo_state = on; ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); -#if XPM_BACKGROUND +#ifdef HAVE_BG_PIXMAP if (bgPixmap.pixmap == None) #endif -#if TRANSPARENT - if (!OPTION (Opt_transparent) || am_transparent == 0) -#endif XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); XGCValues gcvalue; @@ -1808,7 +1806,7 @@ min_it (rc[i].col, ncol - 1); min_it (rc[i].row, nrow - 1); } - +// TODO: this line somehow causes segfault if scr_expose() is called just after resize for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); @@ -1873,10 +1871,11 @@ #ifndef NO_BELL void -rxvt_term::bell_cb (time_watcher &w) +rxvt_term::bell_cb (ev::timer &w, int revents) { rvideo_bell = false; scr_rvideo_mode (rvideo_mode); + refresh_check (); } #endif @@ -1888,22 +1887,32 @@ # ifndef NO_MAPALERT # ifdef MAPALERT_OPTION - if (OPTION (Opt_mapAlert)) + if (option (Opt_mapAlert)) # endif XMapWindow (dpy, parent[0]); # endif - if (OPTION (Opt_visualBell)) +# if ENABLE_FRILLS + if (option (Opt_urgentOnBell)) + { + if (XWMHints *h = XGetWMHints(dpy, parent[0])) + { + h->flags |= XUrgencyHint; + XSetWMHints (dpy, parent[0], h); + } + } +# endif + + if (option (Opt_visualBell)) { rvideo_bell = true; scr_rvideo_mode (rvideo_mode); - display->flush (); + flush (); - bell_ev.start (NOW + VISUAL_BELL_DURATION); + bell_ev.start (VISUAL_BELL_DURATION); } else XBell (dpy, 0); - #endif } @@ -1914,9 +1923,9 @@ { #ifdef PRINTPIPE int nrows, row_start; - FILE *fd; + FILE *fd = popen_printer (); - if ((fd = popen_printer ()) == NULL) + if (!fd) return; if (fullhist) @@ -1971,7 +1980,7 @@ void rxvt_term::scr_refresh () NOTHROW { - unsigned char must_clear, /* use draw_string not draw_image_string */ + unsigned char have_bg, showcursor; /* show the cursor */ int16_t col, row, /* column/row we're processing */ ocrow; /* old cursor row */ @@ -1980,6 +1989,8 @@ rend_t cc1; /* store colours at cursor position (s) */ #endif rend_t *crp; // cursor rendition pointer + rend_t ccol1, /* Cursor colour */ + ccol2; /* Cursor colour2 */ want_refresh = 0; /* screen is current */ @@ -1989,14 +2000,11 @@ /* * A: set up vars */ - must_clear = 0; refresh_count = 0; -#if XPM_BACKGROUND - must_clear |= bgPixmap.pixmap != None; -#endif -#if TRANSPARENT - must_clear |= OPTION (Opt_transparent) && am_transparent; + have_bg = 0; +#ifdef HAVE_BG_PIXMAP + have_bg = bgPixmap.pixmap != None; #endif ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ @@ -2010,8 +2018,6 @@ */ { unsigned char setoldcursor; - rend_t ccol1, /* Cursor colour */ - ccol2; /* Cursor colour2 */ showcursor = (screen.flags & Screen_VisibleCursor); #ifdef CURSOR_BLINK @@ -2028,35 +2034,38 @@ crp = &ROW(screen.cur.row).r[col]; - if (showcursor && focus) - { - if (OPTION (Opt_cursorUnderline)) - *crp ^= RS_Uline; - else - { - *crp ^= RS_RVid; - #ifndef NO_CURSORCOLOR - cc1 = *crp & (RS_fgMask | RS_bgMask); - if (ISSET_PIXCOLOR (Color_cursor)) - ccol1 = Color_cursor; - else + cc1 = *crp & (RS_fgMask | RS_bgMask); + if (ISSET_PIXCOLOR (Color_cursor)) + ccol1 = Color_cursor; + else +#endif #ifdef CURSOR_COLOR_IS_RENDITION_COLOR - ccol1 = fgcolor_of (rstyle); + ccol1 = fgcolor_of (rstyle); #else - ccol1 = Color_fg; + ccol1 = Color_fg; +#endif + +#ifndef NO_CURSORCOLOR + if (ISSET_PIXCOLOR (Color_cursor2)) + ccol2 = Color_cursor2; + else #endif - if (ISSET_PIXCOLOR (Color_cursor2)) - ccol2 = Color_cursor2; - else #ifdef CURSOR_COLOR_IS_RENDITION_COLOR - ccol2 = bgcolor_of (rstyle); + ccol2 = bgcolor_of (rstyle); #else - ccol2 = Color_bg; + ccol2 = Color_bg; #endif + + if (showcursor && focus) + { + if (option (Opt_cursorUnderline)) + *crp ^= RS_Uline; + else + { + *crp ^= RS_RVid; *crp = SET_FGCOLOR (*crp, ccol1); *crp = SET_BGCOLOR (*crp, ccol2); -#endif } } } @@ -2105,9 +2114,10 @@ */ if (!display->is_local && refresh_type == FAST_REFRESH && num_scr_allow && num_scr - && abs (num_scr) < nrow && !must_clear) + && abs (num_scr) < nrow && !have_bg) { int16_t nits; + int i = num_scr; int j; int len, wlen; dLocal (int, num_scr); @@ -2115,6 +2125,7 @@ j = nrow; wlen = len = -1; row = i > 0 ? 0 : j - 1; + for (; j-- >= 0; row += (i > 0 ? 1 : -1)) { if (row + i >= 0 && row + i < nrow && row + i != ocrow) @@ -2145,17 +2156,22 @@ } } - if (len != -1) + if (len >= 0) { /* also comes here at end if needed because of >= above */ if (wlen < len) ::swap (wlen, len); + XGCValues gcv; + + gcv.graphics_exposures = 1; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); XCopyArea (dpy, vt, vt, gc, 0, Row2Pixel (len + i), (unsigned int)this->width, (unsigned int)Height2Pixel (wlen - len + 1), 0, Row2Pixel (len)); + gcv.graphics_exposures = 0; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); + len = -1; } } @@ -2221,14 +2237,14 @@ if (stp[col] != dtp[col] || !RS_SAME (srp[col], drp[col])) { - if (must_clear && (i++ > count / 2)) + if (have_bg && (i++ > count / 2)) break; dtp[col] = stp[col]; drp[col] = rend; i = 0; } - else if (must_clear || (stp[col] != ' ' && ++i >= 16)) + else if (have_bg || (stp[col] != ' ' && ++i >= 16)) break; } @@ -2248,29 +2264,10 @@ // only do special processing if any attributes are set, which is unlikely if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) { -#if ENABLE_STYLES - // "careful" (too wide) character handling - - // include previous careful character(s) if possible, looks nicer (best effort...) - while (text > stp - && srp[text - stp - 1] & RS_Careful - && RS_SAME (rend, srp[text - stp - 1])) - text--, count++, xpixel -= fwidth; - - // force redraw after "careful" characters to avoid pixel droppings - for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) - drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; - - // force redraw before "careful" characters to avoid pixel droppings - for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) - drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; -#endif - bool invert = rend & RS_RVid; #ifndef NO_BOLD_UNDERLINE_REVERSE - if (rend & RS_Bold - && fore == Color_fg) + if (rend & RS_Bold && fore == Color_fg) { if (ISSET_PIXCOLOR (Color_BD)) fore = Color_BD; @@ -2280,8 +2277,7 @@ # endif } - if (rend & RS_Italic - && fore == Color_fg) + if (rend & RS_Italic && fore == Color_fg) { if (ISSET_PIXCOLOR (Color_IT)) fore = Color_IT; @@ -2291,18 +2287,29 @@ # endif } - if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) + if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL)) fore = Color_UL; #endif if (invert) { - ::swap (fore, back); +#ifdef OPTION_HC + if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col) + || !ISSET_PIXCOLOR (Color_HC)) +#endif + /* invert the column if no highlightColor is set or it is the + * current cursor column */ + ::swap (fore, back); +#ifdef OPTION_HC + else if (ISSET_PIXCOLOR (Color_HC)) + back = Color_HC; +#endif #ifndef NO_BOLD_UNDERLINE_REVERSE +# ifndef OPTION_HC if (ISSET_PIXCOLOR (Color_RV)) back = Color_RV; - +# endif if (fore == back) { fore = Color_bg; @@ -2314,15 +2321,33 @@ #ifdef TEXT_BLINK if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) { - if (!text_blink_ev.active) + if (!text_blink_ev.is_active ()) { - text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); + text_blink_ev.again (); hidden_text = 0; } else if (hidden_text) fore = back; } #endif + +#if ENABLE_STYLES + // "careful" (too wide) character handling + + // include previous careful character(s) if possible, looks nicer (best effort...) + while (text > stp + && srp[text - stp - 1] & RS_Careful + && RS_SAME (rend, srp[text - stp - 1])) + text--, count++, xpixel -= fwidth; + + // force redraw after "careful" characters to avoid pixel droppings + for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) + drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; + + // force redraw before "careful" characters to avoid pixel droppings + for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) + drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; +#endif } /* @@ -2330,23 +2355,19 @@ */ rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; - if (back == fore) - font->clear_rect (*drawable, xpixel, ypixel, fwidth * count, fheight, back); - else if (back == Color_bg) + if (have_bg && back == Color_bg) { - if (must_clear) - { - CLEAR_CHARS (xpixel, ypixel, count); + // this is very ugly, maybe push it into ->draw? - for (i = 0; i < count; i++) /* don't draw empty strings */ - if (text[i] != ' ') - { - font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); - break; - } - } - else - font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); + for (i = 0; i < count; i++) /* don't draw empty strings */ + if (text[i] != ' ') + { + font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_transparent); + goto did_clear; + } + + CLEAR_CHARS (xpixel, ypixel, count); + did_clear: ; } else font->draw (*drawable, xpixel, ypixel, text, count, fore, back); @@ -2360,7 +2381,7 @@ #endif XSetForeground (dpy, gc, pix_colors[fore]); - XDrawLine (dpy, drawBuffer, gc, + XDrawLine (dpy, vt, gc, xpixel, ypixel + font->ascent + 1, xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); } @@ -2379,7 +2400,7 @@ { if (focus) { - if (OPTION (Opt_cursorUnderline)) + if (option (Opt_cursorUnderline)) *crp ^= RS_Uline; else { @@ -2404,9 +2425,11 @@ #ifndef NO_CURSORCOLOR if (ISSET_PIXCOLOR (Color_cursor)) XSetForeground (dpy, gc, pix_colors[Color_cursor]); + else #endif + XSetForeground (dpy, gc, pix_colors[ccol1]); - XDrawRectangle (dpy, drawBuffer, gc, + XDrawRectangle (dpy, vt, gc, Col2Pixel (col), Row2Pixel (oldcursor.row), (unsigned int) (Width2Pixel (cursorwidth) - 1), @@ -2451,28 +2474,24 @@ void rxvt_term::scr_recolour () NOTHROW { - if (1 -#if TRANSPARENT - && !am_transparent -#endif -#if XPM_BACKGROUND - && !bgPixmap.pixmap -#endif - ) - { - XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); - XClearWindow (dpy, parent[0]); - XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); -#if HAVE_SCROLLBARS - if (scrollBar.win) - { - XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); - scrollBar.setIdle (); - scrollbar_show (0); - } +#ifdef HAVE_BG_PIXMAP + bgPixmap.apply (); +#else + + XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); + XClearWindow (dpy, parent[0]); + XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); + + if (scrollBar.win) + { + XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); + scrollBar.state = STATE_IDLE; + scrollBar.show (0); + } + #endif - } + /* bgPixmap.apply () does not do the following : */ scr_clear (); scr_touch (true); want_refresh = 1; @@ -2574,7 +2593,7 @@ unsigned int width, towrite; char r1[] = "\n"; - for (row = saveLines - nsaved; + for (row = saveLines + top_row; row < saveLines + nrow - 1; row++) { width = row_buf[row].l >= 0 ? row_buf[row].l @@ -2635,7 +2654,13 @@ if (data[i] == C0_LF) data[i] = C0_CR; + if (priv_modes & PrivMode_BracketPaste) + tt_printf ("\e[200~"); + tt_write (data, len); + + if (priv_modes & PrivMode_BracketPaste) + tt_printf ("\e[201~"); } /* ------------------------------------------------------------------------- */ @@ -2720,7 +2745,7 @@ selection_wait = Sel_incr; incr_buf_fill = 0; - incr_ev.start (NOW + 10); + incr_ev.start (10); goto bailout; } @@ -2739,7 +2764,7 @@ incr_buf_size = 0; incr_ev.stop (); } - else + else { if (selection_wait == Sel_normal && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion @@ -2756,7 +2781,7 @@ } else if (selection_wait == Sel_incr) { - incr_ev.start (NOW + 10); + incr_ev.start (10); while (incr_buf_fill + ct.nitems > incr_buf_size) { @@ -2806,7 +2831,7 @@ } void -rxvt_term::incr_cb (time_watcher &w) NOTHROW +rxvt_term::incr_cb (ev::timer &w, int revents) NOTHROW { selection_wait = Sel_none; @@ -2827,7 +2852,7 @@ /* ------------------------------------------------------------------------- */ /* - * Request the current selection: + * Request the current selection: * Order: > internal selection if available * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) * > CUT_BUFFER0 @@ -2839,7 +2864,8 @@ rxvt_term::selection_request (Time tm, int selnum) NOTHROW { if (selection.text && selnum == Sel_Primary) - { /* internal selection */ + { + /* internal selection */ char *str = rxvt_wcstombs (selection.text, selection.len); paste (str, strlen (str)); free (str); @@ -3115,9 +3141,10 @@ while (selection.mark.col > 0 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) --selection.mark.col; - + if (selection.op) - { /* clear the old selection */ + { + /* clear the old selection */ selection.beg.row = selection.end.row = selection.mark.row; selection.beg.col = selection.end.col = selection.mark.col; } @@ -3316,7 +3343,8 @@ * time of the most recent button3 press */ if (button3 && buttonpress) - { /* button3 press */ + { + /* button3 press */ /* * first determine which edge of the selection we are closest to */ @@ -3344,7 +3372,8 @@ } } else - { /* button1 drag or button3 drag */ + { + /* button1 drag or button3 drag */ if (ROWCOL_IS_AFTER (selection.mark, pos)) { if (selection.mark.row == selection.end.row @@ -3397,7 +3426,7 @@ else if (selection.clicks == 3) { #if ENABLE_FRILLS - if (OPTION (Opt_tripleclickwords)) + if (option (Opt_tripleclickwords)) { selection_delimit_word (UP, &selection.beg, &selection.beg); @@ -3435,7 +3464,8 @@ } if (button3 && buttonpress) - { /* mark may need to be changed */ + { + /* mark may need to be changed */ if (closeto == LEFT) { selection.mark.row = selection.end.row; @@ -3644,22 +3674,6 @@ XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); } - -/* ------------------------------------------------------------------------- * - * MOUSE ROUTINES * - * ------------------------------------------------------------------------- */ - -/* - * return col/row values corresponding to x/y pixel values - */ -void -rxvt_term::pixel_position (int *x, int *y) NOTHROW -{ - *x = Pixel2Col (*x); - /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ - *y = Pixel2Row (*y); - /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ -} /* ------------------------------------------------------------------------- */ #ifdef USE_XIM