Commits

portix committed fe6f25e Merge

Merge branch 'master' of bitbucket.org:portix/dwb

  • Participants
  • Parent commits 880d6ce, dad5808

Comments (0)

Files changed (4)

 
 }/*}}}*/
 
-DwbStatus 
-commands_insert_mode(KeyMap *km, Arg *a) 
-{
-    return dwb_change_mode(INSERT_MODE);
-}
-DwbStatus 
-commands_normal_mode(KeyMap *km, Arg *a) 
-{
-    dwb_change_mode(NORMAL_MODE, true);
-    return STATUS_OK;
-}
-
 /* commands_toggle_proxy {{{*/
 DwbStatus
 commands_toggle_proxy(KeyMap *km, Arg *a) 
 
     return STATUS_OK;
 }/*}}}*/
-/* commands_entry_escape {{{*/
 DwbStatus 
-commands_entry_escape(KeyMap *km, Arg *a) 
+commands_change_mode(KeyMap *km, Arg *a)
 {
-    dwb_change_mode(NORMAL_MODE, true);
-    return STATUS_OK;
-}/*}}}*/
-
+    if (a->b)
+        return dwb_change_mode(a->n, true);
+    else 
+        return dwb_change_mode(a->n);
+}
 /* commands_save_session {{{*/
 DwbStatus
 commands_save_session(KeyMap *km, Arg *arg) 
     return editor_open();
 }/*}}}*/
 
-/* dwb_command_mode {{{*/
-DwbStatus
-commands_command_mode(KeyMap *km, Arg *arg) 
-{
-    return dwb_change_mode(COMMAND_MODE);
-}/*}}}*/
-/* dwb_command_mode {{{*/
+/* dwb_only {{{*/
 DwbStatus
 commands_only(KeyMap *km, Arg *arg) 
 {
 DwbStatus commands_entry_history_back(KeyMap *, Arg *);
 DwbStatus commands_entry_history_forward(KeyMap *, Arg *);
 DwbStatus commands_entry_confirm(KeyMap *km, Arg *a);
-DwbStatus commands_entry_escape(KeyMap *km, Arg *a);
 
 DwbStatus commands_execute_userscript(KeyMap *, Arg *);
 DwbStatus commands_find(KeyMap *, Arg *);
 DwbStatus commands_reload_user_scripts(KeyMap *, Arg *);
 DwbStatus commands_fullscreen(KeyMap *, Arg *);
 DwbStatus commands_open_editor(KeyMap *, Arg *);
-DwbStatus commands_insert_mode(KeyMap *, Arg *);
-DwbStatus commands_command_mode(KeyMap *, Arg *);
+DwbStatus commands_change_mode(KeyMap *, Arg *);
 DwbStatus commands_only(KeyMap *, Arg *);
 DwbStatus commands_toggle_bars(KeyMap *, Arg *);
 DwbStatus commands_presentation_mode(KeyMap *, Arg *);
 DwbStatus commands_tab_move(KeyMap *, Arg *);
 DwbStatus commands_clear_tab(KeyMap *, Arg *);
 DwbStatus commands_cancel_download(KeyMap *, Arg *);
-DwbStatus commands_normal_mode(KeyMap *, Arg *);
 DwbStatus commands_dump(KeyMap *, Arg *);
 DwbStatus commands_sanitize(KeyMap *, Arg *);
 DwbStatus commands_eval(KeyMap *, Arg *);
         {
             for (int i=0; token[i]; i++) 
             {
-                if (func(n->first, token[i]) || (!word_beginnings && n->second && func(n->second, token[i]))) 
+                if ((n->first && func(n->first, token[i])) || (!word_beginnings && n->second && func(n->second, token[i]))) 
                     match = true;
                 else 
                 {
         {
             for (int i=0; m->map->alias[i] != NULL; i++) 
             {
-                if (g_str_has_prefix(m->map->alias[i], input) || !g_strcmp0(input, m->map->alias[i]) ) 
+                if ((m->map->alias[i] && g_str_has_prefix(m->map->alias[i], input)) || !g_strcmp0(input, m->map->alias[i]) ) 
                 {
                     list = completion_create_key_completion(list, m->map->alias[i], m);
                     break;
             continue;
         
         Navigation n = m->map->n;
-        if (g_str_has_prefix(n.first, input)) 
+        if (n.first && g_str_has_prefix(n.first, input)) 
             list = completion_create_key_completion(list, n.first, m);
     }
     return list;
   { "toggle_tab",               {   "@Tab@",      GDK_CONTROL_MASK, 0 }, }, 
   { "reload_bookmarks",         {   NULL,         0, 0 }, }, 
   { "reload_quickmarks",        {   NULL,         0, 0 }, }, 
-  { "print_preview",        {   NULL,         0, 0 }, }, 
+  { "print_preview",            {   NULL,         0, 0 }, }, 
 };
 
 /* FUNCTION_MAP{{{*/
     { .n = OPEN_NEW_WINDOW }, EP_NONE, { NULL }, },
   
   { { "command_mode",          "Enter command mode",                }, 0, 
-    (Func)commands_command_mode,            NULL,                              POST_SM, 
-    {0}, EP_NONE, { NULL }, },
+    (Func)commands_change_mode,            NULL,                              POST_SM, 
+    { .n = COMMAND_MODE, .b = false }, EP_NONE, { NULL }, },
   
   { { "find_backward",         "Find backward ",                    }, CP_COMMANDLINE|CP_HAS_MODE, 
     (Func)commands_find,                NO_URL,                            NEVER_SM,     
     { .n = OPEN_NEW_WINDOW, .i = 1 }, EP_NONE, { "winforward", "wfo", NULL }, },
   
   { { "insert_mode",           "Insert Mode",                       }, CP_COMMANDLINE | CP_HAS_MODE, 
-    (Func)commands_insert_mode,             NULL,                              POST_SM, 
-    { 0 }, EP_NONE, { "i", "insert", NULL }, },
-  
+    (Func)commands_change_mode,             NULL,                              POST_SM, 
+    { .n = INSERT_MODE, .b = false }, EP_NONE, { "i", "insert", NULL }, },
+
   { { "normal_mode",           "Normal Mode",                       }, CP_OVERRIDE_INSERT | CP_OVERRIDE_ENTRY | CP_OVERRIDE_ALL, 
-    (Func)commands_normal_mode,             NULL,                              POST_SM, 
-    { 0 }, EP_NONE, { NULL }, },
+    (Func)commands_change_mode,             NULL,                              POST_SM, 
+    { .n = NORMAL_MODE, .b = true }, EP_NONE, { NULL }, },
   
   { { "load_html",             "Load html",                         }, CP_COMMANDLINE, 
     (Func)commands_open,           NULL,                       NEVER_SM,   
     { 0 }, EP_NONE, { NULL }, },
 
   { { "entry_escape",     "Command line: Alternate escape binding", },             CP_OVERRIDE_ENTRY,  
-    (Func)commands_entry_escape,           NULL,        ALWAYS_SM,  
-    { 0 }, EP_NONE, { NULL }, },
+    (Func)commands_change_mode,           NULL,        ALWAYS_SM,  
+    { .n = NORMAL_MODE, .b = true }, EP_NONE, { NULL }, },
   
   { { "entry_confirm",  "Command line: Alternate return binding", },          CP_OVERRIDE_ENTRY,  
     (Func)commands_entry_confirm,        NULL,        ALWAYS_SM,