Introduction
Introduction Statistics Contact Development Disclaimer Help
Allow changing of X selection for snarf buffer exchange. - sam - An updated ver…
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit 86273326e9dec50a3c9ced2c9bfe5d81d2e89a84
parent a8f72dc47ba63b3cf220a751e282f2e1db9309e5
Author: Rob King <[email protected]>
Date: Fri, 9 Dec 2016 11:27:44 -0600
Allow changing of X selection for snarf buffer exchange.
Diffstat:
doc/samrc.5 | 17 +++++++++++++++++
libXg/gwin.c | 6 ++++--
libXg/xtbinit.c | 3 +++
samterm/main.c | 11 +++++------
samterm/samrc.c | 17 +++++++++++++++++
5 files changed, 46 insertions(+), 8 deletions(-)
---
diff --git a/doc/samrc.5 b/doc/samrc.5
@@ -201,6 +201,20 @@ or
If
.Dq true ","
then tabs will be automatically expanded.
+.It snarfselection
+Indicates which X selection should be exchanged with
+.Nm
+upon execution of the
+.Em exchange
+command
+.Pq "either via the menu item or key binding" "."
+The forms are:
+.Bd -literal
+
+ snarfselection primary
+ snarfselection secondary
+ snarfselection clipboard
+.Ed
.El
.Ss Defaults
The default keybindings and mouse chords are those documented in
@@ -209,6 +223,9 @@ The default foreground and border color is black,
and the default background color is white.
Tabs are not expanded by default,
and tabstops are set at every eight characters.
+The default X selection is
+.Do primary
+.Dc "."
.Ss "Modifier Keys"
The
.Em bind
diff --git a/libXg/gwin.c b/libXg/gwin.c
@@ -11,6 +11,8 @@
#include "GwinP.h"
#include "libgint.h"
+Atom clipselection = XA_PRIMARY;
+
/* Forward declarations */
static void Realize(Widget, XtValueMask *, XSetWindowAttributes *);
static void Resize(Widget);
@@ -582,7 +584,7 @@ SelectSwap(Widget w, String s)
XtFree(gw->gwin.selection);
gw->gwin.selection = NULL;
}
- XtGetSelectionValue(w, XA_PRIMARY, XInternAtom(_dpy, "UTF8_STRING", 0), Se…
+ XtGetSelectionValue(w, clipselection, XInternAtom(_dpy, "UTF8_STRING", 0),…
XtLastTimestampProcessed(XtDisplay(w)));
while(gw->gwin.selection == NULL)
@@ -591,7 +593,7 @@ SelectSwap(Widget w, String s)
gw->gwin.selection = XtMalloc(strlen(s)+1);
strcpy(gw->gwin.selection, s);
- XtOwnSelection(w, XA_PRIMARY, XtLastTimestampProcessed(XtDisplay(w)),
+ XtOwnSelection(w, clipselection, XtLastTimestampProcessed(XtDisplay(w)),
SendSel, NULL, NULL);
return ans;
diff --git a/libXg/xtbinit.c b/libXg/xtbinit.c
@@ -59,6 +59,7 @@ int _ld2d[6] = { 1, 2, 4, 8, 16, 24 };
uint64_t _ld2dmask[6] = { 0x1, 0x3, 0xF, 0xFF, 0xFFFF, 0x00FFFFFF };
Colormap _libg_cmap;
int _cmap_installed;
+Atom XA_CLIPBOARD;
/* xbinit implementation globals */
static XtAppContext app;
@@ -194,6 +195,8 @@ xtbinit(Errfunc f, char *class, int *pargc, char **argv, ch…
_bgpixel = _bgpixels[0];
+ XA_CLIPBOARD = XInternAtom(_dpy, "CLIPBOARD", 0);
+
n = 0;
XtSetArg(args[n], XtNcomposeMod, &compose); n++;
XtGetValues(widg, args, n);
diff --git a/samterm/main.c b/samterm/main.c
@@ -49,12 +49,6 @@ main(int argc, char *argv[])
else
snprintf(rcpath, PATH_MAX, "%s/.samrc", getenv("HOME") ? getenv("HOME"…
- rc = fopen(rcpath, "r");
- if (rc){
- loadrcfile(rc);
- fclose(rc);
- }
-
while ((opt = getopt(argc, argv, "efr:")) != -1){
switch (opt){
case 'r':
@@ -72,6 +66,11 @@ main(int argc, char *argv[])
}
getscreen(argc, argv);
+ rc = fopen(rcpath, "r");
+ if (rc){
+ loadrcfile(rc);
+ fclose(rc);
+ }
initio();
scratch = alloc(100*RUNESIZE);
nscralloc = 100;
diff --git a/samterm/samrc.c b/samterm/samrc.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
+#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
@@ -13,6 +14,7 @@
extern int expandtabs;
extern int tabwidth;
+extern Atom XA_CLIPBOARD;
typedef struct Namemapping Namemapping;
struct Namemapping{
@@ -233,6 +235,20 @@ nametokeysym(const char *n)
}
static int
+dirsnarfselection(const char *s1, const char *s2, const char *s3, const char *…
+{
+ extern Atom clipselection;
+ Namemapping selmapping[] ={
+ {"primary", XA_PRIMARY},
+ {"secondary", XA_SECONDARY},
+ {"clipboard", XA_CLIPBOARD},
+ {NULL, 0}
+ };
+ clipselection = lookupmapping(s1, selmapping);
+ return clipselection >= 0? 0 : -1;
+}
+
+static int
dirchord(const char *s1, const char *s2, const char *s3, const char *s4, const…
{
return installchord(buttontomask(s1), buttontomask(s2), nametocommand(s3),…
@@ -359,6 +375,7 @@ Directive directives[] ={
{" font %1023[^\n]", 1, dirfont…
{" tabs %2[0-9]", 1, dirtabs…
{" expandtabs %99s", 1, direxpa…
+ {" snarfselection %99s", 1, dirsnar…
{" %1[#]", 1, dircomm…
{" %1[^ ]", EOF, dircomm…
{NULL, 0, NULL}
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.