Re: [hackers] [dwm][PATCH] Status bar magic numbers replaced with configurable variables.

From: David Demelier <markand_AT_malikania.fr>
Date: Fri, 25 May 2018 12:59:10 +0200

On Fri, 2018-05-25 at 06:50 +0200, Hiltjo Posthuma wrote:
> On Thu, May 24, 2018 at 10:48:27PM -0400, Christopher Drelich wrote:
> > Currently in dwm there are two magic numbers relating to the
> > statusbar in dwm.c:
> >
> > sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
> >
> > bh = drw->fonts->h + 2;
> >
> > I made a patch that replaced these magic numbers with configurable
> > variables, plus a third configurable variable that made sense with
> > these:
> >
> > vertbarpad is vertical padding for the statusbar.
> > horizbarpad is horizontal padding for the statusbar.
> > statusrpad is right hand padding for StatusText in the statusbar.
> >
> > It would be possible to add a 'statuslpad' as well, or to just make
> > the padding for the StatusText the same as that for other elements
> > of
> > the statusbar, or to divide it by 2 and just use that for the
> > rightpadding.
> >
> > I think that having StatusText have the same padding as other
> > elements
> > in the statusbar would probably end up making things cleanest.
> >
> > The main purpose of this patch is to eliminate 'magic numbers,' so
> > the
> > hope is to open up discussion on how to do that, be it by this
> > patch,
> > a suggested variant of it, something else, or if people think they
> > should just stay.
> > Chris
> >
>
> How are they magic? Is any number in arithmetic some magic number for
> you?
>

Yes but at least when you want to adjust the padding you only have to
do it in one place.

I completely second this patch.

Regards,

-- 
David
Received on Fri May 25 2018 - 12:59:10 CEST

This archive was generated by hypermail 2.3.0 : Fri May 25 2018 - 13:00:34 CEST