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 - 1)) {
@@ -979,6 +1002,7 @@
 					drawbar();
 			}
 		}
+#endif /* STATUS_BAR */
 
 		for(c = clients; c; c = c->next){
 			if(FD_ISSET(c->pty, &rd)){
--- ../dvtm-0.4.orig/config.h	2008-02-16 12:09:13.191369197 +0100
+++ config.h	2008-02-19 13:27:54.730642582 +0100
@@ -24,6 +24,8 @@
 #define ATTR_SELECTED   COLOR(COLOR_RED,COLOR_BLACK)
 /* curses attributes for normal (not selected) windows */
 #define ATTR_NORMAL     A_NORMAL
+
+#if defined(STATUS_BAR)
 /* status bar (command line option -s) position */
 #define BARPOS		BarTop /* BarBot, BarOff */
 /* curses attributes for the status bar */
@@ -31,6 +33,8 @@
 /* true if the statusbar text should be right aligned,
  * set to false if you prefer it left aligned */
 #define BAR_ALIGN_RIGHT true
+#endif /* STATUS_BAR */
+
 /* separator between window title and window number */
 #define SEPARATOR " | "
 /* printf format string for the window title, first %s
@@ -70,7 +74,9 @@
 	{ MOD, 'h', { setmwfact,      { "-0.05" } } },
 	{ MOD, 'l', { setmwfact,      { "+0.05" } } },
 	{ MOD, '.', { toggleminimize, { NULL }    } },
+#if defined(STATUS_BAR)
 	{ MOD, 's', { togglebar,      { NULL }    } },
+#endif /* STATUS_BAR */
 	{ MOD, '\n',{ zoom ,          { NULL }    } },
 	{ MOD, '0', { focusn,         { "0" }     } },
 	{ MOD, '1', { focusn,         { "1" }     } },
--- ../dvtm-0.4.orig/config.mk	2008-02-16 12:09:13.191369197 +0100
+++ config.mk	2008-02-19 13:31:35.264425083 +0100
@@ -13,6 +13,9 @@
 CFLAGS = -std=c99 -Os ${INCS} -DVERSION=\"${VERSION}\" -DNDEBUG
 LDFLAGS = -L/usr/lib -L/usr/local/lib ${LIBS}
 
+# Status bar
+CFLAGS += -DSTATUS_BAR
+
 DEBUG_CFLAGS = -std=c99 -O0 -g -ggdb ${INCS} -Wall -DVERSION=\"${VERSION}\"
 
 CC = cc

Reply via email to