Adding invert patch
This commit is contained in:
parent
4966f31256
commit
d26b46ffa7
|
@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
|
|||
|
||||
### Changelog:
|
||||
|
||||
2020-03-29 - Added invert patch
|
||||
|
||||
2020-03-24 - Upgraded to latest (master) of st (commit 51e19ea11dd42eefed1ca136ee3f6be975f618b1 at the time of writing). Custom changes to make the altscreen mouse scollback patch working.
|
||||
|
||||
2020-03-21 - Added font2 patch
|
||||
|
@ -69,6 +71,10 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
|
|||
- [hidecursor](https://st.suckless.org/patches/hidecursor/)
|
||||
- hides the X cursor whenever a key is pressed and show it back when the mouse is moved in the terminal window
|
||||
|
||||
- [invert](https://st.suckless.org/patches/invert/)
|
||||
- adds a keybinding that lets you invert the current colorscheme of st
|
||||
- this provides a simple way to temporarily switch to a light colorscheme if you use a dark colorscheme or visa-versa
|
||||
|
||||
- [iso14755](https://st.suckless.org/patches/iso14755/)
|
||||
- pressing the default binding Ctrl+Shift-i will popup dmenu, asking you to enter a unicode codepoint that will be converted to a glyph and then pushed to st
|
||||
|
||||
|
|
|
@ -358,6 +358,9 @@ static Shortcut shortcuts[] = {
|
|||
#if ISO14755_PATCH
|
||||
{ TERMMOD, XK_I, iso14755, {.i = 0} },
|
||||
#endif // ISO14755_PATCH
|
||||
#if INVERT_PATCH
|
||||
{ TERMMOD, XK_X, invert, { 0 } },
|
||||
#endif // INVERT_PATCH
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
static int invertcolors = 0;
|
||||
|
||||
void
|
||||
invert(const Arg *dummy)
|
||||
{
|
||||
invertcolors = !invertcolors;
|
||||
redraw();
|
||||
}
|
||||
|
||||
Color
|
||||
invertedcolor(Color *clr)
|
||||
{
|
||||
XRenderColor rc;
|
||||
Color inverted;
|
||||
rc.red = ~clr->color.red;
|
||||
rc.green = ~clr->color.green;
|
||||
rc.blue = ~clr->color.blue;
|
||||
rc.alpha = clr->color.alpha;
|
||||
XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &rc, &inverted);
|
||||
return inverted;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
static void invert(const Arg *);
|
|
@ -11,6 +11,9 @@
|
|||
#if FONT2_PATCH
|
||||
#include "font2.c"
|
||||
#endif
|
||||
#if INVERT_PATCH
|
||||
#include "invert.c"
|
||||
#endif
|
||||
#if KEYBOARDSELECT_PATCH
|
||||
#include "keyboardselect_x.c"
|
||||
#endif
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#if FONT2_PATCH
|
||||
#include "font2.h"
|
||||
#endif
|
||||
#if INVERT_PATCH
|
||||
#include "invert.h"
|
||||
#endif
|
||||
#if KEYBOARDSELECT_PATCH
|
||||
#include "keyboardselect_x.h"
|
||||
#endif
|
||||
|
|
|
@ -88,6 +88,13 @@
|
|||
*/
|
||||
#define HIDECURSOR_PATCH 0
|
||||
|
||||
/* This patch adds a keybinding that lets you invert the current colorscheme of st.
|
||||
* This provides a simple way to temporarily switch to a light colorscheme if you use a dark
|
||||
* colorscheme or visa-versa.
|
||||
* https://st.suckless.org/patches/invert/
|
||||
*/
|
||||
#define INVERT_PATCH 0
|
||||
|
||||
/* Pressing the default binding Ctrl+Shift-i will popup dmenu, asking you to enter a unicode
|
||||
* codepoint that will be converted to a glyph and then pushed to st.
|
||||
* https://st.suckless.org/patches/iso14755/
|
||||
|
|
18
x.c
18
x.c
|
@ -904,9 +904,18 @@ xsetcolorname(int x, const char *name)
|
|||
void
|
||||
xclear(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
#if INVERT_PATCH
|
||||
Color c;
|
||||
c = dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg];
|
||||
if (invertcolors) {
|
||||
c = invertedcolor(&c);
|
||||
}
|
||||
XftDrawRect(xw.draw, &c, x1, y1, x2-x1, y2-y1);
|
||||
#else
|
||||
XftDrawRect(xw.draw,
|
||||
&dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg],
|
||||
x1, y1, x2-x1, y2-y1);
|
||||
#endif // INVERT_PATCH
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1657,6 +1666,15 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
|||
if (base.mode & ATTR_INVISIBLE)
|
||||
fg = bg;
|
||||
|
||||
#if INVERT_PATCH
|
||||
if (invertcolors) {
|
||||
revfg = invertedcolor(fg);
|
||||
revbg = invertedcolor(bg);
|
||||
fg = &revfg;
|
||||
bg = &revbg;
|
||||
}
|
||||
#endif // INVERT_PATCH
|
||||
|
||||
/* Intelligent cleaning up of the borders. */
|
||||
#if ANYSIZE_PATCH
|
||||
if (x == 0) {
|
||||
|
|
Loading…
Reference in New Issue