From dc51c13fb5cd9cfa4b61dab7743308ba9ba19df7 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Thu, 18 Apr 2024 10:23:09 +0200 Subject: [PATCH] rework --- config.h | 38 +++++++++--------- config.mk | 2 +- patches.h | 74 +++++++++++++++++++++++++---------- patches/selection-colors.diff | 74 ----------------------------------- 4 files changed, 75 insertions(+), 113 deletions(-) delete mode 100644 patches/selection-colors.diff diff --git a/config.h b/config.h index 465a328..7c249bb 100644 --- a/config.h +++ b/config.h @@ -62,8 +62,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 = 5; +static double maxlatency = 30; /* * Synchronized-Update timeout in ms @@ -158,11 +158,10 @@ static const char *colorname[] = { unsigned int defaultcs = 256; unsigned int defaultrcs = 257; unsigned int defaultfg = 258; -unsigned int defaultbg = 0; -unsigned int bg = 259; +unsigned int defaultbg = 259; unsigned int selectionfg = 260; unsigned int selectionbg = 261; -static int ignoreselfg = 0; +static int ignoreselfg = 259; /* * 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 @@ -231,19 +230,22 @@ 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}}, - {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_Y, selpaste, {.i = 0}}, - {ShiftMask, XK_Insert, selpaste, {.i = 0}}, - {TERMMOD, XK_Num_Lock, numlock, {.i = 0}}, + /* 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}}, + { 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_Y, selpaste, {.i = 0}}, + { TERMMOD, XK_Num_Lock, numlock, {.i = 0}}, + { TERMMOD, XK_Escape, keyboard_select, {0}}, + { TERMMOD, XK_K, kscrollup, {.i = -1}, S_PRI }, + { TERMMOD, XK_J, kscrolldown, {.i = -1}, S_PRI }, }; /* diff --git a/config.mk b/config.mk index c4cf5a3..8e04344 100644 --- a/config.mk +++ b/config.mk @@ -25,7 +25,7 @@ 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 # includes and libs, uncomment harfbuzz for the ligatures patch INCS = -I$(X11INC) \ diff --git a/patches.h b/patches.h index 255e556..f5b2434 100644 --- a/patches.h +++ b/patches.h @@ -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/ @@ -213,9 +212,11 @@ #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,7 +316,7 @@ /* 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. @@ -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: @@ -399,16 +443,6 @@ */ #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 - /* Briefly inverts window content on terminal bell event. * https://st.suckless.org/patches/visualbell/ */ diff --git a/patches/selection-colors.diff b/patches/selection-colors.diff deleted file mode 100644 index f8ea091..0000000 --- a/patches/selection-colors.diff +++ /dev/null @@ -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;