From 5e40bc60c9cf8cd60393e2054a417b570abfb177 Mon Sep 17 00:00:00 2001 From: pcg Date: Tue, 16 Dec 2003 23:04:12 +0000 Subject: [PATCH] *** empty log message *** --- README.unicode | 3 +- src/command.C | 42 ++---------- src/main.C | 5 +- src/rxvt.h | 12 ++-- src/screen.C | 183 ++++++++++++++++++++++++++----------------------- 5 files changed, 110 insertions(+), 135 deletions(-) diff --git a/README.unicode b/README.unicode index b2116d16..1d2c90e6 100644 --- a/README.unicode +++ b/README.unicode @@ -7,7 +7,8 @@ Sketchy overview of the details: might be broken. - wchar_t MUST be UNICODE or ISO-10646-1 on your system, or various - things will break down. + things will break down. On GNU/Linux, this is true, on Solaris, + this is true only for "@ucs" locales, but you should have plenty of them. - rxvt ALWAYS expects utf-8 input, regardless of the locale, currently. so only start it in a utf-8-locale: "LC_CTYPE=en_US.UTF-8 rxvt" etc.. diff --git a/src/command.C b/src/command.C index 0bc0cd3a..08b67b07 100644 --- a/src/command.C +++ b/src/command.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: command.c *----------------------------------------------------------------------* - * $Id: command.C,v 1.14 2003-12-08 23:14:40 pcg Exp $ + * $Id: command.C,v 1.15 2003-12-16 23:04:13 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -1148,7 +1148,6 @@ rxvt_process_x_event(pR_ XEvent *ev) Window unused_root, unused_child; int unused_root_x, unused_root_y; unsigned int unused_mask; - struct timeval tp; #ifdef DEBUG_X const char *const eventnames[] = @@ -1189,49 +1188,16 @@ rxvt_process_x_event(pR_ XEvent *ev) "ClientMessage", "MappingNotify" }; - struct tm *ltt; -#endif - - /* - * check if we need to get the time for any timeouts - */ - - for (i = NUM_TIMEOUTS; i--; ) - if (R->timeout[i].tv_sec) { - want_timeout = 1; - break; - } - -#ifndef DEBUG_X - if (want_timeout) #endif - (void)gettimeofday(&tp, NULL); #ifdef DEBUG_X + struct timeval tp; + struct tm *ltt; + (void)gettimeofday(&tp, NULL); ltt = localtime(&(tp.tv_sec)); D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial)); #endif - /* X event timeouts */ - if (want_timeout) - for (i = NUM_TIMEOUTS; i--; ) { - if (R->timeout[i].tv_sec == 0) - continue; - if ((tp.tv_sec < R->timeout[i].tv_sec) - || (tp.tv_sec == R->timeout[i].tv_sec - && tp.tv_usec < R->timeout[i].tv_usec)) - continue; - R->timeout[i].tv_sec = 0; - switch(i) { - case TIMEOUT_INCR: - rxvt_print_error("data loss: timeout on INCR selection paste"); - R->selection_wait = Sel_none; - break; - default: - break; - } - } - switch (ev->type) { case KeyPress: rxvt_lookup_key(aR_ (XKeyEvent *)ev); diff --git a/src/main.C b/src/main.C index 3c803e82..da6d3e15 100644 --- a/src/main.C +++ b/src/main.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: main.c *----------------------------------------------------------------------* - * $Id: main.C,v 1.11 2003-12-08 23:14:40 pcg Exp $ + * $Id: main.C,v 1.12 2003-12-16 23:04:13 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -69,7 +69,8 @@ rxvt_term::rxvt_term () #endif x_ev (this, &rxvt_term::x_cb), destroy_ev (this, &rxvt_term::destroy_cb), - check_ev (this, &rxvt_term::check_cb) + check_ev (this, &rxvt_term::check_cb), + incr_ev (this, &rxvt_term::incr_cb) { cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; } diff --git a/src/rxvt.h b/src/rxvt.h index 95533d47..6220cd84 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -1,5 +1,5 @@ /* - * $Id: rxvt.h,v 1.10 2003-12-02 21:49:46 pcg Exp $ + * $Id: rxvt.h,v 1.11 2003-12-16 23:04:13 pcg Exp $ */ #ifndef _RXVT_H_ /* include once only */ @@ -556,11 +556,6 @@ enum { NUM_RESOURCES }; -enum { - TIMEOUT_INCR = 0, - NUM_TIMEOUTS -}; - enum { XA_COMPOUND_TEXT = 0, XA_MULTIPLE, @@ -1071,7 +1066,6 @@ struct rxvt_term : rxvt_vars { #ifdef POINTER_BLANK struct timeval lastmotion; #endif - struct timeval timeout[NUM_TIMEOUTS]; /* these three don't need to be kept but do so to placate some mem checkers */ char *env_windowid; /* environmental variable WINDOWID */ @@ -1093,6 +1087,8 @@ struct rxvt_term : rxvt_vars { unsigned char cmdbuf_base[BUFSIZ]; unsigned char kbuf[KBUFSZ]; + void paste (const unsigned char *data, unsigned int len); + void flush (); void check_cb (check_watcher &w); check_watcher check_ev; @@ -1101,6 +1097,8 @@ struct rxvt_term : rxvt_vars { void pty_cb (io_watcher &w, short revents); io_watcher pty_ev; void x_cb (io_watcher &w, short revents); io_watcher x_ev; + void incr_cb (time_watcher &w); time_watcher incr_ev; + #ifdef CURSOR_BLINK void blink_cb (time_watcher &w); time_watcher blink_ev; #endif diff --git a/src/screen.C b/src/screen.C index d3fc18d8..695b5f2e 100644 --- a/src/screen.C +++ b/src/screen.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*--------------------------------------* * File: screen.c *---------------------------------------------------------------------------* - * $Id: screen.C,v 1.6 2003-12-02 21:49:46 pcg Exp $ + * $Id: screen.C,v 1.7 2003-12-16 23:04:13 pcg Exp $ * * Copyright (c) 1997-2001 Geoff Wing * @@ -2397,22 +2397,23 @@ rxvt_selection_check(pR_ int check_more) /* * 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) + for (i = 0; i < len; i += PROP_SIZE) { - n = min (nitems - 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'; - R->tt_write (ds, (int)n); + + tt_write (ds, (int)n); } free(ds); @@ -2427,75 +2428,99 @@ rxvt_PasteIt (pR_ const unsigned char *data, unsigned int nitems) 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 + 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)); + 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; + 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); + 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"); } /* @@ -2537,13 +2562,11 @@ rxvt_selection_property(pR_ Window win, Atom prop) 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); } /* ------------------------------------------------------------------------- */ /* @@ -2565,7 +2588,7 @@ rxvt_selection_request(pR_ Time tm, int x, int y) 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; @@ -2573,18 +2596,8 @@ rxvt_selection_request(pR_ Time tm, int x, int y) 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; } } @@ -2803,11 +2816,7 @@ rxvt_selection_start_colrow(pR_ int col, int row) /* 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 -- 2.34.1