Se rehace st desde el 0.9.3 original con los parches: - kitty-graphics (oficial, 20251230): muestra imágenes en la terminal; yazi lo detecta solo y no necesita ueberzugpp. Ya incluye anysize, así que ese parche sobra. - alpha, sin cambios. - glyph-wide-support: los iconos anchos (Nerd Font) no se cortan. - ligatures, con los conflictos resueltos como en la rama graphics-with-patches de st-graphics, quitando lo de boxdraw. config.h lleva los mismos cambios de antes sobre el config.def.h nuevo. Necesita imlib2-devel para compilar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016UdJsHrbkmzhoCb6TthP2m
199 lines
6.1 KiB
Diff
199 lines
6.1 KiB
Diff
From 8eac1cd750e01d76d56a0b43ae67b12e2185bae4 Mon Sep 17 00:00:00 2001
|
|
From: wael <40663@protonmail.com>
|
|
Date: Mon, 11 Apr 2022 17:14:06 +0300
|
|
Subject: [PATCH] [PATCH] glyph wide support
|
|
|
|
https://st.suckless.org/patches/glyph_wide_support/
|
|
https://st.suckless.org/patches/glyph_wide_support/st-glyph-wide-support-boxdraw-20220411-ef05519.diff
|
|
---
|
|
st.h | 6 ++++
|
|
x.c | 108 +++++++++++++++++++++++++++++++++--------------------------
|
|
2 files changed, 66 insertions(+), 48 deletions(-)
|
|
|
|
diff --git a/st.h b/st.h
|
|
index 0525b83..1eb7db7 100644
|
|
--- a/st.h
|
|
+++ b/st.h
|
|
@@ -43,6 +43,12 @@ enum glyph_attribute {
|
|
ATTR_IMAGE = 1 << 14,
|
|
};
|
|
|
|
+enum drawing_mode {
|
|
+ DRAW_NONE = 0,
|
|
+ DRAW_BG = 1 << 0,
|
|
+ DRAW_FG = 1 << 1,
|
|
+};
|
|
+
|
|
enum selection_mode {
|
|
SEL_IDLE = 0,
|
|
SEL_EMPTY = 1,
|
|
diff --git a/x.c b/x.c
|
|
index ec1fa47..f83b98e 100644
|
|
--- a/x.c
|
|
+++ b/x.c
|
|
@@ -154,7 +154,7 @@ typedef struct {
|
|
|
|
static inline ushort sixd_to_16bit(int);
|
|
static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int);
|
|
-static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
|
|
+static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int, int);
|
|
static void xdrawglyph(Glyph, int, int);
|
|
static void xdrawimages(Glyph, Line, int x1, int y1, int x2);
|
|
static void xdrawoneimagecell(Glyph, int x, int y);
|
|
@@ -1524,7 +1524,7 @@ xdrawundercurl(Draw draw, Color *color, int x, int y, int w, int h, int thick)
|
|
}
|
|
|
|
void
|
|
-xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
|
|
+xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y, int dmode)
|
|
{
|
|
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
|
|
int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch,
|
|
@@ -1616,24 +1616,29 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
|
fg = bg;
|
|
|
|
/* Intelligent cleaning up of the borders. */
|
|
- if (x == 0) {
|
|
- xclear(0, (y == 0)? 0 : winy, win.hborderpx,
|
|
- winy + win.ch +
|
|
- ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
|
|
- }
|
|
- if (winx + width >= win.hborderpx + win.tw) {
|
|
- xclear(winx + width, (y == 0)? 0 : winy, win.w,
|
|
- ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
|
|
+ if (dmode & DRAW_BG) {
|
|
+ if (x == 0) {
|
|
+ xclear(0, (y == 0)? 0 : winy, win.hborderpx,
|
|
+ winy + win.ch +
|
|
+ ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
|
|
+ }
|
|
+ if (winx + width >= win.hborderpx + win.tw) {
|
|
+ xclear(winx + width, (y == 0)? 0 : winy, win.w,
|
|
+ ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
|
|
+ }
|
|
+ if (y == 0)
|
|
+ xclear(winx, 0, winx + width, win.vborderpx);
|
|
+ if (winy + win.ch >= win.vborderpx + win.th)
|
|
+ xclear(winx, winy + win.ch, winx + width, win.h);
|
|
+
|
|
+ /* Clean up the region we want to draw to. */
|
|
+ XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
|
|
}
|
|
- if (y == 0)
|
|
- xclear(winx, 0, winx + width, win.vborderpx);
|
|
- if (winy + win.ch >= win.vborderpx + win.th)
|
|
- xclear(winx, winy + win.ch, winx + width, win.h);
|
|
|
|
- /* Clean up the region we want to draw to. */
|
|
- XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
|
|
+ if (!(dmode & DRAW_FG))
|
|
+ return;
|
|
|
|
- /* Set the clip region because Xft is sometimes dirty. */
|
|
+ /* Set the clip region only for the underline. */
|
|
r.x = 0;
|
|
r.y = 0;
|
|
r.height = win.ch;
|
|
@@ -1695,6 +1700,9 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
|
}
|
|
}
|
|
|
|
+ /* Reset clip to none. */
|
|
+ XftDrawSetClip(xw.draw, 0);
|
|
+
|
|
if (base.mode & ATTR_BOXDRAW) {
|
|
drawboxes(winx, winy, width / len, win.ch, fg, bg, specs, len);
|
|
} else {
|
|
@@ -1707,9 +1715,6 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
|
XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
|
|
width, thick);
|
|
}
|
|
-
|
|
- /* Reset clip to none. */
|
|
- XftDrawSetClip(xw.draw, 0);
|
|
}
|
|
|
|
void
|
|
@@ -1719,7 +1724,7 @@ xdrawglyph(Glyph g, int x, int y)
|
|
XftGlyphFontSpec spec;
|
|
|
|
numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y);
|
|
- xdrawglyphfontspecs(&spec, g, numspecs, x, y);
|
|
+ xdrawglyphfontspecs(&spec, g, numspecs, x, y, DRAW_BG | DRAW_FG);
|
|
if (g.mode & ATTR_IMAGE) {
|
|
gr_start_drawing(xw.buf, win.cw, win.ch);
|
|
xdrawoneimagecell(g, x, y);
|
|
@@ -1997,36 +2002,43 @@ xstartdraw(void)
|
|
void
|
|
xdrawline(Line line, int x1, int y1, int x2)
|
|
{
|
|
- int i, x, ox, numspecs;
|
|
+ int i, x, ox, numspecs, numspecs_cached;
|
|
Glyph base, new;
|
|
- XftGlyphFontSpec *specs = xw.specbuf;
|
|
-
|
|
- numspecs = xmakeglyphfontspecs(specs, &line[x1], x2 - x1, x1, y1);
|
|
- i = ox = 0;
|
|
- for (x = x1; x < x2 && i < numspecs; x++) {
|
|
- new = line[x];
|
|
- if (new.mode == ATTR_WDUMMY)
|
|
- continue;
|
|
- if (selected(x, y1))
|
|
- new.mode ^= ATTR_REVERSE;
|
|
- if (i > 0 && ATTRCMP(base, new)) {
|
|
- xdrawglyphfontspecs(specs, base, i, ox, y1);
|
|
- if (base.mode & ATTR_IMAGE)
|
|
- xdrawimages(base, line, ox, y1, x);
|
|
- specs += i;
|
|
- numspecs -= i;
|
|
- i = 0;
|
|
- }
|
|
- if (i == 0) {
|
|
- ox = x;
|
|
- base = new;
|
|
+ XftGlyphFontSpec *specs;
|
|
+
|
|
+ numspecs_cached = xmakeglyphfontspecs(xw.specbuf, &line[x1], x2 - x1, x1, y1);
|
|
+
|
|
+ /* Draw line in 2 passes: background and foreground. This way wide
|
|
+ * glyphs won't get truncated (#223) */
|
|
+ for (int dmode = DRAW_BG; dmode <= DRAW_FG; dmode <<= 1) {
|
|
+ specs = xw.specbuf;
|
|
+ numspecs = numspecs_cached;
|
|
+ i = ox = 0;
|
|
+ for (x = x1; x < x2 && i < numspecs; x++) {
|
|
+ new = line[x];
|
|
+ if (new.mode == ATTR_WDUMMY)
|
|
+ continue;
|
|
+ if (selected(x, y1))
|
|
+ new.mode ^= ATTR_REVERSE;
|
|
+ if (i > 0 && ATTRCMP(base, new)) {
|
|
+ xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
|
|
+ if (base.mode & ATTR_IMAGE && dmode == DRAW_FG)
|
|
+ xdrawimages(base, line, ox, y1, x);
|
|
+ specs += i;
|
|
+ numspecs -= i;
|
|
+ i = 0;
|
|
+ }
|
|
+ if (i == 0) {
|
|
+ ox = x;
|
|
+ base = new;
|
|
+ }
|
|
+ i++;
|
|
}
|
|
- i++;
|
|
+ if (i > 0)
|
|
+ xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
|
|
+ if (i > 0 && base.mode & ATTR_IMAGE && dmode == DRAW_FG)
|
|
+ xdrawimages(base, line, ox, y1, x);
|
|
}
|
|
- if (i > 0)
|
|
- xdrawglyphfontspecs(specs, base, i, ox, y1);
|
|
- if (i > 0 && base.mode & ATTR_IMAGE)
|
|
- xdrawimages(base, line, ox, y1, x);
|
|
}
|
|
|
|
void
|
|
--
|
|
2.55.0
|
|
|