changeset 3122:4d967ccd797b

[gaim-migrate @ 3137] Send History committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 03 Apr 2002 03:02:02 +0000
parents 025a8042dd73
children 08c37c2cb5d8
files ChangeLog src/conversation.c src/ui.h
diffstat 3 files changed, 55 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 02 01:04:35 2002 +0000
+++ b/ChangeLog	Wed Apr 03 03:02:02 2002 +0000
@@ -2,7 +2,7 @@
 
 version 0.56:
 	* German translation update (Thanks Karsten Weiss)
-
+	* Shell-like send history binded to Ctrl-Up and Ctrl-Down
 version 0.55 (03/29/2002):
 	* Jabber improvements (Thanks Jim Seymour)
 	* Various sound cleanups (Thanks Robert McQueen)
--- a/src/conversation.c	Tue Apr 02 01:04:35 2002 +0000
+++ b/src/conversation.c	Wed Apr 03 03:02:02 2002 +0000
@@ -183,6 +183,7 @@
 	if (connections)
 		c->gc = (struct gaim_connection *)connections->data;
 	c->history = g_string_new("");
+	c->send_history = g_list_append(NULL, NULL);
 	conversations = g_list_append(conversations, c);
 	show_conv(c);
 	update_icon(c);
@@ -270,6 +271,13 @@
 	if (c->save_icon)
 		gtk_widget_destroy(c->save_icon);
 #endif
+	c->send_history = g_list_first(c->send_history);
+	while (c->send_history) {
+		if (c->send_history->data)
+			g_free(c->send_history->data);
+		c->send_history = c->send_history->next;
+	}
+	g_list_free(c->send_history);
 	if (c->typing_timeout)
 		gtk_timeout_remove(c->typing_timeout);
 	g_string_free(c->history, TRUE);
@@ -841,6 +849,44 @@
 		if (oldpos == pos)
 			gtk_editable_set_position(GTK_EDITABLE(entry), pos + 1);
 	} else if (event->state & GDK_CONTROL_MASK) {
+		int pos = 0;
+		switch (event->keyval) {
+		case GDK_Up:
+			debug_printf("YOU HIT UP!\n");
+			if (!c->send_history)
+				break;
+			debug_printf("history exists\n");
+			if (!c->send_history->prev) {
+				debug_printf("at curent\n");
+				if (c->send_history->data)
+					g_free(c->send_history->data);
+				c->send_history->data = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
+			} 
+			if (c->send_history->next && c->send_history->next->data) {
+				debug_printf("going to ->next\n");
+				c->send_history = c->send_history->next;
+				gtk_editable_delete_text (GTK_EDITABLE(entry),0,-1);
+				gtk_editable_insert_text(GTK_EDITABLE(entry), 
+							 c->send_history->data, 
+							 strlen(c->send_history->data),
+							 &pos);
+			}
+			
+			break;
+		case GDK_Down:
+		  if (!c->send_history) 
+				break;
+			if (c->send_history->prev) {
+			  c->send_history = c->send_history->prev;
+				if (c->send_history->data) {
+					gtk_editable_delete_text (GTK_EDITABLE(entry),0,-1);
+					gtk_editable_insert_text (GTK_EDITABLE(entry), c->send_history->data, 
+								  strlen(c->send_history->data), &pos);
+				
+				}
+			}
+			break;
+		}
 		if (convo_options & OPT_CONVO_CTL_CHARS) {
 			switch (event->keyval) {
 			case 'i':
@@ -1003,6 +1049,7 @@
 	int limit;
 	gulong length=0;
 	int err = 0;
+	GList *first;
 
 	if (!c->gc)
 		return;
@@ -1018,6 +1065,12 @@
 		return;
 	}
 
+	first = g_list_first(c->send_history);
+	if (first->data)
+		g_free(first->data);
+	first->data = g_strdup(buf);
+	c->send_history = g_list_prepend(first, NULL);
+	
 	buf2 = g_malloc(limit);
 
 	if (c->gc->flags & OPT_CONN_HTML) {
--- a/src/ui.h	Tue Apr 02 01:04:35 2002 +0000
+++ b/src/ui.h	Wed Apr 03 03:02:02 2002 +0000
@@ -138,6 +138,7 @@
 	GdkColor fgcol;
 	int hasfg;
 
+	GList *send_history;
 	GString *history;
 
 	GtkWidget *send;