GtkTextBuffer *buffer = vb.gui.buffer;
GtkTextMark *mark;
- /* delegate call to the submode if hinting is active */
- if (vb.mode->flags & FLAG_HINTING) {
- if (RESULT_COMPLETE == hints_keypress(key)) {
- return RESULT_COMPLETE;
- }
+ /* delegate call to the submode */
+ if (RESULT_COMPLETE == hints_keypress(key)) {
+ return RESULT_COMPLETE;
}
switch (key) {
VbResult hints_keypress(unsigned int key)
{
+ /* if we are not already in hint mode we expect to get a ; to start
+ * hinting */
+ if (!(vb.mode->flags & FLAG_HINTING) && key != ';') {
+ return RESULT_ERROR;
+ }
+
if (key == '\n') {
hints_fire();
/* initialize the modes */
mode_init();
- mode_add('n', normal_enter, normal_leave, normal_keypress, normal_input_changed);
+ mode_add('n', normal_enter, normal_leave, normal_keypress, NULL);
mode_add('c', ex_enter, ex_leave, ex_keypress, ex_input_changed);
mode_add('i', input_enter, input_leave, input_keypress, NULL);
mode_add('p', pass_enter, pass_leave, pass_keypress, NULL);
g_signal_connect(
G_OBJECT(vb.gui.window), "key-press-event", G_CALLBACK(map_keypress), NULL
);
+ g_object_connect(
+ G_OBJECT(vb.gui.input),
+ "signal::focus-in-event", G_CALLBACK(mode_input_focusin), NULL,
+ "signal::focus-out-event", G_CALLBACK(mode_input_focusout), NULL,
+ NULL
+ );
g_object_connect(
G_OBJECT(vb.gui.buffer),
"signal::changed", G_CALLBACK(mode_input_changed), NULL,
return RESULT_ERROR;
}
+gboolean mode_input_focusin(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+{
+ /* enter the command mode if the focus is on inputbox */
+ mode_enter('c');
+
+ return false;
+}
+
+gboolean mode_input_focusout(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+{
+ /* if focus is lesft from inputbox - switch back to normal mode */
+ mode_enter('n');
+
+ return false;
+}
+
/**
* Process input changed event on current active mode.
*/
ModeKeyFunc keypress, ModeInputChangedFunc input_changed);
void mode_enter(char id);
VbResult mode_handle_key(unsigned int key);
+gboolean mode_input_focusin(GtkWidget *widget, GdkEventFocus *event, gpointer data);
+gboolean mode_input_focusout(GtkWidget *widget, GdkEventFocus *event, gpointer data);
void mode_input_changed(GtkTextBuffer* buffer, gpointer data);
#endif /* end of include guard: _MODE_H */
return res;
}
-/**
- * Handles changes in the inputbox. If there are usergenerated changes, we
- * switch to command mode.
- */
-void normal_input_changed(const char *text)
-{
- /*mode_enter('i');*/
-}
-
static VbResult normal_clear_input(const NormalCmdInfo *info)
{
vb_set_input_text("");
void normal_enter(void);
void normal_leave(void);
VbResult normal_keypress(unsigned int key);
-void normal_input_changed(const char *text);
#endif /* end of include guard: _NORMAL_H */