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

CVS commit cvs w amba.bydg.pdi.net
Pią, 16 Lut 2007, 02:09:54 CET


Module name:	ekg2
Changes by:	darkjames	07/02/16 02:09:50

Modified files:
	main.c old.c old.h

Log message:
ncurses stuff.

Index: main.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/main.c,v
diff -d -u -r1.79 -r1.80
--- main.c	15 Feb 2007 22:18:08 -0000	1.79
+++ main.c	16 Feb 2007 01:09:48 -0000	1.80
@@ -52,6 +52,8 @@
 int config_margin_size;
 int config_kill_irc_window = 1;
 int config_statusbar_size;
+int config_lastlog_size;
+int config_lastlog_lock;
 
 int ncurses_initialized;
 int ncurses_plugin_destroyed;
@@ -370,71 +372,52 @@
 	return 0;
 }
 
-static int ncurses_ui_window_lastlog_find(window_t *lastlog, const window_t *w, const char *substr) {
-	int items = 0;
-	ncurses_window_t *n = w->private;
-	int i;
-
-	if (w->floating) return 0;	/* XXX */
-
-	for (i = n->backlog_size-1; i >= 0; i--) {
-		int found = 0;
-
-		if (config_lastlog_case) 
-			found = !!xstrstr(n->backlog[i]->str, substr);
-		else	found = !!xstrcasestr(n->backlog[i]->str, substr);
-		
-		if (found) {
-			fstring_t *dup;
-			size_t len;
-#if USE_UNICODE
-			#warning "ncurses_ui_window_lastlog_find() won't work with USE_UNICODE sorry. no time for it. feel free"
-			continue;
-#endif
-
-			dup = xmalloc(sizeof(fstring_t));
+static QUERY(ncurses_lastlog_changed) {
+	window_t *w;
 
-			len = xstrlen(n->backlog[i]->str);
+	if (config_lastlog_size < 0) 
+		config_lastlog_size = 0;
 
-			dup->str		= xmemdup(n->backlog[i]->str, sizeof(char)*(len+1));
-			dup->attr		= xmemdup(n->backlog[i]->attr, sizeof(short)*(len+1));
-			dup->ts			= n->backlog[i]->ts;
-			dup->prompt_len		= n->backlog[i]->prompt_len;
-			dup->prompt_empty	= n->backlog[i]->prompt_empty;
-			dup->margin_left	= n->backlog[i]->margin_left;
-		/* 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;	 */
+	if (!(w = window_find("__lastlog")))
+		return 0;
 
-			ncurses_backlog_add(lastlog, dup);
-			items++;
-		}
-	}
+	ncurses_lastlog_new(w);
+	ncurses_lastlog_update(w);
 
-	return items;
+	ncurses_resize();
+	ncurses_commit();
+	return 0;
 }
 
 static QUERY(ncurses_ui_window_lastlog) {
-	window_t *lastlog_w;
-
 	window_t *w 	= *(va_arg(ap, window_t **));
 	char *str	= *(va_arg(ap, char **));
 
-	list_t l;
-	int retval = 0;
+	window_t *lastlog_w;
+	ncurses_window_t *n;
 
-	if (!str) 
-		return 0;
+	int lock_old = config_lastlog_lock;
+	int retval;
 
-	if ((lastlog_w = window_find("__lastlog"))) 
-		ncurses_clear(lastlog_w, 1);
-	else	lastlog_w = window_new("__lastlog", NULL, 1001);
-	
-	if (w)
-		return ncurses_ui_window_lastlog_find(lastlog_w, w, str);
+	if (!str)
+		return -1;
 
-	for (l = windows; l; l = l->next) 
-		retval += ncurses_ui_window_lastlog_find(lastlog_w, (window_t *) l->data, str);
+	if (!(lastlog_w = window_find("__lastlog")))
+		lastlog_w = window_new("__lastlog", NULL, 1001);
+
+	n = lastlog_w->private;
+
+	if (!n || !n->handle_redraw) {
+		debug_error("ncurses_ui_window_lastlog() BAD __lastlog wnd?\n");
+		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;
 	return retval;
 }
 
@@ -443,6 +426,9 @@
 	config_contacts_size = 9;         /* szerokość okna kontaktów */
 	config_contacts = 2;              /* czy ma być okno kontaktów */
 
+	config_lastlog_size = 10;         /* szerokosc/dlugosc okna kontaktow */
+	config_lastlog_lock = 1;          /* czy blokujemy lastloga.. zeby nam nie zmienialo sie w czasie zmiany okna, *wolne* */
+
 	xfree(config_contacts_options);
 	xfree(config_contacts_groups);
 
@@ -575,6 +561,8 @@
 	variable_add(&ncurses_plugin, ("contacts_options"), VAR_STR, 1, &config_contacts_options, (void (*)(const char *))ncurses_contacts_changed, NULL, dd_contacts);
 	variable_add(&ncurses_plugin, ("contacts_size"), VAR_INT, 1, &config_contacts_size, (void (*)(const char *))ncurses_contacts_changed, NULL, dd_contacts);
 	variable_add(&ncurses_plugin, ("contacts_metacontacts_swallow"), VAR_BOOL, 1, &config_contacts_metacontacts_swallow, (void (*)(const char *))ncurses_all_contacts_changed, NULL, dd_contacts);
+	variable_add(&ncurses_plugin, ("lastlog_size"), VAR_INT, 1, &config_lastlog_size, (void (*)(const char *))ncurses_lastlog_changed, NULL, NULL);
+	variable_add(&ncurses_plugin, ("lastlog_lock"), VAR_BOOL, 1, &config_lastlog_lock, NULL, NULL, NULL);
 	variable_add(&ncurses_plugin, ("display_transparent"), VAR_BOOL, 1, &config_display_transparent, ncurses_display_transparent_changed, NULL, NULL);
 	variable_add(&ncurses_plugin, ("enter_scrolls"), VAR_BOOL, 1, &config_enter_scrolls, NULL, NULL, NULL);
 	variable_add(&ncurses_plugin, ("header_size"), VAR_INT, 1, &config_header_size, header_statusbar_resize, NULL, NULL);

Index: old.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/old.c,v
diff -d -u -r1.121 -r1.122
--- old.c	15 Feb 2007 21:56:33 -0000	1.121
+++ old.c	16 Feb 2007 01:09:48 -0000	1.122
@@ -2278,23 +2278,81 @@
 	}
 }
 
