st

my build of st - simple terminal
git clone git://git.kocotian.pl/st.git
Log | Files | Refs | README | LICENSE

commit 5d5e33930be95d1d5846fd8bb5f216ffc3a7de90
parent 0b9e8fc2be4de8f08b8e3bd5881bb8ecff7199df
Author: kocotian <kocotian@kocotian.pl>
Date:   Wed, 23 Dec 2020 20:02:49 +0100

vertcenter, xclearwin

Diffstat:
Mpatches/st-vertcenter-20180320-6ac8c8a.diff | 0
Mpatches/st-xclearwin-20200419-6ee7143.diff | 0
Mst.c | 6++----
Mwin.h | 1+
Mx.c | 16++++++++++++----
5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/patches/st-vertcenter-20180320-6ac8c8a.diff b/patches/st-vertcenter-20180320-6ac8c8a.diff diff --git a/patches/st-xclearwin-20200419-6ee7143.diff b/patches/st-xclearwin-20200419-6ee7143.diff diff --git a/st.c b/st.c @@ -1925,10 +1925,8 @@ strhandle(void) fprintf(stderr, "erresc: invalid color j=%d, p=%s\n", j, p ? p : "(null)"); } else { - /* - * TODO if defaultbg color is changed, borders - * are dirty - */ + if (j == defaultbg) + xclearwin(); redraw(); } return; diff --git a/win.h b/win.h @@ -38,3 +38,4 @@ void xsetpointermotion(int); void xsetsel(char *); int xstartdraw(void); void xximspot(int, int); +void xclearwin(void); diff --git a/x.c b/x.c @@ -84,6 +84,7 @@ typedef struct { int w, h; /* window width and height */ int ch; /* char height */ int cw; /* char width */ + int cyo; /* char y offset */ int mode; /* window state/mode flags */ int cursor; /* cursor style */ } TermWindow; @@ -838,6 +839,12 @@ xclear(int x1, int y1, int x2, int y2) } void +xclearwin(void) +{ + xclear(0, 0, win.w, win.h); +} + +void xhints(void) { XClassHint class = {opt_name ? opt_name : termname, @@ -1012,6 +1019,7 @@ xloadfonts(char *fontstr, double fontsize) /* Setting character width and height. */ win.cw = ceilf(dc.font.width * cwscale); win.ch = ceilf(dc.font.height * chscale); + win.cyo = ceilf(dc.font.height * (chscale - 1) / 2); FcPatternDel(pattern, FC_SLANT); FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); @@ -1246,7 +1254,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x FcCharSet *fccharset; int i, f, numspecs = 0; - for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) { + for (i = 0, xp = winx, yp = winy + font->ascent + win.cyo; i < len; ++i) { /* Fetch rune and mode for current glyph. */ rune = glyphs[i].u; mode = glyphs[i].mode; @@ -1271,7 +1279,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x font = &dc.bfont; frcflags = FRC_BOLD; } - yp = winy + font->ascent; + yp = winy + font->ascent + win.cyo; } if (mode & ATTR_BOXDRAW) { @@ -1489,12 +1497,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i /* Render underline and strikethrough. */ if (base.mode & ATTR_UNDERLINE) { - XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1, + XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent + 1, width, 1); } if (base.mode & ATTR_STRUCK) { - XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3, + XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent / 3, width, 1); }