--- rxvt-unicode/src/screen.C 2003/11/25 15:25:17 1.4 +++ rxvt-unicode/src/screen.C 2003/12/16 23:04:13 1.7 @@ -1,7 +1,7 @@ /*--------------------------------*-C-*--------------------------------------* * File: screen.c *---------------------------------------------------------------------------* - * $Id: screen.C,v 1.4 2003/11/25 15:25:17 pcg Exp $ + * $Id: screen.C,v 1.7 2003/12/16 23:04:13 pcg Exp $ * * Copyright (c) 1997-2001 Geoff Wing * @@ -39,10 +39,6 @@ *start++ = value; } -#define RESET_CHSTAT(H) \ - if ((H)->chstat == WBYTE) \ - (H)->chstat = SBYTE, (H)->lost_multi = 1 - /* ------------------------------------------------------------------------- */ #define PROP_SIZE 16384 #define TABSIZE 8 /* default tab size */ @@ -166,7 +162,6 @@ D_SCREEN((stderr, "rxvt_scr_reset()")); R->TermWin.view_start = 0; - RESET_CHSTAT(R); R->num_scr = 0; prev_ncol = R->prev_ncol; @@ -365,7 +360,7 @@ R->prev_nrow = nrow; R->prev_ncol = ncol; - rxvt_tt_winsize(R->cmd_fd, R->TermWin.ncol, R->TermWin.nrow, R->cmd_pid); + R->tt_winch (); } /* INTPROTO */ @@ -534,7 +529,6 @@ D_SCREEN((stderr, "rxvt_scr_change_screen(%d)", scrn)); R->TermWin.view_start = 0; - RESET_CHSTAT(R); if (R->current_screen == scrn) return R->current_screen; @@ -799,14 +793,12 @@ row = (++R->screen.cur.row) + R->TermWin.saveLines; stp = R->screen.text[row]; /* _must_ refresh */ srp = R->screen.rend[row]; /* _must_ refresh */ - RESET_CHSTAT(R); continue; case '\r': if (R->screen.tlen[row] != -1) /* XXX: think about this */ MAX_IT(R->screen.tlen[row], R->screen.cur.col); R->screen.flags &= ~Screen_WrapNext; R->screen.cur.col = 0; - RESET_CHSTAT(R); continue; default: if (c == 127) @@ -909,7 +901,6 @@ void rxvt_scr_backspace(pR) { - RESET_CHSTAT(R); R->want_refresh = 1; if (R->screen.cur.col == 0) { if (R->screen.cur.row > 0) { @@ -938,7 +929,6 @@ D_SCREEN((stderr, "rxvt_scr_tab(%d)", count)); R->want_refresh = 1; - RESET_CHSTAT(R); i = x = R->screen.cur.col; if (count == 0) return; @@ -1025,7 +1015,6 @@ { R->want_refresh = 1; ZERO_SCROLLBACK(R); - RESET_CHSTAT(R); #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) rxvt_Gr_scroll(aR_ 0); @@ -1079,7 +1068,6 @@ D_SCREEN((stderr, "rxvt_scr_index(%d)", dirn)); ZERO_SCROLLBACK(R); - RESET_CHSTAT(R); #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) @@ -1113,7 +1101,6 @@ R->want_refresh = 1; D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); ZERO_SCROLLBACK(R); - RESET_CHSTAT(R); #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) @@ -1180,7 +1167,6 @@ R->want_refresh = 1; D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); ZERO_SCROLLBACK(R); - RESET_CHSTAT(R); row_offset = (int32_t)R->TermWin.saveLines; switch (mode) { @@ -1254,7 +1240,6 @@ R->want_refresh = 1; R->num_scr_allow = 0; ZERO_SCROLLBACK(R); - RESET_CHSTAT(R); rxvt_selection_check(aR_ 3); fs = SET_FONT (R->rstyle, R->TermWin.fontset->find_font ('E')); @@ -1277,7 +1262,6 @@ int end; ZERO_SCROLLBACK(R); - RESET_CHSTAT(R); #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) @@ -1318,9 +1302,6 @@ R->want_refresh = 1; ZERO_SCROLLBACK(R); -#if 0 - RESET_CHSTAT(R); -#endif #ifdef RXVT_GRAPHICS if (rxvt_Gr_Displayed(aR)) @@ -1550,8 +1531,7 @@ void rxvt_scr_report_position(pR) { - rxvt_tt_printf(aR_ "\033[%d;%dR", R->screen.cur.row + 1, - R->screen.cur.col + 1); + R->tt_printf("\033[%d;%dR", R->screen.cur.row + 1, R->screen.cur.col + 1); } /* ------------------------------------------------------------------------- * @@ -2417,23 +2397,26 @@ /* * Paste a selection direct to the command fd */ -/* INTPROTO */ void -rxvt_PasteIt(pR_ const unsigned char *data, unsigned int nitems) +rxvt_term::paste (const unsigned char *data, unsigned int len) { - unsigned int i, j, n; - unsigned char *ds = (unsigned char *)rxvt_malloc(PROP_SIZE); - -/* convert normal newline chars into common keyboard Return key sequence */ - for (i = 0; i < nitems; i += PROP_SIZE) { - n = min(nitems - i, PROP_SIZE); - MEMCPY(ds, data + i, n); - for (j = 0; j < n; j++) - if (ds[j] == '\n') - ds[j] = '\r'; - rxvt_tt_write(aR_ ds, (int)n); + unsigned int i, j, n; + unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); + + /* convert normal newline chars into common keyboard Return key sequence */ + for (i = 0; i < len; i += PROP_SIZE) + { + n = min (len - i, PROP_SIZE); + MEMCPY (ds, data + i, n); + + for (j = 0; j < n; j++) + if (ds[j] == '\n') + ds[j] = '\r'; + + tt_write (ds, (int)n); } - free(ds); + + free(ds); } /* ------------------------------------------------------------------------- */ @@ -2445,75 +2428,99 @@ int rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) { - long nread = 0; - unsigned long bytes_after; - XTextProperty ct; -#ifdef MULTICHAR_SET - int dummy_count; - char **cl; -#endif - - D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); - - if (prop == None) { /* check for failed XConvertSelection */ -#ifdef MULTICHAR_SET - if ((R->selection_type & Sel_CompoundText)) { - int selnum = R->selection_type & Sel_whereMask; - - R->selection_type = 0; - if (selnum != Sel_direct) - rxvt_selection_request_other(aR_ XA_STRING, selnum); + long nread = 0; + unsigned long bytes_after; + XTextProperty ct; + int dummy_count; + char **cl; + + D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); + + if (prop == None) /* check for failed XConvertSelection */ + { + if ((R->selection_type & Sel_CompoundText)) + { + int selnum = R->selection_type & Sel_whereMask; + + R->selection_type = 0; + if (selnum != Sel_direct) + rxvt_selection_request_other(aR_ XA_STRING, selnum); } -#endif - return 0; + + return 0; } - for (;;) { - if (XGetWindowProperty(R->Xdisplay, win, prop, (long)(nread / 4), - (long)(PROP_SIZE / 4), delete_prop, - AnyPropertyType, &ct.encoding, &ct.format, - &ct.nitems, &bytes_after, - &ct.value) != Success) - break; - if (ct.encoding == 0) { - D_SELECT((stderr, "rxvt_selection_paste: property didn't exist!")); - break; + + for (;;) + { + if (XGetWindowProperty(R->Xdisplay, win, prop, (long)(nread / 4), + (long)(PROP_SIZE / 4), delete_prop, + AnyPropertyType, &ct.encoding, &ct.format, + &ct.nitems, &bytes_after, + &ct.value) != Success) + break; + + if (ct.encoding == 0) + { + D_SELECT((stderr, "rxvt_selection_paste: property didn't exist!")); + break; } - if (ct.value == NULL) { - D_SELECT((stderr, "rxvt_selection_paste: property shooting blanks!")); - continue; + + if (ct.value == NULL) + { + D_SELECT((stderr, "rxvt_selection_paste: property shooting blanks!")); + continue; } - if (ct.nitems == 0) { - D_SELECT((stderr, "rxvt_selection_paste: property empty - also INCR end")); - if (R->selection_wait == Sel_normal && nread == 0) { - /* - * pass through again trying CUT_BUFFER0 if we've come from - * XConvertSelection() but nothing was presented - */ - D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); - rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); + + if (ct.nitems == 0) + { + D_SELECT((stderr, "rxvt_selection_paste: property empty - also INCR end")); + if (R->selection_wait == Sel_normal && nread == 0) + { + /* + * pass through again trying CUT_BUFFER0 if we've come from + * XConvertSelection() but nothing was presented + */ + D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); + rxvt_selection_paste (aR_ Xroot, XA_CUT_BUFFER0, False); } - nread = -1; /* discount any previous stuff */ - break; + + nread = -1; /* discount any previous stuff */ + break; } - nread += ct.nitems; -#ifdef MULTICHAR_SET - if (XmbTextPropertyToTextList(R->Xdisplay, &ct, &cl, - &dummy_count) == Success && cl) { - rxvt_PasteIt(aR_ cl[0], STRLEN(cl[0])); - XFreeStringList(cl); - } else -#endif - rxvt_PasteIt(aR_ ct.value, (unsigned int)ct.nitems); - if (bytes_after == 0) - break; - XFree(ct.value); + + nread += ct.nitems; + if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, + &dummy_count) == Success && cl) + { + R->paste ((unsigned char *)cl[0], STRLEN (cl[0])); + XFreeStringList (cl); + } + else + R->paste (ct.value, ct.nitems); + + if (bytes_after == 0) + break; + + XFree (ct.value); } - if (ct.value) - XFree(ct.value); - if (R->selection_wait == Sel_normal) - R->selection_wait = Sel_none; - D_SELECT((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); - return (int)nread; + + if (ct.value) + XFree (ct.value); + + if (R->selection_wait == Sel_normal) + R->selection_wait = Sel_none; + + D_SELECT((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); + return (int)nread; +} + +void +rxvt_term::incr_cb (time_watcher &w) +{ + w.stop (); + selection_wait = Sel_none; + + rxvt_print_error("data loss: timeout on INCR selection paste"); } /* @@ -2555,13 +2562,11 @@ if (rxvt_selection_paste(aR_ win, prop, True) == -1) { D_SELECT((stderr, "rxvt_selection_property: INCR: clean end")); R->selection_wait = Sel_none; - R->timeout[TIMEOUT_INCR].tv_sec = 0; /* turn off timer */ + R->incr_ev.stop (); } } - if (reget_time) { /* received more data so reget time */ - (void)gettimeofday(&(R->timeout[TIMEOUT_INCR]), NULL); - R->timeout[TIMEOUT_INCR].tv_sec += 10; /* ten seconds wait */ - } + if (reget_time) /* received more data so reget time */ + R->incr_ev.start (NOW + 10); } /* ------------------------------------------------------------------------- */ /* @@ -2583,7 +2588,7 @@ if (R->selection.text != NULL) { /* internal selection */ D_SELECT((stderr, "rxvt_selection_request: pasting internal")); - rxvt_PasteIt(aR_ R->selection.text, R->selection.len); + R->paste (R->selection.text, R->selection.len); return; } else { int i; @@ -2591,18 +2596,8 @@ R->selection_request_time = tm; R->selection_wait = Sel_normal; for (i = Sel_Primary; i <= Sel_Clipboard; i++) { -#ifdef MULTICHAR_SET R->selection_type = Sel_CompoundText; -#else - R->selection_type = 0; -#endif - if (rxvt_selection_request_other(aR_ -#ifdef MULTICHAR_SET - R->xa[XA_COMPOUND_TEXT], -#else - XA_STRING, -#endif - i)) + if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) return; } } @@ -2821,11 +2816,7 @@ /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ #define DELIMIT_TEXT(x) \ (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR(R->rs[Rs_cutchars], (x)) != NULL)) -#ifdef MULTICHAR_SET -# define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0) -#else -# define DELIMIT_REND(x) 1 -#endif +#define DELIMIT_REND(x) 1 /* INTPROTO */ void