Re: [dwm] on-the-fly tags creation and deletion

From: Sander van Dijk <a.h.vandijk_AT_gmail.com>
Date: Mon, 21 Aug 2006 11:24:44 +0200

On 8/21/06, Julian Romero <julian.romero+dwm_AT_gmail.com> wrote:
> > > #define TAGS \
> > > -const char *tags[] = { "0", "1", "2", "3", "4", NULL };
> > > +char *tags[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
> >
> > I think this tag-interface is quite an ugly hack. What happens
> > if a user creates 15 new tags or more during runtime?
> >
> That's an implementation problem (I'm not very fluent in C) Nothing to
> do with the interface or with the feature itself, doesn't it?

Well, I find that it does have something to do with the interface.
This reusing of stdin for sending commands was suggested before (maybe
by you, I don't remember, sorry), and I find it quite ugly. Stdin is
for status-info, using it in this way for commands too is conceptually
"not nice". It would be slightly better if you'd change it so that
status displaying is a command too, so that only lines with the form
(for instance) "status blabla" would be displayed (without the leading
"status " of course). Than at least things would be more consistent. I
think it would still be too crude for dwm main though...

> Now I'll try to write a better implementation (to merge with my sticky
> layout mainly)
> Any help will be welcomed.

One aesthetic suggestion: get rid of the #define CMDLEN. It's an
abstraction that's quite useless I believe (and it puts an unnecessary
restriction on any future commands you might want to add). I'd
hardcode the value of CMDLEN in the
strncmp's, add a char* argument to addtag() and seltag(), and then
pass stext+cmdlen to these functions (so that CMDLEN isn't needed in
there anymore).
Something like this:
    if (0 == strncmp("add tag ", stext, 8))
        addtag(stext+8);

I think that would both look cleaner and make it easier to extend (add
longer/shorter commands) in the future.

Greetings, Sander.
Received on Mon Aug 21 2006 - 11:24:46 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:30:15 UTC