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);
}
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 */
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;
view_scrollto(view, csr);
/* locate the cursor if visible */
find_cursor(view, csrx, csry);
+#endif
}
Row* view_getrow(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
/* 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)
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;
}
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);
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);
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;
}
}