summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oeSQ.diff193
-rwxr-xr-xstbin115232 -> 115232 bytes
-rw-r--r--st.h6
-rw-r--r--x.c139
-rw-r--r--x.obin85072 -> 85256 bytes
5 files changed, 280 insertions, 58 deletions
diff --git a/oeSQ.diff b/oeSQ.diff
new file mode 100644
index 0000000..5e83d03
--- /dev/null
+++ b/oeSQ.diff
@@ -0,0 +1,193 @@
+diff --git a/st.h b/st.h
+index a584b72..7ac4d7c 100644
+--- a/st.h
++++ b/st.h
+@@ -37,6 +37,12 @@ enum glyph_attribute {
+ ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
+ };
+
++enum drawing_mode {
++ DRAW_NONE = 0,
++ DRAW_BG = 1 << 0,
++ DRAW_FG = 1 << 1,
++};
++
+ enum selection_mode {
+ SEL_IDLE = 0,
+ SEL_EMPTY = 1,
+diff --git a/x.c b/x.c
+index 1560382..b552e8d 100644
+--- a/x.c
++++ b/x.c
+@@ -145,7 +145,7 @@ typedef struct {
+
+ static inline ushort sixd_to_16bit(int);
+ static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int);
+-static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
++static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int, int);
+ static void xdrawglyph(Glyph, int, int);
+ static void xclear(int, int, int, int);
+ static int xgeommasktogravity(int);
+@@ -1488,7 +1488,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
+ }
+
+ void
+-xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
++xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y, int dmode)
+ {
+ int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
+ int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch,
+@@ -1579,23 +1579,21 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
+ if (base.mode & ATTR_INVISIBLE)
+ fg = bg;
+
+- /* Intelligent cleaning up of the borders. */
+- if (x == 0) {
+- xclear(0, (y == 0)? 0 : winy, win.hborderpx,
+- winy + win.ch +
+- ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
+- }
+- if (winx + width >= win.hborderpx + win.tw) {
+- xclear(winx + width, (y == 0)? 0 : winy, win.w,
+- ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
+- }
+- if (y == 0)
+- xclear(winx, 0, winx + width, win.vborderpx);
+- if (winy + win.ch >= win.vborderpx + win.th)
+- xclear(winx, winy + win.ch, winx + width, win.h);
+-
+- /* Clean up the region we want to draw to. */
+- XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
++ if (dmode & DRAW_BG) {
++ /* Intelligent cleaning up of the borders. */
++ if (x == 0) {
++ xclear(0, (y == 0)? 0 : winy, win.vborderpx,
++ winy + win.ch +
++ ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
++ }
++ if (winx + width >= win.hborderpx + win.tw) {
++ xclear(winx + width, (y == 0)? 0 : winy, win.w,
++ ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
++ }
++ if (y == 0)
++ xclear(winx, 0, winx + width, win.hborderpx);
++ if (winy + win.ch >= win.vborderpx + win.th)
++ xclear(winx, winy + win.ch, winx + width, win.h);
+
+ /* Set the clip region because Xft is sometimes dirty. */
+ r.x = 0;
+@@ -1604,22 +1602,29 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
+ r.width = width;
+ XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1);
+
+- if (base.mode & ATTR_BOXDRAW) {
+- drawboxes(winx, winy, width / len, win.ch, fg, bg, specs, len);
+- } else {
+- /* Render the glyphs. */
+- XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
+- }
++ /* Fill the background */
++ XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
+
+- /* Render underline and strikethrough. */
+- if (base.mode & ATTR_UNDERLINE) {
+- 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 + win.cyo + 2 * dc.font.ascent / 3,
+- width, 1);
++ if (dmode & DRAW_FG) {
++ if (base.mode & ATTR_BOXDRAW) {
++ drawboxes(winx, winy, width / len, win.ch, fg, bg, specs, len);
++ } else {
++ /* Render the glyphs. */
++ XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
++ }
++
++ /* Render underline and strikethrough. */
++ if (base.mode & ATTR_UNDERLINE) {
++ 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 + win.cyo + 2 * dc.font.ascent / 3,
++ width, 1);
++ }
+ }
+
+ /* Reset clip to none. */
+@@ -1633,7 +1638,7 @@ xdrawglyph(Glyph g, int x, int y)
+ XftGlyphFontSpec spec;
+
+ numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y);
+- xdrawglyphfontspecs(&spec, g, numspecs, x, y);
++ xdrawglyphfontspecs(&spec, g, numspecs, x, y, DRAW_BG | DRAW_FG);
+ }
+
+ void
+@@ -1768,32 +1773,39 @@ xstartdraw(void)
+ void
+ xdrawline(Line line, int x1, int y1, int x2)
+ {
+- int i, x, ox, numspecs;
++ int i, x, ox, numspecs, numspecs_cached;
+ Glyph base, new;
+- XftGlyphFontSpec *specs = xw.specbuf;
+-
+- numspecs = xmakeglyphfontspecs(specs, &line[x1], x2 - x1, x1, y1);
+- i = ox = 0;
+- for (x = x1; x < x2 && i < numspecs; x++) {
+- new = line[x];
+- if (new.mode == ATTR_WDUMMY)
+- continue;
+- if (selected(x, y1))
+- new.mode ^= ATTR_REVERSE;
+- if (i > 0 && ATTRCMP(base, new)) {
+- xdrawglyphfontspecs(specs, base, i, ox, y1);
+- specs += i;
+- numspecs -= i;
+- i = 0;
+- }
+- if (i == 0) {
+- ox = x;
+- base = new;
++ XftGlyphFontSpec *specs;
++
++ numspecs_cached = xmakeglyphfontspecs(xw.specbuf, &line[x1], x2 - x1, x1, y1);
++
++ /* Draw line in 2 passes: background and foreground. This way wide glyphs
++ won't get truncated (#223) */
++ for (int dmode = DRAW_BG; dmode <= DRAW_FG; dmode <<= 1) {
++ specs = xw.specbuf;
++ numspecs = numspecs_cached;
++ i = ox = 0;
++ for (x = x1; x < x2 && i < numspecs; x++) {
++ new = line[x];
++ if (new.mode == ATTR_WDUMMY)
++ continue;
++ if (selected(x, y1))
++ new.mode ^= ATTR_REVERSE;
++ if (i > 0 && ATTRCMP(base, new)) {
++ xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
++ specs += i;
++ numspecs -= i;
++ i = 0;
++ }
++ if (i == 0) {
++ ox = x;
++ base = new;
++ }
++ i++;
+ }
+- i++;
++ if (i > 0)
++ xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
+ }
+- if (i > 0)
+- xdrawglyphfontspecs(specs, base, i, ox, y1);
+ }
+
+ void
diff --git a/st b/st
index d32463d..6216640 100755
--- a/st
+++ b/st
Binary files differ
diff --git a/st.h b/st.h
index f6bd3b4..7185544 100644
--- a/st.h
+++ b/st.h
@@ -37,6 +37,12 @@ enum glyph_attribute {
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
};
+enum drawing_mode {
+ DRAW_NONE = 0,
+ DRAW_BG = 1 << 0,
+ DRAW_FG = 1 << 1,
+};
+
enum selection_mode {
SEL_IDLE = 0,
SEL_EMPTY = 1,
diff --git a/x.c b/x.c
index 9747ce0..0a7a7dc 100644
--- a/x.c
+++ b/x.c
@@ -158,7 +158,7 @@ typedef struct {
static inline ushort sixd_to_16bit(int);
static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int);
-static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
+static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int, int);
static void xdrawglyph(Glyph, int, int);
static void xclear(int, int, int, int);
static int xgeommasktogravity(int);
@@ -1498,7 +1498,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
}
void
-xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
+xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y, int dmode)
{
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch,
@@ -1584,25 +1584,23 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
if (base.mode & ATTR_INVISIBLE)
fg = bg;
+ if (dmode & DRAW_BG) {
+ /* Intelligent cleaning up of the borders. */
+ if (x == 0) {
+ xclear(0, (y == 0)? 0 : winy, win.vborderpx,
+ winy + win.ch +
+ ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
+ }
+ if (winx + width >= win.hborderpx + win.tw) {
+ xclear(winx + width, (y == 0)? 0 : winy, win.w,
+ ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
+ }
+ if (y == 0)
+ xclear(winx, 0, winx + width, win.hborderpx);
+ if (winy + win.ch >= win.vborderpx + win.th)
+ xclear(winx, winy + win.ch, winx + width, win.h);
- /* Intelligent cleaning up of the borders. */
- if (x == 0) {
- xclear(0, (y == 0)? 0 : winy, win.vborderpx,
- winy + win.ch +
- ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
- }
- if (winx + width >= win.hborderpx + win.tw) {
- xclear(winx + width, (y == 0)? 0 : winy, win.w,
- ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
- }
- if (y == 0)
- xclear(winx, 0, winx + width, win.vborderpx);
- if (winy + win.ch >= win.vborderpx + win.th)
- xclear(winx, winy + win.ch, winx + width, win.h);
-
- /* Clean up the region we want to draw to. */
- XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
-
+
/* Set the clip region because Xft is sometimes dirty. */
r.x = 0;
r.y = 0;
@@ -1610,27 +1608,45 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
r.width = width;
XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1);
- if (base.mode & ATTR_BOXDRAW) {
- drawboxes(winx, winy, width / len, win.ch, fg, bg, specs, len);
- } else {
- /* Render the glyphs. */
- XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
- }
+
+ /* Fill the background */
+ XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
+ }
/* Render underline and strikethrough. */
- if (base.mode & ATTR_UNDERLINE) {
+ ///if (base.mode & ATTR_UNDERLINE) {
//XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1,
//XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent * chscale + 1,
- XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent + 1,
- width, 1);
- }
+ /// XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent + 1,
+ /// width, 1);
+ //}
- if (base.mode & ATTR_STRUCK) {
+ ///if (base.mode & ATTR_STRUCK) {
//XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent * chscale / 3,
//XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent * chscale / 3,
- XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent / 3,
- width, 1);
- }
+ /// XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent / 3,
+ /// width, 1);
+ ///}
+
+ if (dmode & DRAW_FG) {
+ if (base.mode & ATTR_BOXDRAW) {
+ drawboxes(winx, winy, width / len, win.ch, fg, bg, specs, len);
+ } else {
+ /* Render the glyphs. */
+ XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
+ }
+
+ /* Render underline and strikethrough. */
+ if (base.mode & ATTR_UNDERLINE) {
+ 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 + win.cyo + 2 * dc.font.ascent / 3,
+ width, 1);
+ }
+ }
/* Reset clip to none. */
XftDrawSetClip(xw.draw, 0);
@@ -1643,7 +1659,7 @@ xdrawglyph(Glyph g, int x, int y)
XftGlyphFontSpec spec;
numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y);
- xdrawglyphfontspecs(&spec, g, numspecs, x, y);
+ xdrawglyphfontspecs(&spec, g, numspecs, x, y, DRAW_BG | DRAW_FG);
}
void
@@ -1793,32 +1809,39 @@ xstartdraw(void)
void
xdrawline(Line line, int x1, int y1, int x2)
{
- int i, x, ox, numspecs;
+ int i, x, ox, numspecs, numspecs_cached;
Glyph base, new;
- XftGlyphFontSpec *specs = xw.specbuf;
-
- numspecs = xmakeglyphfontspecs(specs, &line[x1], x2 - x1, x1, y1);
- i = ox = 0;
- for (x = x1; x < x2 && i < numspecs; x++) {
- new = line[x];
- if (new.mode == ATTR_WDUMMY)
- continue;
- if (selected(x, y1))
- new.mode ^= ATTR_REVERSE;
- if (i > 0 && ATTRCMP(base, new)) {
- xdrawglyphfontspecs(specs, base, i, ox, y1);
- specs += i;
- numspecs -= i;
- i = 0;
- }
- if (i == 0) {
- ox = x;
- base = new;
+ XftGlyphFontSpec *specs;
+
+ numspecs_cached = xmakeglyphfontspecs(xw.specbuf, &line[x1], x2 - x1, x1, y1);
+
+ /* Draw line in 2 passes: background and foreground. This way wide glyphs
+ won't get truncated (#223) */
+ for (int dmode = DRAW_BG; dmode <= DRAW_FG; dmode <<= 1) {
+ specs = xw.specbuf;
+ numspecs = numspecs_cached;
+ i = ox = 0;
+ for (x = x1; x < x2 && i < numspecs; x++) {
+ new = line[x];
+ if (new.mode == ATTR_WDUMMY)
+ continue;
+ if (selected(x, y1))
+ new.mode ^= ATTR_REVERSE;
+ if (i > 0 && ATTRCMP(base, new)) {
+ xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
+ specs += i;
+ numspecs -= i;
+ i = 0;
+ }
+ if (i == 0) {
+ ox = x;
+ base = new;
+ }
+ i++;
}
- i++;
+ if (i > 0)
+ xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
}
- if (i > 0)
- xdrawglyphfontspecs(specs, base, i, ox, y1);
}
void
diff --git a/x.o b/x.o
index 6c9538e..64dd5b1 100644
--- a/x.o
+++ b/x.o
Binary files differ