On Tue, Mar 10, 2015 at 05:18:49PM -0400, Greg Reagle wrote: > It could go the other way and do a variant of Ctrl+C for copy and Ctrl+V > for paste. I wouldn't use them directly because the programs running in > st probably need those keys. So Alt+Ctrl+C/V or Shitf+Ctrl+C/V or > Alt+C/V. > > Also, it could provide key bindings for both CUA and the other way. I > don't think that would complicate the code much.
Are you thinking of something like the attached?
diff --git a/config.def.h b/config.def.h
index cd9292a..667f334 100644
--- a/config.def.h
+++ b/config.def.h
@@ -120,7 +120,8 @@ static Shortcut shortcuts[] = {
{ MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} },
{ MODKEY|ShiftMask, XK_Home, xzoomreset, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
- { MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} },
+ { ControlMask|ShiftMask,XK_C, clipcopy, {.i = 0} },
+ { ControlMask|ShiftMask,XK_V, clippaste, {.i = 0} },
{ MODKEY, XK_Num_Lock, numlock, {.i = 0} },
};
diff --git a/st.c b/st.c
index 595a955..b969fc3 100644
--- a/st.c
+++ b/st.c
@@ -312,6 +312,7 @@ typedef struct {
} Shortcut;
/* function definitions used in config.h */
+static void clipcopy(const Arg *);
static void clippaste(const Arg *);
static void numlock(const Arg *);
static void selpaste(const Arg *);
@@ -479,7 +480,6 @@ static void (*handler[LASTEvent])(XEvent *) = {
[MotionNotify] = bmotion,
[ButtonPress] = bpress,
[ButtonRelease] = brelease,
- [SelectionClear] = selclear,
[SelectionNotify] = selnotify,
[SelectionRequest] = selrequest,
};
@@ -1027,10 +1027,8 @@ selpaste(const Arg *dummy) {
void
clippaste(const Arg *dummy) {
- Atom clipboard;
-
- clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
- XConvertSelection(xw.dpy, clipboard, sel.xtarget, XA_PRIMARY,
+ Atom clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
+ XConvertSelection(xw.dpy, clipboard, sel.xtarget, clipboard,
xw.win, CurrentTime);
}
@@ -1079,15 +1077,16 @@ selrequest(XEvent *e) {
void
xsetsel(char *str) {
- /* register the selection for both the clipboard and the primary */
- Atom clipboard;
-
free(sel.clip);
sel.clip = str;
XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, CurrentTime);
+}
- clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
+void
+clipcopy(const Arg *arg) {
+ /* sel.clip already set by xsetsel---can't copy without selecting. */
+ Atom clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime);
}
@@ -4051,4 +4050,3 @@ run:
return 0;
}
-
pgpVLyFCGCbPD.pgp
Description: PGP signature
