From 487bbb24d02190efa3d18093cadfa376f816d7fa Mon Sep 17 00:00:00 2001 From: Johannes Postma Date: Thu, 5 Mar 2015 15:52:51 +0000 Subject: [PATCH 01/16] Update kdch1 definition to three octal digits. ncurses wasn't able to detect the delete-character key as KEY_DC. This patch fixes that. kdch1 was defined as "\0177", but terminfo(5) states: ... characters may be given as three octal digits after a \. The delete-character key is correctly defined in config.def.h. --- st.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.info b/st.info index 99c066d..b91812f 100644 --- a/st.info +++ b/st.info @@ -73,7 +73,7 @@ st| simpleterm, kri=\E[1;2A, kclr=\E[3;5~, kdl1=\E[3;2~, - kdch1=\0177, + kdch1=\177, kich1=\E[2~, kend=\E[4~, kf1=\EOP, -- 2.20.1 From b0bddc694a79dd24edb8f997acadecbff356a9e0 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Mon, 9 Mar 2015 23:16:03 +0100 Subject: [PATCH 02/16] Add a hack to handle unknown chars in fontconfig. The unicode long is added to the cache. So when fontconfig does fall back to the default font (where there is no easy way to find this out from the pattern) it isn't reloaded. --- st.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/st.c b/st.c index e1139ec..e27daf0 100644 --- a/st.c +++ b/st.c @@ -522,6 +522,7 @@ enum { typedef struct { XftFont *font; int flags; + long unicodep; } Fontcache; /* Fontcache is an array now. A new font will be appended to the array. */ @@ -3208,7 +3209,7 @@ void xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { int winx = borderpx + x * xw.cw, winy = borderpx + y * xw.ch, width = charlen * xw.cw, xp, i; - int frcflags; + int frcflags, charexists; int u8fl, u8fblen, u8cblen, doesexist; char *u8c, *u8fs; long unicodep; @@ -3391,8 +3392,13 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { /* Search the font cache. */ for(i = 0; i < frclen; i++) { - if(XftCharExists(xw.dpy, frc[i].font, unicodep) - && frc[i].flags == frcflags) { + charexists = XftCharExists(xw.dpy, frc[i].font, unicodep); + /* Everything correct. */ + if(charexists && frc[i].flags == frcflags) + break; + /* We got a default font for a not found glyph. */ + if(!charexists && frc[i].flags == frcflags \ + && unicodep == unicodep) { break; } } @@ -3421,10 +3427,11 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { FcConfigSubstitute(0, fcpattern, FcMatchPattern); + FcPatternPrint(fcpattern); FcDefaultSubstitute(fcpattern); - fontpattern = FcFontSetMatch(0, fcsets, - FcTrue, fcpattern, &fcres); + fontpattern = FcFontSetMatch(0, fcsets, 1, + fcpattern, &fcres); /* * Overwrite or create the new cache entry. @@ -3432,11 +3439,13 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { if(frclen >= LEN(frc)) { frclen = LEN(frc) - 1; XftFontClose(xw.dpy, frc[frclen].font); + frc[frclen].unicodep = 0; } frc[frclen].font = XftFontOpenPattern(xw.dpy, fontpattern); frc[frclen].flags = frcflags; + frc[frclen].unicodep = unicodep; i = frclen; frclen++; -- 2.20.1 From 230d0c8428456603ce3629dac75c46abc4c9f016 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 10 Mar 2015 00:00:44 +0100 Subject: [PATCH 03/16] Finally resolving the backspace problem. The majority now using the Linux behaviour. Minorities have to live in their ghettos. --- config.def.h | 5 +++-- st.info | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index 1667ed6..5b985cd 100644 --- a/config.def.h +++ b/config.def.h @@ -203,7 +203,7 @@ static Key key[] = { { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0, 0}, { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, - { XK_KP_Delete, XK_ANY_MOD, "\177", +1, 0, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0, 0}, { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0, 0}, { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0, 0}, @@ -258,7 +258,8 @@ static Key key[] = { { XK_Delete, ShiftMask, "\033[2K", -1, 0, 0}, { XK_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, - { XK_Delete, XK_ANY_MOD, "\177", +1, 0, 0}, + { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, + { XK_BackSpace, XK_ANY_MOD, "\177", +1, 0, 0}, { XK_Home, ShiftMask, "\033[2J", 0, -1, 0}, { XK_Home, ShiftMask, "\033[1;2H", 0, +1, 0}, { XK_Home, XK_ANY_MOD, "\033[H", 0, -1, 0}, diff --git a/st.info b/st.info index b91812f..2acd8b2 100644 --- a/st.info +++ b/st.info @@ -53,7 +53,7 @@ st| simpleterm, ka3=\E[5~, kc1=\E[4~, kc3=\E[6~, - kbs=\010, + kbs=\177, kcbt=\E[Z, kb2=\EOu, kcub1=\EOD, @@ -73,7 +73,7 @@ st| simpleterm, kri=\E[1;2A, kclr=\E[3;5~, kdl1=\E[3;2~, - kdch1=\177, + kdch1=\E[3~, kich1=\E[2~, kend=\E[4~, kf1=\EOP, -- 2.20.1 From cf1fcc4d96f9162272003f82839388093c01360e Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 10 Mar 2015 00:20:28 +0100 Subject: [PATCH 04/16] Change the FAQ for the new Backspace behaviour. --- FAQ | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/FAQ b/FAQ index 61f94a5..ee1c154 100644 --- a/FAQ +++ b/FAQ @@ -98,10 +98,14 @@ If you want to compile st for OpenBSD you have to remove -lrt from config.mk, an st will compile without any loss of functionality, because all the functions are included in libc on this platform. -## Backspace key does not work +## The Backspace Case + +St is emulating the Linux way of handling backspace being delete and delete being +backspace. This is an issue that was discussed in suckless mailing list -: +. Here is why some old grumpy +terminal users wants its backspace to be how he feels it: Well, I am going to comment why I want to change the behaviour of this key. When ASCII was defined in 1968, communication @@ -155,11 +159,9 @@ This is an issue that was discussed in suckless mailing list [1] http://www.ibb.net/~anne/keyboard.html [2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html -## But I really want a wrong backspace key and a wrong delete key +## But I really want the old grumpy behaviour of my terminal -If you really want emulate the errors of another terminal emulators -and have a backspace key that generates a DELETE and a delete key -that generates BACKSPACE, then you can apply the patch -found in [1], but please do not tell me it. +Apply [1]. [1] http://st.suckless.org/patches/delkey + -- 2.20.1 From 9494362d0b35dfe2fa22c3e36ed7b2043b2e8a3d Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 10 Mar 2015 21:11:04 +0100 Subject: [PATCH 05/16] Fixing the C reading test. This was a test to see if anyone actually reads what is submitted. The list of people not contributing will be valuable in the future. --- st.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/st.c b/st.c index e27daf0..a494c7d 100644 --- a/st.c +++ b/st.c @@ -3398,7 +3398,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { break; /* We got a default font for a not found glyph. */ if(!charexists && frc[i].flags == frcflags \ - && unicodep == unicodep) { + && frc[i].unicodep == unicodep) { break; } } @@ -3427,7 +3427,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { FcConfigSubstitute(0, fcpattern, FcMatchPattern); - FcPatternPrint(fcpattern); FcDefaultSubstitute(fcpattern); fontpattern = FcFontSetMatch(0, fcsets, 1, -- 2.20.1 From adeb2e95d633cf4bbe1bbe5d2caba71776577c21 Mon Sep 17 00:00:00 2001 From: Alexander Huemer Date: Tue, 10 Mar 2015 01:23:07 +0100 Subject: [PATCH 06/16] FAQ: fix wording --- FAQ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FAQ b/FAQ index ee1c154..cdf4f45 100644 --- a/FAQ +++ b/FAQ @@ -92,7 +92,7 @@ in TERM. ## I cannot compile st in OpenBSD -OpenBSD lacks of librt, despite it begin mandatory in POSIX +OpenBSD lacks librt, despite it began to be mandatory in POSIX . If you want to compile st for OpenBSD you have to remove -lrt from config.mk, and st will compile without any loss of functionality, because all the functions are -- 2.20.1 From 28259f5750f0dc7f52bbaf8b746ec3dc576a58ee Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Tue, 10 Mar 2015 21:58:32 +0100 Subject: [PATCH 07/16] St now does only set PRIMARY on selection. http://standards.freedesktop.org/clipboards-spec/clipboards-latest.txt --- st.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/st.c b/st.c index a494c7d..39a6836 100644 --- a/st.c +++ b/st.c @@ -1079,16 +1079,9 @@ 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); - XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime); } void -- 2.20.1 From f5075a9e9d27c64e115e056c5b973ab783c6c0f3 Mon Sep 17 00:00:00 2001 From: Ivan Delalande Date: Wed, 11 Mar 2015 17:13:35 +0000 Subject: [PATCH 08/16] Backspace value shouldn't depend on keypad state --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 5b985cd..28a413b 100644 --- a/config.def.h +++ b/config.def.h @@ -259,7 +259,7 @@ static Key key[] = { { XK_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, - { XK_BackSpace, XK_ANY_MOD, "\177", +1, 0, 0}, + { XK_BackSpace, XK_ANY_MOD, "\177", 0, 0, 0}, { XK_Home, ShiftMask, "\033[2J", 0, -1, 0}, { XK_Home, ShiftMask, "\033[1;2H", 0, +1, 0}, { XK_Home, XK_ANY_MOD, "\033[H", 0, -1, 0}, -- 2.20.1 From 4f60751440df55c11a8c601470b5d141d853e594 Mon Sep 17 00:00:00 2001 From: Alexander Huemer Date: Tue, 10 Mar 2015 01:23:07 +0100 Subject: [PATCH 09/16] FAQ: fix wording --- FAQ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FAQ b/FAQ index cdf4f45..3502c60 100644 --- a/FAQ +++ b/FAQ @@ -92,7 +92,7 @@ in TERM. ## I cannot compile st in OpenBSD -OpenBSD lacks librt, despite it began to be mandatory in POSIX +OpenBSD lacks librt, despite it being mandatory in POSIX . If you want to compile st for OpenBSD you have to remove -lrt from config.mk, and st will compile without any loss of functionality, because all the functions are -- 2.20.1 From b746816b78447b9e4a3af7333a4e992eb8d32254 Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Fri, 13 Mar 2015 07:26:16 +0000 Subject: [PATCH 10/16] Allow combinations with Backspace XN_ANY_MOD makes that any combination of backspace will return always DEL. This patch lets to X to decide which value returns. --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 28a413b..8a8236c 100644 --- a/config.def.h +++ b/config.def.h @@ -259,7 +259,7 @@ static Key key[] = { { XK_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, - { XK_BackSpace, XK_ANY_MOD, "\177", 0, 0, 0}, + { XK_BackSpace, XK_NO_MOD, "\177", 0, 0, 0}, { XK_Home, ShiftMask, "\033[2J", 0, -1, 0}, { XK_Home, ShiftMask, "\033[1;2H", 0, +1, 0}, { XK_Home, XK_ANY_MOD, "\033[H", 0, -1, 0}, -- 2.20.1 From 2fcfea1bf149f839cdbcba5c1efc7c4ce31f6d95 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 14 Mar 2015 07:41:59 +0100 Subject: [PATCH 11/16] Add Mod + Shift + c/v and no selclear. Thanks to Alex Pilon ! Now there is a distinction between the primary and clipboard selection. With Mod + Shift + c/v the clipboard is handled. The old Insert behavious does reside. --- config.def.h | 2 ++ st.c | 69 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/config.def.h b/config.def.h index 8a8236c..56bae2d 100644 --- a/config.def.h +++ b/config.def.h @@ -119,6 +119,8 @@ static Shortcut shortcuts[] = { { MODKEY|ShiftMask, XK_Home, xzoomreset, {.i = 0} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} }, { MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} }, + { MODKEY|ShiftMask, XK_C, clipcopy, {.i = 0} }, + { MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} }, { MODKEY, XK_Num_Lock, numlock, {.i = 0} }, }; diff --git a/st.c b/st.c index 39a6836..4b98b27 100644 --- a/st.c +++ b/st.c @@ -290,7 +290,7 @@ typedef struct { int x, y; } nb, ne, ob, oe; - char *clip; + char *primary, *clipboard; Atom xtarget; bool alt; struct timespec tclick1; @@ -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,11 @@ static void (*handler[LASTEvent])(XEvent *) = { [MotionNotify] = bmotion, [ButtonPress] = bpress, [ButtonRelease] = brelease, - [SelectionClear] = selclear, +/* + * Uncomment if you want the selection to disappear when you select something + * different in another window. + */ +/* [SelectionClear] = selclear, */ [SelectionNotify] = selnotify, [SelectionRequest] = selrequest, }; @@ -640,7 +645,8 @@ selinit(void) { memset(&sel.tclick2, 0, sizeof(sel.tclick2)); sel.mode = 0; sel.ob.x = -1; - sel.clip = NULL; + sel.primary = NULL; + sel.clipboard = NULL; sel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0); if(sel.xtarget == None) sel.xtarget = XA_STRING; @@ -985,12 +991,15 @@ selnotify(XEvent *e) { int format; uchar *data, *last, *repl; Atom type; + XSelectionEvent *xsev; ofs = 0; + xsev = (XSelectionEvent *)e; do { - if(XGetWindowProperty(xw.dpy, xw.win, XA_PRIMARY, ofs, BUFSIZ/4, - False, AnyPropertyType, &type, &format, - &nitems, &rem, &data)) { + if(XGetWindowProperty(xw.dpy, xw.win, xsev->property, ofs, + BUFSIZ/4, False, AnyPropertyType, + &type, &format, &nitems, &rem, + &data)) { fprintf(stderr, "Clipboard allocation failed\n"); return; } @@ -1025,12 +1034,26 @@ selpaste(const Arg *dummy) { xw.win, CurrentTime); } +void +clipcopy(const Arg *dummy) { + Atom clipboard; + + if(sel.clipboard != NULL) + free(sel.clipboard); + + if(sel.primary != NULL) { + sel.clipboard = xstrdup(sel.primary); + clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); + XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime); + } +} + void clippaste(const Arg *dummy) { Atom clipboard; clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); - XConvertSelection(xw.dpy, clipboard, sel.xtarget, XA_PRIMARY, + XConvertSelection(xw.dpy, clipboard, sel.xtarget, clipboard, xw.win, CurrentTime); } @@ -1046,7 +1069,8 @@ void selrequest(XEvent *e) { XSelectionRequestEvent *xsre; XSelectionEvent xev; - Atom xa_targets, string; + Atom xa_targets, string, clipboard; + char *seltext; xsre = (XSelectionRequestEvent *) e; xev.type = SelectionNotify; @@ -1065,11 +1089,25 @@ selrequest(XEvent *e) { XA_ATOM, 32, PropModeReplace, (uchar *) &string, 1); xev.property = xsre->property; - } else if(xsre->target == sel.xtarget && sel.clip != NULL) { - XChangeProperty(xsre->display, xsre->requestor, xsre->property, - xsre->target, 8, PropModeReplace, - (uchar *) sel.clip, strlen(sel.clip)); - xev.property = xsre->property; + } else if(xsre->target == sel.xtarget) { + clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); + if(xsre->selection == XA_PRIMARY) { + seltext = sel.primary; + } else if(xsre->selection == clipboard) { + seltext = sel.clipboard; + } else { + fprintf(stderr, + "Unhandled clipboard selection 0x%lx\n", + xsre->selection); + return; + } + if(seltext != NULL) { + XChangeProperty(xsre->display, xsre->requestor, + xsre->property, xsre->target, + 8, PropModeReplace, + (uchar *)seltext, strlen(seltext)); + xev.property = xsre->property; + } } /* all done, send a notification to the listener */ @@ -1079,8 +1117,9 @@ selrequest(XEvent *e) { void xsetsel(char *str) { - free(sel.clip); - sel.clip = str; + free(sel.primary); + sel.primary = str; + XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, CurrentTime); } -- 2.20.1 From 72d2accc2299cdda9379db17ed62e8e5df5a9426 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 14 Mar 2015 08:43:57 +0100 Subject: [PATCH 12/16] Glibc wants me to use _DEFAULT_SOURCe. I do obey. --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 46457f7..7ae510e 100644 --- a/config.mk +++ b/config.mk @@ -19,7 +19,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXext -lXft \ `pkg-config --libs freetype2` # flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_XOPEN_SOURCE=600 +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS} LDFLAGS += -g ${LIBS} -- 2.20.1 From 5406e655daa576a909ad69a5ee6ed1f72ca5b15a Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 14 Mar 2015 08:52:37 +0100 Subject: [PATCH 13/16] Add the new selection shortcuts to the manpage. --- st.1 | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/st.1 b/st.1 index 0700787..a9fec15 100644 --- a/st.1 +++ b/st.1 @@ -45,9 +45,9 @@ for further details. .B \-i will fixate the position given with the -g option. .TP -.BI \-o " file" +.BI \-o " iofile" writes all the I/O to -.I file. +.I iofile. This feature is useful when recording st sessions. A value of "-" means standard output. .TP @@ -67,31 +67,40 @@ st executes instead of the shell. If this is used it .B must be the last option on the command line, as in xterm / rxvt. -.SH USAGE +.SH SHORTCUTS .TP .B Ctrl-Print Screen -toggleprinter() +Toggle if st should print to the +.I iofile. .TP .B Shift-Print Screen -printscreen() +Print the full screen to the +.I iofile. .TP .B Print Screen -printsel() +Print the selection to the +.I iofile. .TP .B Alt-Shift-Page Up -increase font size +Increase font size. .TP .B Alt-Shift-Page Down -decrease font size +Decrease font size. .TP .B Alt-Shift-Home -reset to default font size +Reset to default font size. .TP .B Shift-Insert -paste from primary selection +Paste from primary selection (middle mouse button). .TP .B Alt-Shift-Insert -paste from clipboard selection +Paste from clipboard selection. +.TP +.B Alt-Shift-c +Copy the selected text to the clipboard selection. +.TP +.B Alt-Shift-v +Paste from the clipboard selection. .SH CUSTOMIZATION .B st can be customized by creating a custom config.h and (re)compiling the source -- 2.20.1 From c7e24e44c8d66cd5b0a6b015d2112da5f1e4e581 Mon Sep 17 00:00:00 2001 From: Christoph Lohmann <20h@r-36.net> Date: Sat, 14 Mar 2015 08:53:41 +0100 Subject: [PATCH 14/16] TODO: Fix fontconfig --- TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO b/TODO index 00cfdac..90e3d56 100644 --- a/TODO +++ b/TODO @@ -11,6 +11,7 @@ code & interface drawing ------- * add diacritics support to xdraws() + * switch to a suckless font drawing library * make the font cache simpler * add better support for brightening of the upper colors -- 2.20.1 From 86d1e432a823dad7bb64808b8192014fddc8cd9f Mon Sep 17 00:00:00 2001 From: "Roberto E. Vargas Caballero" Date: Sun, 15 Mar 2015 18:07:46 +0000 Subject: [PATCH 15/16] Support XA_STRING in notify request Some programs can only deal with XA_STRING, and it makes impossible st be able of copying to them. This patch makes st answer also to XA_STRING, althought it sends utf8 strings. It is not a problem because moderm applications must support utf8. --- st.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/st.c b/st.c index 4b98b27..aa4185c 100644 --- a/st.c +++ b/st.c @@ -1089,7 +1089,11 @@ selrequest(XEvent *e) { XA_ATOM, 32, PropModeReplace, (uchar *) &string, 1); xev.property = xsre->property; - } else if(xsre->target == sel.xtarget) { + } else if(xsre->target == sel.xtarget || xsre->target == XA_STRING) { + /* + * xith XA_STRING non ascii characters may be incorrect in the + * requestor. It is not our problem, use utf8. + */ clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); if(xsre->selection == XA_PRIMARY) { seltext = sel.primary; -- 2.20.1 From 580302f3179ef3f24cf0329755686dfa7100996b Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 18 Mar 2015 21:12:47 +0100 Subject: [PATCH 16/16] Support the DECSCUSR CSI escape sequence --- st.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/st.c b/st.c index aa4185c..00fca99 100644 --- a/st.c +++ b/st.c @@ -197,14 +197,14 @@ typedef struct { } TCursor; /* CSI Escape sequence structs */ -/* ESC '[' [[ [] [;]] ] */ +/* ESC '[' [[ [] [;]] []] */ typedef struct { char buf[ESC_BUF_SIZ]; /* raw string */ int len; /* raw string length */ char priv; int arg[ESC_ARG_SIZ]; int narg; /* nb of args */ - char mode; + char mode[2]; } CSIEscape; /* STR Escape sequence structs */ @@ -257,6 +257,7 @@ typedef struct { int ch; /* char height */ int cw; /* char width */ char state; /* focus, redraw, visible */ + int cursor; /* cursor style */ } XWindow; typedef struct { @@ -1545,7 +1546,8 @@ csiparse(void) { break; p++; } - csiescseq.mode = *p; + csiescseq.mode[0] = *p++; + csiescseq.mode[1] = (p < csiescseq.buf+csiescseq.len) ? *p : '\0'; } /* for absolute user moves, when decom is set */ @@ -1983,7 +1985,7 @@ csihandle(void) { char buf[40]; int len; - switch(csiescseq.mode) { + switch(csiescseq.mode[0]) { default: unknown: fprintf(stderr, "erresc: unknown csi "); @@ -2171,6 +2173,19 @@ csihandle(void) { case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */ tcursor(CURSOR_LOAD); break; + case ' ': + switch (csiescseq.mode[1]) { + case 'q': /* DECSCUSR -- Set Cursor Style */ + DEFAULT(csiescseq.arg[0], 1); + if (!BETWEEN(csiescseq.arg[0], 0, 6)) { + goto unknown; + } + xw.cursor = csiescseq.arg[0]; + break; + default: + goto unknown; + } + break; } } @@ -3551,16 +3566,36 @@ xdrawcursor(void) { /* draw the new one */ if(xw.state & WIN_FOCUSED) { - if(IS_SET(MODE_REVERSE)) { - g.mode |= ATTR_REVERSE; - g.fg = defaultcs; - g.bg = defaultfg; - } + switch (xw.cursor) { + case 0: /* Blinking Block */ + case 1: /* Blinking Block (Default) */ + case 2: /* Steady Block */ + if(IS_SET(MODE_REVERSE)) { + g.mode |= ATTR_REVERSE; + g.fg = defaultcs; + g.bg = defaultfg; + } - sl = utf8len(g.c); - width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\ - ? 2 : 1; - xdraws(g.c, g, term.c.x, term.c.y, width, sl); + sl = utf8len(g.c); + width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\ + ? 2 : 1; + xdraws(g.c, g, term.c.x, term.c.y, width, sl); + break; + case 3: /* Blinking Underline */ + case 4: /* Steady Underline */ + XftDrawRect(xw.draw, &dc.col[defaultcs], + borderpx + curx * xw.cw, + borderpx + (term.c.y + 1) * xw.ch - 1, + xw.cw, 1); + break; + case 5: /* Blinking bar */ + case 6: /* Steady bar */ + XftDrawRect(xw.draw, &dc.col[defaultcs], + borderpx + curx * xw.cw, + borderpx + term.c.y * xw.ch, + 1, xw.ch); + break; + } } else { XftDrawRect(xw.draw, &dc.col[defaultcs], borderpx + curx * xw.cw, @@ -3985,6 +4020,7 @@ main(int argc, char *argv[]) { xw.l = xw.t = 0; xw.isfixed = False; + xw.cursor = 0; ARGBEGIN { case 'a': -- 2.20.1