From e2b7ec997e5cf166f366ef444ad9e03306e2a429 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 12 Jan 2016 15:25:15 +1100 Subject: [PATCH] Fix drawing of cursor. Draw block background in gtk display. Also fix handling around '<'. Signed-off-by: NeilBrown --- doc-text.c | 7 ++++++- python/display-pygtk.py | 22 ++++++++++++++++------ render-lines.c | 2 ++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/doc-text.c b/doc-text.c index 9cd5cdf0..3967df4e 100644 --- a/doc-text.c +++ b/doc-text.c @@ -1649,8 +1649,13 @@ DEF_CMD(render_line) buf_concat(&b, attr); buf_append(&b, '>'); } - if (ch == '<') + if (ch == '<') { + if (o >= 0 && b.len+1 >= o) { + mark_prev(d, m); + break; + } buf_append(&b, '<'); + } if (ch < ' ' && ch != '\t' && ch != '\n') { buf_concat(&b, "^"); buf_append(&b, '@' + ch); diff --git a/python/display-pygtk.py b/python/display-pygtk.py index 59252b8a..4151c189 100644 --- a/python/display-pygtk.py +++ b/python/display-pygtk.py @@ -64,6 +64,8 @@ class EdDisplay(gtk.Window): self.gc = t.window.new_gc() cmap = t.get_colormap() self.gc.set_foreground(cmap.alloc_color(gtk.gdk.color_parse("blue"))) + if not self.bg: + self.bg = t.window.new_gc() (x,y) = a["xy"] f = a["focus"] @@ -79,7 +81,10 @@ class EdDisplay(gtk.Window): pm = self.get_pixmap(f) metric = ctx.get_metrics(fd) ascent = metric.get_ascent() / pango.SCALE - pm.draw_layout(self.gc, x, y-ascent, layout, fg, bg) + ink,(lx,ly,width,height) = layout.get_pixel_extents() + self.bg.set_foreground(bg) + pm.draw_rectangle(self.bg, True, x+lx, y-ascent+ly, width, height) + pm.draw_layout(self.gc, x, y-ascent, layout, fg) if a['numeric'] >= 0: cx,cy,cw,ch = layout.index_to_pos(a["numeric"]) if cw <= 0: @@ -96,8 +101,14 @@ class EdDisplay(gtk.Window): extra = False f = f.parent if extra: - pm.draw_rectangle(self.gc, False, x+cx+1, y-ascent+cy+1, - cw-3, ch-3); + pm.draw_rectangle(self.gc, True, x+cx, y-ascent+cy, + cw, ch); + c = a["numeric"] + if c < len(a["str"]): + s = unicode(a["str"][c:], "utf-8") + l2 = pango.Layout(ctx) + l2.set_text(s[0]) + pm.draw_layout(self.gc, x+cx, y-ascent+cy, l2, bg) if key == "Notify:Close": f = a["focus"] @@ -258,10 +269,9 @@ class EdDisplay(gtk.Window): def do_clear(self, pm, colour): t = self.text - if not self.bg or True: + if not self.bg: self.bg = t.window.new_gc() - cmap = t.get_colormap() - self.bg.set_foreground(colour) + self.bg.set_foreground(colour) (w,h) = pm.get_size() pm.draw_rectangle(self.bg, True, 0, 0, w, h) diff --git a/render-lines.c b/render-lines.c index 3f684d2d..17db3032 100644 --- a/render-lines.c +++ b/render-lines.c @@ -332,6 +332,8 @@ static void render_line(struct pane *p, char *line, int *yp, int dodraw, if (ch == '<') { line += 1; if (*line == '<') { + if (offset == start - line_start) + offset += 1; start = line; line += 1; } else { -- 2.39.5