about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authormarco <marco@conformal.com>2011-11-15 10:13:05 -0600
committermarco <marco@conformal.com>2011-11-15 10:13:05 -0600
commit2be99590e2febc04b6e38d0079fad3f4fc47965c (patch)
tree33779bb5c5755851ef517fb847131039193dba9c
parentc37bb324d30ab5315d472d80861b70765caafbc3 (diff)
downloadxombrero-2be99590e2febc04b6e38d0079fad3f4fc47965c.tar.gz
add a hybrid input mode
-rw-r--r--settings.c32
-rw-r--r--xxxterm.c7
-rw-r--r--xxxterm.h4
3 files changed, 43 insertions, 0 deletions
diff --git a/settings.c b/settings.c
index 1f904e3..9a155ba 100644
--- a/settings.c
+++ b/settings.c
@@ -86,6 +86,7 @@ char		command_file[PATH_MAX];
 char		*encoding = NULL;
 int		autofocus_onload = 0;
 int		js_autorun_enabled = 1;
+int		edit_mode = XT_EM_HYBRID;
 
 char		*cmd_font_name = NULL;
 char		*oops_font_name = NULL;
@@ -96,6 +97,7 @@ char		*get_download_dir(struct settings *);
 char		*get_default_script(struct settings *);
 char		*get_runtime_dir(struct settings *);
 char		*get_tab_style(struct settings *);
+char		*get_edit_mode(struct settings *);
 char		*get_work_dir(struct settings *);
 
 int		add_cookie_wl(struct settings *, char *);
@@ -109,6 +111,7 @@ int		set_download_dir(struct settings *, char *);
 int		set_default_script(struct settings *, char *);
 int		set_runtime_dir(struct settings *, char *);
 int		set_tab_style(struct settings *, char *);
+int		set_edit_mode(struct settings *, char *);
 int		set_work_dir(struct settings *, char *);
 
 void		walk_mime_type(struct settings *, void (*)(struct settings *,
@@ -229,6 +232,12 @@ struct special		s_tab_style = {
 	NULL
 };
 
+struct special		s_edit_mode = {
+	set_edit_mode,
+	get_edit_mode,
+	NULL
+};
+
 struct settings		rs[] = {
 	{ "allow_volatile_cookies",	XT_S_INT, 0,		&allow_volatile_cookies, NULL, NULL },
 	{ "append_next",		XT_S_INT, 0,		&append_next, NULL, NULL },
@@ -240,6 +249,7 @@ struct settings		rs[] = {
 	{ "default_zoom_level",		XT_S_FLOAT, 0,		NULL, NULL, NULL, &default_zoom_level },
 	{ "default_script",		XT_S_STR, 0, NULL, NULL,&s_default_script },
 	{ "download_dir",		XT_S_STR, 0, NULL, NULL,&s_download_dir },
+	{ "edit_mode",			XT_S_STR, 0, NULL, NULL,&s_edit_mode },
 	{ "enable_cookie_whitelist",	XT_S_INT, 0,		&enable_cookie_whitelist, NULL, NULL },
 	{ "enable_js_whitelist",	XT_S_INT, 0,		&enable_js_whitelist, NULL, NULL },
 	{ "enable_plugin_whitelist",	XT_S_INT, 0,		&enable_plugin_whitelist, NULL, NULL },
@@ -957,6 +967,28 @@ set_tab_style(struct settings *s, char *val)
 }
 
 char *
+get_edit_mode(struct settings *s)
+{
+	if (tab_style == XT_EM_HYBRID)
+		return (g_strdup("hybrid"));
+	else
+		return (g_strdup("vi"));
+}
+
+int
+set_edit_mode(struct settings *s, char *val)
+{
+	if (!strcmp(val, "hybrid"))
+		tab_style = XT_EM_HYBRID;
+	else if (!strcmp(val, "vi"))
+		tab_style = XT_EM_VI;
+	else
+		return (1);
+
+	return (0);
+}
+
+char *
 get_work_dir(struct settings *s)
 {
 	if (work_dir[0] == '\0')
diff --git a/xxxterm.c b/xxxterm.c
index 9564195..6b9c5a0 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -4848,12 +4848,19 @@ wv_keypress_cb(GtkEntry *w, GdkEventKey *e, struct tab *t)
 		return (handle_keypress(t, e, 0));
 	}
 
+	/* insert mode */
 	if (CLEAN(e->state) == 0 && e->keyval == GDK_Escape) {
 		t->mode = XT_MODE_COMMAND;
 		input_focus_blur(t, active);
 		return (XT_CB_HANDLED);
 	}
 
+	if (edit_mode == XT_EM_HYBRID) {
+		/* eat most modded commands */
+		if (e->state & CTRL || e->state & MOD1)
+			return (XT_CB_PASSTHROUGH);
+	}
+fprintf(stderr, "state 0x%x kyval 0x%x\n", e->state, e->keyval);
 	return (XT_CB_PASSTHROUGH);
 }
 
diff --git a/xxxterm.h b/xxxterm.h
index 8b0890d..b23be70 100644
--- a/xxxterm.h
+++ b/xxxterm.h
@@ -424,6 +424,9 @@ int		command_mode(struct tab *, struct karg *);
 #define XT_TABS_NORMAL		(0)
 #define XT_TABS_COMPACT		(1)
 
+#define XT_EM_HYBRID		(0)
+#define XT_EM_VI		(1)
+
 #define CTRL			GDK_CONTROL_MASK
 #define MOD1			GDK_MOD1_MASK
 #define SHFT			GDK_SHIFT_MASK
@@ -526,6 +529,7 @@ extern char	*cmd_font_name;
 extern char	*oops_font_name;
 extern char	*statusbar_font_name;
 extern char	*tabbar_font_name;
+extern int	edit_mode;
 
 /* globals */
 extern char		*version;