int closing;
};
+DEF_CMD(text_size_callback)
+{
+ struct call_return *cr = container_of(ci->comm, struct call_return, c);
+ cr->x = ci->x;
+ cr->y = ci->y;
+ cr->i = ci->numeric;
+ cr->i2 = ci->extra;
+ return 1;
+}
+
+static int line_height(struct pane *p)
+{
+ struct call_return cr;
+
+ cr.c = text_size_callback;
+ call_comm7("text-size", p, -1, NULL, "x", 0, "", &cr.c);
+ return cr.y;
+}
+
static void popup_resize(struct pane *p, char *style)
{
int x,y,w,h;
+ int lh;
+
/* First find the size */
+ lh = line_height(p);
if (strchr(style, 'M'))
h = p->parent->h/2 + 1;
else
- h = 3;
+ h = lh * 3;
w = p->parent->w/2;
if (strchr(style, '1')) w = (p->parent->w-2)/4 + 1;
if (strchr(style, '3')) w = 3 * (p->parent->w-2)/4;
self.set_title("EDLIB")
self.connect('destroy', self.close_win)
self.create_ui()
+ self.need_refresh = True
self.pane.w = self.charwidth * 80
self.pane.h = self.lineheight * 24
self.show()
l2 = pango.Layout(ctx)
l2.set_text(s[0])
pm.draw_layout(self.gc, x+cx, y-ascent+cy, l2, bg)
+ return True
if key == "Notify:Close":
f = a["focus"]
def refresh(self, *a):
- self.pane.refresh()
+ if self.need_refresh:
+ self.pane.refresh()
+ self.need_refresh = False
l = self.panes.keys()
l.sort(key=lambda pane: pane.abs_z)
for p in l:
def reconfigure(self, w, ev):
alloc = w.get_allocation()
+ if self.pane.w == alloc.width and self.pane.h == alloc.height:
+ return None
self.pane.w = alloc.width
self.pane.h = alloc.height
+ self.need_refresh = True
self.text.queue_draw()
def press(self, c, event):
if event.state & gtk.gdk.MOD1_MASK:
s = "M-" + s;
self.pane.call_xy("Mouse-event", "Click-1", self.pane, (x,y))
- self.refresh()
+ self.pane.refresh()
eventmap = { "Return" : "Return",
"Tab" : "Tab",
CP = offset - (start - line_start);
ret = 0;
- if (offset >= 0 && line - line_start <= offset) {
+ if (offset >= 0 && start - line_start <= offset) {
*cyp = y;
*cxp = x;
}
if (attr.len == 2)
attr.len = 0;
}
+ if (offset == start - line_start)
+ offset += line-start;
start = line;
mwidth = -1;
}