tAdd sequence for printing the current selection - st - [fork] customized build… | |
git clone git://src.adamsgaard.dk/st | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 78f8843bc7d6dc731f23d5ff3a8536fdcc5e4be6 | |
parent 96c230e476a4fb446a8fa8d651c88fda32cd5427 | |
Author: Roberto E. Vargas Caballero <[email protected]> | |
Date: Sat, 1 Feb 2014 13:41:58 +0100 | |
Add sequence for printing the current selection | |
This is very usefull in order to can select what is sent | |
tto the plumber. | |
Diffstat: | |
M config.def.h | 1 + | |
M st.c | 32 ++++++++++++++++++++++++++++-… | |
2 files changed, 30 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/config.def.h b/config.def.h | |
t@@ -109,6 +109,7 @@ static Shortcut shortcuts[] = { | |
/* mask keysym function argument */ | |
{ ControlMask, XK_Print, toggleprinter, {.i = 0} }, | |
{ ShiftMask, XK_Print, printscreen, {.i = 0} }, | |
+ { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, | |
{ MODKEY|ShiftMask, XK_Prior, xzoom, {.i = +1} }, | |
{ MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} }, | |
{ ShiftMask, XK_Insert, selpaste, {.i = 0} }, | |
diff --git a/st.c b/st.c | |
t@@ -314,6 +314,7 @@ static void clippaste(const Arg *); | |
static void numlock(const Arg *); | |
static void selpaste(const Arg *); | |
static void xzoom(const Arg *); | |
+static void printsel(const Arg *); | |
static void printscreen(const Arg *) ; | |
static void toggleprinter(const Arg *); | |
t@@ -359,6 +360,7 @@ static void strreset(void); | |
static int tattrset(int); | |
static void tprinter(char *s, size_t len); | |
+static void tdumpsel(void); | |
static void tdumpline(int); | |
static void tdump(void); | |
static void tclearregion(int, int, int, int); | |
t@@ -435,6 +437,7 @@ static void selrequest(XEvent *); | |
static void selinit(void); | |
static void selsort(void); | |
static inline bool selected(int, int); | |
+static char *getsel(void); | |
static void selcopy(void); | |
static void selscroll(int, int); | |
static void selsnap(int, int *, int *, int); | |
t@@ -955,8 +958,8 @@ bpress(XEvent *e) { | |
} | |
} | |
-void | |
-selcopy(void) { | |
+char * | |
+getsel(void) { | |
char *str, *ptr; | |
int x, y, bufsize, size, i, ex; | |
Glyph *gp, *last; | |
t@@ -1015,7 +1018,12 @@ selcopy(void) { | |
} | |
*ptr = 0; | |
} | |
- xsetsel(str); | |
+ return str; | |
+} | |
+ | |
+void | |
+selcopy(void) { | |
+ xsetsel(getsel()); | |
} | |
void | |
t@@ -1994,6 +2002,9 @@ csihandle(void) { | |
case 1: | |
tdumpline(term.c.y); | |
break; | |
+ case 2: | |
+ tdumpsel(); | |
+ break; | |
case 4: | |
term.mode &= ~MODE_PRINT; | |
break; | |
t@@ -2295,6 +2306,21 @@ printscreen(const Arg *arg) { | |
} | |
void | |
+printsel(const Arg *arg) { | |
+ tdumpsel(); | |
+} | |
+ | |
+void | |
+tdumpsel(void) | |
+{ | |
+ char *ptr; | |
+ | |
+ ptr = getsel(); | |
+ tprinter(ptr, strlen(ptr)); | |
+ free(ptr); | |
+} | |
+ | |
+void | |
tdumpline(int n) { | |
Glyph *bp, *end; | |