gtk_editable_set_position(GTK_EDITABLE(vp.gui.inputbox), -1);
- Arg a = {VP_MODE_COMMAND};
- return vp_set_mode(&a);
+ return vp_set_mode(VP_MODE_COMMAND, FALSE);
}
gboolean command_close(const Arg* arg)
/* check for escape or modkeys or counts */
if (IS_ESCAPE_KEY(keyval, state)) {
- completion_clean();
/* switch to normal mode and clear the input box */
- Arg a = {VP_MODE_NORMAL, ""};
- vp_set_mode(&a);
+ vp_set_mode(VP_MODE_NORMAL, TRUE);
return TRUE;
}
break;
case WEBKIT_LOAD_COMMITTED:
- {
- Arg a = {VP_MODE_NORMAL};
- vp_set_mode(&a);
- }
/* status bar is updated by vp_set_mode */
+ vp_set_mode(VP_MODE_NORMAL , FALSE);
vp_update_urlbar(uri);
break;
/* switch to normal mode after running command without success the
* mode after success is set by command_run to the value defined
* for the command */
- Arg a = {VP_MODE_NORMAL};
- vp_set_mode(&a);
+ vp_set_mode(VP_MODE_NORMAL , FALSE);
}
}
}
g_free(uri);
/* change state to normal mode */
- Arg a = {VP_MODE_NORMAL};
- vp_set_mode(&a);
+ vp_set_mode(VP_MODE_NORMAL, FALSE);
return TRUE;
}
* Set the base modes. All other mode flags like completion can be set directly
* to vp.state.mode.
*/
-gboolean vp_set_mode(const Arg* arg)
+gboolean vp_set_mode(Mode mode, gboolean clean)
{
- vp.state.mode = arg->i;
+ if (vp.state.mode & VP_MODE_COMPLETE) {
+ completion_clean();
+ }
+ vp.state.mode = mode;
vp.state.modkey = vp.state.count = 0;
- switch (CLEAN_MODE(arg->i)) {
+ switch (CLEAN_MODE(mode)) {
case VP_MODE_NORMAL:
gtk_widget_grab_focus(GTK_WIDGET(vp.gui.webview));
break;
}
/* echo message if given */
- if (arg->s) {
- vp_echo(VP_MSG_NORMAL, FALSE, arg->s);
+ if (clean) {
+ vp_echo(VP_MSG_NORMAL, FALSE, "");
}
vp_update_statusbar();
result = webkit_web_view_get_hit_test_result(vp.gui.webview, (GdkEventButton*)event);
g_object_get(result, "context", &context, NULL);
if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
- Arg a = {VP_MODE_INSERT};
- vp_set_mode(&a);
+ vp_set_mode(VP_MODE_INSERT, FALSE);
}
}
void vp_update_statusbar(void);
void vp_update_urlbar(const gchar* uri);
void vp_echo(const MessageType type, gboolean hide, const char *error, ...);
-gboolean vp_set_mode(const Arg* arg);
+gboolean vp_set_mode(Mode mode, gboolean clean);
void vp_set_widget_font(GtkWidget* widget, const VpColor* fg, const VpColor* bg, PangoFontDescription* font);
gboolean vp_load_uri(const Arg* arg);
void vp_clean_up(void);