From: Michael D. Lowis Date: Sat, 14 Apr 2018 00:51:21 +0000 (-0400) Subject: removed color attributes from view X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=2334889542108477a14df371fda6b5201ab27f70;p=projs%2Ftide.git removed color attributes from view --- diff --git a/inc/edit.h b/inc/edit.h index 2d2276b..8b3b8f1 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -73,7 +73,6 @@ char* buf_fetch(Buf* buf, bool (*isword)(Rune), size_t off); /* Screen management functions *****************************************************************************/ typedef struct { - uint32_t attr; /* attributes applied to this cell */ Rune rune; /* rune value for the cell */ } UGlyph; @@ -90,7 +89,6 @@ typedef struct { CENTER = (1 << 1), } sync_flags; Buf buffer; /* the buffer used to populate the view */ - int clrnor, clrsel; /* text color pairs for normal and selected text */ size_t nrows, ncols; /* number of rows and columns in the view */ Row** rows; /* array of row data structures */ } View; diff --git a/lib/view.c b/lib/view.c index e347f1e..a9ef06e 100644 --- a/lib/view.c +++ b/lib/view.c @@ -13,7 +13,7 @@ static void move_to(View* view, bool extsel, size_t off); static bool selection_visible(View* view); static void find_cursor(View* view, size_t* csrx, size_t* csry); static void clearrow(View* view, size_t row); -static size_t setcell(View* view, size_t row, size_t col, uint32_t attr, Rune r); +static size_t setcell(View* view, size_t row, size_t col, Rune r); static size_t fill_row(View* view, unsigned row, size_t pos); static unsigned prev_screen_line(View* view, unsigned bol, unsigned off); static unsigned scroll_up(View* view); @@ -58,6 +58,7 @@ size_t view_limitrows(View* view, size_t maxrows, size_t ncols) { } void view_resize(View* view, size_t nrows, size_t ncols) { +#if 1 size_t off = 0; if (view->nrows == nrows && view->ncols == ncols) return; /* free the old row data */ @@ -75,11 +76,12 @@ void view_resize(View* view, size_t nrows, size_t ncols) { view->rows[0]->off = off; view->nrows = nrows; view->ncols = ncols; +#endif } void view_update(View* view, int clrnor, int clrsel, size_t* csrx, size_t* csry) { +#if 1 if (!view->nrows) return; - view->clrnor = clrnor, view->clrsel = clrsel; size_t csr = CSRPOS; /* scroll the view and reflow the screen lines */ size_t pos = view->rows[0]->off; @@ -90,6 +92,7 @@ void view_update(View* view, int clrnor, int clrsel, size_t* csrx, size_t* csry) view_scrollto(view, csr); /* locate the cursor if visible */ find_cursor(view, csrx, csry); +#endif } Row* view_getrow(View* view, size_t row) { @@ -339,12 +342,11 @@ static void clearrow(View* view, size_t row) { scrrow->len = 0; } -static size_t setcell(View* view, size_t row, size_t col, uint32_t attr, Rune r) { +static size_t setcell(View* view, size_t row, size_t col, Rune r) { if (row >= view->nrows || col >= view->ncols) return 0; Row* scrrow = view_getrow(view, row); int ncols = runewidth(col, r); /* write the rune to the screen buf */ - scrrow->cols[col].attr = attr; if (r == '\t') scrrow->cols[col].rune = ' '; else @@ -352,7 +354,6 @@ static size_t setcell(View* view, size_t row, size_t col, uint32_t attr, Rune r) /* Update lengths */ scrrow->rlen += 1; for (int i = 1; i < ncols; i++) { - scrrow->cols[col].attr = attr; scrrow->cols[col+i].rune = '\0'; } if ((col + ncols) > scrrow->len) @@ -364,9 +365,8 @@ static size_t fill_row(View* view, unsigned row, size_t pos) { view_getrow(view, row)->off = pos; clearrow(view, row); for (size_t x = 0; x < view->ncols;) { - uint32_t attr = (buf_insel(BUF, pos) ? view->clrsel : view->clrnor); Rune r = buf_getrat(BUF, pos++); - x += setcell(view, row, x, attr, r); + x += setcell(view, row, x, r); if (buf_iseol(BUF, pos-1)) { break; } diff --git a/lib/x11.c b/lib/x11.c index c5d4dd5..1b0a8c5 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -306,21 +306,10 @@ 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, int bg, XGlyphSpec* specs, size_t nspecs, bool eol) { +static void place_glyphs(int fg, XGlyphSpec* specs, size_t nspecs, bool eol) { if (!nspecs) return; XftFont* font = specs[0].font; - XftColor fgc, bgc; - if (bg > 0) { - XGlyphInfo extent; - XftTextExtentsUtf8(X.display, font, (const FcChar8*)"0", 1, &extent); - int w = extent.xOff; - int h = (font->height - font->descent) + LineSpacing; - xftcolor(&bgc, bg); - size_t width = specs[nspecs-1].x - specs[0].x + w; - if (eol) width = X.width - specs[0].x; - draw_rect(bg, specs[0].x, specs[0].y - h, width, font->height + LineSpacing); - XftColorFree(X.display, X.visual, X.colormap, &bgc); - } + XftColor fgc; xftcolor(&fgc, fg); XftDrawGlyphFontSpec(X.xft, &fgc, (XftGlyphFontSpec*)specs, nspecs); XftColorFree(X.display, X.visual, X.colormap, &fgc); @@ -332,8 +321,7 @@ static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t rlen, size_t bool eol = false; while (rlen && i < ncols) { int numspecs = 0; - uint32_t attr = glyphs[i].attr; - while (i < ncols && glyphs[i].attr == attr) { + while (i < ncols) { if (glyphs[i].rune == '\n') glyphs[i].rune = ' ', eol = true; getglyph(&(specs[numspecs]), glyphs[i].rune); @@ -349,9 +337,7 @@ static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t rlen, size_t x += font_width(); } /* Draw the glyphs with the proper colors */ - uint8_t bg = attr >> 8; - uint8_t fg = attr & 0xFF; - place_glyphs(fg, bg, specs, numspecs, eol); + place_glyphs(EditFg, specs, numspecs, eol); eol = false, rlen -= numspecs; } }