[ekg2-commit] ekg2: main.c (HEAD) old.c (HEAD) [darkjames]

CVS commit cvs w amba.bydg.pdi.net
Pią, 16 Lut 2007, 16:01:15 CET


Module name:	ekg2
Changes by:	darkjames	07/02/16 16:01:12

Modified files:
	main.c old.c

Log message:
ncurses lastlog stuff.

Index: main.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/main.c,v
diff -d -u -r1.80 -r1.81
--- main.c	16 Feb 2007 01:09:48 -0000	1.80
+++ main.c	16 Feb 2007 15:01:11 -0000	1.81
@@ -412,9 +412,6 @@
 		return -1;
 	}
 
-	xfree(n->prompt);	n->prompt 	= xstrdup(str);
-				n->prompt_len	= !!w;
-
 	config_lastlog_lock = 0;
 	retval = n->handle_redraw(lastlog_w);
 	config_lastlog_lock = lock_old;

Index: old.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/old.c,v
diff -d -u -r1.123 -r1.124
--- old.c	16 Feb 2007 12:04:05 -0000	1.123
+++ old.c	16 Feb 2007 15:01:11 -0000	1.124
@@ -2279,33 +2279,45 @@
 	}
 }
 
-static int ncurses_ui_window_lastlog_find(window_t *lastlog, const window_t *w, const char *substr) {
-	int items = 0;
-	int i;
+static int ncurses_ui_window_lastlog(window_t *lastlog_w, window_t *w) {
+	window_lastlog_t *lastlog;
+	window_t *ww;
 	ncurses_window_t *n;
-	
-	if (!w) {
-		list_t l;
-		int retval = 0;
 
-		for (l = windows; l; l = l->next) {
-			if (!l->data) continue;
-			retval += ncurses_ui_window_lastlog_find(lastlog, (window_t *) l->data, substr);
-		}
+	int local_config_lastlog_case;
 
-		return retval;
-	}
+	int items = 0;
+	int i;
 	
-	if (w->floating) return 0;	/* XXX */
+	lastlog = w->lastlog;				/* get private lastlog */
+	if (!lastlog && (w == window_current || config_lastlog_display_all == 2))	/* if not found, but it's current window, or lastlog_display_all eq 2 */
+		lastlog = lastlog_current;			/* get global-current-window-lastlog */
+
+	if (!lastlog) 
+		return -1;
 
+	ww = lastlog->w ? lastlog->w : window_current;
 	n = w->private;
+
+	local_config_lastlog_case = (lastlog->casense == -1) ? config_lastlog_case : lastlog->casense;
+
 	for (i = n->backlog_size-1; i >= 0; i--) {
 		int found = 0;
 
-/* XXX allow regexp's as well. */
-		if (config_lastlog_case) 
-			found = !!xstrstr(n->backlog[i]->str, substr);
-		else	found = !!xstrcasestr(n->backlog[i]->str, substr);
+		if (lastlog->isregexp) {		/* regexp */
+#ifdef HAVE_REGEX_H
+			int rs;
+			if (!(rs = regexec(&(lastlog->reg), n->backlog[i]->str, 0, NULL, 0))) 
+				found = 1;
+			else if (rs != REG_NOMATCH) {
+				/* blad wyrazenia? */
+			}
+#endif
+		} else {				/* substring */
+			if (local_config_lastlog_case) 
+				found = !!xstrstr(n->backlog[i]->str, lastlog->expression);
+			else	found = !!xstrcasestr(n->backlog[i]->str, lastlog->expression);
+		}
 		
 		if (found) {
 			fstring_t *dup;
@@ -2328,7 +2340,7 @@
 		/* org. window for example if we would like user allow move under that line with mouse and double-click.. or whatever */
 /*			dup->private		= (void *) w;	 */
 
-			ncurses_backlog_add(lastlog, dup);
+			ncurses_backlog_add(lastlog_w, dup);
 			items++;
 		}
 	}
@@ -2338,6 +2350,9 @@
 
 int ncurses_lastlog_update(window_t *w) {
 	ncurses_window_t *n;
+	list_t l;
+	int retval = 0;
+
 	if (config_lastlog_lock) return 0;
 
 	if (!w) w = window_find("__lastlog");
@@ -2345,10 +2360,20 @@
 
 	ncurses_clear(w, 1);
 
+	/* first lookat current window.. */
+	retval += ncurses_ui_window_lastlog(w, window_current);
+
+	if (config_lastlog_display_all) {
+		/* other windows? */
+		for (l = windows; l; l = l->next) {
+			if (l->data == window_current) continue;
+			retval += ncurses_ui_window_lastlog(w, (window_t *) l->data);
+		}
+	}
+
 	n = w->private;
 	n->redraw = 1;
-
-	return ncurses_ui_window_lastlog_find(w, n->prompt_len ? window_current : NULL, n->prompt);
+	return retval;
 }
 
 void ncurses_lastlog_new(window_t *w) {


Więcej informacji o liście dyskusyjnej ekg2-commit