]> code.delx.au - spectrwm/commitdiff
Add new character sequence used for padding.
authorTiago Cunha <tcunha@gmx.com>
Wed, 13 Jun 2012 21:44:12 +0000 (22:44 +0100)
committerTiago Cunha <tcunha@gmx.com>
Tue, 26 Jun 2012 18:44:27 +0000 (19:44 +0100)
Instead of inserting sequential spaces one by one, add support for
padding with the +< character pair. Uses the specified limit or one
otherwise.

spectrwm.1
spectrwm.c
spectrwm.conf

index 2404cfb0decbc4ecbebb9a5f20ab118ba6b790ab..e2335d7421753ea395ba3d181ce7c28fd1471eb7 100644 (file)
@@ -115,6 +115,7 @@ before being used.
 It may contain the following character sequences:
 .Bl -column "Character sequence" "Replaced with" -offset indent
 .It Sy "Character sequence" Ta Sy "Replaced with"
+.It Li "+<" Ta "Pad with a space"
 .It Li "+A" Ta "Output of the external script"
 .It Li "+C" Ta "Window class"
 .It Li "+D" Ta "Workspace name"
index 05d5a737fa576c6b945d69bcbed7b8c57fa0b030..891633198db222576cf5aae5173a72c512dffbfd 100644 (file)
@@ -1486,21 +1486,21 @@ bar_fmt(const char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz)
        /* only show the workspace name if there's actually one */
        if (r != NULL && r->ws != NULL && r->ws->name != NULL)
                strlcat(fmtnew, "<+D>", sz);
-       strlcat(fmtnew, "   ", sz);
+       strlcat(fmtnew, "+3<", sz);
 
        if (clock_enabled) {
                strlcat(fmtnew, fmtexp, sz);
-               strlcat(fmtnew, "    ", sz);
+               strlcat(fmtnew, "+4<", sz);
        }
 
        /* bar_urgent already adds the space before the last asterisk */
        if (urgent_enabled)
-               strlcat(fmtnew, "* +U*    ", sz);
+               strlcat(fmtnew, "* +U*+4<", sz);
 
        if (title_class_enabled) {
                strlcat(fmtnew, "+C", sz);
                if (title_name_enabled == 0)
-                       strlcat(fmtnew, "    ", sz);
+                       strlcat(fmtnew, "+4<", sz);
        }
 
        /* checks needed by the colon and floating strlcat(3) calls below */
@@ -1508,7 +1508,7 @@ bar_fmt(const char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz)
                if (title_name_enabled) {
                        if (title_class_enabled)
                                strlcat(fmtnew, ":", sz);
-                       strlcat(fmtnew, "+T    ", sz);
+                       strlcat(fmtnew, "+T+4<", sz);
                }
                if (window_name_enabled) {
                        if (r->ws->focus->floating)
@@ -1518,7 +1518,7 @@ bar_fmt(const char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz)
        }
 
        /* finally add the action script output and the version */
-       strlcat(fmtnew, "    +A    +V", sz);
+       strlcat(fmtnew, "+4<+A+4<+V", sz);
 }
 
 /* replaces the bar format character sequences (like in tmux(1)) */
@@ -1556,6 +1556,12 @@ bar_replace_seq(char *fmt, char *fmtrep, struct swm_region *r, size_t *offrep,
                return (fmt);
 
        switch (*fmt) {
+       case '<':
+               /* special case; no limit given, pad one space, instead */
+               if (limit == sizeof tmp - 1)
+                       limit = 1;
+               snprintf(tmp, sizeof tmp, "%*s", limit, " ");
+               break;
        case 'A':
                snprintf(tmp, sizeof tmp, "%s", bar_ext);
                break;
index 9c234f8431c1e77c858f7c770e2daf01acf16942..f56559ad3e8bda4fff2568444b7b1196d8a4b7e0 100644 (file)
@@ -27,7 +27,7 @@
 # bar_action           = baraction.sh
 # bar_delay            = 1
 # bar_justify          = left
-# bar_format           = +N:+I +S <+D>   %a %b %d %R %Z %Y             +A    +V
+# bar_format           = +N:+I +S <+D>+4<%a %b %d %R %Z %Y+8<+A+4<+V
 # bar_at_bottom                = 1
 # stack_enabled                = 1
 # clock_enabled                = 1