Merge branch 'main' of git.snaile.de:snailed/st-custom

This commit is contained in:
Luca Bilke 2024-04-25 14:24:05 +02:00
commit 9ba6b45a14
No known key found for this signature in database
GPG Key ID: B753481DA0B6FA47
9 changed files with 199 additions and 239 deletions

View File

@ -11,7 +11,7 @@ on:
jobs:
build-and-publish:
runs-on: docker
container: git.snaile.de/snailed/xbps-builder:2024.46.1156@sha256:c69bcb9da724a31d9c1fff36fa6dc8f363b2d9f2470d3ec7887a0905c84b66ea
container: git.snaile.de/snailed/xbps-builder:2024.0418.1149
env:
LICENSE: "GPL-2.0"
SHORT_DESCRIPTION: "Customized st"

View File

@ -8,4 +8,8 @@ for patch in patches/*.diff; do
done
cp -f config.h st-final/
cd st-final || exit 1
make "$1"
if [ "$1" = "-i" ]; then
sudo make install
else
make
fi

154
config.h
View File

@ -5,13 +5,12 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char *font = "FiraCode Nerd Font:size=12";
static char *font = "FiraCode Nerd Font:pixelsize=14";
/* Spare fonts */
static char *font2[] = {
"Noto Color Emoji:size=11",
"Noto Color Emoji:pixelsize=14",
};
static int borderpx = 2;
/* modkey options: ControlMask, ShiftMask or XK_ANY_MOD */
@ -33,7 +32,10 @@ char *scroll = NULL;
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
/* identification sequence returned in DA and DECID */
char *vtiden = "\033[?12;4c";
char *vtiden = "\033[?62;4c"; /* VT200 family (62) with sixel (4) */
/* sixel rgb byte order: LSBFirst or MSBFirst */
int const sixelbyteorder = LSBFirst;
/* Kerning / character bounding-box multipliers */
static float cwscale = 1.0;
@ -46,6 +48,10 @@ static float chscale = 1.0;
*/
wchar_t *worddelimiters = L" `'\"()[]{}=,";
/* Word delimiters for short and long jumps in the keyboard select patch */
wchar_t *kbds_sdelim = L"!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~ ";
wchar_t *kbds_ldelim = L" ";
/* selection timeouts (in milliseconds) */
static unsigned int doubleclicktimeout = 300;
static unsigned int tripleclicktimeout = 600;
@ -63,8 +69,8 @@ int allowwindowops = 0;
* near minlatency, but it waits longer for slow updates to avoid partial draw.
* low minlatency will tear/flicker more, as it can "detect" idle too early.
*/
static double minlatency = 3;
static double maxlatency = 25;
static double minlatency = 2;
static double maxlatency = 33;
/*
* Synchronized-Update timeout in ms
@ -83,6 +89,9 @@ static unsigned int blinktimeout = 800;
*/
static unsigned int cursorthickness = 2;
/* Hide the X cursor whenever a key is pressed. 0: off, 1: on */
int hidecursor = 1;
/*
* 1: render most of the lines/blocks characters without using the font for
* perfect alignment between cells (U2500 - U259F except dashes/diagonals).
@ -121,31 +130,25 @@ char *termname = "st-256color";
*/
unsigned int tabspaces = 8;
/* bg opacity */
float alpha = 0.9;
float alphaUnfocused = 0.8;
#define BLACK "#15161E"
#define RED "#f7768e"
#define GREEN "#9ece6a"
#define ORANGE "#e0af68"
#define BLUE "#7aa2f7"
#define MAGENTA "#bb9af7"
#define CYAN "#7dcfff"
#define LIGHT_GRAY "#a9b1d6"
#define GRAY "#414868"
#define WHITE "#c0caf5"
#define UNDEFINED "#ff0000"
/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
/* 8 normal colors */
"#1d202f",
"#f7768e",
"#9ece6a",
"#e0af68",
"#7aa2f7",
"#bb9af7",
"#7dcfff",
"#a9b1d6",
BLACK, RED, GREEN, ORANGE, BLUE, MAGENTA, CYAN, LIGHT_GRAY,
/* 8 bright colors */
"#414868",
"#f7768e",
"#9ece6a",
"#e0af68",
"#7aa2f7",
"#bb9af7",
"#7dcfff",
"#c0caf5",
GRAY, RED, GREEN, ORANGE, BLUE, MAGENTA, CYAN, WHITE,
[255] = 0,
@ -154,27 +157,27 @@ static const char *colorname[] = {
"#1a1b26", /* 257 -> default inverted cursor colour */
"#c0caf5", /* 258 -> default foreground colour */
"#1a1b26", /* 259 -> default background colour */
"#c0caf5", /* 260 -> unfocused foreground colour */
"#1a1b26", /* 261 -> unfocused background colour */
"#c0caf5", /* 262 -> default selection foreground colour */
"#33467C", /* 263 -> default selection background colour */
"#c0caf5", /* 260 -> default selection foreground colour */
"#33467C", /* 261 -> default selection background colour */
};
/*
* Default colors (colorname index)
* foreground, background, cursor, reverse cursor
*/
unsigned int defaultfg = 258;
unsigned int defaultbg = 259;
unsigned int defaultcs = 256;
unsigned int defaultrcs = 257;
unsigned int defaultfg = 258;
unsigned int defaultbg = 0;
unsigned int bg = 259;
unsigned int bgUnfocused = 261;
unsigned int selectionfg = 262;
unsigned int selectionbg = 263;
static int ignoreselfg = 0;
unsigned int selectionfg = 260;
unsigned int selectionbg = 261;
/* If 0 use selectionfg as foreground in order to have a uniform
* foreground-color */
/* Else if 1 keep original foreground-color of each cell => more colors :) */
static int ignoreselfg = 1;
/* Foreground and background color of search results */
unsigned int highlightfg = 3;
unsigned int highlightbg = 0;
/*
* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81
@ -200,9 +203,11 @@ static unsigned int cols = 80;
static unsigned int rows = 24;
/*
* Default shape of the mouse cursor
* Default colour and shape of the mouse cursor
*/
static char* mouseshape = "xterm";
static unsigned int mouseshape = XC_xterm;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
/*
* Color used to display font attributes when fontconfig selected a font which
@ -210,37 +215,6 @@ static char* mouseshape = "xterm";
*/
static unsigned int defaultattr = 11;
/*
* Xresources preferences to load at startup
*/
ResourcePref resources[] = {
{ "color0", STRING, &colorname[0] },
{ "color1", STRING, &colorname[1] },
{ "color2", STRING, &colorname[2] },
{ "color3", STRING, &colorname[3] },
{ "color4", STRING, &colorname[4] },
{ "color5", STRING, &colorname[5] },
{ "color6", STRING, &colorname[6] },
{ "color7", STRING, &colorname[7] },
{ "color8", STRING, &colorname[8] },
{ "color9", STRING, &colorname[9] },
{ "color10", STRING, &colorname[10] },
{ "color11", STRING, &colorname[11] },
{ "color12", STRING, &colorname[12] },
{ "color13", STRING, &colorname[13] },
{ "color14", STRING, &colorname[14] },
{ "color15", STRING, &colorname[15] },
{ "cursorColor", STRING, &colorname[256] },
{ "foreground", STRING, &colorname[258] },
{ "background", STRING, &colorname[259] },
{ "unfocusedForeground", STRING, &colorname[260] },
{ "unfocusedBackground", STRING, &colorname[261] },
{ "selectionForeground", STRING, &colorname[262] },
{ "selectionBackground", STRING, &colorname[263] },
{ "alpha", FLOAT, &alpha },
{ "alphaUnfocused",FLOAT, &alphaUnfocused },
};
/*
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
* Note that if you want to use ShiftMask with selmasks, set this to an other
@ -253,12 +227,10 @@ static uint forcemousemod = ShiftMask;
* Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
/* mask button function argument release screen */
// { XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 },
// { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
// { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
// { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
// { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
/* mask button function argument release
screen */
{ShiftMask, Button4, kscrollup, {.i = 1}, 0, S_PRI},
{ShiftMask, Button5, kscrolldown, {.i = 1}, 0, S_PRI},
};
/* Internal keyboard shortcuts. */
@ -269,29 +241,26 @@ static char *openurlcmd[] = { "/bin/sh", "-c",
"xurls | dmenu -l 10 -w $WINDOWID | xargs -r open",
"externalpipe", NULL};
static char *setbgcolorcmd[] = { "/bin/sh", "-c",
"printf '\033]11;#008000\007'",
static char *setbgcolorcmd[] = {"/bin/sh", "-c", "printf '\033]11;#008000\007'",
"externalpipein", NULL};
static Shortcut shortcuts[] = {
/* mask keysym function argument screen */
{XK_ANY_MOD, XK_Break, sendbreak, {.i = 0}},
{ControlMask, XK_Print, toggleprinter, {.i = 0}},
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
{TERMMOD, XK_Print, printscreen, {.i = 0}},
{XK_ANY_MOD, XK_Print, printsel, {.i = 0}},
{TERMMOD, XK_Prior, zoom, {.f = +3}},
{TERMMOD, XK_Next, zoom, {.f = -3}},
{TERMMOD, XK_Home, zoomreset, {.f = 0}},
{TERMMOD, XK_C, clipcopy, {.i = 0}},
{TERMMOD, XK_V, clippaste, {.i = 0}},
{ TERMMOD, XK_O, changealpha, {.f = +0.05} },
{ TERMMOD, XK_P, changealpha, {.f = -0.05} },
//{ TERMMOD, XK_, changealphaunfocused, {.f = +0.05} },
//{ TERMMOD, XK_, changealphaunfocused, {.f = -0.05} },
{TERMMOD, XK_Y, selpaste, {.i = 0}},
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{TERMMOD, XK_K, kscrollup, {.i = 20}, S_PRI},
{TERMMOD, XK_J, kscrolldown, {.i = 20}, S_PRI},
{TERMMOD, XK_Num_Lock, numlock, {.i = 0}},
{ TERMMOD, XK_I, iso14755, {.i = 0} },
{TERMMOD, XK_Escape, keyboard_select, {0}},
{TERMMOD, XK_F, searchforward, {0}},
{TERMMOD, XK_B, searchbackward, {0}},
};
/*
@ -315,14 +284,12 @@ static Shortcut shortcuts[] = {
* position for a key.
*/
/*
* State bits to ignore when matching key or button events. By default,
* numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
*/
static uint ignoremod = Mod2Mask | XK_SWITCH_MOD;
/*
* Selection types' masks.
* Use the same masks as usual.
@ -338,17 +305,10 @@ static uint selmasks[] = {
* Printable characters in ASCII, used to estimate the advance width
* of single wide characters.
*/
static char ascii_printable[] =
" !\"#$%&'()*+,-./0123456789:;<=>?"
static char ascii_printable[] = " !\"#$%&'()*+,-./0123456789:;<=>?"
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
"`abcdefghijklmnopqrstuvwxyz{|}~";
/*
* plumb_cmd is run on mouse button 3 click, with argument set to
* current selection and with cwd set to the cwd of the active shell
*/
static char *plumb_cmd = "plumb";
/**
* Undercurl style. Set UNDERCURL_STYLE to one of the available styles.
*

View File

@ -1,11 +1,13 @@
# st version
VERSION = 0.9
VERSION = 0.9.1
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
ICONPREFIX = $(PREFIX)/share/pixmaps
ICONNAME = st.png
X11INC = /usr/include/X11
X11LIB = /usr/lib
@ -13,10 +15,10 @@ X11LIB = /usr/lib
PKG_CONFIG = pkg-config
# Uncomment this for the alpha patch / ALPHA_PATCH
XRENDER = -lXrender
#XRENDER = `$(PKG_CONFIG) --libs xrender`
# Uncomment this for the themed cursor patch / THEMED_CURSOR_PATCH
XCURSOR = -lXcursor
#XCURSOR = `$(PKG_CONFIG) --libs xcursor`
# Uncomment the lines below for the ligatures patch / LIGATURES_PATCH
LIGATURES_C = hb.c
@ -25,20 +27,25 @@ LIGATURES_INC = `$(PKG_CONFIG) --cflags harfbuzz`
LIGATURES_LIBS = `$(PKG_CONFIG) --libs harfbuzz`
# Uncomment this for the SIXEL patch / SIXEL_PATCH
# SIXEL_C = sixel.c sixel_hls.c
SIXEL_C = sixel.c sixel_hls.c
SIXEL_LIBS = `$(PKG_CONFIG) --libs imlib2`
# Uncomment for the netwmicon patch / NETWMICON_PATCH
#NETWMICON_LIBS = `$(PKG_CONFIG) --libs gdlib`
# includes and libs, uncomment harfbuzz for the ligatures patch
INCS = -I$(X11INC) \
`$(PKG_CONFIG) --cflags fontconfig` \
`$(PKG_CONFIG) --cflags freetype2` \
$(LIGATURES_INC)
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft ${XRENDER} ${XCURSOR}\
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft ${SIXEL_LIBS} ${XRENDER} ${XCURSOR}\
`$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2` \
$(LIGATURES_LIBS)
$(LIGATURES_LIBS) \
$(NETWMICON_LIBS)
# flags
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -DICON=\"$(ICONPREFIX)/$(ICONNAME)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
STLDFLAGS = $(LIBS) $(LDFLAGS)

View File

@ -14,7 +14,7 @@
* when including this patch.
* https://st.suckless.org/patches/alpha/
*/
#define ALPHA_PATCH 1
#define ALPHA_PATCH 0
/* The alpha focus highlight patch allows the user to specify two distinct opacity values or
* background colors in order to easily differentiate between focused and unfocused terminal
@ -22,7 +22,7 @@
* https://github.com/juliusHuelsmann/st-focus/
* https://st.suckless.org/patches/alpha_focus_highlight/
*/
#define ALPHA_FOCUS_HIGHLIGHT_PATCH 1
#define ALPHA_FOCUS_HIGHLIGHT_PATCH 0
/* Adds gradient transparency to st, depends on the alpha patch.
* https://st.suckless.org/patches/gradient/
@ -77,9 +77,8 @@
#define CLIPBOARD_PATCH 0
/* This patch allows st to be resized without cutting off text when the terminal window is
* made larger again. Text does not wrap when the terminal window is made smaller.
*
* The vim browse patch takes precedence over this patch.
* made larger again. Text does not wrap when the terminal window is made smaller, you may
* also want to have a look at the reflow patch.
*
* https://github.com/bakkeby/st-flexipatch/issues/34
*/
@ -121,7 +120,7 @@
/* Return BS on pressing backspace and DEL on pressing the delete key.
* https://st.suckless.org/patches/delkey/
*/
#define DELKEY_PATCH 0
#define DELKEY_PATCH 1
/* This patch adds the option of disabling bold fonts globally.
* https://st.suckless.org/patches/disable_bold_italic_fonts/
@ -141,7 +140,7 @@
/* This patch makes the cursor color the inverse of the current cell color.
* https://st.suckless.org/patches/dynamic-cursor-color/
*/
#define DYNAMIC_CURSOR_COLOR_PATCH 0
#define DYNAMIC_CURSOR_COLOR_PATCH 1
/* Reading and writing st's screen through a pipe, e.g. pass info to dmenu.
* https://st.suckless.org/patches/externalpipe/
@ -210,12 +209,14 @@
* codepoint that will be converted to a glyph and then pushed to st.
* https://st.suckless.org/patches/iso14755/
*/
#define ISO14755_PATCH 1
#define ISO14755_PATCH 0
/* This patch allows you to select text on the terminal using keyboard shortcuts.
* NB: An improved variant of this patch is enabled if combined with the reflow patch.
*
* https://st.suckless.org/patches/keyboard_select/
*/
#define KEYBOARDSELECT_PATCH 0
#define KEYBOARDSELECT_PATCH 1
/* This patch adds support for drawing ligatures using the Harfbuzz library to transform
* original text of a single line to a list of glyphs with ligatures included.
@ -233,16 +234,45 @@
*/
#define MONOCHROME_PATCH 0
/* This patch sets the _NET_WM_ICON X property with a hardcoded icon for st.
/* This patch sets the _NET_WM_ICON X property with an icon that is read from a .png file.
* This patch depends on the GD Graphics Library and headers to compile.
* You need to uncomment the corresponding lines in config.mk to use the gd library.
*
* The default location for the .png file is:
* - /usr/local/share/pixmaps/st.png
*
* https://st.suckless.org/patches/netwmicon/
*/
#define NETWMICON_PATCH 0
/* This patch sets the _NET_WM_ICON X property with an icon that is read from a farbfeld image.
* The benefit of this patch is that you do not need an additional dependency on an external
* library to read and convert the farbfeld image.
*
* The default location for the farbfeld image is:
* - /usr/local/share/pixmaps/st.ff
*
* Remember to change the ICONNAME in config.mk from st.png to st.ff when using this patch.
*
* Example command to convert a .png to farbfeld:
* $ png2ff < st.png > st.ff
*
* https://tools.suckless.org/farbfeld/
* https://github.com/bakkeby/patches/wiki/netwmicon/
*/
#define NETWMICON_FF_PATCH 0
/* This patch sets the _NET_WM_ICON X property with a hardcoded icon for st. This is the
* original version that predates the version that reads the image from a .png file.
* https://st.suckless.org/patches/netwmicon/
*/
#define NETWMICON_LEGACY_PATCH 0
/* This patch allows you to spawn a new st terminal using Ctrl-Shift-Return. It will have the
* same CWD (current working directory) as the original st instance.
* https://st.suckless.org/patches/newterm/
*/
#define NEWTERM_PATCH 0
#define NEWTERM_PATCH 1
/* This patch will set the _MOTIF_WM_HINTS property for the st window which, if the window manager
* respects it, will show the st window without window decorations.
@ -264,6 +294,13 @@
*/
#define OPENURLONCLICK_PATCH 1
/* Reflow.
* Allows st to be resized without cutting off text when the terminal window is made larger again.
* Text wraps when the terminal window is made smaller.
* Comes with scrollback.
*/
#define REFLOW_PATCH 1
/* This patch allows you to specify a border that is relative in size to the width of a cell
* in the terminal.
* https://st.suckless.org/patches/relativeborder/
@ -279,13 +316,13 @@
/* Scroll back through terminal output using Shift+{PageUp, PageDown}.
* https://st.suckless.org/patches/scrollback/
*/
#define SCROLLBACK_PATCH 0
#define SCROLLBACK_PATCH 1
/* Scroll back through terminal output using Shift+MouseWheel.
* This variant depends on SCROLLBACK_PATCH being enabled.
* https://st.suckless.org/patches/scrollback/
*/
#define SCROLLBACK_MOUSE_PATCH 0
#define SCROLLBACK_MOUSE_PATCH 1
/* Scroll back through terminal output using mouse wheel (when not in MODE_ALTSCREEN).
* This variant depends on SCROLLBACK_PATCH being enabled.
@ -293,6 +330,13 @@
*/
#define SCROLLBACK_MOUSE_ALTSCREEN_PATCH 0
/* This patch adds the two color-settings selectionfg and selectionbg to config.def.h.
* Those define the fore- and background colors which are used when text on the screen is selected
* with the mouse. This removes the default behaviour which would simply reverse the colors.
* https://st.suckless.org/patches/selectioncolors/
*/
#define SELECTION_COLORS_PATCH 1
/* This is the single drawable buffer patch as outlined in the FAQ to get images
* in w3m to display. While this patch does not break the alpha patch it images
* are not shown in w3m if the alpha patch is applied.
@ -312,7 +356,7 @@
*
* https://gist.github.com/saitoha/70e0fdf22e3e8f63ce937c7f7da71809
*/
#define SIXEL_PATCH 0
#define SIXEL_PATCH 1
/* This patch allows clients to embed into the st window and is useful if you tend to
* start X applications from the terminal. For example:
@ -354,7 +398,7 @@
* when including this patch.
* https://st.suckless.org/patches/themed_cursor/
*/
#define THEMED_CURSOR_PATCH 1
#define THEMED_CURSOR_PATCH 0
/* Adds support for special underlines.
*
@ -397,17 +441,7 @@
/* Vertically center lines in the space available if you have set a larger chscale in config.h
* https://st.suckless.org/patches/vertcenter/
*/
#define VERTCENTER_PATCH 1
/* The vim-browse patch offers the possibility to move through the terminal history-buffer,
* search for strings using VIM-like motions, operations and quantifiers. It overlays the
* screen with highlighted search results and displays the current operation / motions / search
* string in the bottom right corner.
*
* https://github.com/juliusHuelsmann/st-history-vim
* https://st.suckless.org/patches/vim_browse/
*/
#define VIM_BROWSE_PATCH 0
#define VERTCENTER_PATCH 0
/* Briefly inverts window content on terminal bell event.
* https://st.suckless.org/patches/visualbell/
@ -445,10 +479,10 @@
* apply the resources named in the resources[] array in config.h.
* https://st.suckless.org/patches/xresources/
*/
#define XRESOURCES_PATCH 1
#define XRESOURCES_PATCH 0
/* This patch adds the ability to reload the Xresources config when a SIGUSR1 signal is received
* e.g.: killall -USR1 st
* Depends on the XRESOURCES_PATCH.
*/
#define XRESOURCES_RELOAD_PATCH 1
#define XRESOURCES_RELOAD_PATCH 0

View File

@ -0,0 +1,18 @@
--- a/x.c
+++ b/x.c
@@ -173,13 +173,13 @@ static char *usedfont = NULL;
static double usedfontsize = 0;
static double defaultfontsize = 0;
-static char *opt_class = NULL;
+static char *opt_class = "St";
static char **opt_cmd = NULL;
static char *opt_embed = NULL;
static char *opt_font = NULL;
static char *opt_io = NULL;
static char *opt_line = NULL;
-static char *opt_name = NULL;
+static char *opt_name = "st";
static char *opt_title = NULL;
static char *opt_dir = NULL;

View File

@ -4,7 +4,7 @@
* e. g.
* FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
*/
-hb_feature_t features[] = { 0 };
-hb_feature_t features[] = { };
+hb_feature_t features[] = {
+ FEATURE('c','v','0','2'),
+ FEATURE('c','v','1','6'),

11
patches/histsize.diff Normal file
View File

@ -0,0 +1,11 @@
--- a/st.h
+++ b/st.h
@@ -27,7 +27,7 @@
#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
#define IS_TRUECOL(x) (1 << 24 & (x))
-#define HISTSIZE 2000
+#define HISTSIZE 7500
enum glyph_attribute {
ATTR_NULL = 0,

View File

@ -1,74 +0,0 @@
--- a/st.h
+++ b/st.h
@@ -42,6 +42,7 @@ enum glyph_attribute {
ATTR_WDUMMY = 1 << 10,
ATTR_BOXDRAW = 1 << 11,
ATTR_LIGA = 1 << 12,
+ ATTR_SELECTED = 1 << 13,
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
ATTR_DIRTYUNDERLINE = 1 << 15,
};
--- a/x.c
+++ b/x.c
@@ -1565,6 +1565,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
}
}
+ if (base.mode & ATTR_SELECTED) {
+ bg = &dc.col[selectionbg];
+ if (!ignoreselfg)
+ fg = &dc.col[selectionfg];
+ }
+
if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
fg = bg;
@@ -2005,7 +2011,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
/* remove the old cursor */
if (selected(ox, oy))
- og.mode ^= ATTR_REVERSE;
+ og.mode |= ATTR_SELECTED;
/* Redraw the line where cursor was previously.
* It will restore the ligatures broken by the cursor. */
xdrawline(line, 0, oy, len);
@@ -2020,25 +2026,13 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
if (IS_SET(MODE_REVERSE)) {
g.mode |= ATTR_REVERSE;
+ g.fg = defaultcs;
g.bg = defaultfg;
- if (selected(cx, cy)) {
- drawcol = dc.col[defaultcs];
- g.fg = defaultrcs;
- } else {
- drawcol = dc.col[defaultrcs];
- g.fg = defaultcs;
- }
+ drawcol = dc.col[defaultrcs];
} else {
- if (selected(cx, cy)) {
- g.fg = defaultfg;
- g.bg = defaultrcs;
- }
- else {
- g.fg = defaultbg;
- g.bg = defaultcs;
- }
-
- drawcol = dc.col[g.bg];
+ g.fg = defaultbg;
+ g.bg = defaultcs;
+ drawcol = dc.col[defaultcs];
}
/* draw the new one */
@@ -2196,7 +2190,7 @@ xdrawline(Line line, int x1, int y1, int x2)
if (new.mode == ATTR_WDUMMY)
continue;
if (selected(x, y1))
- new.mode ^= ATTR_REVERSE;
+ new.mode |= ATTR_SELECTED;
if (i > 0 && ATTRCMP(base, new)) {
xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
specs += i;