Hi,

On Tue, Feb 23, 2010 at 01:57:17PM +0100, markus schnalke wrote:
> I used surf for several weeks last year. I had the same problem, so I
> hacked a mode interface like vi has. It is just a quick hack, it is
> outdated, and I don't use it anymore, but maybe it helps.

Thanks for that.  I've cleaned up the patch to be sure it works with
0.3, and I've removed all the other things - anyone who is interested
will find it attached.

I think, though, that a better approach might be to have this mode
activated automatically when a textbox gets focus.  If one goes to a
search engine whose scripts put your cursor straight in the search box
anyway, then it's stupid to have to press i first before you can type
something in it.  I'll try to find the time to see how uzbl does it, as
has been suggested.

S

-- 
Sean Whitton / <s...@silentflame.com>
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/

Only in surf-0.3~: b
diff -up surf-0.3/config.def.h surf-0.3~/config.def.h
--- surf-0.3/config.def.h	2009-10-30 12:41:02.000000000 +0000
+++ surf-0.3~/config.def.h	2010-02-23 14:09:08.000000000 +0000
@@ -33,6 +34,7 @@ static Key keys[] = {
     { MODKEY,               GDK_slash,  spawn,      SETPROP("_SURF_FIND") },
     { MODKEY,               GDK_n,      find,       { .b = TRUE } },
     { MODKEY|GDK_SHIFT_MASK,GDK_n,      find,       { .b = FALSE } },
+	{ 0,                    GDK_i,      insert,     { 0 } },
 };
 
 static Item items[] = {
diff -up surf-0.3/surf.c surf-0.3~/surf.c
--- surf-0.3/surf.c	2009-10-30 12:41:02.000000000 +0000
+++ surf-0.3~/surf.c	2010-02-23 14:04:52.000000000 +0000
@@ -65,7 +65,9 @@ static int ignorexprop = 0;
 static char winid[64];
 static char *progname;
 static gboolean lockcookie = FALSE;
+static gboolean insert_mode = FALSE;
 
+static void insert(Client *c, const Arg *arg);
 static char *buildpath(const char *path);
 static void changecookie(SoupCookieJar *jar, SoupCookie *o, SoupCookie *n, gpointer p);
 static void cleanup(void);
@@ -391,21 +393,59 @@ itemclick(GtkMenuItem *mi, Client *c) {
 			items[i].func(c, &(items[i].arg));
 }
 
+void
+insert(Client *c, const Arg *arg) {
+	insert_mode = TRUE;
+	update(clients);
+}
+
 gboolean
 keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
 	guint i;
 	gboolean processed = FALSE;
 
 	updatewinid(c);
+
+	if (ev->type   != GDK_KEY_PRESS ||
+		ev->keyval == GDK_Return   ||
+		ev->keyval == GDK_Page_Up   ||
+		ev->keyval == GDK_Page_Down ||
+		ev->keyval == GDK_Up        ||
+		ev->keyval == GDK_Down    ||
+		ev->keyval == GDK_Left    ||
+		ev->keyval == GDK_Right  ||
+		ev->keyval == GDK_Shift_L   ||
+		ev->keyval == GDK_Shift_R)
+		return FALSE;
+	
+	/* turn off insert mode */
+	if (insert_mode && (ev->keyval == GDK_Escape)) {
+		insert_mode = FALSE;
+		update(c);
+		return TRUE;
+	}
+	
+	if (insert_mode && ( ((ev->state & MODKEY) != MODKEY) || !MODKEY ) ) {
+		return FALSE;
+	}
+	
+	if (ev->keyval == GDK_Escape) {
+		webkit_web_view_set_highlight_text_matches(c->view, FALSE);
+		/* return TRUE; */
+	}
+
+
+
 	for(i = 0; i < LENGTH(keys); i++) {
-		if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval
-				&& CLEANMASK(ev->state) == keys[i].mod
+		if(ev->keyval == keys[i].keyval
+				/* && CLEANMASK(ev->state) == keys[i].mod */
 				&& keys[i].func) {
 			keys[i].func(c, &(keys[i].arg));
 			processed = TRUE;
 		}
 	}
-	return processed;
+	/* return processed; */
+	return TRUE;
 }
 
 void

Attachment: signature.asc
Description: Digital signature

Reply via email to