/* switch focus first to make sure we can write to the inputbox without
* disturbing the user */
gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
- vb_echo(VB_MSG_NORMAL, false, "-- INPUT --");
+ vb_update_mode_label("-- INPUT --");
}
/**
*/
void input_leave(void)
{
- vb_set_input_text("");
+ vb_update_mode_label("");
}
/**
VbResult res = normal_keypress(key);
if (res != RESULT_MORE) {
ctrlo = false;
- vb_echo(VB_MSG_NORMAL, false, "-- INPUT --");
+ /* Don't overwrite the mode label in case we landed in another
+ * mode. This might occurre by CTRL-0 CTRL-Z or after running ex
+ * command, where we mainly end up in normal mode. */
+ if (vb.mode->id == 'i') {
+ /* reenter the input mode */
+ input_enter();
+ }
}
return res;
}
/* enter CTRL-0 mode to execute next command in normal mode */
ctrlo = true;
vb.mode->flags |= FLAG_NOMAP;
- vb_echo(VB_MSG_NORMAL, false, "-- (input) --");
+ vb_update_mode_label("-- (input) --");
return RESULT_MORE;
case CTRL('T'):
vb_set_widget_font(
vb.gui.eventbox, &vb.style.status_fg[type], &vb.style.status_bg[type], vb.style.status_font[type]
);
+ vb_set_widget_font(
+ vb.gui.statusbar.mode, &vb.style.status_fg[type], &vb.style.status_bg[type], vb.style.status_font[type]
+ );
vb_set_widget_font(
vb.gui.statusbar.left, &vb.style.status_fg[type], &vb.style.status_bg[type], vb.style.status_font[type]
);
#endif
}
+void vb_update_mode_label(const char *label)
+{
+ if (GET_BOOL("input-autohide")) {
+ /* if the inputbox is potentially not shown write mode into statusbar */
+ gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.mode), label);
+ } else {
+ vb_echo(VB_MSG_NORMAL, false, "%s", label);
+ }
+}
+
void vb_quit(gboolean force)
{
/* if not forced quit - don't quit if there are still running downloads */
gui->box = GTK_BOX(gtk_vbox_new(false, 0));
gui->statusbar.box = GTK_BOX(gtk_hbox_new(false, 0));
#endif
+ gui->statusbar.mode = gtk_label_new(NULL);
gui->statusbar.left = gtk_label_new(NULL);
gui->statusbar.right = gtk_label_new(NULL);
gui->statusbar.cmd = gtk_label_new(NULL);
gtk_container_add(GTK_CONTAINER(gui->eventbox), GTK_WIDGET(gui->statusbar.box));
gtk_container_add(GTK_CONTAINER(gui->window), GTK_WIDGET(gui->pane));
#ifdef HAS_GTK3
+ gtk_widget_set_halign(gui->statusbar.mode, GTK_ALIGN_START);
gtk_widget_set_halign(gui->statusbar.left, GTK_ALIGN_START);
#else
+ gtk_misc_set_alignment(GTK_MISC(gui->statusbar.mode), 0.0, 0.0);
gtk_misc_set_alignment(GTK_MISC(gui->statusbar.left), 0.0, 0.0);
#endif
gtk_label_set_ellipsize(GTK_LABEL(gui->statusbar.left), PANGO_ELLIPSIZE_END);
+ gtk_box_pack_start(gui->statusbar.box, gui->statusbar.mode, false, true, 0);
gtk_box_pack_start(gui->statusbar.box, gui->statusbar.left, true, true, 2);
gtk_box_pack_start(gui->statusbar.box, gui->statusbar.cmd, false, false, 0);
gtk_box_pack_start(gui->statusbar.box, gui->statusbar.right, false, false, 2);
/* statusbar */
typedef struct {
GtkBox *box;
+ GtkWidget *mode;
GtkWidget *left;
GtkWidget *right;
GtkWidget *cmd;
void vb_update_status_style(void);
void vb_update_input_style(void);
void vb_update_urlbar(const char *uri);
+void vb_update_mode_label(const char *label);
void vb_register_add(char buf, const char *value);
const char *vb_register_get(char buf);
gboolean vb_download(WebKitWebView *view, WebKitDownload *download, const char *path);