From: Daniel Carl Date: Sat, 15 Dec 2012 18:03:58 +0000 (+0100) Subject: Added new function to write input text. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=a9038a71ce2c04fa42fe0d61364e02d1b0405743;p=vimb.git Added new function to write input text. --- diff --git a/src/command.c b/src/command.c index 8939152..a26780d 100644 --- a/src/command.c +++ b/src/command.c @@ -70,6 +70,9 @@ static CommandInfo cmd_list[] = { {"hint-focus-prev", command_hints_focus, {1}, VP_MODE_HINTING}, }; +static void command_write_input(const gchar* str); + + void command_init(void) { guint i; @@ -107,10 +110,8 @@ gboolean command_run(const gchar* name, const gchar* param) result = c->function(&a); g_free(a.s); - /* if command was run, remove the modkey and count */ - vp.state.modkey = vp.state.count = 0; - vp.state.mode = c->mode; - vp_update_statusbar(); + /* set the new mode */ + vp_set_mode(c->mode, FALSE); return result; } @@ -122,31 +123,21 @@ gboolean command_open(const Arg* arg) gboolean command_input(const Arg* arg) { - gint pos = 0; const gchar* url; - - /* reset the colors and fonts to defalts */ - vp_set_widget_font( - vp.gui.inputbox, - &vp.style.input_fg[VP_MSG_NORMAL], - &vp.style.input_bg[VP_MSG_NORMAL], - vp.style.input_font[VP_MSG_NORMAL] - ); - - /* remove content from input box */ - gtk_entry_set_text(GTK_ENTRY(vp.gui.inputbox), ""); - - /* insert string from arg */ - gtk_editable_insert_text(GTK_EDITABLE(vp.gui.inputbox), arg->s, -1, &pos); + gchar* input = NULL; /* add current url if requested */ if (VP_INPUT_CURRENT_URI == arg->i - && (url = webkit_web_view_get_uri(vp.gui.webview))) { - gtk_editable_insert_text(GTK_EDITABLE(vp.gui.inputbox), url, -1, &pos); + && (url = webkit_web_view_get_uri(vp.gui.webview)) + ) { + /* append the crrent url to the input message */ + input = g_strconcat(arg->s, url, NULL); + command_write_input(input); + g_free(input); + } else { + command_write_input(arg->s); } - gtk_editable_set_position(GTK_EDITABLE(vp.gui.inputbox), -1); - return vp_set_mode(VP_MODE_COMMAND, FALSE); } @@ -293,3 +284,22 @@ gboolean command_hints_focus(const Arg* arg) return TRUE; } + +static void command_write_input(const gchar* str) +{ + gint pos = 0; + /* reset the colors and fonts to defalts */ + vp_set_widget_font( + vp.gui.inputbox, + &vp.style.input_fg[VP_MSG_NORMAL], + &vp.style.input_bg[VP_MSG_NORMAL], + vp.style.input_font[VP_MSG_NORMAL] + ); + + /* remove content from input box */ + gtk_entry_set_text(GTK_ENTRY(vp.gui.inputbox), ""); + + /* insert string from arg */ + gtk_editable_insert_text(GTK_EDITABLE(vp.gui.inputbox), str, -1, &pos); + gtk_editable_set_position(GTK_EDITABLE(vp.gui.inputbox), -1); +}