/*--------------------------------*-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 <jdb@ukc.ac.uk>
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[] =
"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);
/*--------------------------------*-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 <gcw@pobox.com>
*
/*
* 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);
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");
}
/*
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);
}
/* ------------------------------------------------------------------------- */
/*
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;
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;
}
}
/* 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