]> git.neil.brown.name Git - edlib.git/commitdiff
Fix drawing of cursor.
authorNeilBrown <neil@brown.name>
Tue, 12 Jan 2016 04:25:15 +0000 (15:25 +1100)
committerNeilBrown <neil@brown.name>
Wed, 13 Jan 2016 04:42:15 +0000 (15:42 +1100)
Draw block background in gtk display.
Also fix handling around '<'.

Signed-off-by: NeilBrown <neil@brown.name>
doc-text.c
python/display-pygtk.py
render-lines.c

index 9cd5cdf074cffe0f87b3fbceb78fd8b967533c3a..3967df4e6421423ee46eb46ed6bfa9b049cf7d43 100644 (file)
@@ -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, "<fg:red>^");
                        buf_append(&b, '@' + ch);
index 59252b8a559bc32d6ebe82cf995cb78fa5fcfa34..4151c189ccdf8b8f5c2ae3f688f1c14b07685525 100644 (file)
@@ -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)
 
index 3f684d2d6db0789720ca014bfd878d50d955dffc..17db30326c75424fc80f8008d434ea8b172a7387 100644 (file)
@@ -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 {