On Fri, Apr 20, 2018 at 11:02:58AM -0400, Carlos Torres wrote: > Thats a cool idea. Its currently not implemented but patches are welcome :)
> > Is it possible somehow to make st's cursor changing according to the > > current language? > > So it would alternate between two colors? > > > > Offtopic: is it possible to do the same in xterm? VIM and Emacs? This is it, I'm changing keyboard layout by caps lock, but somehow, it's scroll lock which is changing :) I'm not familiar with X Windows at all, so this is more proof-of-concept. Maybe someone can point me how to make it better. Also, color isn't changing right after caps lock press, but one press after... Don't know how to fix this, yet... -- -- http://www.yurichev.com Sometimes I may delay my E-Mail reply. Sorry in advance for the inconvenience. It's advisable to use PGP if/when possible. My public keys: http://yurichev.com/pgp.html I also use https://bitmessage.org/ my ID: BM-2cUyrfGUDyjuUHyzAA63kq5NHAB2zMo4Q2
diff -rupN st-0.8.1.original/config.def.h st-0.8.1/config.def.h --- st-0.8.1.original/config.def.h 2018-03-20 22:29:59.000000000 +0200 +++ st-0.8.1/config.def.h 2018-04-24 01:23:49.669365424 +0300 @@ -118,7 +118,11 @@ static const char *colorname[] = { */ unsigned int defaultfg = 7; unsigned int defaultbg = 0; -static unsigned int defaultcs = 256; + +//static unsigned int defaultcs = 256; +static unsigned int defaultcs1 = 10; // green cursor +static unsigned int defaultcs2 = 9; // red cursor + static unsigned int defaultrcs = 257; /* diff -rupN st-0.8.1.original/x.c st-0.8.1/x.c --- st-0.8.1.original/x.c 2018-03-20 22:29:59.000000000 +0200 +++ st-0.8.1/x.c 2018-04-24 01:24:08.017487621 +0300 @@ -20,6 +20,15 @@ static char *argv0; #include "st.h" #include "win.h" +int get_scroll_lock() +{ + Display *dpy = XOpenDisplay(":0"); + XKeyboardState x; + XGetKeyboardControl(dpy, &x); + XCloseDisplay(dpy); + return !!(x.led_mask&4); +} + /* types used in config.h */ typedef struct { uint mod; @@ -1400,6 +1409,13 @@ xdrawglyph(Glyph g, int x, int y) void xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) { + unsigned int defaultcs; + + if (get_scroll_lock()) + defaultcs=defaultcs2; + else + defaultcs=defaultcs1; + Color drawcol; /* remove the old cursor */
signature.asc
Description: PGP signature