]> git.neil.brown.name Git - edlib.git/commitdiff
Use pane_attr_get to get linecount attributes for 'view'.
authorNeilBrown <neil@brown.name>
Thu, 10 Dec 2015 02:33:30 +0000 (13:33 +1100)
committerNeilBrown <neil@brown.name>
Thu, 10 Dec 2015 04:10:01 +0000 (15:10 +1100)
This reduced need for 'doc'.

Signed-off-by: NeilBrown <neil@brown.name>
core.h
lib-view.c

diff --git a/core.h b/core.h
index cbf9da989b3dca961c6de0ffc2cfe192ed6d794b..1e2526649574c09f5ca70ba829504f34d0d68901 100644 (file)
--- a/core.h
+++ b/core.h
@@ -336,6 +336,19 @@ char *pane_attr_get(struct pane *p, char *key);
 struct pane *call_pane(char *key, struct pane *focus, int numeric,
                       struct mark *m, int extra);
 
+static inline int pane_attr_get_int(struct pane *p, char *key)
+{
+       char *c = pane_attr_get(p, key);
+       int rv;
+       char *end;
+       if (!c)
+               return -1;
+       rv = strtol(c, &end, 10);
+       if (end == c || *end)
+               return -1;
+       return rv;
+}
+
 static inline struct pane *pane_child(struct pane *p)
 {
        /* Find a child (if any) with z=0.  There should be
index 811e4c6c35cf97ae527c85f81087ed5f12c8ec66..722f5421578086839f3dc751d6aaa20a51f726af 100644 (file)
@@ -67,9 +67,9 @@ static int view_refresh(struct cmd_info *ci)
                        key_handle(&ci2);
 
                        ln = attr_find_int(*mark_attr(m), "lines");
-                       l = attr_find_int(d->attrs, "lines");
-                       w = attr_find_int(d->attrs, "words");
-                       c = attr_find_int(d->attrs, "chars");
+                       l = pane_attr_get_int(ci->home, "lines");
+                       w = pane_attr_get_int(ci->home, "words");
+                       c = pane_attr_get_int(ci->home, "chars");
                        if (l <= 0)
                                l = 1;
                        mid = 1 + (p->h-4) * ln / l;