From 1ea800a030aee6d63f1e8e5d45666e65ca033658 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 18 Apr 2018 16:11:22 -0400 Subject: [PATCH] removed some unnecessary functions --- lib/x11.c | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/lib/x11.c b/lib/x11.c index f9e40f3..94f9c17 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -277,17 +277,12 @@ static void xftcolor(XftColor* xc, int id) { XftColorAllocValue(X.display, X.visual, X.colormap, &(xc->color), xc); } -static void getglyph(XGlyphSpec* spec, uint32_t rune) { - spec->glyph = XftCharIndex(X.display, CurrFont.match, rune); - spec->font = CurrFont.match; -} - size_t glyph_width(int c) { XGlyphInfo extents; if (c == '\t') { FcChar32 index = XftCharIndex(X.display, CurrFont.match, '0'); XftTextExtents32(X.display, CurrFont.match, &index, 1, &extents); - return (4 * extents.xOff); + return (TabWidth * extents.xOff); } else { FcChar32 index = XftCharIndex(X.display, CurrFont.match, c); XftTextExtents32(X.display, CurrFont.match, &index, 1, &extents); @@ -295,23 +290,6 @@ size_t glyph_width(int c) { } } -static size_t getglyphs(XGlyphSpec* specs, const XGlyph* glyphs, int len, int x, int y) { - int winx = x, winy = y; - size_t numspecs = 0; - for (int i = 0, xp = winx, yp = winy; i < len;) { - getglyph(&(specs[numspecs]), glyphs[i].rune); - specs[numspecs].x = xp; - specs[numspecs].y = yp; - xp += font_width(); - numspecs++; - i++; - /* skip over null chars which mark multi column runes */ - for (; i < len && !glyphs[i].rune; i++) - xp += font_width(); - } - return numspecs; -} - static void draw_rect(int color, int x, int y, int width, int height) { XftColor clr; xftcolor(&clr, color); @@ -319,30 +297,21 @@ static void draw_rect(int color, int x, int y, int width, int height) { XftColorFree(X.display, X.visual, X.colormap, &clr); } -static void place_glyphs(int fg, XGlyphSpec* specs, size_t nspecs, bool eol) { - if (!nspecs) return; - XftFont* font = specs[0].font; - XftColor fgc; - xftcolor(&fgc, fg); - XftDrawGlyphFontSpec(X.xft, &fgc, (XftGlyphFontSpec*)specs, nspecs); - XftColorFree(X.display, X.visual, X.colormap, &fgc); -} - static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t len) { - XGlyphSpec specs[len]; + XftGlyphSpec specs[len]; size_t i = 0; bool eol = false; for (size_t i = 0; i < len; i++) { if (glyphs[i].rune == '\r' || glyphs[i].rune == '\n' || glyphs[i].rune == '\t') glyphs[i].rune = ' '; - getglyph(&(specs[i]), glyphs[i].rune); + specs[i].glyph = XftCharIndex(X.display, CurrFont.match, glyphs[i].rune); specs[i].x = x; - specs[i].y = y - font_descent(); + specs[i].y = y - CurrFont.match->descent; x += glyphs[i].width; } XftColor fgc; xftcolor(&fgc, EditFg); - XftDrawGlyphFontSpec(X.xft, &fgc, (XftGlyphFontSpec*)specs, len); + XftDrawGlyphSpec(X.xft, &fgc, CurrFont.match, specs, len); XftColorFree(X.display, X.visual, X.colormap, &fgc); } -- 2.49.0