From: NeilBrown Date: Thu, 10 Dec 2015 02:33:30 +0000 (+1100) Subject: Use pane_attr_get to get linecount attributes for 'view'. X-Git-Tag: lca2016~79 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=81e0600a95b2ed0e0a867548ad241839c8744762;p=edlib.git Use pane_attr_get to get linecount attributes for 'view'. This reduced need for 'doc'. Signed-off-by: NeilBrown --- diff --git a/core.h b/core.h index cbf9da98..1e252664 100644 --- 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 diff --git a/lib-view.c b/lib-view.c index 811e4c6c..722f5421 100644 --- a/lib-view.c +++ b/lib-view.c @@ -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;