aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2014-02-01 13:41:58 +0100
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2014-03-06 07:55:07 +0100
commit78f8843bc7d6dc731f23d5ff3a8536fdcc5e4be6 (patch)
tree14f30649bc8b478258b37353ea190425f4e5be6a
parent96c230e476a4fb446a8fa8d651c88fda32cd5427 (diff)
downloadst-patched-78f8843bc7d6dc731f23d5ff3a8536fdcc5e4be6.tar.bz2
st-patched-78f8843bc7d6dc731f23d5ff3a8536fdcc5e4be6.tar.xz
st-patched-78f8843bc7d6dc731f23d5ff3a8536fdcc5e4be6.zip
Add sequence for printing the current selection
This is very usefull in order to can select what is sent to the plumber.
-rw-r--r--config.def.h1
-rw-r--r--st.c32
2 files changed, 30 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h
index 47018a3..58b470e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -109,6 +109,7 @@ static Shortcut shortcuts[] = {
109 /* mask keysym function argument */ 109 /* mask keysym function argument */
110 { ControlMask, XK_Print, toggleprinter, {.i = 0} }, 110 { ControlMask, XK_Print, toggleprinter, {.i = 0} },
111 { ShiftMask, XK_Print, printscreen, {.i = 0} }, 111 { ShiftMask, XK_Print, printscreen, {.i = 0} },
112 { XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
112 { MODKEY|ShiftMask, XK_Prior, xzoom, {.i = +1} }, 113 { MODKEY|ShiftMask, XK_Prior, xzoom, {.i = +1} },
113 { MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} }, 114 { MODKEY|ShiftMask, XK_Next, xzoom, {.i = -1} },
114 { ShiftMask, XK_Insert, selpaste, {.i = 0} }, 115 { ShiftMask, XK_Insert, selpaste, {.i = 0} },
diff --git a/st.c b/st.c
index 9f9c161..c97712c 100644
--- a/st.c
+++ b/st.c
@@ -314,6 +314,7 @@ static void clippaste(const Arg *);
314static void numlock(const Arg *); 314static void numlock(const Arg *);
315static void selpaste(const Arg *); 315static void selpaste(const Arg *);
316static void xzoom(const Arg *); 316static void xzoom(const Arg *);
317static void printsel(const Arg *);
317static void printscreen(const Arg *) ; 318static void printscreen(const Arg *) ;
318static void toggleprinter(const Arg *); 319static void toggleprinter(const Arg *);
319 320
@@ -359,6 +360,7 @@ static void strreset(void);
359 360
360static int tattrset(int); 361static int tattrset(int);
361static void tprinter(char *s, size_t len); 362static void tprinter(char *s, size_t len);
363static void tdumpsel(void);
362static void tdumpline(int); 364static void tdumpline(int);
363static void tdump(void); 365static void tdump(void);
364static void tclearregion(int, int, int, int); 366static void tclearregion(int, int, int, int);
@@ -435,6 +437,7 @@ static void selrequest(XEvent *);
435static void selinit(void); 437static void selinit(void);
436static void selsort(void); 438static void selsort(void);
437static inline bool selected(int, int); 439static inline bool selected(int, int);
440static char *getsel(void);
438static void selcopy(void); 441static void selcopy(void);
439static void selscroll(int, int); 442static void selscroll(int, int);
440static void selsnap(int, int *, int *, int); 443static void selsnap(int, int *, int *, int);
@@ -955,8 +958,8 @@ bpress(XEvent *e) {
955 } 958 }
956} 959}
957 960
958void 961char *
959selcopy(void) { 962getsel(void) {
960 char *str, *ptr; 963 char *str, *ptr;
961 int x, y, bufsize, size, i, ex; 964 int x, y, bufsize, size, i, ex;
962 Glyph *gp, *last; 965 Glyph *gp, *last;
@@ -1015,7 +1018,12 @@ selcopy(void) {
1015 } 1018 }
1016 *ptr = 0; 1019 *ptr = 0;
1017 } 1020 }
1018 xsetsel(str); 1021 return str;
1022}
1023
1024void
1025selcopy(void) {
1026 xsetsel(getsel());
1019} 1027}
1020 1028
1021void 1029void
@@ -1994,6 +2002,9 @@ csihandle(void) {
1994 case 1: 2002 case 1:
1995 tdumpline(term.c.y); 2003 tdumpline(term.c.y);
1996 break; 2004 break;
2005 case 2:
2006 tdumpsel();
2007 break;
1997 case 4: 2008 case 4:
1998 term.mode &= ~MODE_PRINT; 2009 term.mode &= ~MODE_PRINT;
1999 break; 2010 break;
@@ -2295,6 +2306,21 @@ printscreen(const Arg *arg) {
2295} 2306}
2296 2307
2297void 2308void
2309printsel(const Arg *arg) {
2310 tdumpsel();
2311}
2312
2313void
2314tdumpsel(void)
2315{
2316 char *ptr;
2317
2318 ptr = getsel();
2319 tprinter(ptr, strlen(ptr));
2320 free(ptr);
2321}
2322
2323void
2298tdumpline(int n) { 2324tdumpline(int n) {
2299 Glyph *bp, *end; 2325 Glyph *bp, *end;
2300 2326