diff options
| author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-02-01 13:41:58 +0100 |
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2014-03-06 07:55:07 +0100 |
| commit | 78f8843bc7d6dc731f23d5ff3a8536fdcc5e4be6 (patch) | |
| tree | 14f30649bc8b478258b37353ea190425f4e5be6a | |
| parent | 96c230e476a4fb446a8fa8d651c88fda32cd5427 (diff) | |
| download | st-78f8843bc7d6dc731f23d5ff3a8536fdcc5e4be6.tar.gz st-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.h | 1 | ||||
| -rw-r--r-- | st.c | 32 |
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} }, |
| @@ -314,6 +314,7 @@ static void clippaste(const Arg *); | |||
| 314 | static void numlock(const Arg *); | 314 | static void numlock(const Arg *); |
| 315 | static void selpaste(const Arg *); | 315 | static void selpaste(const Arg *); |
| 316 | static void xzoom(const Arg *); | 316 | static void xzoom(const Arg *); |
| 317 | static void printsel(const Arg *); | ||
| 317 | static void printscreen(const Arg *) ; | 318 | static void printscreen(const Arg *) ; |
| 318 | static void toggleprinter(const Arg *); | 319 | static void toggleprinter(const Arg *); |
| 319 | 320 | ||
| @@ -359,6 +360,7 @@ static void strreset(void); | |||
| 359 | 360 | ||
| 360 | static int tattrset(int); | 361 | static int tattrset(int); |
| 361 | static void tprinter(char *s, size_t len); | 362 | static void tprinter(char *s, size_t len); |
| 363 | static void tdumpsel(void); | ||
| 362 | static void tdumpline(int); | 364 | static void tdumpline(int); |
| 363 | static void tdump(void); | 365 | static void tdump(void); |
| 364 | static void tclearregion(int, int, int, int); | 366 | static void tclearregion(int, int, int, int); |
| @@ -435,6 +437,7 @@ static void selrequest(XEvent *); | |||
| 435 | static void selinit(void); | 437 | static void selinit(void); |
| 436 | static void selsort(void); | 438 | static void selsort(void); |
| 437 | static inline bool selected(int, int); | 439 | static inline bool selected(int, int); |
| 440 | static char *getsel(void); | ||
| 438 | static void selcopy(void); | 441 | static void selcopy(void); |
| 439 | static void selscroll(int, int); | 442 | static void selscroll(int, int); |
| 440 | static void selsnap(int, int *, int *, int); | 443 | static void selsnap(int, int *, int *, int); |
| @@ -955,8 +958,8 @@ bpress(XEvent *e) { | |||
| 955 | } | 958 | } |
| 956 | } | 959 | } |
| 957 | 960 | ||
| 958 | void | 961 | char * |
| 959 | selcopy(void) { | 962 | getsel(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 | |||
| 1024 | void | ||
| 1025 | selcopy(void) { | ||
| 1026 | xsetsel(getsel()); | ||
| 1019 | } | 1027 | } |
| 1020 | 1028 | ||
| 1021 | void | 1029 | void |
| @@ -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 | ||
| 2297 | void | 2308 | void |
| 2309 | printsel(const Arg *arg) { | ||
| 2310 | tdumpsel(); | ||
| 2311 | } | ||
| 2312 | |||
| 2313 | void | ||
| 2314 | tdumpsel(void) | ||
| 2315 | { | ||
| 2316 | char *ptr; | ||
| 2317 | |||
| 2318 | ptr = getsel(); | ||
| 2319 | tprinter(ptr, strlen(ptr)); | ||
| 2320 | free(ptr); | ||
| 2321 | } | ||
| 2322 | |||
| 2323 | void | ||
| 2298 | tdumpline(int n) { | 2324 | tdumpline(int n) { |
| 2299 | Glyph *bp, *end; | 2325 | Glyph *bp, *end; |
| 2300 | 2326 | ||
