--- rxvt-unicode/src/screen.C 2004/03/15 00:08:11 1.59 +++ rxvt-unicode/src/screen.C 2004/05/09 18:19:49 1.74 @@ -1,5 +1,5 @@ /*--------------------------------*-C-*--------------------------------------* - * File: screen.c + * File: screen.C *---------------------------------------------------------------------------* * * Copyright (c) 1997-2001 Geoff Wing @@ -191,7 +191,7 @@ if (prev_nrow == 0) { /* - * first time called so just malloc everything : don't rely on realloc + * first time called so just malloc everything: don't rely on realloc * Note: this is still needed so that all the scrollback lines are NULL */ screen.text = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); @@ -258,6 +258,7 @@ for (p = nrow; p < prev_nrow; p++) { q = p + TermWin.saveLines; + if (screen.text[q]) { #ifdef DEBUG_STRICT @@ -266,6 +267,7 @@ talloc->free (screen.text[q]); ralloc->free (screen.rend[q]); } + if (swap.text[p]) { #ifdef DEBUG_STRICT @@ -274,6 +276,7 @@ talloc->free (swap.text[p]); ralloc->free (swap.rend[p]); } + #ifdef DEBUG_STRICT assert (drawn_text[p] && drawn_rend[p]); #endif @@ -313,7 +316,7 @@ swap.rend[p] = NULL; drawn_text[p] = NULL; drawn_rend[p] = NULL; - scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); + scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); } @@ -338,7 +341,6 @@ /* resize columns */ if (ncol != prev_ncol) { - int common = min (prev_ncol, ncol); rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); @@ -346,39 +348,38 @@ { if (screen.text[p]) { - text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t; - rend_t *r = (rend_t *)ra->alloc (); memcpy (r, screen.rend[p], common * sizeof (rend_t)); screen.rend[p] = r; + screen.text[p] = (text_t *)ta->alloc (screen.text[p], prev_ncol * sizeof (text_t)); + screen.rend[p] = (rend_t *)ra->alloc (screen.rend[p], prev_ncol * sizeof (rend_t)); MIN_IT (screen.tlen[p], (int16_t)ncol); if (ncol > prev_ncol) - scr_blank_line (& (screen.text[p][prev_ncol]), - & (screen.rend[p][prev_ncol]), - ncol - prev_ncol, - setrstyle); + scr_blank_line (&screen.text[p][prev_ncol], + &screen.rend[p][prev_ncol], + ncol - prev_ncol, setrstyle); } } for (p = 0; p < nrow; p++) { - text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t; - rend_t *r = (rend_t *)ra->alloc (); memcpy (r, drawn_rend[p], common * sizeof (rend_t)); drawn_rend[p] = r; + drawn_text[p] = (text_t *)ta->alloc (drawn_text[p], prev_ncol * sizeof (text_t)); + drawn_rend[p] = (rend_t *)ra->alloc (drawn_rend[p], prev_ncol * sizeof (rend_t)); if (ncol > prev_ncol) - scr_blank_line (& (drawn_text[p][prev_ncol]), - & (drawn_rend[p][prev_ncol]), + scr_blank_line (&drawn_text[p][prev_ncol], + &drawn_rend[p][prev_ncol], ncol - prev_ncol, setrstyle); if (swap.text[p]) { - text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t; - rend_t *r = (rend_t *)ra->alloc (); memcpy (r, swap.rend[p], common * sizeof (rend_t)); swap.rend[p] = r; + swap.text[p] = (text_t *)ta->alloc (swap.text[p], prev_ncol * sizeof (text_t)); + swap.rend[p] = (rend_t *)ra->alloc (swap.rend[p], prev_ncol * sizeof (rend_t)); MIN_IT (swap.tlen[p], (int16_t)ncol); if (ncol > prev_ncol) - scr_blank_line (& (swap.text[p][prev_ncol]), - & (swap.rend[p][prev_ncol]), + scr_blank_line (&swap.text[p][prev_ncol], + &swap.rend[p][prev_ncol], ncol - prev_ncol, setrstyle); } @@ -441,15 +442,6 @@ total_rows = TermWin.nrow + TermWin.saveLines; -#ifdef DEBUG_STRICT - for (i = 0; i < total_rows; i++) - { - if (screen.text[i]) - /* then so is screen.rend[i] */ - assert (screen.rend[i]); - } -#endif - delete talloc; talloc = 0; delete ralloc; ralloc = 0; @@ -487,7 +479,7 @@ prev_nrow = prev_ncol = 0; scr_reset (); - scr_clear (); + scr_clear (true); scr_refresh (SLOW_REFRESH); } @@ -502,16 +494,17 @@ void rxvt_term::scr_cursor (int mode) { - screen_t *s; + screen_t *s; D_SCREEN ((stderr, "rxvt_scr_cursor (%c)", mode)); #if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) if (current_screen == SECONDARY) - s = & (swap); + s = &swap; else #endif - s = & (screen); + s = &screen; + switch (mode) { case SAVE: @@ -521,6 +514,7 @@ s->s_charset = s->charset; s->s_charset_char = charsets[s->charset]; break; + case RESTORE: want_refresh = 1; s->cur.row = s->s_cur.row; @@ -532,6 +526,7 @@ set_font_style (); break; } + /* boundary check in case screen size changed between SAVE and RESTORE */ MIN_IT (s->cur.row, TermWin.nrow - 1); MIN_IT (s->cur.col, TermWin.ncol - 1); @@ -553,9 +548,9 @@ int rxvt_term::scr_change_screen (int scrn) { - int i; + int i; #if NSCREENS - int offset; + int offset; #endif want_refresh = 1; @@ -565,41 +560,43 @@ TermWin.view_start = 0; if (current_screen == scrn) - return current_screen; + return scrn; selection_check (2); /* check for boundary cross */ SWAP_IT (current_screen, scrn, int); #if NSCREENS - num_scr = 0; - offset = TermWin.saveLines; - for (i = prev_nrow; i--;) + if (Options & Opt_secondaryScreen) { - SWAP_IT (screen.text[i + offset], swap.text[i], text_t *); - SWAP_IT (screen.tlen[i + offset], swap.tlen[i], int16_t); - SWAP_IT (screen.rend[i + offset], swap.rend[i], rend_t *); - } - SWAP_IT (screen.cur.row, swap.cur.row, int16_t); - SWAP_IT (screen.cur.col, swap.cur.col, int16_t); + num_scr = 0; + offset = TermWin.saveLines; + for (i = prev_nrow; i--;) + { + SWAP_IT (screen.text[i + offset], swap.text[i], text_t *); + SWAP_IT (screen.tlen[i + offset], swap.tlen[i], int16_t); + SWAP_IT (screen.rend[i + offset], swap.rend[i], rend_t *); + } + SWAP_IT (screen.cur.row, swap.cur.row, int16_t); + SWAP_IT (screen.cur.col, swap.cur.col, int16_t); # ifdef DEBUG_STRICT - assert ((screen.cur.row >= 0) && (screen.cur.row < prev_nrow)); - assert ((screen.cur.col >= 0) && (screen.cur.col < prev_ncol)); + assert ((screen.cur.row >= 0) && (screen.cur.row < prev_nrow)); + assert ((screen.cur.col >= 0) && (screen.cur.col < prev_ncol)); # else /* drive with your eyes closed */ - MAX_IT (screen.cur.row, 0); - MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); - MAX_IT (screen.cur.col, 0); - MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); -# endif - SWAP_IT (screen.charset, swap.charset, int16_t); - SWAP_IT (screen.flags, swap.flags, int); - screen.flags |= Screen_VisibleCursor; - swap.flags |= Screen_VisibleCursor; -#else -# ifdef SCROLL_ON_NO_SECONDARY - if (current_screen == PRIMARY) - scr_scroll_text (0, (prev_nrow - 1), prev_nrow, 0); + MAX_IT (screen.cur.row, 0); + MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); + MAX_IT (screen.cur.col, 0); + MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); # endif + SWAP_IT (screen.charset, swap.charset, int16_t); + SWAP_IT (screen.flags, swap.flags, int); + screen.flags |= Screen_VisibleCursor; + swap.flags |= Screen_VisibleCursor; + } + else #endif + if (Options & Opt_secondaryScroll) + //if (current_screen == PRIMARY) + scr_scroll_text (0, (prev_nrow - 1), prev_nrow, 0); return scrn; } @@ -651,7 +648,8 @@ want_refresh = 1; D_SCREEN ((stderr, "rxvt_scroll_text (%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary")); - if ((count > 0) && (row1 == 0) && (current_screen == PRIMARY)) + if (row1 == 0 && count > 0 + && (current_screen == PRIMARY || Options & Opt_secondaryScroll)) { nscrolled = (long)TermWin.nscrolled + (long)count; @@ -714,6 +712,7 @@ buf_text[i] = screen.text[j]; buf_rend[i] = screen.rend[j]; } + /* A2: Rotate lines */ for (j = row1, i = j + count; i <= row2; i++, j++) { @@ -721,6 +720,7 @@ screen.text[j] = screen.text[i]; screen.rend[j] = screen.rend[i]; } + j = row2 - count + 1, i = count; } else /* if (j < 0) */ @@ -733,6 +733,7 @@ buf_text[i] = screen.text[j]; buf_rend[i] = screen.rend[j]; } + /* B2: Rotate lines */ for (j = row2, i = j - count; i >= row1; i--, j--) { @@ -740,6 +741,7 @@ screen.text[j] = screen.text[i]; screen.rend[j] = screen.rend[i]; } + j = row1, i = count; count = -count; } @@ -752,8 +754,7 @@ screen.rend[j] = buf_rend[i]; if (!spec) /* line length may not equal TermWin.ncol */ - scr_blank_screen_mem (screen.text, screen.rend, - (unsigned int)j, rstyle); + scr_blank_screen_mem (screen.text, screen.rend, (unsigned int)j, rstyle); } return count; @@ -803,43 +804,46 @@ #endif row = screen.cur.row + TermWin.saveLines; - checksel = (selection.op - && current_screen == selection.screen) ? 1 : 0; + checksel = selection.op && current_screen == selection.screen ? 1 : 0; clearsel = 0; stp = screen.text[row]; srp = screen.rend[row]; - for (i = 0; i < len;) + while (len--) { - c = str[i++]; - switch (c) - { - case '\t': - scr_tab (1); - continue; - case '\n': - if (screen.tlen[row] != -1) /* XXX: think about this */ - MAX_IT (screen.tlen[row], screen.cur.col); - screen.flags &= ~Screen_WrapNext; - if (screen.cur.row == screen.bscroll) - scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); - else if (screen.cur.row < (TermWin.nrow - 1)) - row = (++screen.cur.row) + TermWin.saveLines; - stp = screen.text[row]; /* _must_ refresh */ - srp = screen.rend[row]; /* _must_ refresh */ - continue; - case '\r': - if (screen.tlen[row] != -1) /* XXX: think about this */ - MAX_IT (screen.tlen[row], screen.cur.col); - screen.flags &= ~Screen_WrapNext; - screen.cur.col = 0; - continue; - default: - if (c == 127) - continue; /* yummmm..... */ - break; - } + c = *str++; + + if (c < 0x20) + switch (c) + { + case C0_HT: + scr_tab (1); + continue; + + case C0_LF: + if (screen.tlen[row] != -1) /* XXX: think about this */ + MAX_IT (screen.tlen[row], screen.cur.col); + + screen.flags &= ~Screen_WrapNext; + + if (screen.cur.row == screen.bscroll) + scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); + else if (screen.cur.row < (TermWin.nrow - 1)) + row = (++screen.cur.row) + TermWin.saveLines; + + stp = screen.text[row]; /* _must_ refresh */ + srp = screen.rend[row]; /* _must_ refresh */ + continue; + + case C0_CR: + if (screen.tlen[row] != -1) /* XXX: think about this */ + MAX_IT (screen.tlen[row], screen.cur.col); + + screen.flags &= ~Screen_WrapNext; + screen.cur.col = 0; + continue; + } if (checksel /* see if we're writing within selection */ && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) @@ -868,27 +872,27 @@ // rely on wcwidth to tell us the character width, at least for non-latin1 // do wcwidth before further replacements, as wcwidth says that line-drawing - // characters have width -1 (DOH!) on gnu/linux sometimes. + // characters have width -1 (DOH!) on GNU/Linux sometimes. int width = c < 256 ? 1 : wcwidth (c); if (charsets[screen.charset] == '0') // DEC SPECIAL - switch (c) - { - // vt100 special graphics and line drawing - case '`': c = 0x25c6; break; case '_': c = 0x0020; break; - case 'a': c = 0x2592; break; case 'b': c = 0x2409; break; case 'c': c = 0x240c; break; - case 'd': c = 0x240d; break; case 'e': c = 0x240a; break; case 'f': c = 0x00b0; break; - case 'g': c = 0x00b1; break; case 'h': c = 0x2424; break; case 'i': c = 0x240b; break; - case 'j': c = 0x2518; break; case 'k': c = 0x2510; break; case 'l': c = 0x250c; break; - case 'm': c = 0x2514; break; case 'n': c = 0x253c; break; case 'o': c = 0x23ba; break; - case 'p': c = 0x23bb; break; case 'q': c = 0x2500; break; case 'r': c = 0x23bc; break; - case 's': c = 0x23bd; break; case 't': c = 0x251c; break; case 'u': c = 0x2524; break; - case 'v': c = 0x2534; break; case 'w': c = 0x252c; break; case 'x': c = 0x2502; break; - case 'y': c = 0x2264; break; case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; - case '|': c = 0x2260; break; case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; - } + { + // vt100 special graphics and line drawing + static uint16_t vt100_0[32] = { // 5f .. 7e + 0x0020, 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, + 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, + 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, + 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, + }; - if (width > 0) + if (c >= 0x5f && c <= 0x7e) + { + c = vt100_0[c - 0x5f]; + width = 1; + } + } + + if (width != 0) { #if !UNICODE_3 && ENABLE_COMBINING // trim characters we can't store directly :( @@ -990,6 +994,7 @@ rxvt_term::scr_backspace () { want_refresh = 1; + if (screen.cur.col == 0) { if (screen.cur.row > 0) @@ -1004,6 +1009,7 @@ } else if ((screen.flags & Screen_WrapNext) == 0) scr_gotorc (0, -1, RELATIVE); + screen.flags &= ~Screen_WrapNext; } @@ -1016,11 +1022,12 @@ void rxvt_term::scr_tab (int count) { - int i, x; + int i, x; D_SCREEN ((stderr, "rxvt_scr_tab (%d)", count)); want_refresh = 1; i = x = screen.cur.col; + if (count == 0) return; else if (count > 0) @@ -1032,6 +1039,7 @@ if (!--count) break; } + if (count) x = TermWin.ncol - 1; } @@ -1044,9 +1052,11 @@ if (!++count) break; } + if (count) x = 0; } + if (x != screen.cur.col) scr_gotorc (0, x, R_RELATIVE); } @@ -1113,8 +1123,7 @@ D_SCREEN ((stderr, "rxvt_scr_gotorc (r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col)); - screen.cur.col = ((relative & C_RELATIVE) ? (screen.cur.col + col) - : col); + screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; MAX_IT (screen.cur.col, 0); MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); @@ -1163,7 +1172,7 @@ void rxvt_term::scr_index (enum page_dirn direction) { - int dirn; + int dirn; want_refresh = 1; dirn = ((direction == UP) ? 1 : -1); @@ -1233,8 +1242,7 @@ } if (screen.text[row]) - scr_blank_line (& (screen.text[row][col]), - & (screen.rend[row][col]), num, rstyle); + scr_blank_line (&screen.text[row][col], &screen.rend[row][col], num, rstyle); else scr_blank_screen_mem (screen.text, screen.rend, row, rstyle); } @@ -1249,10 +1257,10 @@ void rxvt_term::scr_erase_screen (int mode) { - int num; - int32_t row, row_offset; - rend_t ren; - XGCValues gcvalue; + int num; + int32_t row, row_offset; + rend_t ren; + XGCValues gcvalue; want_refresh = 1; D_SCREEN ((stderr, "rxvt_scr_erase_screen (%d) at screen row: %d", mode, screen.cur.row)); @@ -1281,15 +1289,20 @@ default: return; } + refresh_type |= REFRESH_BOUNDS; + if (selection.op && current_screen == selection.screen && ((selection.beg.row >= row && selection.beg.row <= row + num) || (selection.end.row >= row && selection.end.row <= row + num))) CLEAR_SELECTION (); + if (row >= TermWin.nrow) /* Out Of Bounds */ return; + MIN_IT (num, (TermWin.nrow - row)); + if (rstyle & (RS_RVid | RS_Uline)) ren = (rend_t) ~RS_None; else if (GET_BASEBG (rstyle) == Color_bg) @@ -1306,6 +1319,7 @@ gcvalue.foreground = PixColors[Color_fg]; XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue); } + for (; num--; row++) { scr_blank_screen_mem (screen.text, screen.rend, @@ -1349,7 +1363,7 @@ void rxvt_term::scr_insdel_lines (int count, int insdel) { - int end; + int end; ZERO_SCROLLBACK (); @@ -1378,11 +1392,11 @@ void rxvt_term::scr_insdel_chars (int count, int insdel) { - int col, row; - rend_t tr; - text_t *stp; - rend_t *srp; - int16_t *slp; + int col, row; + rend_t tr; + text_t *stp; + rend_t *srp; + int16_t *slp; want_refresh = 1; ZERO_SCROLLBACK (); @@ -1399,6 +1413,7 @@ stp = screen.text[row]; srp = screen.rend[row]; slp = & (screen.tlen[row]); + switch (insdel) { case INSERT: @@ -1408,11 +1423,13 @@ stp[col] = stp[col - count]; srp[col] = srp[col - count]; } + if (*slp != -1) { *slp += count; MIN_IT (*slp, TermWin.ncol); } + if (selection.op && current_screen == selection.screen && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) { @@ -1426,9 +1443,11 @@ selection.end.col += count; } } + scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), (unsigned int)count, rstyle); break; + case ERASE: screen.cur.col += count; /* don't worry if > TermWin.ncol */ selection_check (1); @@ -1436,21 +1455,26 @@ scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), (unsigned int)count, rstyle); break; + case DELETE: - tr = srp[TermWin.ncol - 1] - & (RS_fgMask | RS_bgMask | RS_baseattrMask); + tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); + for (col = screen.cur.col; (col + count) < TermWin.ncol; col++) { stp[col] = stp[col + count]; srp[col] = srp[col + count]; } + scr_blank_line (& (stp[TermWin.ncol - count]), & (srp[TermWin.ncol - count]), (unsigned int)count, tr); + if (*slp == -1) /* break line continuation */ *slp = TermWin.ncol; + *slp -= count; MAX_IT (*slp, 0); + if (selection.op && current_screen == selection.screen && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) { @@ -1466,6 +1490,7 @@ selection.end.col -= count; } } + break; } } @@ -1480,8 +1505,10 @@ { MAX_IT (top, 0); MIN_IT (bot, (int)TermWin.nrow - 1); + if (top > bot) return; + screen.tscroll = top; screen.bscroll = bot; scr_gotorc (0, 0, 0); @@ -1497,6 +1524,7 @@ rxvt_term::scr_cursor_visible (int mode) { want_refresh = 1; + if (mode) screen.flags |= Screen_VisibleCursor; else @@ -1744,8 +1772,7 @@ 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)); for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) - fill_text (& (drawn_text[i][rc[PART_BEG].col]), 0, - (rc[PART_END].col - rc[PART_BEG].col + 1)); + fill_text (&drawn_text[i][rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); if (refresh) scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); @@ -1822,6 +1849,7 @@ want_refresh = 1; num_scr -= (TermWin.view_start - oldviewstart); } + return (int) (TermWin.view_start - oldviewstart); } @@ -1949,9 +1977,9 @@ * C: set the cursor character (s) */ { - unsigned char setoldcursor; - rend_t ccol1, /* Cursor colour */ - ccol2; /* Cursor colour2 */ + unsigned char setoldcursor; + rend_t ccol1, /* Cursor colour */ + ccol2; /* Cursor colour2 */ showcursor = (screen.flags & Screen_VisibleCursor); #ifdef CURSOR_BLINK @@ -1961,8 +1989,7 @@ if (showcursor) { - srp = & (screen.rend[screen.cur.row + TermWin.saveLines] - [screen.cur.col]); + srp = &(screen.rend[screen.cur.row + TermWin.saveLines][screen.cur.col]); if (showcursor && TermWin.focus) { @@ -2000,9 +2027,8 @@ { if (ocrow < TermWin.nrow && oldcursor.col < TermWin.ncol) - { - drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); - } + drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); + if (TermWin.focus || !showcursor) oldcursor.row = -1; else @@ -2011,6 +2037,7 @@ } else if (!TermWin.focus) setoldcursor = 1; + if (setoldcursor) { if (screen.cur.row + TermWin.view_start >= TermWin.nrow) @@ -2032,11 +2059,11 @@ if (refresh_type == FAST_REFRESH && num_scr_allow && i && abs (i) < TermWin.nrow && !must_clear) { - int16_t nits; - int j; - rend_t *drp2; - text_t *dtp2; - int len, wlen; + int16_t nits; + int j; + rend_t *drp2; + text_t *dtp2; + int len, wlen; j = TermWin.nrow; wlen = len = -1; @@ -2498,8 +2525,8 @@ MEMCPY (ds, data + i, n); for (j = 0; j < n; j++) - if (ds[j] == '\n') - ds[j] = '\r'; + if (ds[j] == C0_LF) + ds[j] = C0_CR; tt_write (ds, (int)n); } @@ -2590,8 +2617,7 @@ char **cl; int cr; - if (XmbTextPropertyToTextList (display->display, &ct, &cl, - &cr) >= 0 && cl) + if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 && cl) { for (int i = 0; i < cr; i++) paste ((unsigned char *)cl[i], STRLEN (cl[i])); @@ -2622,7 +2648,7 @@ { selection_wait = Sel_none; - rxvt_print_error ("data loss: timeout on INCR selection paste"); + rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); } /* @@ -2711,6 +2737,7 @@ selection_request_time = tm; selection_wait = Sel_normal; + for (i = Sel_Primary; i <= Sel_Clipboard; i++) { #if X_HAVE_UTF8_STRING @@ -2774,6 +2801,9 @@ selection.text = NULL; selection.len = 0; CLEAR_SELECTION (); + + if (display->selection_owner == this) + display->selection_owner = 0; } /* ------------------------------------------------------------------------- */ @@ -2856,11 +2886,11 @@ } if (screen.tlen[row] != -1 && row != end_row) - new_selection_text[ofs++] = L'\n'; + new_selection_text[ofs++] = C0_LF; } if (end_col != selection.end.col) - new_selection_text[ofs++] = L'\n'; + new_selection_text[ofs++] = C0_LF; new_selection_text[ofs] = 0; @@ -2880,7 +2910,7 @@ if (XGetSelectionOwner (display->display, XA_PRIMARY) == TermWin.vt) display->set_selection_owner (this); else - rxvt_print_error ("can't get primary selection"); + rxvt_warn ("can't get primary selection, ignoring.\n"); #if 0 XTextProperty ct; @@ -3097,9 +3127,9 @@ void rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) { - int16_t ncol = TermWin.ncol; - int end_col; - row_col_t pos; + int16_t ncol = TermWin.ncol; + int end_col; + row_col_t pos; enum { LEFT, RIGHT } closeto = RIGHT; @@ -3394,8 +3424,8 @@ else if (rq.target == xa[XA_TIMESTAMP] && selection.text) { XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER, - (8 * sizeof (Time)), PropModeReplace, - (unsigned char *)&selection_time, 1); + (8 * sizeof (Time)), PropModeReplace, + (unsigned char *)&selection_time, 1); ev.property = rq.property; } else if (rq.target == XA_STRING @@ -3492,50 +3522,3 @@ #endif /* ------------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------------- * - * DEBUG ROUTINES * - * ------------------------------------------------------------------------- */ -#if 0 -void -rxvt_debug_colors (void) -{ - int color; - const char *name[] = - { - "fg", "bg", - "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white" - }; - - fprintf (stderr, "Color ( "); - if (rstyle & RS_RVid) - fprintf (stderr, "rvid "); - if (rstyle & RS_Bold) - fprintf (stderr, "bold "); - if (rstyle & RS_Blink) - fprintf (stderr, "blink "); - if (rstyle & RS_Uline) - fprintf (stderr, "uline "); - fprintf (stderr, "): "); - - color = GET_FGCOLOR (rstyle); -#ifndef NO_BRIGHTCOLOR - if (color >= minBrightCOLOR && color <= maxBrightCOLOR) - { - color -= (minBrightCOLOR - minCOLOR); - fprintf (stderr, "bright "); - } -#endif - fprintf (stderr, "%s on ", name[color]); - - color = GET_BGCOLOR (rstyle); -#ifndef NO_BRIGHTCOLOR - if (color >= minBrightCOLOR && color <= maxBrightCOLOR) - { - color -= (minBrightCOLOR - minCOLOR); - fprintf (stderr, "bright "); - } -#endif - fprintf (stderr, "%s\n", name[color]); -} -#endif