-static int ncurses_lastlog_update(window_t *w) {
+static int ncurses_ui_window_lastlog_find(window_t *lastlog, const window_t *w, const char *substr) {
+	int items = 0;
+	int i;
+	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);
+		}
+
+		return retval;
+	}
+	
+	if (w->floating) return 0;	/* XXX */
+
+	n = w->private;
+	for (i = n->backlog_size-1; i >= 0; i--) {
+		int found = 0;
+
+		if (config_lastlog_case) 
+			found = !!xstrstr(n->backlog[i]->str, substr);
+		else	found = !!xstrcasestr(n->backlog[i]->str, substr);
+		
+		if (found) {
+			fstring_t *dup;
+			size_t len;
+#if USE_UNICODE
+			#warning "ncurses_ui_window_lastlog_find() won't work with USE_UNICODE sorry. no time for it. feel free"
+			continue;
+#endif
+
+			dup = xmalloc(sizeof(fstring_t));
+
+			len = xstrlen(n->backlog[i]->str);
+
+			dup->str		= xmemdup(n->backlog[i]->str, sizeof(char)*(len+1));
+			dup->attr		= xmemdup(n->backlog[i]->attr, sizeof(short)*(len+1));
+			dup->ts			= n->backlog[i]->ts;
+			dup->prompt_len		= n->backlog[i]->prompt_len;
+			dup->prompt_empty	= n->backlog[i]->prompt_empty;
+			dup->margin_left	= n->backlog[i]->margin_left;
+		/* 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);
+			items++;
+		}
+	}
+
+	return items;
+}
+
+int ncurses_lastlog_update(window_t *w) {
 	ncurses_window_t *n;
+	if (config_lastlog_lock) return 0;
 
 	if (!w) w = window_find("__lastlog");
 	if (!w) return -1;
 
-	n = w->private;
+/* if lastlog_lock return 1; */
+	ncurses_clear(w, 1);
 
+	n = w->private;
 	n->redraw = 1;
-	
-	return 0;
+
+	return ncurses_ui_window_lastlog_find(w, n->prompt_len ? window_current : NULL, n->prompt);
 }
 
-static void ncurses_lastlog_new(window_t *w) {
+void ncurses_lastlog_new(window_t *w) {
 #define lastlog_edge		WF_BOTTOM
 #define lastlog_margin		1
-#define config_lastlog_size	10
 #define lastlog_frame		WF_TOP
 #define lastlog_wrap		0
 
@@ -2344,13 +2402,13 @@
 
 	w->private = n = xmalloc(sizeof(ncurses_window_t));
 
-	if (!xstrcmp(w->target, "__contacts"))
+	if (!xstrcmp(w->target, "__contacts")) {
 		ncurses_contacts_new(w);
 
-	if (!xstrcmp(w->target, "__lastlog")) 
+	} else if (!xstrcmp(w->target, "__lastlog")) {
 		ncurses_lastlog_new(w);
 
-	if (w->target) {
+	} else if (w->target) {
 		const char *f = format_find("ncurses_prompt_query");
 
 		n->prompt = format_string(f, w->target);

Index: old.h
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/old.h,v
diff -d -u -r1.31 -r1.32
--- old.h	21 Sep 2006 17:10:25 -0000	1.31
+++ old.h	16 Feb 2007 01:09:49 -0000	1.32
@@ -155,6 +155,11 @@
 extern int config_statusbar_size;
 extern int config_kill_irc_window;
 
+int ncurses_lastlog_update(window_t *w);
+void ncurses_lastlog_new(window_t *w);
+extern int config_lastlog_size;
+extern int config_lastlog_lock;
+
 WATCHER(ncurses_watch_stdin);
 WATCHER(ncurses_watch_winch);
 int ncurses_command_window(void *data, va_list ap);


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