Re: [dev] wmii9menu items alignment

From: Kris Maglione <>
Date: Thu, 26 Aug 2010 14:33:51 -0400

On Wed, Aug 25, 2010 at 09:48:24PM -0400, Vladimir Levin wrote:
>I'm very new to this mailing list, but have been using wmii for
>a year or so now. It's an awesome WM. Thank you very much for
>maintaining it.
>Here's my humble contribution.
>I found that some menu scripts that I've thrown together look
>much better with the items aligned to the left. As a result, I
>wrote a small patch to the wmii9menu.c which adds an optional
>-p flag and takes left right or centered as an argument. This
>allows the user to specify which way to align the items in the

I've actually considered this myself. I've written scripts which
have looked rather bad with the items centered. However, if I
were going to add a feature, it would only be a -l flag for left
alignment, since I can't see a use for right alignment and
couldn't justify the extra complexity.

>The diff follows. I'm not sure how people react to these things
>(I'm new to all mailing lists)... but hopefully this helps
>someone who might be looking for the same thing.

Patches are generally well received, so long as you don't expect
them to be added to mainline when new features are involved.

I will say, though, that you should try to stick to the coding
style of the files you patched. It may just be your mail client,
but it looks like you've changed tabstops to 4 and expanded
tabs, which means that this patch won't apply without the -l
flag. Also, I'd suggest the following modifications to maintain
consistent style:

diff -r b767f9a84346 cmd/x11/wmii9menu.c
--- a/cmd/x11/wmii9menu.c Mon Aug 16 19:38:17 2010 -0400
+++ b/cmd/x11/wmii9menu.c Wed Aug 25 21:37:41 2010 -0400
@@ -71,6 +71,7 @@
  static char** labels; /* list of labels and commands */
  static char** commands;
  static int numitems;
+static Align align = Center;

  void usage(void);
  void run_menu(void);
@@ -124,6 +127,17 @@
      case 'i':
          initial = EARGF(usage());
+ case 'p':
+ cp = EARGF(usage());
+ align = (strcmp(alignString, "left") == 0) ? West :
+ (strcmp(alignString, "right") == 0) ? East :
+ (strcmp(alignString, "center") == 0) ? Center :
+ North;
+ if(align == North)
+ usage();
+ break;
@@ -173,7 +187,7 @@
      lprint(2, "usage: %s -v\n", argv0);
- lprint(2, " %s [-a <address>] [-i <arg>] menitem[:command]
...\n", argv0);
+ lprint(2, " %s [-a <address>] [-i <arg>] [-p <left|center|right>]
menitem[:command] ...\n", argv0);

@@ -306,7 +320,7 @@
              c = &cnorm;
          r = rectsetorigin(r, Pt(0, i * high));
          fill(menuwin, r, &c->bg);
- drawstring(menuwin, font, r, Center, labels[i], &c->fg);
+ drawstring(menuwin, font, r, align, labels[i], &c->fg);

Kris Maglione
The trouble with the world is that the stupid are cocksure and the
intelligent full of doubt.
         --Bertrand Russell
Received on Thu Aug 26 2010 - 20:33:51 CEST

This archive was generated by hypermail 2.2.0 : Thu Aug 26 2010 - 20:36:02 CEST