diff --git a/.cache/clangd/index/arg.h.A401262204973496.idx b/.cache/clangd/index/arg.h.A401262204973496.idx new file mode 100644 index 0000000..2738c4a Binary files /dev/null and b/.cache/clangd/index/arg.h.A401262204973496.idx differ diff --git a/.cache/clangd/index/config.h.55C22FC103E368DE.idx b/.cache/clangd/index/config.h.55C22FC103E368DE.idx new file mode 100644 index 0000000..c83200f Binary files /dev/null and b/.cache/clangd/index/config.h.55C22FC103E368DE.idx differ diff --git a/.cache/clangd/index/st.c.E8CA231F6CA78C63.idx b/.cache/clangd/index/st.c.E8CA231F6CA78C63.idx new file mode 100644 index 0000000..5d923dc Binary files /dev/null and b/.cache/clangd/index/st.c.E8CA231F6CA78C63.idx differ diff --git a/.cache/clangd/index/st.h.71592236F0FD2482.idx b/.cache/clangd/index/st.h.71592236F0FD2482.idx new file mode 100644 index 0000000..8d316ce Binary files /dev/null and b/.cache/clangd/index/st.h.71592236F0FD2482.idx differ diff --git a/.cache/clangd/index/win.h.6205A783DBE07871.idx b/.cache/clangd/index/win.h.6205A783DBE07871.idx new file mode 100644 index 0000000..11ffe13 Binary files /dev/null and b/.cache/clangd/index/win.h.6205A783DBE07871.idx differ diff --git a/.cache/clangd/index/x.c.A60DB311B91E8C2C.idx b/.cache/clangd/index/x.c.A60DB311B91E8C2C.idx new file mode 100644 index 0000000..ca5d2cc Binary files /dev/null and b/.cache/clangd/index/x.c.A60DB311B91E8C2C.idx differ diff --git a/.gitignore b/.gitignore index 689f412..fc92f23 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /st st.o x.o +compile_commands.json +.cache diff --git a/Makefile b/Makefile index 15db421..0e887b5 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,8 @@ # See LICENSE file for copyright and license details. .POSIX: +.PHONY: all tooling + include config.mk SRC = st.c x.c @@ -9,6 +11,8 @@ OBJ = $(SRC:.c=.o) all: st +tooling: compile_commands.json + config.h: cp config.def.h config.h @@ -20,6 +24,9 @@ x.o: arg.h config.h st.h win.h $(OBJ): config.h config.mk +compile_commands.json: clean + bear -- make st + st: $(OBJ) $(CC) -o $@ $(OBJ) $(STLDFLAGS) diff --git a/config.h b/config.h index df7519c..73ef5b7 100644 --- a/config.h +++ b/config.h @@ -6,7 +6,7 @@ * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ static char *font = "TamzenForPowerline:pixelsize=16:style=regular:antialias=false:hinting=false"; -static int borderpx = 4; +static int borderpx = 2; /* * What program is execed by st depends of these precedence rules: @@ -65,7 +65,7 @@ static unsigned int blinktimeout = 800; /* * thickness of underline and bar cursors */ -static unsigned int cursorthickness = 2; +static unsigned int cursorthickness = 4; /* * bell volume. It must be a value between -100 and 100. Use 0 for disabling diff --git a/config.mk b/config.mk index fdc29a7..9c3f709 100644 --- a/config.mk +++ b/config.mk @@ -33,4 +33,4 @@ STLDFLAGS = $(LIBS) $(LDFLAGS) #MANPREFIX = ${PREFIX}/man # compiler and linker -# CC = c99 +CC = clang diff --git a/patches/st-font2-0.8.5.diff b/patches/st-font2-0.8.5.diff deleted file mode 100644 index 9b22b8a..0000000 --- a/patches/st-font2-0.8.5.diff +++ /dev/null @@ -1,163 +0,0 @@ -From 1635e04d3643dd4caa0c7c2043b585c6d7e4705f Mon Sep 17 00:00:00 2001 -From: Rizqi Nur Assyaufi -Date: Mon, 18 Jul 2022 01:15:45 +0800 -Subject: [PATCH] [st][patch][font2] Add patch for st-0.8.5 - ---- - config.def.h | 6 +++ - x.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 107 insertions(+) - -diff --git a/config.def.h b/config.def.h -index 91ab8ca..717b2f0 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -6,6 +6,12 @@ - * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html - */ - static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; -+/* Spare fonts */ -+static char *font2[] = { -+/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */ -+/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */ -+}; -+ - static int borderpx = 2; - - /* -diff --git a/x.c b/x.c -index 8a16faa..220fc4f 100644 ---- a/x.c -+++ b/x.c -@@ -157,6 +157,8 @@ static void xhints(void); - static int xloadcolor(int, const char *, Color *); - static int xloadfont(Font *, FcPattern *); - static void xloadfonts(const char *, double); -+static int xloadsparefont(FcPattern *, int); -+static void xloadsparefonts(void); - static void xunloadfont(Font *); - static void xunloadfonts(void); - static void xsetenv(void); -@@ -306,6 +308,7 @@ zoomabs(const Arg *arg) - { - xunloadfonts(); - xloadfonts(usedfont, arg->f); -+ xloadsparefonts(); - cresize(0, 0); - redraw(); - xhints(); -@@ -1034,6 +1037,101 @@ xloadfonts(const char *fontstr, double fontsize) - FcPatternDestroy(pattern); - } - -+int -+xloadsparefont(FcPattern *pattern, int flags) -+{ -+ FcPattern *match; -+ FcResult result; -+ -+ match = FcFontMatch(NULL, pattern, &result); -+ if (!match) { -+ return 1; -+ } -+ -+ if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) { -+ FcPatternDestroy(match); -+ return 1; -+ } -+ -+ frc[frclen].flags = flags; -+ /* Believe U+0000 glyph will present in each default font */ -+ frc[frclen].unicodep = 0; -+ frclen++; -+ -+ return 0; -+} -+ -+void -+xloadsparefonts(void) -+{ -+ FcPattern *pattern; -+ double sizeshift, fontval; -+ int fc; -+ char **fp; -+ -+ if (frclen != 0) -+ die("can't embed spare fonts. cache isn't empty"); -+ -+ /* Calculate count of spare fonts */ -+ fc = sizeof(font2) / sizeof(*font2); -+ if (fc == 0) -+ return; -+ -+ /* Allocate memory for cache entries. */ -+ if (frccap < 4 * fc) { -+ frccap += 4 * fc - frccap; -+ frc = xrealloc(frc, frccap * sizeof(Fontcache)); -+ } -+ -+ for (fp = font2; fp - font2 < fc; ++fp) { -+ -+ if (**fp == '-') -+ pattern = XftXlfdParse(*fp, False, False); -+ else -+ pattern = FcNameParse((FcChar8 *)*fp); -+ -+ if (!pattern) -+ die("can't open spare font %s\n", *fp); -+ -+ if (defaultfontsize > 0) { -+ sizeshift = usedfontsize - defaultfontsize; -+ if (sizeshift != 0 && -+ FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) == -+ FcResultMatch) { -+ fontval += sizeshift; -+ FcPatternDel(pattern, FC_PIXEL_SIZE); -+ FcPatternDel(pattern, FC_SIZE); -+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval); -+ } -+ } -+ -+ FcPatternAddBool(pattern, FC_SCALABLE, 1); -+ -+ FcConfigSubstitute(NULL, pattern, FcMatchPattern); -+ XftDefaultSubstitute(xw.dpy, xw.scr, pattern); -+ -+ if (xloadsparefont(pattern, FRC_NORMAL)) -+ die("can't open spare font %s\n", *fp); -+ -+ FcPatternDel(pattern, FC_SLANT); -+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); -+ if (xloadsparefont(pattern, FRC_ITALIC)) -+ die("can't open spare font %s\n", *fp); -+ -+ FcPatternDel(pattern, FC_WEIGHT); -+ FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); -+ if (xloadsparefont(pattern, FRC_ITALICBOLD)) -+ die("can't open spare font %s\n", *fp); -+ -+ FcPatternDel(pattern, FC_SLANT); -+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); -+ if (xloadsparefont(pattern, FRC_BOLD)) -+ die("can't open spare font %s\n", *fp); -+ -+ FcPatternDestroy(pattern); -+ } -+} -+ - void - xunloadfont(Font *f) - { -@@ -1131,6 +1229,9 @@ xinit(int cols, int rows) - usedfont = (opt_font == NULL)? font : opt_font; - xloadfonts(usedfont, 0); - -+ /* spare fonts */ -+ xloadsparefonts(); -+ - /* colors */ - xw.cmap = XDefaultColormap(xw.dpy, xw.scr); - xloadcols(); --- -2.37.1 - diff --git a/x.c b/x.c index bd23686..f28c233 100644 --- a/x.c +++ b/x.c @@ -415,8 +415,8 @@ mousereport(XEvent *e) if (!IS_SET(MODE_MOUSEX10)) { code += ((state & ShiftMask ) ? 4 : 0) - + ((state & Mod1Mask ) ? 8 : 0) /* meta key: alt */ - + ((state & ControlMask) ? 16 : 0); + + ((state & Mod1Mask ) ? 8 : 0) /* meta key: alt */ + + ((state & ControlMask) ? 16 : 0); } if (IS_SET(MODE_MOUSESGR)) { @@ -437,11 +437,11 @@ uint buttonmask(uint button) { return button == Button1 ? Button1Mask - : button == Button2 ? Button2Mask - : button == Button3 ? Button3Mask - : button == Button4 ? Button4Mask - : button == Button5 ? Button5Mask - : 0; + : button == Button2 ? Button2Mask + : button == Button3 ? Button3Mask + : button == Button4 ? Button4Mask + : button == Button5 ? Button5Mask + : 0; } int @@ -454,9 +454,9 @@ mouseaction(XEvent *e, uint release) for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { if (ms->release == release && - ms->button == e->xbutton.button && - (match(ms->mod, state) || /* exact or forced */ - match(ms->mod, state & ~forcemousemod))) { + ms->button == e->xbutton.button && + (match(ms->mod, state) || /* exact or forced */ + match(ms->mod, state & ~forcemousemod))) { ms->func(&(ms->arg)); return 1; } @@ -782,7 +782,7 @@ xloadcolor(int i, const char *name, Color *ncolor) color.green = color.blue = color.red; } return XftColorAllocValue(xw.dpy, xw.vis, - xw.cmap, &color, ncolor); + xw.cmap, &color, ncolor); } else name = colorname[i]; } @@ -860,7 +860,7 @@ void xhints(void) { XClassHint class = {opt_name ? opt_name : termname, - opt_class ? opt_class : termname}; + opt_class ? opt_class : termname}; XWMHints wm = {.flags = InputHint, .input = 1}; XSizeHints *sizeh; @@ -941,22 +941,22 @@ xloadfont(Font *f, FcPattern *pattern) } if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) == - XftResultMatch)) { + XftResultMatch)) { /* * Check if xft was unable to find a font with the appropriate * slant but gave us one anyway. Try to mitigate. */ if ((XftPatternGetInteger(f->match->pattern, "slant", 0, - &haveattr) != XftResultMatch) || haveattr < wantattr) { + &haveattr) != XftResultMatch) || haveattr < wantattr) { f->badslant = 1; fputs("font slant does not match\n", stderr); } } if ((XftPatternGetInteger(pattern, "weight", 0, &wantattr) == - XftResultMatch)) { + XftResultMatch)) { if ((XftPatternGetInteger(f->match->pattern, "weight", 0, - &haveattr) != XftResultMatch) || haveattr != wantattr) { + &haveattr) != XftResultMatch) || haveattr != wantattr) { f->badweight = 1; fputs("font weight does not match\n", stderr); } @@ -1022,7 +1022,7 @@ xloadfonts(const char *fontstr, double fontsize) if (usedfontsize < 0) { FcPatternGetDouble(dc.font.match->pattern, - FC_PIXEL_SIZE, 0, &fontval); + FC_PIXEL_SIZE, 0, &fontval); usedfontsize = fontval; if (fontsize == 0) defaultfontsize = fontval; @@ -1084,17 +1084,17 @@ ximopen(Display *dpy) if (XSetIMValues(xw.ime.xim, XNDestroyCallback, &imdestroy, NULL)) fprintf(stderr, "XSetIMValues: " - "Could not set XNDestroyCallback.\n"); + "Could not set XNDestroyCallback.\n"); xw.ime.spotlist = XVaCreateNestedList(0, XNSpotLocation, &xw.ime.spot, - NULL); + NULL); if (xw.ime.xic == NULL) { xw.ime.xic = XCreateIC(xw.ime.xim, XNInputStyle, - XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, xw.win, - XNDestroyCallback, &icdestroy, - NULL); + XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, xw.win, + XNDestroyCallback, &icdestroy, + NULL); } if (xw.ime.xic == NULL) fprintf(stderr, "XCreateIC: Could not create input context.\n"); @@ -1107,7 +1107,7 @@ ximinstantiate(Display *dpy, XPointer client, XPointer call) { if (ximopen(dpy)) XUnregisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, - ximinstantiate, NULL); + ximinstantiate, NULL); } void @@ -1115,7 +1115,7 @@ ximdestroy(XIM xim, XPointer client, XPointer call) { xw.ime.xim = NULL; XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, - ximinstantiate, NULL); + ximinstantiate, NULL); XFree(xw.ime.spotlist); } @@ -1193,7 +1193,7 @@ xinit(int cols, int rows) /* input methods */ if (!ximopen(xw.dpy)) { XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, - ximinstantiate, NULL); + ximinstantiate, NULL); } /* white cursor, black outline */ @@ -1312,7 +1312,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x if (f >= frclen) { if (!font->set) font->set = FcFontSort(0, font->pattern, - 1, 0, &fcres); + 1, 0, &fcres); fcsets[0] = font->set; /* @@ -1376,7 +1376,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i { int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1); int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, - width = charlen * win.cw; + width = charlen * win.cw; Color *fg, *bg, *temp, revfg, revbg, truefg, truebg; XRenderColor colfg, colbg; XRectangle r; @@ -1386,7 +1386,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i if (dc.ibfont.badslant || dc.ibfont.badweight) base.fg = defaultattr; } else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) || - (base.mode & ATTR_BOLD && dc.bfont.badweight)) { + (base.mode & ATTR_BOLD && dc.bfont.badweight)) { base.fg = defaultattr; } @@ -1621,7 +1621,7 @@ xseticontitle(char *p) p = opt_title; if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, - &prop) != Success) + &prop) != Success) return; XSetWMIconName(xw.dpy, xw.win, &prop); XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname); @@ -1638,7 +1638,7 @@ xsettitle(char *p) p = opt_title; if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, - &prop) != Success) + &prop) != Success) return; XSetWMName(xw.dpy, xw.win, &prop); XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname); @@ -1995,7 +1995,7 @@ run(void) drawing = 1; } timeout = (maxlatency - TIMEDIFF(now, trigger)) \ - / maxlatency * minlatency; + / maxlatency * minlatency; if (timeout > 0) continue; /* we have time, try to find idle */ } @@ -2024,13 +2024,13 @@ void usage(void) { die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]" - " [-n name] [-o file]\n" - " [-T title] [-t title] [-w windowid]" - " [[-e] command [args ...]]\n" - " %s [-aiv] [-c class] [-f font] [-g geometry]" - " [-n name] [-o file]\n" - " [-T title] [-t title] [-w windowid] -l line" - " [stty_args ...]\n", argv0, argv0); + " [-n name] [-o file]\n" + " [-T title] [-t title] [-w windowid]" + " [[-e] command [args ...]]\n" + " %s [-aiv] [-c class] [-f font] [-g geometry]" + " [-n name] [-o file]\n" + " [-T title] [-t title] [-w windowid] -l line" + " [stty_args ...]\n", argv0, argv0); } int