From 2be99590e2febc04b6e38d0079fad3f4fc47965c Mon Sep 17 00:00:00 2001 From: marco Date: Tue, 15 Nov 2011 10:13:05 -0600 Subject: [PATCH] add a hybrid input mode --- settings.c | 32 ++++++++++++++++++++++++++++++++ xxxterm.c | 7 +++++++ xxxterm.h | 4 ++++ 3 files changed, 43 insertions(+) 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; -- 2.11.4.GIT