[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
X selections (was Re: ile, once again)
| But I do have a nice workaround: We have here a nice little program
| called xcb that will, among various other things, print the contents
| of the X cut buffer on stdout.
Speaking of that, the problem with cut buffers is that they store the
cut text inside the server. If you use the clipboard, or some other
selection, the cut data is stored in the client, usually not even
copied anywhere until someone asks for it. Now if only there was a
client that did for selections what xcb does for cut buffers... Well
in leu of that, here's a really gross hack to xcutsel that lets you
noninteractively snarf an X selection and write it to stdout. It reads
PRIMARY by default, but if you call it as ``xcut -s CLIPBOARD'' it will
read that instead.
*** X11R5/mit/clients/xclipboard/xcutsel.c Sun Feb 17 12:05:42 1991
--- xsel.c Sun May 2 21:00:11 1993
***************
*** 1,3 ****
--- 1,5 ----
+ /* xsel.c -- hacked from xcutsel.c */
+
/*
* $XConsortium: xcutsel.c,v 1.15 91/02/17 12:05:27 dave Exp $
*
***************
*** 81,86 ****
--- 83,99 ----
}
+ /* ARGSUSED */
+ static void Quit(w, closure, callData)
+ Widget w;
+ XtPointer closure; /* unused */
+ XtPointer callData; /* unused */
+ {
+ XtCloseDisplay( XtDisplay(w) );
+ exit(0);
+ }
+
+
static void StoreBuffer(w, client_data, selection, type, value, length, format)
Widget w;
XtPointer client_data;
***************
*** 91,100 ****
--- 104,117 ----
{
if (*type == 0 || *type == XT_CONVERT_FAIL || *length == 0) {
+ Quit(w, 0, 0);
XBell( XtDisplay(w), 0 );
return;
}
+ printf("%*s\n", (int)*length, (char*)value);
+ Quit(w, 0, 0);
+
XStoreBuffer( XtDisplay(w), (char*)value, (int)(*length),
options.buffer );
***************
*** 211,227 ****
/* ARGSUSED */
- static void Quit(w, closure, callData)
- Widget w;
- XtPointer closure; /* unused */
- XtPointer callData; /* unused */
- {
- XtCloseDisplay( XtDisplay(w) );
- exit(0);
- }
-
-
- /* ARGSUSED */
static void GetSelection(w, closure, callData)
Widget w;
XtPointer closure; /* unused */
--- 228,233 ----
***************
*** 300,305 ****
--- 306,313 ----
state.button = button;
state.is_on = False;
+ XtSetMappedWhenManaged(shell, False);
XtRealizeWidget(shell);
+ GetSelection(shell, 0, 0);
XtAppMainLoop(appcon);
}