X-Git-Url: https://git.distorted.org.uk/~mdw/xtoys/blobdiff_plain/3a4bdbcb848307f089c1dc06b63a0b7e3a43978b..c5f8baff93b1a66fd66136781db7a75a846e84e7:/xscsize.c diff --git a/xscsize.c b/xscsize.c index 0cd4cbd..46d58f7 100644 --- a/xscsize.c +++ b/xscsize.c @@ -74,6 +74,23 @@ Options:\n\ fp); } +static void print_var(const char *name, unsigned long value) +{ + if (index >= 0) { + dstr_putf(&d, "XSCR%d_%s", index, name); + name = d.buf; + } + if (flags & F_SH) { + printf("%s=%lu", name, value); + if (flags & F_EXPORT) printf("; export %s", name); + } else if (flags & F_CSH) { + if (flags & F_EXPORT) printf("setenv %s %lu", name, value); + else printf("set %s=%lu", name, value); + } + putchar('\n'); + dstr_destroy(&d); +} + int main(int argc, char *argv[]) { Display *dpy; @@ -150,18 +167,8 @@ int main(int argc, char *argv[]) /* --- Do the output thing --- */ - if (f & f_sh) { - printf("XWIDTH=%lu XHEIGHT=%lu", wd, ht); - if (f & f_export) - printf("; export XWIDTH XHEIGHT"); - } - if (f & f_csh) { - if (f & f_export) - printf("setenv XWIDTH %lu; setenv XHEIGHT %lu", wd, ht); - else - printf("set XWIDTH=%lu XHEIGHT=%lu", wd, ht); - } - putchar('\n'); + print_var("XWIDTH", wd); + print_var("XHEIGHT", ht); /* --- Done --- */