Re: [dwm] [dvtm-patch] Status bar optional
On Tue, Feb 19, 2008 at 07:10:09PM +0100, Claudio M. Alessi wrote: On Tue, Feb 19, 2008 at 06:57:21PM +0100, Marc Andre Tanner wrote: I don't want to clutter the code with all the #ifdefs plus some day we might introduce tags/workspaces and then a statusbar will become more important. I hope this will never happen. Have a nice day. Bad news for you then, i have already played around a bit with this. See the branch called tagging in the git repository for the outcome. If you set BARPOS to BarOff in config.h you shouldn't notice a difference to the current default behaviour. Regards, Marc -- Marc Andre Tanner http://www.brain-dump.org/ GPG key: CF7D56C0
Re: [dwm] [dvtm-patch] Status bar optional
I'm not trying to insult you, but I don't see the point of having the status bar as a compile time option. I cannot try it know, but I think when you don't set the status text to anything (you don't use the -s option), you won't have the status bar. Adding complexity with the code with #ifdefs for this option is not a good idea, IMO. Maybe you want to have a look at http://doc.cat-v.org/henry_spencer/ifdef_considered_harmful.pdf, it is worth reading. hth, -- - yiyus || JGL .
[dwm] [dvtm-patch] Status bar optional
Hi, i'm continuing to study the dvtm code in order to be able to make some real improvement. I'm a (not so) beginner C programmer so all my experiments and your points of view about are useful to improve myself (not only dvtm). It's free software, after all. As for the mouse support, i don't use the status bar at all (at least not in box other than my laptop) so there is no reason to build such feature. Even i think that such modularization help to make the code cleaner (e.g. i had to move the terminal size variables from the updatebaros() function to the resize_screen() one, which seems to be a better place for them). This will give a bit of work to Leonardo Taccari which is working on the pkgsrc dvtm packages; a new option is needed, i guess. Hope this helps but, if not, feel free to insult me ;-) -- Claudio M. Alessi -BEGIN GEEK CODE BLOCK- Version: 3.1 GCS/MU d-@ s: a-- C++(+++) UB++$ P+ !L E--- W++(+++) N+@ o-- K? w+@ O-@ M- V? PS+@ PE+@ Y+ PGP t(-)@ 5? X+ R? tv-- b+ DI-- D? G e+@ h--@ r y* --END GEEK CODE BLOCK-- --- ../dvtm-0.4.orig/dvtm.c 2008-02-16 12:09:13.191369197 +0100 +++ dvtm.c 2008-02-19 13:31:27.751955582 +0100 @@ -101,7 +101,6 @@ void focusprev(const char *args[]); void focusprevnm(const char *args[]); void toggleminimize(const char *args[]); -void togglebar(const char *args[]); void setmwfact(const char *args[]); void setlayout(const char *args[]); void redraw(const char *args[]); @@ -112,10 +111,14 @@ void mouse_minimize(const char *args[]); void mouse_zoom(const char *args[]); +#if defined(STATUS_BAR) +void togglebar(const char *args[]); +void drawbar(); +#endif /* STATUS_BAR */ + void clear_workspace(); void draw_all(bool border); void draw_border(Client *c); -void drawbar(); void resize(Client* c, int x, int y, int w, int h); unsigned int bh = 1, by, waw, wah, wax, way; @@ -129,9 +132,13 @@ double mwfact = MWFACT; Layout *layout = layouts; Client *client_killed = NULL; + +#if defined(STATUS_BAR) int statusfd = -1; -char stext[512]; int barpos = BARPOS; +#endif /* STATUS_BAR */ + +char stext[512]; const char *shell; bool need_screen_resize = true; int width, height; @@ -348,13 +355,9 @@ arrange(); } +#if defined(STATUS_BAR) void updatebarpos(void) { - by = 0; - wax = 0; - way = 0; - waw = width; - wah = height; if(statusfd == -1) return; if(barpos == BarTop){ @@ -378,6 +381,33 @@ } void +drawbar(){ + int s, l, maxlen = width - 2; + char t = stext[maxlen]; + if(barpos == BarOff || !*stext) + return; + curs_set(0); + attrset(BAR_ATTR); + mvaddch(by, 0, '['); + stext[maxlen] = '\0'; + l = strlen(stext); + if(BAR_ALIGN_RIGHT) + for(s = 0; s + l maxlen; s++) + addch(' '); + else + for(; l maxlen; l++) + stext[l] = ' '; + addstr(stext); + stext[maxlen] = t; + addch(']'); + attrset(ATTR_NORMAL); + if(sel) + curs_set(madtty_cursor(sel-term)); + refresh(); +} +#endif /* STATUS_BAR */ + +void setlayout(const char *args[]) { unsigned int i; @@ -503,32 +533,6 @@ } void -drawbar(){ - int s, l, maxlen = width - 2; - char t = stext[maxlen]; - if(barpos == BarOff || !*stext) - return; - curs_set(0); - attrset(BAR_ATTR); - mvaddch(by, 0, '['); - stext[maxlen] = '\0'; - l = strlen(stext); - if(BAR_ALIGN_RIGHT) - for(s = 0; s + l maxlen; s++) - addch(' '); - else - for(; l maxlen; l++) - stext[l] = ' '; - addstr(stext); - stext[maxlen] = t; - addch(']'); - attrset(ATTR_NORMAL); - if(sel) - curs_set(madtty_cursor(sel-term)); - refresh(); -} - -void escapekey(const char *args[]){ int key; if(sel (!sel-minimized || isarrange(fullscreen))) { @@ -778,8 +782,14 @@ wrefresh(curscr); refresh(); } + + by = wax = way = 0; + waw = width, wah = height; + +#if defined(STATUS_BAR) updatebarpos(); drawbar(); +#endif /* STATUS_BAR */ arrange(); need_screen_resize = false; } @@ -819,8 +829,10 @@ void cleanup(){ endwin(); +#if defined(STATUS_BAR) if(statusfd 0) close(statusfd); +#endif /* STATUS_BAR */ } void @@ -832,7 +844,13 @@ void usage(){ cleanup(); - eprint(usage: dvtm [-v] [-m mod] [-s status] [cmd...]\n); + eprint( usage: dvtm [-v] [-m mod] +#if defined(STATUS_BAR) + [-s status] +#endif /* STATUS_BAR */ + [cmd...]\n + ); + exit(EXIT_FAILURE); } @@ -864,6 +882,7 @@ for(i = 0; i countof(keys); i++) keys[i].mod = *mod; break; +#if defined(STATUS_BAR) case 's': if(++arg = argc) usage(); @@ -879,6 +898,7 @@ } updatebarpos(); break; +#endif /* STATUS_BAR */ default: usage(); } @@ -908,10 +928,12 @@ FD_ZERO(rd); FD_SET(STDIN_FILENO, rd); +#if defined(STATUS_BAR) if(statusfd != -1){ FD_SET(statusfd, rd); nfds = max(nfds, statusfd); } +#endif /* STATUS_BAR */ for(c = clients; c; c = c-next){ FD_SET(c-pty, rd); @@ -959,6 +981,7 @@ continue; } +#if defined(STATUS_BAR) if(statusfd != -1 FD_ISSET(statusfd, rd)){ char *p; switch(r = read(statusfd, stext, sizeof stext -
Re: [dwm] [dvtm-patch] Status bar optional
I'm not trying to insult you, but I don't see the point of having the status bar as a compile time option. The point is that if the code is not needed there is no reason to have it, even why we have a larger binary and a slowest build time (other than C statements and checks that will never be true). Thanks to not insult me, btw ;-) I cannot try it know, but I think when you don't set the status text to anything (you don't use the -s option), you won't have the status bar. Adding complexity with the code with #ifdefs for this option is not a good idea, IMO. That's the same with the mouse support which is not used at all if you don't bind the keys. Though there is no need to build it when not used. Why shouldn't be the same for the status bar? I also wondering where all this complexity come from but please, consider i'm a beginner of C programming so i'll appreciated any eventually further technical explanation. A bit of patience! Maybe you want to have a look at http://doc.cat-v.org/henry_spencer/ifdef_considered_harmful.pdf, it is worth reading. Yes, i understand your point and i also agree with some of the things discussed in that paper. Though this is not a portability issues nor, to me, a wrong use of the conditional preprocessor statements. I'm just trying to remove stuff i don't need. Remove them is not the same as not use them. I appreciated your reply (and i will any further one). Please, sorry for my (often wrong) english and have a nice day. -- Claudio M. Alessi -BEGIN GEEK CODE BLOCK- Version: 3.1 GCS/MU d-@ s: a-- C++(+++) UB++$ P+ !L E--- W++(+++) N+@ o-- K? w+@ O-@ M- V? PS+@ PE+@ Y+ PGP t(-)@ 5? X+ R? tv-- b+ DI-- D? G e+@ h--@ r y* --END GEEK CODE BLOCK--
Re: [dwm] [dvtm-patch] Status bar optional
On Feb 19, 2008 12:57 PM, Marc Andre Tanner [EMAIL PROTECTED] wrote: On Tue, Feb 19, 2008 at 01:50:40PM +0100, Claudio M. Alessi wrote: Hi, i'm continuing to study the dvtm code in order to be able to make some real improvement. I'm a (not so) beginner C programmer so all my experiments and your points of view about are useful to improve myself (not only dvtm). It's free software, after all. As for the mouse support, i don't use the status bar at all (at least not in box other than my laptop) so there is no reason to build such feature. Even i think that such modularization help to make the code cleaner ( e.g. i had to move the terminal size variables from the updatebaros() function to the resize_screen() one, which seems to be a better place for them). This will give a bit of work to Leonardo Taccari which is working on the pkgsrc dvtm packages; a new option is needed, i guess. Hope this helps but, if not, feel free to insult me ;-) I don't want to clutter the code with all the #ifdefs plus some day we might introduce tags/workspaces and then a statusbar will become more important. I can support not using #ifdefs unless absolutely necessary. I have large chunks of my own code (thankfully not for long term use) where I used a lot of #ifdefs... so I know the hard way :(. I guess the argument is that code should be modular for programmer's ease (may be secondarily for conserving memory or hard-drive space). I think it will be a welcome effort if somebody can separate the mouse handling and status bar routines cleanly from dvtm code and allow simple config.h lines to enable/disable them. The other thing is that compilers are *supposed* to dead code eliminate anything inside normal conditional statements if they know for sure... which makes a case for using const variables and normal if statements for doing #ifdef like stuff. Using const also helps with type checking and better error messages. Bad news is the *supposed* in the first statement ;). For workspaces, here's a crazy idea... why not just use dvtm inside screen (may be that's still not good enough for tags :/ )? If bloat is a factor, I have always been curious: besides terminal emulation, regions and fullscreen windows... what more is there in screen? _r
Re: [dwm] [dvtm-patch] Status bar optional
On Tue, Feb 19, 2008 at 01:50:40PM +0100, Claudio M. Alessi wrote: Hi, i'm continuing to study the dvtm code in order to be able to make some real improvement. I'm a (not so) beginner C programmer so all my experiments and your points of view about are useful to improve myself (not only dvtm). It's free software, after all. As for the mouse support, i don't use the status bar at all (at least not in box other than my laptop) so there is no reason to build such feature. Even i think that such modularization help to make the code cleaner (e.g. i had to move the terminal size variables from the updatebaros() function to the resize_screen() one, which seems to be a better place for them). This will give a bit of work to Leonardo Taccari which is working on the pkgsrc dvtm packages; a new option is needed, i guess. Hope this helps but, if not, feel free to insult me ;-) I don't want to clutter the code with all the #ifdefs plus some day we might introduce tags/workspaces and then a statusbar will become more important. Regards, Marc -- Marc Andre Tanner http://www.brain-dump.org/ GPG key: CF7D56C0
Re: [dwm] [dvtm-patch] Status bar optional
On Tue, Feb 19, 2008 at 06:57:21PM +0100, Marc Andre Tanner wrote: I don't want to clutter the code with all the #ifdefs plus some day we might introduce tags/workspaces and then a statusbar will become more important. I hope this will never happen. Have a nice day. -- Claudio M. Alessi -BEGIN GEEK CODE BLOCK- Version: 3.1 GCS/MU d-@ s: a-- C++(+++) UB++$ P+ !L E--- W++(+++) N+@ o-- K? w+@ O-@ M- V? PS+@ PE+@ Y+ PGP t(-)@ 5? X+ R? tv-- b+ DI-- D? G e+@ h--@ r y* --END GEEK CODE BLOCK--
Re: [dwm] [dvtm-patch] Status bar optional
On Tue, Feb 19, 2008 at 01:11:21PM -0500, Ritesh Kumar wrote: For workspaces, here's a crazy idea... why not just use dvtm inside screen (may be that's still not good enough for tags :/ )? It would be hard (impossible?) to move a client from one workspace to another if the workspaces were managed outside dvtm. Regards, Christian @Marc: I had to chuckle when I read the I hope that will never happen regarding the introduction of tags/workspaces in dvtm ;-) -- Christian.Garbs.http://www.cgarbs.de I'm proud to be paying taxes in the United States. The only thing is -- I could be just as proud for half the money. -- Arthur Godfrey