Browse Source

Cattpuccin

main
Yigit Colakoglu 1 year ago
parent
commit
ae1dae2bf2
42 changed files with 2538 additions and 46 deletions
  1. +5
    -5
      .local/src/dmenu/colors.h
  2. BIN
      .local/src/dmenu/dmenu
  3. +1238
    -0
      .local/src/dmenu/dmenu.c.orig
  4. BIN
      .local/src/dmenu/dmenu.o
  5. BIN
      .local/src/dmenu/drw.o
  6. +25
    -0
      .local/src/dmenu/patches/dmenu-border-4.9.diff
  7. BIN
      .local/src/dmenu/stest
  8. BIN
      .local/src/dmenu/stest.o
  9. BIN
      .local/src/dmenu/util.o
  10. +1
    -3
      .local/src/dwm/keybinds.h
  11. +90
    -0
      .local/src/dwm/patches/dwm-focusmaster-return-6.2.diff
  12. +58
    -0
      .local/src/dwm/patches/dwm-sticky-6.1.diff
  13. +95
    -0
      .local/src/dwm/patches/dwm-zoomswap-6.2.diff
  14. +4
    -1
      .local/src/dwm/rules.h
  15. +2
    -2
      .local/src/dwm/theme.h
  16. +4
    -4
      .local/src/dwmblocks/config.h
  17. BIN
      .local/src/dwmblocks/dwmblocks
  18. BIN
      .local/src/dwmblocks/dwmblocks.o
  19. BIN
      .local/src/paleofetch/paleofetch
  20. BIN
      .local/src/scroll/scroll
  21. +250
    -0
      .local/src/slock/slock-message-20191002-b46028b.diff
  22. +1
    -0
      .local/src/st/.gitignore
  23. +32
    -31
      .local/src/st/config.h
  24. +74
    -0
      .local/src/st/patches/st-externalpipe-eternal-0.8.3.diff
  25. +42
    -0
      .local/src/st/patches/st-w3m-0.8.3.diff
  26. BIN
      .local/src/st/st
  27. +600
    -0
      .local/src/st/st-boxdraw_v2-0.8.3.diff
  28. BIN
      .local/src/st/st.o
  29. BIN
      .local/src/st/x.o
  30. +17
    -0
      .local/src/sxiv/.ccls
  31. BIN
      .local/src/sxiv/autoreload_inotify.o
  32. BIN
      .local/src/sxiv/commands.o
  33. BIN
      .local/src/sxiv/image.o
  34. BIN
      .local/src/sxiv/main.o
  35. BIN
      .local/src/sxiv/options.o
  36. BIN
      .local/src/sxiv/thumbs.o
  37. BIN
      .local/src/sxiv/util.o
  38. BIN
      .local/src/sxiv/window.o
  39. BIN
      .local/src/tabbed/tabbed
  40. BIN
      .local/src/tabbed/tabbed.o
  41. BIN
      .local/src/tabbed/xembed
  42. BIN
      .local/src/tabbed/xembed.o

+ 5
- 5
.local/src/dmenu/colors.h View File

@ -3,11 +3,11 @@
static const unsigned int border_width = 0; /* Fix border transparency */
static const char *colors[SchemeLast][2] = {
/* fg bg */
[SchemeNorm] = { "#e5e9f0", "#0f111a", "#bf616a" },
[SchemeSel] = { "#0f111a", "#bf616a", "#bf616a" },
[SchemeOut] = { "#000000", "#00ffff", "#bf616a" },
[SchemeNormHighlight] = { "#81a1c1", "#0f111a", "#bf616a" },
[SchemeSelHighlight] = { "#88c0d0", "#bf616a", "#bf616a" },
[SchemeNorm] = { "#cdd6f4", "#1e1e2e" },
[SchemeSel] = { "#1e1e2e", "#89dceb" },
[SchemeOut] = { "#000000", "#89dceb" },
[SchemeNormHighlight] = { "#cdd6f4", "#1e1e2e", "#1e1e2e" },
[SchemeSelHighlight] = { "#1e1e2e", "#89dceb", "#a6e3a1" },
};


BIN
.local/src/dmenu/dmenu View File


+ 1238
- 0
.local/src/dmenu/dmenu.c.orig
File diff suppressed because it is too large
View File


BIN
.local/src/dmenu/dmenu.o View File


BIN
.local/src/dmenu/drw.o View File


+ 25
- 0
.local/src/dmenu/patches/dmenu-border-4.9.diff View File

@ -0,0 +1,25 @@
diff -up dmenu-4.9-b/config.def.h dmenu-4.9-a/config.def.h
--- dmenu-4.9-b/config.def.h 2019-02-02 13:55:02.000000000 +0100
+++ dmenu-4.9-a/config.def.h 2019-05-19 02:10:12.740040403 +0200
@@ -21,3 +21,6 @@ static unsigned int lines = 0;
* for example: " /?\"&[]"
*/
static const char worddelimiters[] = " ";
+
+/* Size of the window border */
+static const unsigned int border_width = 5;
diff -up dmenu-4.9-b/dmenu.c dmenu-4.9-a/dmenu.c
--- dmenu-4.9-b/dmenu.c 2019-02-02 13:55:02.000000000 +0100
+++ dmenu-4.9-a/dmenu.c 2019-05-19 02:11:20.966710117 +0200
@@ -654,9 +654,10 @@ setup(void)
swa.override_redirect = True;
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
XSetClassHint(dpy, win, &ch);
/* open input methods */

BIN
.local/src/dmenu/stest View File


BIN
.local/src/dmenu/stest.o View File


BIN
.local/src/dmenu/util.o View File


+ 1
- 3
.local/src/dwm/keybinds.h View File

