diff options
-rw-r--r-- | src/dom.c | 3 | ||||
-rw-r--r-- | src/ex.c | 11 | ||||
-rw-r--r-- | src/hints.c | 11 | ||||
-rw-r--r-- | src/input.c | 5 | ||||
-rw-r--r-- | src/main.c | 194 | ||||
-rw-r--r-- | src/main.h | 6 | ||||
-rw-r--r-- | src/map.c | 3 | ||||
-rw-r--r-- | src/mode.c | 192 | ||||
-rw-r--r-- | src/mode.h | 37 | ||||
-rw-r--r-- | src/normal.c | 17 | ||||
-rw-r--r-- | tests/test-map.c | 7 |
11 files changed, 212 insertions, 274 deletions
@@ -20,7 +20,6 @@ #include "config.h" #include "main.h" #include "dom.h" -#include "mode.h" extern VbCore vb; @@ -208,7 +207,7 @@ static gboolean auto_insert(Element *element) * want to remove the content and force a switch to input mode. And to * switch to input mode when this is already active makes no sense. */ if (vb.mode->id == 'n' && dom_is_editable(element)) { - mode_enter('i'); + vb_enter('i'); return true; } @@ -28,7 +28,6 @@ #include "ascii.h" #include "completion.h" #include "hints.h" -#include "mode.h" #include "command.h" #include "history.h" #include "dom.h" @@ -279,7 +278,7 @@ VbResult ex_keypress(int key) case CTRL('['): case CTRL('C'): - mode_enter('n'); + vb_enter('n'); vb_set_input_text(""); break; @@ -361,7 +360,7 @@ VbResult ex_keypress(int key) if (check_empty) { gtk_text_buffer_get_bounds(buffer, &start, &end); if (gtk_text_iter_equal(&start, &end)) { - mode_enter('n'); + vb_enter('n'); vb_set_input_text(""); } } @@ -451,7 +450,7 @@ static void input_activate(void) switch (*text) { case '/': count = 1; /* fall through */ case '?': - mode_enter('n'); + vb_enter('n'); command_search(&((Arg){count, cmd})); break; @@ -461,7 +460,7 @@ static void input_activate(void) break; case ':': - mode_enter('n'); + vb_enter('n'); res = ex_run_string(cmd, true); if (!(res & VB_CMD_KEEPINPUT)) { /* clear input on success if this is not explicit ommited */ @@ -832,7 +831,7 @@ static VbCmdResult ex_unmap(const ExArg *arg) static VbCmdResult ex_normal(const ExArg *arg) { - mode_enter('n'); + vb_enter('n'); /* if called with bang - don't apply mapping */ map_handle_string(arg->rhs->str, !arg->bang); diff --git a/src/hints.c b/src/hints.c index b0a40ed..0249b8c 100644 --- a/src/hints.c +++ b/src/hints.c @@ -26,7 +26,6 @@ #include "dom.h" #include "command.h" #include "hints.js.h" -#include "mode.h" #include "input.h" #include "map.h" #include "js.h" @@ -135,7 +134,7 @@ void hints_create(const char *input) if (!hints_parse_prompt(input, &hints.mode, &hints.gmode)) { /* if input is not valid, clear possible previous hint mode */ if (vb.mode->flags & FLAG_HINTING) { - mode_enter('n'); + vb_enter('n'); } return; } @@ -301,11 +300,11 @@ static gboolean call_hints_function(const char *func, int count, JSValueRef para * normal mode when the hinting triggered a click that set focus on * editable element that lead vimb to switch to input mode. */ if (!hints.gmode && vb.mode->id == 'c') { - mode_enter('n'); + vb_enter('n'); } } else if (!strncmp(value, "INSERT:", 7)) { fire_timeout(false); - mode_enter('i'); + vb_enter('i'); if (hints.mode == 'e') { input_open_editor(); } @@ -314,7 +313,7 @@ static gboolean call_hints_function(const char *func, int count, JSValueRef para /* switch first to normal mode - else we would clear the inputbox * on switching mode also if we want to show yanked data */ if (!hints.gmode) { - mode_enter('n'); + vb_enter('n'); } char *v = (value + 5); @@ -334,7 +333,7 @@ static gboolean call_hints_function(const char *func, int count, JSValueRef para case 'T': vb_echo(VB_MSG_NORMAL, false, "%s %s", (hints.mode == 'T') ? ":tabopen" : ":open", v); if (!hints.gmode) { - mode_enter('c'); + vb_enter('c'); } break; diff --git a/src/input.c b/src/input.c index 26bd599..8b88254 100644 --- a/src/input.c +++ b/src/input.c @@ -19,7 +19,6 @@ #include "config.h" #include <glib/gstdio.h> -#include "mode.h" #include "main.h" #include "input.h" #include "dom.h" @@ -81,7 +80,7 @@ VbResult input_keypress(int key) switch (key) { case CTRL('['): /* esc */ - mode_enter('n'); + vb_enter('n'); return RESULT_COMPLETE; case CTRL('O'): @@ -95,7 +94,7 @@ VbResult input_keypress(int key) return input_open_editor(); case CTRL('Z'): - mode_enter('p'); + vb_enter('p'); return RESULT_COMPLETE; } @@ -34,7 +34,6 @@ #include "history.h" #include "cookiejar.h" #include "hsts.h" -#include "mode.h" #include "normal.h" #include "ex.h" #include "input.h" @@ -44,12 +43,15 @@ #include "autocmd.h" #include "arh.h" #include "io.h" +#include "ascii.h" /* variables */ static char *argv0; VbCore vb; /* callbacks */ + +static void buffer_changed_cb(GtkTextBuffer* buffer, gpointer data); #if WEBKIT_CHECK_VERSION(1, 10, 0) static gboolean context_menu_cb(WebKitWebView *view, GtkWidget *menu, WebKitHitTestResult *hitTestResult, gboolean keyboard, gpointer data); @@ -66,6 +68,8 @@ static void webview_request_starting_cb(WebKitWebView *view, WebKitNetworkResponse *resp, gpointer data); static void destroy_window_cb(GtkWidget *widget); static void scroll_cb(GtkAdjustment *adjustment); +static gboolean input_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, + gpointer data); static WebKitWebView *inspector_new(WebKitWebInspector *inspector, WebKitWebView *webview); static gboolean inspector_show(WebKitWebInspector *inspector); static gboolean inspector_close(WebKitWebInspector *inspector); @@ -115,6 +119,29 @@ static gboolean hide_message(); static void set_status(const StatusType status); static void input_print(gboolean force, const MessageType type, gboolean hide, const char *message); static void vb_cleanup(void); +static void cleanup_modes(void); +static void free_mode(Mode *mode); + +/** + * Creates a new mode with given callback functions. + */ +void vb_add_mode(char id, ModeTransitionFunc enter, ModeTransitionFunc leave, + ModeKeyFunc keypress, ModeInputChangedFunc input_changed) +{ + Mode *new = g_slice_new(Mode); + new->id = id; + new->enter = enter; + new->leave = leave; + new->keypress = keypress; + new->input_changed = input_changed; + new->flags = 0; + + /* Initialize the hashmap if this was not done before */ + if (!vb.modes) { + vb.modes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)free_mode); + } + g_hash_table_insert(vb.modes, GINT_TO_POINTER(id), new); +} void vb_echo_force(const MessageType type, gboolean hide, const char *error, ...) { @@ -142,6 +169,103 @@ void vb_echo(const MessageType type, gboolean hide, const char *error, ...) g_free(buffer); } +/** + * Enter into the new given mode and leave possible active current mode. + */ +void vb_enter(char id) +{ + Mode *new = g_hash_table_lookup(vb.modes, GINT_TO_POINTER(id)); + + g_return_if_fail(new != NULL); + + if (vb.mode) { + /* don't do anything if the mode isn't a new one */ + if (vb.mode == new) { + return; + } + + /* if there is a active mode, leave this first */ + if (vb.mode->leave) { + vb.mode->leave(); + } + } + + /* reset the flags of the new entered mode */ + new->flags = 0; + + /* set the new mode so that it is available also in enter function */ + vb.mode = new; + /* call enter only if the new mode isn't the current mode */ + if (new->enter) { + new->enter(); + } + +#ifndef TESTLIB + vb_update_statusbar(); +#endif +} + +/** + * Set the prompt chars and switch to new mode. + * + * @id: Mode id. + * @prompt: Prompt string to set as current prompt. + * @print_prompt: Indicates if the new set prompt should be put into inputbox + * after switching the mode. + */ +void vb_enter_prompt(char id, const char *prompt, gboolean print_prompt) +{ + /* set the prompt to be accessible in vb_enter */ + strncpy(vb.state.prompt, prompt, PROMPT_SIZE - 1); + vb.state.prompt[PROMPT_SIZE - 1] = '\0'; + + vb_enter(id); + + if (print_prompt) { + /* set it after the mode was entered so that the modes input change + * event listener could grep the new prompt */ + vb_echo_force(VB_MSG_NORMAL, false, vb.state.prompt); + } +} + +VbResult vb_handle_key(int key) +{ + VbResult res; + static gboolean ctrl_v = false; + + if (ctrl_v) { + vb.state.processed_key = false; + ctrl_v = false; + + return RESULT_COMPLETE; + } + if (vb.mode->id != 'p' && key == CTRL('V')) { + vb.mode->flags |= FLAG_NOMAP; + ctrl_v = true; + + return RESULT_MORE; + } + + if (vb.mode && vb.mode->keypress) { +#ifdef DEBUG + int flags = vb.mode->flags; + int id = vb.mode->id; + res = vb.mode->keypress(key); + if (vb.mode) { + PRINT_DEBUG( + "%c[%d]: %#.2x '%c' -> %c[%d]", + id - ' ', flags, key, (key >= 0x20 && key <= 0x7e) ? key : ' ', + vb.mode->id - ' ', vb.mode->flags + ); + } +#else + res = vb.mode->keypress(key); +#endif + return res; + } + return RESULT_ERROR; +} + static void input_print(gboolean force, const MessageType type, gboolean hide, const char *message) { @@ -467,6 +591,28 @@ static gboolean hide_message() return false; } +/** + * Process input changed event on current active mode. + */ +static void buffer_changed_cb(GtkTextBuffer* buffer, gpointer data) +{ + char *text; + GtkTextIter start, end; + /* don't observe changes in completion mode */ + if (vb.mode->flags & FLAG_COMPLETION) { + return; + } + /* don't process changes not typed by the user */ + if (gtk_widget_is_focus(vb.gui.input) && vb.mode && vb.mode->input_changed) { + gtk_text_buffer_get_bounds(buffer, &start, &end); + text = gtk_text_buffer_get_text(buffer, &start, &end, false); + + vb.mode->input_changed(text); + + g_free(text); + } +} + #if WEBKIT_CHECK_VERSION(1, 10, 0) static gboolean context_menu_cb(WebKitWebView *view, GtkWidget *menu, WebKitHitTestResult *hitTestResult, gboolean keyboard, gpointer data) @@ -613,7 +759,7 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec) #endif /* if we load a page from a submitted form, leave the insert mode */ if (vb.mode->id == 'i') { - mode_enter('n'); + vb_enter('n'); } break; @@ -688,6 +834,15 @@ static void scroll_cb(GtkAdjustment *adjustment) vb_update_statusbar(); } +static gboolean input_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, + gpointer data) +{ + /* enter the command mode if the focus is on inputbox */ + vb_enter('c'); + + return false; +} + static WebKitWebView *inspector_new(WebKitWebInspector *inspector, WebKitWebView *webview) { return WEBKIT_WEB_VIEW(webkit_web_view_new()); @@ -857,11 +1012,10 @@ static void init_core(void) #endif /* initialize the modes */ - mode_init(); - 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); + vb_add_mode('n', normal_enter, normal_leave, normal_keypress, NULL); + vb_add_mode('c', ex_enter, ex_leave, ex_keypress, ex_input_changed); + vb_add_mode('i', input_enter, input_leave, input_keypress, NULL); + vb_add_mode('p', pass_enter, pass_leave, pass_keypress, NULL); /* initialize the marks with empty values */ marks_clear(); @@ -897,7 +1051,7 @@ static void init_core(void) } /* enter normal mode */ - mode_enter('n'); + vb_enter('n'); vb.config.default_zoom = 1.0; @@ -992,7 +1146,7 @@ static void setup_signals() G_OBJECT(vb.gui.window), "key-press-event", G_CALLBACK(map_keypress), NULL ); g_signal_connect( - G_OBJECT(vb.gui.input), "focus-in-event", G_CALLBACK(mode_input_focusin), NULL + G_OBJECT(vb.gui.input), "focus-in-event", G_CALLBACK(input_focus_in_cb), NULL ); /* inspector */ @@ -1008,7 +1162,7 @@ static void setup_signals() /* There is no inputbox in kioskmode - but the contents may be changed in * case vimb is controlled via socket. To track inputbox changes is * required for the hinting to work. */ - g_signal_connect(G_OBJECT(vb.gui.buffer), "changed", G_CALLBACK(mode_input_changed), NULL); + g_signal_connect(G_OBJECT(vb.gui.buffer), "changed", G_CALLBACK(buffer_changed_cb), NULL); /* webview adjustment */ g_signal_connect(G_OBJECT(vb.gui.adjust_v), "value-changed", G_CALLBACK(scroll_cb), NULL); @@ -1184,11 +1338,11 @@ static gboolean button_relase_cb(WebKitWebView *webview, GdkEventButton *event) * element after a click - switch to insert mode. The later is * used for WYSIWYG editors where the click runs into a div and * not the editable element itself. */ - mode_enter('i'); + vb_enter('i'); } else if (vb.mode->id == 'i' || vb.mode->id == 'c') { /* make sure we leave insert mode or command/hint mode if the user * click on a none editable element */ - mode_enter('n'); + vb_enter('n'); } } g_object_unref(result); @@ -1549,7 +1703,7 @@ static void vb_cleanup(void) completion_clean(); map_cleanup(); - mode_cleanup(); + cleanup_modes(); setting_cleanup(); history_cleanup(); session_cleanup(); @@ -1574,6 +1728,20 @@ static void vb_cleanup(void) } } +static void cleanup_modes(void) +{ + if (vb.modes) { + g_hash_table_destroy(vb.modes); + vb.modes = NULL; + vb.mode = NULL; + } +} + +static void free_mode(Mode *mode) +{ + g_slice_free(Mode, mode); +} + static gboolean autocmdOptionArgFunc(const gchar *option_name, const gchar *value, gpointer data, GError **error) { vb.config.cmdargs = g_slist_append(vb.config.cmdargs, g_strdup(value)); @@ -380,14 +380,20 @@ typedef struct { #else GdkNativeWindow embed; #endif + GHashTable *modes; /* all available browser main modes */ } VbCore; /* main object */ extern VbCore core; /* functions */ +void vb_add_mode(char id, ModeTransitionFunc enter, ModeTransitionFunc leave, + ModeKeyFunc keypress, ModeInputChangedFunc input_changed); void vb_echo_force(const MessageType type,gboolean hide, const char *error, ...); void vb_echo(const MessageType type, gboolean hide, const char *error, ...); +void vb_enter(char id); +void vb_enter_prompt(char id, const char *prompt, gboolean print_prompt); +VbResult vb_handle_key(int key); void vb_set_input_text(const char *text); char *vb_get_input_text(void); void vb_input_activate(void); @@ -22,7 +22,6 @@ #include "map.h" #include "normal.h" #include "ascii.h" -#include "mode.h" /* convert the lower 4 bits of byte n to its hex character */ #define NR2HEX(n) (n & 0xf) <= 9 ? (n & 0xf) + '0' : (c & 0xf) - 10 + 'a' @@ -239,7 +238,7 @@ MapState map_handle_keys(const guchar *keys, int keylen, gboolean use_map) vb.mode->flags &= ~FLAG_NOMAP; /* send the key to the parser */ - if (RESULT_MORE != mode_handle_key((int)qk)) { + if (RESULT_MORE != vb_handle_key((int)qk)) { showcmd(0); showlen = 0; } else if (showlen > 0) { diff --git a/src/mode.c b/src/mode.c deleted file mode 100644 index 237591e..0000000 --- a/src/mode.c +++ /dev/null @@ -1,192 +0,0 @@ -/** - * vimb - a webkit based vim like browser. - * - * Copyright (C) 2012-2015 Daniel Carl - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#include "config.h" -#include "main.h" -#include "mode.h" -#include "ascii.h" -#include <glib.h> - -static GHashTable *modes = NULL; -extern VbCore vb; - -static void free_mode(Mode *mode); - - -void mode_init(void) -{ - modes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)free_mode); -} - -void mode_cleanup(void) -{ - if (modes) { - g_hash_table_destroy(modes); - vb.mode = NULL; - } -} - -/** - * Creates a new mode with given callback functions. - */ -void mode_add(char id, ModeTransitionFunc enter, ModeTransitionFunc leave, - ModeKeyFunc keypress, ModeInputChangedFunc input_changed) -{ - Mode *new = g_slice_new(Mode); - new->id = id; - new->enter = enter; - new->leave = leave; - new->keypress = keypress; - new->input_changed = input_changed; - new->flags = 0; - - g_hash_table_insert(modes, GINT_TO_POINTER(id), new); -} - -/** - * Enter into the new given mode and leave possible active current mode. - */ -void mode_enter(char id) -{ - Mode *new = g_hash_table_lookup(modes, GINT_TO_POINTER(id)); - - g_return_if_fail(new != NULL); - - if (vb.mode) { - /* don't do anything if the mode isn't a new one */ - if (vb.mode == new) { - return; - } - - /* if there is a active mode, leave this first */ - if (vb.mode->leave) { - vb.mode->leave(); - } - } - - /* reset the flags of the new entered mode */ - new->flags = 0; - - /* set the new mode so that it is available also in enter function */ - vb.mode = new; - /* call enter only if the new mode isn't the current mode */ - if (new->enter) { - new->enter(); - } - -#ifndef TESTLIB - vb_update_statusbar(); -#endif -} - -/** - * Set the prompt chars and switch to new mode. - * - * @id: Mode id. - * @prompt: Prompt string to set as current prompt. - * @print_prompt: Indicates if the new set prompt should be put into inputbox - * after switching the mode. - */ -void mode_enter_prompt(char id, const char *prompt, gboolean print_prompt) -{ - /* set the prompt to be accessible in mode_enter */ - strncpy(vb.state.prompt, prompt, PROMPT_SIZE - 1); - vb.state.prompt[PROMPT_SIZE - 1] = '\0'; - - mode_enter(id); - - if (print_prompt) { - /* set it after the mode was entered so that the modes input change - * event listener could grep the new prompt */ - vb_echo_force(VB_MSG_NORMAL, false, vb.state.prompt); - } -} - -VbResult mode_handle_key(int key) -{ - VbResult res; - static gboolean ctrl_v = false; - - if (ctrl_v) { - vb.state.processed_key = false; - ctrl_v = false; - - return RESULT_COMPLETE; - } - if (vb.mode->id != 'p' && key == CTRL('V')) { - vb.mode->flags |= FLAG_NOMAP; - ctrl_v = true; - - return RESULT_MORE; - } - - if (vb.mode && vb.mode->keypress) { -#ifdef DEBUG - int flags = vb.mode->flags; - int id = vb.mode->id; - res = vb.mode->keypress(key); - if (vb.mode) { - PRINT_DEBUG( - "%c[%d]: %#.2x '%c' -> %c[%d]", - id - ' ', flags, key, (key >= 0x20 && key <= 0x7e) ? key : ' ', - vb.mode->id - ' ', vb.mode->flags - ); - } -#else - res = vb.mode->keypress(key); -#endif - return res; - } - 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; -} - -/** - * Process input changed event on current active mode. - */ -void mode_input_changed(GtkTextBuffer* buffer, gpointer data) -{ - char *text; - GtkTextIter start, end; - /* don't observe changes in completion mode */ - if (vb.mode->flags & FLAG_COMPLETION) { - return; - } - /* don't process changes not typed by the user */ - if (gtk_widget_is_focus(vb.gui.input) && vb.mode && vb.mode->input_changed) { - gtk_text_buffer_get_bounds(buffer, &start, &end); - text = gtk_text_buffer_get_text(buffer, &start, &end, false); - - vb.mode->input_changed(text); - - g_free(text); - } -} - -static void free_mode(Mode *mode) -{ - g_slice_free(Mode, mode); -} diff --git a/src/mode.h b/src/mode.h deleted file mode 100644 index ccac3d5..0000000 --- a/src/mode.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * vimb - a webkit based vim like browser. - * - * Copyright (C) 2012-2015 Daniel Carl - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#ifndef _MODE_H -#define _MODE_H - -#include "config.h" -#include "main.h" - -void mode_init(void); -void mode_cleanup(void); -void mode_add(char id, ModeTransitionFunc enter, ModeTransitionFunc leave, - ModeKeyFunc keypress, ModeInputChangedFunc input_changed); -void mode_enter(char id); -void mode_enter_prompt(char id, const char *prompt, gboolean print_prompt); -VbResult mode_handle_key(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 */ diff --git a/src/normal.c b/src/normal.c index fa9ddfd..b43f48b 100644 --- a/src/normal.c +++ b/src/normal.c @@ -19,7 +19,6 @@ #include <gdk/gdkkeysyms.h> #include "config.h" -#include "mode.h" #include "main.h" #include "normal.h" #include "ascii.h" @@ -329,7 +328,7 @@ void pass_leave(void) VbResult pass_keypress(int key) { if (key == CTRL('[')) { /* esc */ - mode_enter('n'); + vb_enter('n'); } vb.state.processed_key = false; return RESULT_COMPLETE; @@ -401,12 +400,12 @@ static VbResult normal_descent(const NormalCmdInfo *info) static VbResult normal_ex(const NormalCmdInfo *info) { if (info->key == 'F') { - mode_enter_prompt('c', ";t", true); + vb_enter_prompt('c', ";t", true); } else if (info->key == 'f') { - mode_enter_prompt('c', ";o", true); + vb_enter_prompt('c', ";o", true); } else { char prompt[2] = {info->key, '\0'}; - mode_enter_prompt('c', prompt, true); + vb_enter_prompt('c', prompt, true); } return RESULT_COMPLETE; @@ -415,7 +414,7 @@ static VbResult normal_ex(const NormalCmdInfo *info) static VbResult normal_focus_input(const NormalCmdInfo *info) { if (dom_focus_input(vb.gui.webview)) { - mode_enter('i'); + vb_enter('i'); return RESULT_COMPLETE; } @@ -479,7 +478,7 @@ static VbResult normal_do_hint(const char *prompt) return RESULT_ERROR; } - mode_enter_prompt('c', prompt, true); + vb_enter_prompt('c', prompt, true); return RESULT_COMPLETE; } @@ -503,7 +502,7 @@ static VbResult normal_input_open(const NormalCmdInfo *info) } /* switch mode after setting the input text to not trigger the * commands modes input change handler */ - mode_enter_prompt('c', ":", false); + vb_enter_prompt('c', ":", false); return RESULT_COMPLETE; } @@ -611,7 +610,7 @@ static VbResult normal_open(const NormalCmdInfo *info) static VbResult normal_pass(const NormalCmdInfo *info) { - mode_enter('p'); + vb_enter('p'); return RESULT_COMPLETE; } diff --git a/tests/test-map.c b/tests/test-map.c index e0a66b5..8fe5ace 100644 --- a/tests/test-map.c +++ b/tests/test-map.c @@ -21,7 +21,7 @@ #include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms-compat.h> #include <src/map.h> -#include <src/mode.h> +#include <src/main.h> static char queue[20]; /* receives the keypresses */ static int qpos = 0; /* points to the queue entry for the next keypress */ @@ -147,9 +147,8 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); /* add a test mode to handle the maped sequences */ - mode_init(); - mode_add('t', NULL, NULL, keypress, NULL); - mode_enter('t'); + vb_add_mode('t', NULL, NULL, keypress, NULL); + vb_enter('t'); map_init(); g_test_add_func("/test-map/handle_string/simple", test_handle_string_simple); |