summaryrefslogtreecommitdiffstats
path: root/layout-custom.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-01-30 20:57:02 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-01-30 20:57:02 +0000
commit49a5a587ec6c99e4030d51cb65f04d49c87e3c31 (patch)
tree3fc2fbe7ac5452bc84db72ae6318823698573e09 /layout-custom.c
parent677ed3e5f0ed6296e421c974a3e4c90cefe2024c (diff)
Add pane id to each pane in layout description (while still accepting
the old form). Based on diff from George Nachman.
Diffstat (limited to 'layout-custom.c')
-rw-r--r--layout-custom.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/layout-custom.c b/layout-custom.c
index 9fb9cebd..88fcde1f 100644
--- a/layout-custom.c
+++ b/layout-custom.c
@@ -79,8 +79,13 @@ layout_append(struct layout_cell *lc, char *buf, size_t len)
if (len == 0)
return (-1);
- tmplen = xsnprintf(tmp, sizeof tmp,
- "%ux%u,%u,%u", lc->sx, lc->sy, lc->xoff, lc->yoff);
+ if (lc->wp != NULL) {
+ tmplen = xsnprintf(tmp, sizeof tmp, "%ux%u,%u,%u,%u",
+ lc->sx, lc->sy, lc->xoff, lc->yoff, lc->wp->id);
+ } else {
+ tmplen = xsnprintf(tmp, sizeof tmp, "%ux%u,%u,%u",
+ lc->sx, lc->sy, lc->xoff, lc->yoff);
+ }
if (tmplen > (sizeof tmp) - 1)
return (-1);
if (strlcat(buf, tmp, len) >= len)
@@ -202,7 +207,8 @@ layout_construct(struct layout_cell *lcparent, const char **layout)
if (!isdigit((u_char) **layout))
return (NULL);
- if (sscanf(*layout, "%ux%u,%u,%u", &sx, &sy, &xoff, &yoff) != 4)
+ if (sscanf(*layout, "%ux%u,%u,%u,%*u", &sx, &sy, &xoff, &yoff) != 5 &&
+ sscanf(*layout, "%ux%u,%u,%u", &sx, &sy, &xoff, &yoff) != 4)
return (NULL);
while (isdigit((u_char) **layout))
@@ -222,6 +228,11 @@ layout_construct(struct layout_cell *lcparent, const char **layout)
(*layout)++;
while (isdigit((u_char) **layout))
(*layout)++;
+ if (**layout == ',') {
+ (*layout)++;
+ while (isdigit((u_char) **layout))
+ (*layout)++;
+ }
lc = layout_create_cell(lcparent);
lc->sx = sx;