@ -38,8 +38,7 @@ static const char *refresh[] = {"/home/yigit/.local/bin/dmenu-refresh", NULL};
static const char *keyboard[] = {"/home/yigit/.local/bin/kbmap_toggle", NULL};
static const char *screenshot[] = { "scrot", "/tmp/%Y-%m-%d-%s_$wx$h.png", "-e","xclip -selection clipboard -target image/png -i $f; cp $f ~/Pictures/Screenshots;notify-send -a \"SNAP\" \"$f\"", NULL };
static const char *selectshot[] = { "scrot", "-s","/tmp/%Y-%m-%d-%s_$wx$h.png", "-e","xclip -selection clipboard -target image/png -i $f; cp $f ~/Pictures/Screenshots;notify-send -a \"SNAP\" \"$f\"", NULL };
static const char *windowshot[] = { "scrot", "-u", "/tmp/%Y-%m-%d-%s_$wx$h.png", "-e","xclip -selection clipboard -target image/png -i $f; cp $f ~/Pictures/Screenshots;notify-send -a \"SNAP\" \"$f\"", NULL };
static const char *windowshot[] = { "flameshot", "gui", NULL };
static const char *simcrop[] = {"simcrop","-fc","-sc", "-g", "900x500",NULL};
static const char *notification[] = {"/home/yigit/.local/bin/dunst_toggle.sh", "-t",NULL};
@ -135,7 +134,6 @@ static Key keys[] = {
{ 0, XK_Print, spawn, {.v = screenshot } },
{ MODKEY|ShiftMask|Mod1Mask, XK_s, togglesticky, { 0 } },
{ MODKEY, XK_Print, spawn, {.v = windowshot } },
{ MODKEY|Mod1Mask, XK_Print, spawn, {.v = selectshot } },
{ MODKEY|ShiftMask, XK_s, spawn, {.v = xrandr } },
{ MODKEY|ShiftMask, XK_l, spawn, {.v = sessionload } },
{ MODKEY, XK_u, spawn, {.v = web} },


+ 90
- 0
.local/src/dwm/patches/dwm-focusmaster-return-6.2.diff View File

@ -0,0 +1,90 @@
From 8f662e7a556f94bda83ec724fb036e15b2badaac Mon Sep 17 00:00:00 2001
From: Jack Bird <jack.bird@durham.ac.uk>
Date: Fri, 27 Aug 2021 01:14:44 +0100
Subject: [PATCH] 6.2 focusmaster return
---
dwm.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/dwm.c b/dwm.c
index 4465af1..5219cbd 100644
--- a/dwm.c
+++ b/dwm.c
@@ -127,6 +127,7 @@ struct Monitor {
Client *clients;
Client *sel;
Client *stack;
+ Client *tagmarked[32];
Monitor *next;
Window barwin;
const Layout *lt[2];
@@ -167,6 +168,7 @@ static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
static void focusin(XEvent *e);
+static void focusmaster(const Arg *arg);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
static int getrootptr(int *x, int *y);
@@ -659,6 +661,10 @@ detach(Client *c)
{
Client **tc;
+ for (int i = 1; i < LENGTH(tags); i++)
+ if (c == c->mon->tagmarked[i])
+ c->mon->tagmarked[i] = NULL;
+
for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
*tc = c->next;
}
@@ -815,6 +821,34 @@ focusin(XEvent *e)
setfocus(selmon->sel);
}
+void
+focusmaster(const Arg *arg)
+{
+ Client *master;
+
+ if (selmon->nmaster > 1)
+ return;
+ if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
+ return;
+
+ master = nexttiled(selmon->clients);
+
+ if (!master)
+ return;
+
+ int i;
+ for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);
+ i++;
+
+ if (selmon->sel == master) {
+ if (selmon->tagmarked[i] && ISVISIBLE(selmon->tagmarked[i]))
+ focus(selmon->tagmarked[i]);
+ } else {
+ selmon->tagmarked[i] = selmon->sel;
+ focus(master);
+ }
+}
+
void
focusmon(const Arg *arg)
{
@@ -1202,6 +1236,11 @@ nexttiled(Client *c)
void
pop(Client *c)
{
+ int i;
+ for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);
+ i++;
+
+ c->mon->tagmarked[i] = nexttiled(c->mon->clients);
detach(c);
attach(c);
focus(c);
--
2.33.0

+ 58
- 0
.local/src/dwm/patches/dwm-sticky-6.1.diff View File

@ -0,0 +1,58 @@
diff --git a/config.def.h b/config.def.h
index 7054c06..9b5d5b8 100644
--- a/config.def.h
+++ b/config.def.h
@@ -76,6 +76,7 @@ static Key keys[] = {
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_s, togglesticky, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
diff --git a/dwm.c b/dwm.c
index 0362114..0ef5c7f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -49,7 +49,7 @@
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
-#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
@@ -92,7 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, issticky;
Client *next;
Client *snext;
Monitor *mon;
@@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void togglesticky(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -1713,6 +1714,15 @@ togglefloating(const Arg *arg)
}
void
+togglesticky(const Arg *arg)
+{
+ if (!selmon->sel)
+ return;
+ selmon->sel->issticky = !selmon->sel->issticky;
+ arrange(selmon);
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;

+ 95
- 0
.local/src/dwm/patches/dwm-zoomswap-6.2.diff View File

@ -0,0 +1,95 @@
From 3867ef5a68e15a4faff377ddbc8371853de4a800 Mon Sep 17 00:00:00 2001
From: aleks <aleks.stier@icloud.com>
Date: Sat, 19 Oct 2019 00:56:21 +0200
Subject: [PATCH] Put master to exact position of zoomed client
The default behaviour when zooming a client is to put the previous
master on top of the client-stack. This patch puts the master to the
exact position of the zoomed client in the stack.
---
dwm.c | 44 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/dwm.c b/dwm.c
index 4465af1..1719b36 100644
--- a/dwm.c
+++ b/dwm.c
@@ -165,6 +165,7 @@ static void drawbar(Monitor *m);
static void drawbars(void);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
+static Client *findbefore(Client *c);
static void focus(Client *c);
static void focusin(XEvent *e);
static void focusmon(const Arg *arg);
@@ -235,6 +236,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
/* variables */
+static Client *prevzoom = NULL;
static const char broken[] = "broken";
static char stext[256];
static int screen;
@@ -780,6 +782,16 @@ expose(XEvent *e)
drawbar(m);
}
+Client *
+findbefore(Client *c)
+{
+ Client *tmp;
+ if (c == selmon->clients)
+ return NULL;
+ for (tmp = selmon->clients; tmp && tmp->next != c; tmp = tmp->next);
+ return tmp;
+}
+
void
focus(Client *c)
{
@@ -2114,14 +2126,38 @@ void
zoom(const Arg *arg)
{
Client *c = selmon->sel;
+ Client *at = NULL, *cold, *cprevious = NULL;
if (!selmon->lt[selmon->sellt]->arrange
|| (selmon->sel && selmon->sel->isfloating))
return;
- if (c == nexttiled(selmon->clients))
- if (!c || !(c = nexttiled(c->next)))
- return;
- pop(c);
+ if (c == nexttiled(selmon->clients)) {
+ at = findbefore(prevzoom);
+ if (at)
+ cprevious = nexttiled(at->next);
+ if (!cprevious || cprevious != prevzoom) {
+ prevzoom = NULL;
+ if (!c || !(c = nexttiled(c->next)))
+ return;
+ } else
+ c = cprevious;
+ }
+ cold = nexttiled(selmon->clients);
+ if (c != cold && !at)
+ at = findbefore(c);
+ detach(c);
+ attach(c);
+ /* swap windows instead of pushing the previous one down */
+ if (c != cold && at) {
+ prevzoom = cold;
+ if (cold && at != cold) {
+ detach(cold);
+ cold->next = at->next;
+ at->next = cold;
+ }
+ }
+ focus(c);
+ arrange(c->mon);
}
int
--
2.23.0

+ 4
- 1
.local/src/dwm/rules.h View File

@ -20,6 +20,7 @@ static const Rule rules[] = {
/* class instance title tags mask isfloating floatpos isterminal noswallow monitor */
{ "discord" , NULL , NULL , 1 << 8 , NULL , NULL , 0 , 0 , -1 },
{ "spot" , NULL , NULL , 1 << 8 , NULL , NULL , 0 , 0 , -1 },
{ "Signal" , NULL , NULL , 1 << 8 , NULL , NULL , 0 , 0 , -1 },
{ "Brave-browser" , NULL , NULL , 1 << 1 , NULL , NULL , 0 , 0 , -1 },
{ "Firefox" , NULL , NULL , 1 << 1 , NULL , NULL , 0 , 0 , -1 },
@ -29,7 +30,8 @@ static const Rule rules[] = {
{ "tabbed-surf" , NULL , NULL , 1 << 1 , NULL , NULL , 0 , 0 , -1 },
{ "bitwarden" , NULL , NULL , 1 << 6 , NULL , NULL , 0 , 0 , -1 },
{ "QtPass" , NULL , NULL , 1 << 6 , NULL , NULL , 0 , 0 , -1 },
{ "st-256color" , NULL , NULL , 1 << 0 , NULL , NULL , 1 , 0 , -1 },
{ "st-256color" , NULL , NULL , 1 << 0 , NULL , NULL , 1 , 1 , -1 },
{ "gef_helper" , NULL , NULL , 0 , NULL , NULL , 1 , 1 , -1 },
{ "Tor Browser" , NULL , NULL , 1 << 1 , NULL , NULL , 0 , 0 , -1 },
{ "TelegramDesktop" , NULL , NULL , 1 << 8 , NULL , NULL , 0 , 0 , -1 },
{ "thunderbird" , NULL , NULL , 1 << 7 , NULL , NULL , 0 , 0 , -1 },
@ -50,6 +52,7 @@ static const Rule rules[] = {
{ "htop" , NULL , NULL , 0 , 1 , "50% 50% 1200W 600H" , 0 , 0 , -1 },
{ "Pavucontrol" , NULL , NULL , 0 , 1 , "50% 50% 1200W 600H" , 0 , 0 , -1 },
{ "Zathura" , NULL , NULL , 0 , 0 , NULL , 0 , 1 , -1 },
{ "DEA" , NULL , NULL , 0 , 1 , NULL , 0 , 1 , -1 },
{ "Qemu-system-x86_64", NULL , NULL , 0 , 1 , NULL , 0 , 1 , -1 },
{ "spfeh" , NULL , NULL , SPTAG(1) , 1 , NULL , 0 , 0 , -1 },
{ "obsidian" , NULL , NULL , 1 << 4 , 0 , NULL , 0 , 1 , -1 },


+ 2
- 2
.local/src/dwm/theme.h View File

@ -27,8 +27,8 @@ static int floatposgrid_x = 5; /* float grid columns */
static int floatposgrid_y = 5; /* float grid rows */
static const char *fonts[] = { "CaskaydiaCove Nerd Font:size=10" };
static const char fore[] = "#e5e9f0";
static const char back[] = "#0f111a";
static const char fore[] = "#cdd6f4";
static const char back[] = "#1e1e2e";
static const char border[] = "#3a575c";
static const char col0[] = "#3b4252";
static const char col1[] = "#bf616a"; /* red */


+ 4
- 4
.local/src/dwmblocks/config.h View File

@ -17,12 +17,12 @@ static Block blocks[] = {
{ "", PATH("keyboard"), 120, 24},
{ "", PATH("redshift"), 120, 29},
// { "", PATH("mpc"), 240, 29},
{ "", PATH("hamster"), 60, 31},
// { "", PATH("hamster"), 60, 31},
{ "", PATH("bluetooth"), 120, 26},
{ "", PATH("timer"), 5, 30},
{ "", PATH("mconnect"), 120, 20},
{ "", PATH("todo"), 120, 27},
{ "", PATH("nextcloud"), 600, 25},
// { "", PATH("mconnect"), 120, 20},
// { "", PATH("todo"), 120, 27},
// { "", PATH("nextcloud"), 600, 25},
{ "", PATH("cpu-temp"), 30, 17},
{ "", PATH("memory"), 120, 21},
{ "", PATH("weather"), 60, 16},


BIN
.local/src/dwmblocks/dwmblocks View File


BIN
.local/src/dwmblocks/dwmblocks.o View File


BIN
.local/src/paleofetch/paleofetch View File


BIN
.local/src/scroll/scroll View File


+ 250
- 0
.local/src/slock/slock-message-20191002-b46028b.diff View File

@ -0,0 +1,250 @@
From b46028b2797b886154258dcafe71c349cdc68b43 Mon Sep 17 00:00:00 2001
From: Blair Drummond <blair.robert.drummond@gmail.com>
Date: Wed, 2 Oct 2019 14:59:00 -0400
Subject: [PATCH] Add a message command. Fixes old version's bugs.
---
config.def.h | 9 ++++
config.mk | 2 +-
slock.1 | 7 +++
slock.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 133 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index 9855e21..c2a0ab2 100644
--- a/config.def.h
+++ b/config.def.h
@@ -10,3 +10,12 @@ static const char *colorname[NUMCOLS] = {
/* treat a cleared input like a wrong password (color) */
static const int failonclear = 1;
+
+/* default message */
+static const char * message = "Suckless: Software that sucks less.";
+
+/* text color */
+static const char * text_color = "#ffffff";
+
+/* text size (must be a valid size) */
+static const char * font_name = "6x10";
diff --git a/config.mk b/config.mk
index 74429ae..c4ccf66 100644
--- a/config.mk
+++ b/config.mk
@@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib
# includes and libs
INCS = -I. -I/usr/include -I${X11INC}
-LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr
+LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lXinerama
# flags
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
diff --git a/slock.1 b/slock.1
index 82cdcd6..946165f 100644
--- a/slock.1
+++ b/slock.1
@@ -6,6 +6,8 @@
.Sh SYNOPSIS
.Nm
.Op Fl v
+.Op Fl f
+.Op Fl m Ar message
.Op Ar cmd Op Ar arg ...
.Sh DESCRIPTION
.Nm
@@ -16,6 +18,11 @@ is executed after the screen has been locked.
.Bl -tag -width Ds
.It Fl v
Print version information to stdout and exit.
+.It Fl f
+List all valid X fonts and exit.
+.It Fl m Ar message
+Overrides default slock lock message.
+.TP
.El
.Sh SECURITY CONSIDERATIONS
To make sure a locked screen can not be bypassed by switching VTs
diff --git a/slock.c b/slock.c
index 5ae738c..610929b 100644
--- a/slock.c
+++ b/slock.c
@@ -15,6 +15,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <X11/extensions/Xrandr.h>
+#include <X11/extensions/Xinerama.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -24,6 +25,9 @@
char *argv0;
+/* global count to prevent repeated error messages */
+int count_error = 0;
+
enum {
INIT,
INPUT,
@@ -83,6 +87,98 @@ dontkillme(void)
}
#endif
+static void
+writemessage(Display *dpy, Window win, int screen)
+{
+ int len, line_len, width, height, s_width, s_height, i, j, k, tab_replace, tab_size;
+ XGCValues gr_values;
+ XFontStruct *fontinfo;
+ XColor color, dummy;
+ XineramaScreenInfo *xsi;
+ GC gc;
+ fontinfo = XLoadQueryFont(dpy, font_name);
+
+ if (fontinfo == NULL) {
+ if (count_error == 0) {
+ fprintf(stderr, "slock: Unable to load font \"%s\"\n", font_name);
+ fprintf(stderr, "slock: Try listing fonts with 'slock -f'\n");
+ count_error++;
+ }
+ return;
+ }
+
+ tab_size = 8 * XTextWidth(fontinfo, " ", 1);
+
+ XAllocNamedColor(dpy, DefaultColormap(dpy, screen),
+ text_color, &color, &dummy);
+
+ gr_values.font = fontinfo->fid;
+ gr_values.foreground = color.pixel;
+ gc=XCreateGC(dpy,win,GCFont+GCForeground, &gr_values);
+
+ /* To prevent "Uninitialized" warnings. */
+ xsi = NULL;
+
+ /*
+ * Start formatting and drawing text
+ */
+
+ len = strlen(message);
+
+ /* Max max line length (cut at '\n') */
+ line_len = 0;
+ k = 0;
+ for (i = j = 0; i < len; i++) {
+ if (message[i] == '\n') {
+ if (i - j > line_len)
+ line_len = i - j;
+ k++;
+ i++;
+ j = i;
+ }
+ }
+ /* If there is only one line */
+ if (line_len == 0)
+ line_len = len;
+
+ if (XineramaIsActive(dpy)) {
+ xsi = XineramaQueryScreens(dpy, &i);
+ s_width = xsi[0].width;
+ s_height = xsi[0].height;
+ } else {
+ s_width = DisplayWidth(dpy, screen);
+ s_height = DisplayHeight(dpy, screen);
+ }
+
+ height = s_height*3/7 - (k*20)/3;
+ width = (s_width - XTextWidth(fontinfo, message, line_len))/2;
+
+ /* Look for '\n' and print the text between them. */
+ for (i = j = k = 0; i <= len; i++) {
+ /* i == len is the special case for the last line */
+ if (i == len || message[i] == '\n') {
+ tab_replace = 0;
+ while (message[j] == '\t' && j < i) {
+ tab_replace++;
+ j++;
+ }
+
+ XDrawString(dpy, win, gc, width + tab_size*tab_replace, height + 20*k, message + j, i - j);
+ while (i < len && message[i] == '\n') {
+ i++;
+ j = i;
+ k++;
+ }
+ }
+ }
+
+ /* xsi should not be NULL anyway if Xinerama is active, but to be safe */
+ if (XineramaIsActive(dpy) && xsi != NULL)
+ XFree(xsi);
+}
+
+
+
static const char *
gethash(void)
{
@@ -194,6 +290,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
locks[screen]->win,
locks[screen]->colors[color]);
XClearWindow(dpy, locks[screen]->win);
+ writemessage(dpy, locks[screen]->win, screen);
}
oldc = color;
}
@@ -300,7 +397,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
static void
usage(void)
{
- die("usage: slock [-v] [cmd [arg ...]]\n");
+ die("usage: slock [-v] [-f] [-m message] [cmd [arg ...]]\n");
}
int
@@ -313,12 +410,25 @@ main(int argc, char **argv) {
gid_t dgid;
const char *hash;
Display *dpy;
- int s, nlocks, nscreens;
+ int i, s, nlocks, nscreens;
+ int count_fonts;
+ char **font_names;
ARGBEGIN {
case 'v':
fprintf(stderr, "slock-"VERSION"\n");
return 0;
+ case 'm':
+ message = EARGF(usage());
+ break;
+ case 'f':
+ if (!(dpy = XOpenDisplay(NULL)))
+ die("slock: cannot open display\n");
+ font_names = XListFonts(dpy, "*", 10000 /* list 10000 fonts*/, &count_fonts);
+ for (i=0; i<count_fonts; i++) {
+ fprintf(stderr, "%s\n", *(font_names+i));
+ }
+ return 0;
default:
usage();
} ARGEND
@@ -363,10 +473,12 @@ main(int argc, char **argv) {
if (!(locks = calloc(nscreens, sizeof(struct lock *))))
die("slock: out of memory\n");
for (nlocks = 0, s = 0; s < nscreens; s++) {
- if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL)
+ if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL) {
+ writemessage(dpy, locks[s]->win, s);
nlocks++;
- else
+ } else {
break;
+ }
}
XSync(dpy, 0);
--
2.20.1

+ 1
- 0
.local/src/st/.gitignore View File

@ -0,0 +1 @@
ccls-cache

+ 32
- 31
.local/src/st/config.h View File

@ -56,41 +56,42 @@ char *termname = "st-256color";
unsigned int tabspaces = 8;
/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
/* 8 normal colors */
"#45475A",
"#F38BA8",
"#A6E3A1",
"#F9E2AF",
"#89B4FA",
"#F5C2E7",
"#94E2D5",
"#BAC2DE",
/* 8 bright colors */
"#585B70",
"#F38BA8",
"#A6E3A1",
"#F9E2AF",
"#89B4FA",
"#F5C2E7",
"#94E2D5",
"#A6ADC8",
[256] = "#CDD6F4", /* default foreground colour */
[257] = "#1E1E2E", /* default background colour */
[258] = "#F5E0DC", /*575268*/
/* 8 normal colors */
[0] = "#3b4252", /* black */
[1] = "#bf616a", /* red */
[2] = "#a3be8c", /* green */
[3] = "#ebcb8b", /* yellow */
[4] = "#81a1c1", /* blue */
[5] = "#b48ead", /* magenta */
[6] = "#88c0d0", /* cyan */
[7] = "#e5e9f0", /* white */
/* 8 bright colors */
[8] = "#4c566a", /* black */
[9] = "#bf616a", /* red */
[10] = "#a3be8c", /* green */
[11] = "#ebcb8b", /* yellow */
[12] = "#81a1c1", /* blue */
[13] = "#b48ead", /* magenta */
[14] = "#8fbcbb", /* cyan */
[15] = "#eceff4", /* white */
/* special colors */
[256] = "#0f111a", /* background */
[257] = "#d8dee9", /* foreground */
/* More special colors */
};
unsigned int defaultfg = 257;
unsigned int defaultbg = 256;
unsigned int bg = 256, bgUnfocused = 256;
static unsigned int defaultcs = 257;
static unsigned int defaultrcs = 256;
/*
* foreground, background, cursor, reverse cursor
*/
unsigned int defaultfg = 256;
unsigned int defaultbg = 257;
unsigned int defaultcs = 258;
unsigned int bg = 257, bgUnfocused = 257;
static unsigned int defaultrcs = 258;
static unsigned int defaultitalic = 7;
static unsigned int defaultunderline = 7;


+ 74
- 0
.local/src/st/patches/st-externalpipe-eternal-0.8.3.diff View File

@ -0,0 +1,74 @@
From 2228468a6db1e648c69849860d30867c0e77650e Mon Sep 17 00:00:00 2001
From: AtomToast <reg-2@t-online.de>
Date: Wed, 29 Apr 2020 02:31:29 +0200
Subject: [PATCH] apply Luke Smiths external pipe eternal patch
Enables external pipe to work on the entire scrollback history.
Source: https://github.com/LukeSmithxyz/st/commit/da13ef12463d1870caed94584db464d68c6b3182
Made to work on semi-vanilla st.
This patch requires both externalpipe and scrollback patch in order to work
---
st.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/st.c b/st.c
index d4c88a2..2716f44 100644
--- a/st.c
+++ b/st.c
@@ -46,6 +46,7 @@
#define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - \
term.scr + HISTSIZE + 1) % HISTSIZE] : \
term.line[(y) - term.scr])
+#define TLINE_HIST(y) ((y) <= HISTSIZE-term.row+2 ? term.hist[(y)] : term.line[(y-HISTSIZE+term.row-3)])
enum term_mode {
MODE_WRAP = 1 << 0,
@@ -431,6 +432,20 @@ tlinelen(int y)
return i;
}
+int
+tlinehistlen(int y)
+{
+ int i = term.col;
+
+ if (TLINE_HIST(y)[i - 1].mode & ATTR_WRAP)
+ return i;
+
+ while (i > 0 && TLINE_HIST(y)[i - 1].u == ' ')
+ --i;
+
+ return i;
+}
+
void
selstart(int col, int row, int snap)
{
@@ -2025,16 +2040,18 @@ externalpipe(const Arg *arg)
/* ignore sigpipe for now, in case child exists early */
oldsigpipe = signal(SIGPIPE, SIG_IGN);
newline = 0;
- for (n = 0; n < term.row; n++) {
- bp = term.line[n];
- lastpos = MIN(tlinelen(n) + 1, term.col) - 1;
+ for (n = 0; n <= HISTSIZE + 2; n++) {
+ bp = TLINE_HIST(n);
+ lastpos = MIN(tlinehistlen(n) + 1, term.col) - 1;
if (lastpos < 0)
break;
+ if (lastpos == 0)
+ continue;
end = &bp[lastpos + 1];
for (; bp < end; ++bp)
if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
break;
- if ((newline = term.line[n][lastpos].mode & ATTR_WRAP))
+ if ((newline = TLINE_HIST(n)[lastpos].mode & ATTR_WRAP))
continue;
if (xwrite(to[1], "\n", 1) < 0)
break;
--
2.26.2

+ 42
- 0
.local/src/st/patches/st-w3m-0.8.3.diff View File

@ -0,0 +1,42 @@
From 69cffc587b54b0a9cd81adb87abad8e526d5b25b Mon Sep 17 00:00:00 2001
From: "Avi Halachmi (:avih)" <avihpit@yahoo.com>
Date: Thu, 4 Jun 2020 17:35:08 +0300
Subject: [PATCH] support w3m images
w3m images are a hack which renders on top of the terminal's drawable,
which didn't work in st because when using double buffering, the front
buffer (on which w3m draws its images) is ignored, and st draws only
on the back buffer, which is then copied to the front buffer.
There's a patch to make it work at the FAQ already, but that patch
canceles double-buffering, which can have negative side effects on
some cases such as flickering.
This patch achieves the same goal but instead of canceling the double
buffer it first copies the front buffer to the back buffer.
This has the same issues as the FAQ patch in that the cursor line is
deleted at the image (because st renders always full lines), but
otherwise it's simpler and does keeps double buffering.
---
x.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/x.c b/x.c
index e5f1737..b6ae162 100644
--- a/x.c
+++ b/x.c
@@ -1594,6 +1594,8 @@ xsettitle(char *p)
int
xstartdraw(void)
{
+ if (IS_SET(MODE_VISIBLE))
+ XCopyArea(xw.dpy, xw.win, xw.buf, dc.gc, 0, 0, win.w, win.h, 0, 0);
return IS_SET(MODE_VISIBLE);
}
base-commit: 43a395ae91f7d67ce694e65edeaa7bbc720dd027
--
2.17.1

BIN
.local/src/st/st View File


+ 600
- 0
.local/src/st/st-boxdraw_v2-0.8.3.diff View File

@ -0,0 +1,600 @@
From 3f3b80b9966c60086f4ed80ce4de0cbf03468d36 Mon Sep 17 00:00:00 2001
From: "Avi Halachmi (:avih)" <avihpit@yahoo.com>
Date: Wed, 26 Dec 2018 14:51:45 +0200
Subject: [PATCH] boxdraw_v2: custom render lines/blocks/braille for perfect
alignment
It seems impossible to ensure that blocks and line drawing glyphs
align without visible gaps for all combinations of arbitrary font,
size and width/height scale factor.
This commit adds options to render most of the lines/blocks and
braille codepoints without using the font such that they align
perfectly regardless of font, size or other configuration values.
Supported codepoints are U+2500 - U+259F except dashes/diagonals,
and U28XX.
The lines/blocks data is stored as 16-bit values at boxdraw_data.h
boxdraw/braille are independent, disabled by default at config[.def].h
---
Makefile | 3 +-
boxdraw.c | 194 ++++++++++++++++++++++++++++++++++++++++++++
boxdraw_data.h | 214 +++++++++++++++++++++++++++++++++++++++++++++++++
config.def.h | 12 +++
st.c | 3 +
st.h | 10 +++
x.c | 21 +++--
7 files changed, 451 insertions(+), 6 deletions(-)
create mode 100644 boxdraw.c
create mode 100644 boxdraw_data.h
diff --git a/Makefile b/Makefile
index 470ac86..6dfa212 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
include config.mk
-SRC = st.c x.c
+SRC = st.c x.c boxdraw.c
OBJ = $(SRC:.c=.o)
all: options st
@@ -23,6 +23,7 @@ config.h:
st.o: config.h st.h win.h
x.o: arg.h config.h st.h win.h
+boxdraw.o: config.h st.h boxdraw_data.h
$(OBJ): config.h config.mk
diff --git a/boxdraw.c b/boxdraw.c
new file mode 100644
index 0000000..28a92d0
--- /dev/null
+++ b/boxdraw.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2018 Avi Halachmi (:avih) avihpit@yahoo.com https://github.com/avih
+ * MIT/X Consortium License
+ */
+
+#include <X11/Xft/Xft.h>
+#include "st.h"
+#include "boxdraw_data.h"
+
+/* Rounded non-negative integers division of n / d */
+#define DIV(n, d) (((n) + (d) / 2) / (d))
+
+static Display *xdpy;
+static Colormap xcmap;
+static XftDraw *xd;
+static Visual *xvis;
+
+static void drawbox(int, int, int, int, XftColor *, XftColor *, ushort);
+static void drawboxlines(int, int, int, int, XftColor *, ushort);
+
+/* public API */
+
+void
+boxdraw_xinit(Display *dpy, Colormap cmap, XftDraw *draw, Visual *vis)
+{
+ xdpy = dpy; xcmap = cmap; xd = draw, xvis = vis;
+}
+
+int
+isboxdraw(Rune u)
+{
+ Rune block = u & ~0xff;
+ return (boxdraw && block == 0x2500 && boxdata[(uint8_t)u]) ||
+ (boxdraw_braille && block == 0x2800);
+}
+
+/* the "index" is actually the entire shape data encoded as ushort */
+ushort
+boxdrawindex(const Glyph *g)
+{
+ if (boxdraw_braille && (g->u & ~0xff) == 0x2800)
+ return BRL | (uint8_t)g->u;
+ if (boxdraw_bold && (g->mode & ATTR_BOLD))
+ return BDB | boxdata[(uint8_t)g->u];
+ return boxdata[(uint8_t)g->u];
+}
+
+void
+drawboxes(int x, int y, int cw, int ch, XftColor *fg, XftColor *bg,
+ const XftGlyphFontSpec *specs, int len)
+{
+ for ( ; len-- > 0; x += cw, specs++)
+ drawbox(x, y, cw, ch, fg, bg, (ushort)specs->glyph);
+}
+
+/* implementation */
+
+void
+drawbox(int x, int y, int w, int h, XftColor *fg, XftColor *bg, ushort bd)
+{
+ ushort cat = bd & ~(BDB | 0xff); /* mask out bold and data */
+ if (bd & (BDL | BDA)) {
+ /* lines (light/double/heavy/arcs) */
+ drawboxlines(x, y, w, h, fg, bd);
+
+ } else if (cat == BBD) {
+ /* lower (8-X)/8 block */
+ int d = DIV((uint8_t)bd * h, 8);
+ XftDrawRect(xd, fg, x, y + d, w, h - d);
+
+ } else if (cat == BBU) {
+ /* upper X/8 block */
+ XftDrawRect(xd, fg, x, y, w, DIV((uint8_t)bd * h, 8));
+
+ } else if (cat == BBL) {
+ /* left X/8 block */
+ XftDrawRect(xd, fg, x, y, DIV((uint8_t)bd * w, 8), h);
+
+ } else if (cat == BBR) {
+ /* right (8-X)/8 block */
+ int d = DIV((uint8_t)bd * w, 8);
+ XftDrawRect(xd, fg, x + d, y, w - d, h);
+
+ } else if (cat == BBQ) {
+ /* Quadrants */
+ int w2 = DIV(w, 2), h2 = DIV(h, 2);
+ if (bd & TL)
+ XftDrawRect(xd, fg, x, y, w2, h2);
+ if (bd & TR)
+ XftDrawRect(xd, fg, x + w2, y, w - w2, h2);
+ if (bd & BL)
+ XftDrawRect(xd, fg, x, y + h2, w2, h - h2);
+ if (bd & BR)
+ XftDrawRect(xd, fg, x + w2, y + h2, w - w2, h - h2);
+
+ } else if (bd & BBS) {
+ /* Shades - data is 1/2/3 for 25%/50%/75% alpha, respectively */
+ int d = (uint8_t)bd;
+ XftColor xfc;
+ XRenderColor xrc = { .alpha = 0xffff };
+
+ xrc.red = DIV(fg->color.red * d + bg->color.red * (4 - d), 4);
+ xrc.green = DIV(fg->color.green * d + bg->color.green * (4 - d), 4);
+ xrc.blue = DIV(fg->color.blue * d + bg->color.blue * (4 - d), 4);
+
+ XftColorAllocValue(xdpy, xvis, xcmap, &xrc, &xfc);
+ XftDrawRect(xd, &xfc, x, y, w, h);
+ XftColorFree(xdpy, xvis, xcmap, &xfc);
+
+ } else if (cat == BRL) {
+ /* braille, each data bit corresponds to one dot at 2x4 grid */
+ int w1 = DIV(w, 2);
+ int h1 = DIV(h, 4), h2 = DIV(h, 2), h3 = DIV(3 * h, 4);
+
+ if (bd & 1) XftDrawRect(xd, fg, x, y, w1, h1);
+ if (bd & 2) XftDrawRect(xd, fg, x, y + h1, w1, h2 - h1);
+ if (bd & 4) XftDrawRect(xd, fg, x, y + h2, w1, h3 - h2);
+ if (bd & 8) XftDrawRect(xd, fg, x + w1, y, w - w1, h1);
+ if (bd & 16) XftDrawRect(xd, fg, x + w1, y + h1, w - w1, h2 - h1);
+ if (bd & 32) XftDrawRect(xd, fg, x + w1, y + h2, w - w1, h3 - h2);
+ if (bd & 64) XftDrawRect(xd, fg, x, y + h3, w1, h - h3);
+ if (bd & 128) XftDrawRect(xd, fg, x + w1, y + h3, w - w1, h - h3);
+
+ }
+}
+
+void
+drawboxlines(int x, int y, int w, int h, XftColor *fg, ushort bd)
+{
+ /* s: stem thickness. width/8 roughly matches underscore thickness. */
+ /* We draw bold as 1.5 * normal-stem and at least 1px thicker. */
+ /* doubles draw at least 3px, even when w or h < 3. bold needs 6px. */
+ int mwh = MIN(w, h);
+ int base_s = MAX(1, DIV(mwh, 8));
+ int bold = (bd & BDB) && mwh >= 6; /* possibly ignore boldness */
+ int s = bold ? MAX(base_s + 1, DIV(3 * base_s, 2)) : base_s;
+ int w2 = DIV(w - s, 2), h2 = DIV(h - s, 2);
+ /* the s-by-s square (x + w2, y + h2, s, s) is the center texel. */
+ /* The base length (per direction till edge) includes this square. */
+
+ int light = bd & (LL | LU | LR | LD);
+ int double_ = bd & (DL | DU | DR | DD);
+
+ if (light) {
+ /* d: additional (negative) length to not-draw the center */
+ /* texel - at arcs and avoid drawing inside (some) doubles */
+ int arc = bd & BDA;
+ int multi_light = light & (light - 1);
+ int multi_double = double_ & (double_ - 1);
+ /* light crosses double only at DH+LV, DV+LH (ref. shapes) */
+ int d = arc || (multi_double && !multi_light) ? -s : 0;
+
+ if (bd & LL)
+ XftDrawRect(xd, fg, x, y + h2, w2 + s + d, s);
+ if (bd & LU)
+ XftDrawRect(xd, fg, x + w2, y, s, h2 + s + d);
+ if (bd & LR)
+ XftDrawRect(xd, fg, x + w2 - d, y + h2, w - w2 + d, s);
+ if (bd & LD)
+ XftDrawRect(xd, fg, x + w2, y + h2 - d, s, h - h2 + d);
+ }
+
+ /* double lines - also align with light to form heavy when combined */
+ if (double_) {
+ /*
+ * going clockwise, for each double-ray: p is additional length
+ * to the single-ray nearer to the previous direction, and n to
+ * the next. p and n adjust from the base length to lengths
+ * which consider other doubles - shorter to avoid intersections
+ * (p, n), or longer to draw the far-corner texel (n).
+ */
+ int dl = bd & DL, du = bd & DU, dr = bd & DR, dd = bd & DD;
+ if (dl) {
+ int p = dd ? -s : 0, n = du ? -s : dd ? s : 0;
+ XftDrawRect(xd, fg, x, y + h2 + s, w2 + s + p, s);
+ XftDrawRect(xd, fg, x, y + h2 - s, w2 + s + n, s);
+ }
+ if (du) {
+ int p = dl ? -s : 0, n = dr ? -s : dl ? s : 0;
+ XftDrawRect(xd, fg, x + w2 - s, y, s, h2 + s + p);
+ XftDrawRect(xd, fg, x + w2 + s, y, s, h2 + s + n);
+ }
+ if (dr) {
+ int p = du ? -s : 0, n = dd ? -s : du ? s : 0;
+ XftDrawRect(xd, fg, x + w2 - p, y + h2 - s, w - w2 + p, s);
+ XftDrawRect(xd, fg, x + w2 - n, y + h2 + s, w - w2 + n, s);
+ }
+ if (dd) {
+ int p = dr ? -s : 0, n = dl ? -s : dr ? s : 0;
+ XftDrawRect(xd, fg, x + w2 + s, y + h2 - p, s, h - h2 + p);
+ XftDrawRect(xd, fg, x + w2 - s, y + h2 - n, s, h - h2 + n);
+ }
+ }
+}
diff --git a/boxdraw_data.h b/boxdraw_data.h
new file mode 100644
index 0000000..7890500
--- /dev/null
+++ b/boxdraw_data.h
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2018 Avi Halachmi (:avih) avihpit@yahoo.com https://github.com/avih
+ * MIT/X Consortium License
+ */
+
+/*
+ * U+25XX codepoints data
+ *
+ * References:
+ * http://www.unicode.org/charts/PDF/U2500.pdf
+ * http://www.unicode.org/charts/PDF/U2580.pdf
+ *
+ * Test page:
+ * https://github.com/GNOME/vte/blob/master/doc/boxes.txt
+ */
+
+/* Each shape is encoded as 16-bits. Higher bits are category, lower are data */
+/* Categories (mutually exclusive except BDB): */
+/* For convenience, BDL/BDA/BBS/BDB are 1 bit each, the rest are enums */
+#define BDL (1<<8) /* Box Draw Lines (light/double/heavy) */
+#define BDA (1<<9) /* Box Draw Arc (light) */
+
+#define BBD (1<<10) /* Box Block Down (lower) X/8 */
+#define BBL (2<<10) /* Box Block Left X/8 */
+#define BBU (3<<10) /* Box Block Upper X/8 */
+#define BBR (4<<10) /* Box Block Right X/8 */
+#define BBQ (5<<10) /* Box Block Quadrants */
+#define BRL (6<<10) /* Box Braille (data is lower byte of U28XX) */
+
+#define BBS (1<<14) /* Box Block Shades */
+#define BDB (1<<15) /* Box Draw is Bold */
+
+/* (BDL/BDA) Light/Double/Heavy x Left/Up/Right/Down/Horizontal/Vertical */
+/* Heavy is light+double (literally drawing light+double align to form heavy) */
+#define LL (1<<0)
+#define LU (1<<1)
+#define LR (1<<2)
+#define LD (1<<3)
+#define LH (LL+LR)
+#define LV (LU+LD)
+
+#define DL (1<<4)
+#define DU (1<<5)
+#define DR (1<<6)
+#define DD (1<<7)
+#define DH (DL+DR)
+#define DV (DU+DD)
+
+#define HL (LL+DL)
+#define HU (LU+DU)
+#define HR (LR+DR)
+#define HD (LD+DD)
+#define HH (HL+HR)
+#define HV (HU+HD)
+
+/* (BBQ) Quadrants Top/Bottom x Left/Right */
+#define TL (1<<0)
+#define TR (1<<1)
+#define BL (1<<2)
+#define BR (1<<3)
+
+/* Data for U+2500 - U+259F except dashes/diagonals */
+static const unsigned short boxdata[256] = {
+ /* light lines */
+ [0x00] = BDL + LH, /* light horizontal */
+ [0x02] = BDL + LV, /* light vertical */
+ [0x0c] = BDL + LD + LR, /* light down and right */
+ [0x10] = BDL + LD + LL, /* light down and left */
+ [0x14] = BDL + LU + LR, /* light up and right */
+ [0x18] = BDL + LU + LL, /* light up and left */
+ [0x1c] = BDL + LV + LR, /* light vertical and right */
+ [0x24] = BDL + LV + LL, /* light vertical and left */
+ [0x2c] = BDL + LH + LD, /* light horizontal and down */
+ [0x34] = BDL + LH + LU, /* light horizontal and up */
+ [0x3c] = BDL + LV + LH, /* light vertical and horizontal */
+ [0x74] = BDL + LL, /* light left */
+ [0x75] = BDL + LU, /* light up */
+ [0x76] = BDL + LR, /* light right */
+ [0x77] = BDL + LD, /* light down */
+
+ /* heavy [+light] lines */
+ [0x01] = BDL + HH,
+ [0x03] = BDL + HV,
+ [0x0d] = BDL + HR + LD,
+ [0x0e] = BDL + HD + LR,
+ [0x0f] = BDL + HD + HR,
+ [0x11] = BDL + HL + LD,
+ [0x12] = BDL + HD + LL,
+ [0x13] = BDL + HD + HL,
+ [0x15] = BDL + HR + LU,
+ [0x16] = BDL + HU + LR,
+ [0x17] = BDL + HU + HR,
+ [0x19] = BDL + HL + LU,
+ [0x1a] = BDL + HU + LL,
+ [0x1b] = BDL + HU + HL,
+ [0x1d] = BDL + HR + LV,
+ [0x1e] = BDL + HU + LD + LR,
+ [0x1f] = BDL + HD + LR + LU,
+ [0x20] = BDL + HV + LR,
+ [0x21] = BDL + HU + HR + LD,
+ [0x22] = BDL + HD + HR + LU,
+ [0x23] = BDL + HV + HR,
+ [0x25] = BDL + HL + LV,
+ [0x26] = BDL + HU + LD + LL,
+ [0x27] = BDL + HD + LU + LL,
+ [0x28] = BDL + HV + LL,
+ [0x29] = BDL + HU + HL + LD,
+ [0x2a] = BDL + HD + HL + LU,
+ [0x2b] = BDL + HV + HL,
+ [0x2d] = BDL + HL + LD + LR,
+ [0x2e] = BDL + HR + LL + LD,
+ [0x2f] = BDL + HH + LD,
+ [0x30] = BDL + HD + LH,
+ [0x31] = BDL + HD + HL + LR,
+ [0x32] = BDL + HR + HD + LL,
+ [0x33] = BDL + HH + HD,
+ [0x35] = BDL + HL + LU + LR,
+ [0x36] = BDL + HR + LU + LL,
+ [0x37] = BDL + HH + LU,
+ [0x38] = BDL + HU + LH,
+ [0x39] = BDL + HU + HL + LR,
+ [0x3a] = BDL + HU + HR + LL,
+ [0x3b] = BDL + HH + HU,
+ [0x3d] = BDL + HL + LV + LR,
+ [0x3e] = BDL + HR + LV + LL,
+ [0x3f] = BDL + HH + LV,
+ [0x40] = BDL + HU + LH + LD,
+ [0x41] = BDL + HD + LH + LU,
+ [0x42] = BDL + HV + LH,
+ [0x43] = BDL + HU + HL + LD + LR,
+ [0x44] = BDL + HU + HR + LD + LL,
+ [0x45] = BDL + HD + HL + LU + LR,
+ [0x46] = BDL + HD + HR + LU + LL,
+ [0x47] = BDL + HH + HU + LD,
+ [0x48] = BDL + HH + HD + LU,
+ [0x49] = BDL + HV + HL + LR,
+ [0x4a] = BDL + HV + HR + LL,
+ [0x4b] = BDL + HV + HH,
+ [0x78] = BDL + HL,
+ [0x79] = BDL + HU,
+ [0x7a] = BDL + HR,
+ [0x7b] = BDL + HD,
+ [0x7c] = BDL + HR + LL,
+ [0x7d] = BDL + HD + LU,
+ [0x7e] = BDL + HL + LR,
+ [0x7f] = BDL + HU + LD,
+
+ /* double [+light] lines */
+ [0x50] = BDL + DH,
+ [0x51] = BDL + DV,
+ [0x52] = BDL + DR + LD,
+ [0x53] = BDL + DD + LR,
+ [0x54] = BDL + DR + DD,
+ [0x55] = BDL + DL + LD,
+ [0x56] = BDL + DD + LL,
+ [0x57] = BDL + DL + DD,
+ [0x58] = BDL + DR + LU,
+ [0x59] = BDL + DU + LR,
+ [0x5a] = BDL + DU + DR,
+ [0x5b] = BDL + DL + LU,
+ [0x5c] = BDL + DU + LL,
+ [0x5d] = BDL + DL + DU,
+ [0x5e] = BDL + DR + LV,
+ [0x5f] = BDL + DV + LR,
+ [0x60] = BDL + DV + DR,
+ [0x61] = BDL + DL + LV,
+ [0x62] = BDL + DV + LL,
+ [0x63] = BDL + DV + DL,
+ [0x64] = BDL + DH + LD,
+ [0x65] = BDL + DD + LH,
+ [0x66] = BDL + DD + DH,
+ [0x67] = BDL + DH + LU,
+ [0x68] = BDL + DU + LH,
+ [0x69] = BDL + DH + DU,
+ [0x6a] = BDL + DH + LV,
+ [0x6b] = BDL + DV + LH,
+ [0x6c] = BDL + DH + DV,
+
+ /* (light) arcs */
+ [0x6d] = BDA + LD + LR,
+ [0x6e] = BDA + LD + LL,
+ [0x6f] = BDA + LU + LL,
+ [0x70] = BDA + LU + LR,
+
+ /* Lower (Down) X/8 block (data is 8 - X) */
+ [0x81] = BBD + 7, [0x82] = BBD + 6, [0x83] = BBD + 5, [0x84] = BBD + 4,
+ [0x85] = BBD + 3, [0x86] = BBD + 2, [0x87] = BBD + 1, [0x88] = BBD + 0,
+
+ /* Left X/8 block (data is X) */
+ [0x89] = BBL + 7, [0x8a] = BBL + 6, [0x8b] = BBL + 5, [0x8c] = BBL + 4,
+ [0x8d] = BBL + 3, [0x8e] = BBL + 2, [0x8f] = BBL + 1,
+
+ /* upper 1/2 (4/8), 1/8 block (X), right 1/2, 1/8 block (8-X) */
+ [0x80] = BBU + 4, [0x94] = BBU + 1,
+ [0x90] = BBR + 4, [0x95] = BBR + 7,
+
+ /* Quadrants */
+ [0x96] = BBQ + BL,
+ [0x97] = BBQ + BR,
+ [0x98] = BBQ + TL,
+ [0x99] = BBQ + TL + BL + BR,
+ [0x9a] = BBQ + TL + BR,
+ [0x9b] = BBQ + TL + TR + BL,
+ [0x9c] = BBQ + TL + TR + BR,
+ [0x9d] = BBQ + TR,
+ [0x9e] = BBQ + BL + TR,
+ [0x9f] = BBQ + BL + TR + BR,
+
+ /* Shades, data is an alpha value in 25% units (1/4, 1/2, 3/4) */
+ [0x91] = BBS + 1, [0x92] = BBS + 2, [0x93] = BBS + 3,
+
+ /* U+2504 - U+250B, U+254C - U+254F: unsupported (dashes) */
+ /* U+2571 - U+2573: unsupported (diagonals) */
+};
diff --git a/config.def.h b/config.def.h
index 0895a1f..bf6718b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -58,6 +58,18 @@ static unsigned int blinktimeout = 800;
*/
static unsigned int cursorthickness = 2;
+/*
+ * 1: render most of the lines/blocks characters without using the font for
+ * perfect alignment between cells (U2500 - U259F except dashes/diagonals).
+ * Bold affects lines thickness if boxdraw_bold is not 0. Italic is ignored.
+ * 0: disable (render all U25XX glyphs normally from the font).
+ */
+const int boxdraw = 0;
+const int boxdraw_bold = 0;
+
+/* braille (U28XX): 1: render as adjacent "pixels", 0: use font */
+const int boxdraw_braille = 0;
+
/*
* bell volume. It must be a value between -100 and 100. Use 0 for disabling
* it
diff --git a/st.c b/st.c
index 0ce6ac2..c035e19 100644
--- a/st.c
+++ b/st.c
@@ -1230,6 +1230,9 @@ tsetchar(Rune u, Glyph *attr, int x, int y)
term.dirty[y] = 1;
term.line[y][x] = *attr;
term.line[y][x].u = u;
+
+ if (isboxdraw(u))
+ term.line[y][x].mode |= ATTR_BOXDRAW;
}
void
diff --git a/st.h b/st.h
index d978458..a6c382a 100644
--- a/st.h
+++ b/st.h
@@ -33,6 +33,7 @@ enum glyph_attribute {
ATTR_WRAP = 1 << 8,
ATTR_WIDE = 1 << 9,
ATTR_WDUMMY = 1 << 10,
+ ATTR_BOXDRAW = 1 << 11,
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
};
@@ -111,6 +112,14 @@ void *xmalloc(size_t);
void *xrealloc(void *, size_t);
char *xstrdup(char *);
+int isboxdraw(Rune);
+ushort boxdrawindex(const Glyph *);
+#ifdef XFT_VERSION
+/* only exposed to x.c, otherwise we'll need Xft.h for the types */
+void boxdraw_xinit(Display *, Colormap, XftDraw *, Visual *);
+void drawboxes(int, int, int, int, XftColor *, XftColor *, const XftGlyphFontSpec *, int);
+#endif
+
/* config.h globals */
extern char *utmp;
extern char *scroll;
@@ -122,3 +131,4 @@ extern char *termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;
extern unsigned int defaultbg;
+extern const int boxdraw, boxdraw_bold, boxdraw_braille;
diff --git a/x.c b/x.c
index e5f1737..6f7ea2c 100644
--- a/x.c
+++ b/x.c
@@ -1205,6 +1205,8 @@ xinit(int cols, int rows)
xsel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0);
if (xsel.xtarget == None)
xsel.xtarget = XA_STRING;
+
+ boxdraw_xinit(xw.dpy, xw.cmap, xw.draw, xw.vis);
}
int
@@ -1251,8 +1253,13 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
yp = winy + font->ascent;
}
- /* Lookup character index with default font. */
- glyphidx = XftCharIndex(xw.dpy, font->match, rune);
+ if (mode & ATTR_BOXDRAW) {
+ /* minor shoehorning: boxdraw uses only this ushort */
+ glyphidx = boxdrawindex(&glyphs[i]);
+ } else {
+ /* Lookup character index with default font. */
+ glyphidx = XftCharIndex(xw.dpy, font->match, rune);
+ }
if (glyphidx) {
specs[numspecs].font = font->match;
specs[numspecs].glyph = glyphidx;
@@ -1456,8 +1463,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
r.width = width;
XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1);
- /* Render the glyphs. */
- XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
+ if (base.mode & ATTR_BOXDRAW) {
+ drawboxes(winx, winy, width / len, win.ch, fg, bg, specs, len);
+ } else {
+ /* Render the glyphs. */
+ XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
+ }
/* Render underline and strikethrough. */
if (base.mode & ATTR_UNDERLINE) {
@@ -1500,7 +1511,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
/*
* Select the right color for the right mode.
*/
- g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE;
+ g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE|ATTR_BOXDRAW;
if (IS_SET(MODE_REVERSE)) {
g.mode |= ATTR_REVERSE;
base-commit: 43a395ae91f7d67ce694e65edeaa7bbc720dd027
--
2.20.1

BIN
.local/src/st/st.o View File


BIN
.local/src/st/x.o View File


+ 17
- 0
.local/src/sxiv/.ccls View File

@ -0,0 +1,17 @@
-I
../include
-I
../vendor/include
-I
/usr/include/freetype2
-I
/usr/include/libpng16
-I
/usr/include/harfbuzz
-I
/usr/include/glib-2.0
-I
/usr/lib/glib-2.0/include
-std=c++14
-stdlib=libc++
-fPIC

BIN
.local/src/sxiv/autoreload_inotify.o View File


BIN
.local/src/sxiv/commands.o View File


BIN
.local/src/sxiv/image.o View File


BIN
.local/src/sxiv/main.o View File


BIN
.local/src/sxiv/options.o View File


BIN
.local/src/sxiv/thumbs.o View File


BIN
.local/src/sxiv/util.o View File


BIN
.local/src/sxiv/window.o View File


BIN
.local/src/tabbed/tabbed View File


BIN
.local/src/tabbed/tabbed.o View File


BIN
.local/src/tabbed/xembed View File


BIN
.local/src/tabbed/xembed.o View File


Loading…
Cancel
Save