diff options
| author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2011-04-03 00:35:02 +0200 |
|---|---|---|
| committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2011-04-03 00:35:02 +0200 |
| commit | 674434ef6f75247fb25d8e5b39786bca9a0cabec (patch) | |
| tree | e411a8784f99b2064ea632f79a69b30d967480bc | |
| parent | a047431d34aa77ac7a8fab08151fb569bbe2148e (diff) | |
| download | st-674434ef6f75247fb25d8e5b39786bca9a0cabec.tar.gz st-674434ef6f75247fb25d8e5b39786bca9a0cabec.zip | |
add support for utf8 clipboard. fix usage message.
| -rw-r--r-- | st.c | 10 |
1 files changed, 7 insertions, 3 deletions
| @@ -32,7 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | #define USAGE \ | 33 | #define USAGE \ |
| 34 | "st-" VERSION ", (c) 2010 st engineers\n" \ | 34 | "st-" VERSION ", (c) 2010 st engineers\n" \ |
| 35 | "usage: st [-t title] [-c class] [-e cmd] [-v]\n" | 35 | "usage: st [-t title] [-c class] [-v] [-e cmd]\n" |
| 36 | 36 | ||
| 37 | /* Arbitrary sizes */ | 37 | /* Arbitrary sizes */ |
| 38 | #define ESC_TITLE_SIZ 256 | 38 | #define ESC_TITLE_SIZ 256 |
| @@ -152,6 +152,7 @@ typedef struct { | |||
| 152 | int ex, ey; | 152 | int ex, ey; |
| 153 | struct {int x, y;} b, e; | 153 | struct {int x, y;} b, e; |
| 154 | char *clip; | 154 | char *clip; |
| 155 | Atom xtarget; | ||
| 155 | } Selection; | 156 | } Selection; |
| 156 | 157 | ||
| 157 | #include "config.h" | 158 | #include "config.h" |
| @@ -370,6 +371,9 @@ selinit(void) { | |||
| 370 | sel.mode = 0; | 371 | sel.mode = 0; |
| 371 | sel.bx = -1; | 372 | sel.bx = -1; |
| 372 | sel.clip = NULL; | 373 | sel.clip = NULL; |
| 374 | sel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0); | ||
| 375 | if(sel.xtarget == None) | ||
| 376 | sel.xtarget = XA_STRING; | ||
| 373 | } | 377 | } |
| 374 | 378 | ||
| 375 | static inline int | 379 | static inline int |
| @@ -453,7 +457,7 @@ selnotify(XEvent *e) { | |||
| 453 | 457 | ||
| 454 | void | 458 | void |
| 455 | selpaste() { | 459 | selpaste() { |
| 456 | XConvertSelection(xw.dpy, XA_PRIMARY, XA_STRING, XA_PRIMARY, xw.win, CurrentTime); | 460 | XConvertSelection(xw.dpy, XA_PRIMARY, sel.xtarget, XA_PRIMARY, xw.win, CurrentTime); |
| 457 | } | 461 | } |
| 458 | 462 | ||
| 459 | void | 463 | void |
| @@ -474,7 +478,7 @@ selrequest(XEvent *e) { | |||
| 474 | xa_targets = XInternAtom(xw.dpy, "TARGETS", 0); | 478 | xa_targets = XInternAtom(xw.dpy, "TARGETS", 0); |
| 475 | if(xsre->target == xa_targets) { | 479 | if(xsre->target == xa_targets) { |
| 476 | /* respond with the supported type */ | 480 | /* respond with the supported type */ |
| 477 | Atom string = XA_STRING; | 481 | Atom string = sel.xtarget; |
| 478 | XChangeProperty(xsre->display, xsre->requestor, xsre->property, | 482 | XChangeProperty(xsre->display, xsre->requestor, xsre->property, |
| 479 | XA_ATOM, 32, PropModeReplace, | 483 | XA_ATOM, 32, PropModeReplace, |
| 480 | (unsigned char *) &string, 1); | 484 | (unsigned char *) &string, 1); |
