binds.lua

changeset 1
4d7540af8518
parent 0
98e4b0c9fcac
--- a/binds.lua	Wed Sep 01 03:53:30 2010 +0100
+++ b/binds.lua	Wed Sep 01 03:59:23 2010 +0100
@@ -10,7 +10,7 @@
 -- Globals or defaults that are used in binds
 local scroll_step = globals.scroll_step or 20
 local zoom_step   = globals.zoom_step or 0.1
-local homepage    = globals.homepage or "http://luakit.org"
+local homepage    = globals.homepage or "http://google.co.uk/"
 
 -- Add key bindings to be used across all windows in the given modes.
 binds.mode_binds = {
@@ -18,101 +18,58 @@
      -- key({Modifiers}, Key name,      function (w, opts)         .. end, opts),
      -- but({Modifiers}, Button num,    function (w, opts)         .. end, opts),
     all = {
-        key({},          "Escape",      function (w) w:set_mode() end),
-        key({"Control"}, "[",           function (w) w:set_mode() end),
+        key({},          "Escape",      function (w) w:set_mode("normal") end),
+        key({"Control"}, "e",           function (w) w:set_mode("command") end),
+        key({"Control"}, "n",           function (w) w:set_mode("normal") end),
+        
+        key({"Control"}, "x",           function (w) w:close_tab() end),
 
-        but({},          8,             function (w) w:back()    end),
-        but({},          9,             function (w) w:forward() end),
-    },
-    normal = {
-        key({},          "i",           function (w) w:set_mode("insert")  end),
-        key({},          ":",           function (w) w:set_mode("command") end),
+        key({"Control"}, "c",           function (w) if w:get_mode() ~= "normal" then w:set_mode("normal"); end end),
+
+	-- Location
+        key({"Control"}, "t",           function (w) w:new_tab(homepage); end),
 
-        -- Scrolling
-        key({},          "j",           function (w) w:scroll_vert("+"..scroll_step.."px") end),
-        key({},          "k",           function (w) w:scroll_vert("-"..scroll_step.."px") end),
-        key({},          "h",           function (w) w:scroll_horiz("-"..scroll_step.."px") end),
-        key({},          "l",           function (w) w:scroll_horiz("+"..scroll_step.."px") end),
-        key({"Control"}, "d",           function (w) w:scroll_page(0.5)    end),
-        key({"Control"}, "u",           function (w) w:scroll_page(-0.5)   end),
-        key({"Control"}, "f",           function (w) w:scroll_page(1.0)    end),
-        key({"Control"}, "b",           function (w) w:scroll_page(-1.0)   end),
-        buf("^gg$",                     function (w) w:scroll_vert("0%")   end),
-        buf("^G$",                      function (w) w:scroll_vert("100%") end),
-        buf("^[\-\+]?[0-9]+[%%G]$",     function (w, b) w:scroll_vert(string.match(b, "^([\-\+]?%d+)[%%G]$") .. "%") end),
+	-- Location
+        key({"Control"}, "l",           function (w) w:set_mode("url-entry"); end),
+        
+        -- Web search
+        key({"Control"}, "k",           function (w) w:enter_cmd(":websearch google ") end);
+        
+        -- Back and forth
+	key({"Mod1"},    "Left",        function (w) w:back()    end);
+	key({"Mod1"},    "Right",       function (w) w:forward()    end);
+	
+	-- Tab/buffer switching
+	key({"Mod1"},    ".",           function (w) w:next_tab(1)    end);
+	key({"Mod1"},    ",",           function (w) w:prev_tab(1)    end);
+        key({"Control"}, "Page_Up",     function (w) w:prev_tab() end),
+        key({"Control"}, "Page_Down",   function (w) w:next_tab() end),
+	
+        key({"Control"}, "p",           function (w) w:navigate(luakit.get_selection("c")) end),
+        key({"Control"}, "P",           function (w) w:new_tab(luakit.get_selection("c"))  end),
+        key({"Control"}, "y",           function (w) luakit.set_selection((w:get_current() or {}).uri or "", "c") end),
+        key({"Control"}, "Y",           function (w) luakit.set_selection(w.win.title, "c") end),
 
-        -- Traditional scrolling commands
-        key({},          "Down",        function (w) w:scroll_vert("+"..scroll_step.."px") end),
-        key({},          "Up",          function (w) w:scroll_vert("-"..scroll_step.."px") end),
-        key({},          "Left",        function (w) w:scroll_horiz("-"..scroll_step.."px") end),
-        key({},          "Right",       function (w) w:scroll_horiz("+"..scroll_step.."px") end),
-        key({},          "Page_Down",   function (w) w:scroll_page(1.0)    end),
-        key({},          "Page_Up",     function (w) w:scroll_page(-1.0)   end),
-        key({},          "Home",        function (w) w:scroll_vert("0%")   end),
-        key({},          "End",         function (w) w:scroll_vert("100%") end),
+        key({"Control"}, "r",           function (w) w:reload() end),
 
-        -- Zooming
-        buf("^z0$",                     function (w) w:zoom_reset()        end),
-        buf("^zI$",                     function (w) w:zoom_in(zoom_step)  end),
-        buf("^zO$",                     function (w) w:zoom_out(zoom_step) end),
+	key({"Mod1"},    "Home",        function (w) w:navigate(homepage)  end);
+
         key({"Control"}, "+",           function (w) w:zoom_in(zoom_step)  end),
         key({"Control"}, "-",           function (w) w:zoom_out(zoom_step) end),
 
-        -- Clipboard
-        key({},          "p",           function (w) w:navigate(luakit.get_selection()) end),
-        key({},          "P",           function (w) w:new_tab(luakit.get_selection())  end),
-        buf("^yy$",                     function (w) luakit.set_selection((w:get_current() or {}).uri or "") end),
-        buf("^yt$",                     function (w) luakit.set_selection(w.win.title) end),
-
-        -- Commands
-        buf("^o$",                      function (w, c) w:enter_cmd(":open ")    end),
-        buf("^t$",                      function (w, c) w:enter_cmd(":tabopen ") end),
-        buf("^w$",                      function (w, c) w:enter_cmd(":winopen ") end),
-        buf("^O$",                      function (w, c) w:enter_cmd(":open "    .. ((w:get_current() or {}).uri or "")) end),
-        buf("^T$",                      function (w, c) w:enter_cmd(":tabopen " .. ((w:get_current() or {}).uri or "")) end),
-        buf("^W$",                      function (w, c) w:enter_cmd(":winopen " .. ((w:get_current() or {}).uri or "")) end),
-        buf("^,g$",                     function (w, c) w:enter_cmd(":websearch google ") end),
+        but({},          8,             function (w) w:back()    end),
+        but({},          9,             function (w) w:forward() end),
 
-        -- Debian search shorcut access
-        buf("^\\dbug$",                function (w, c) w:enter_cmd(":websearch debbugs ") end),
-        buf("^\\dpts$",                function (w, c) w:enter_cmd(":websearch dpts ") end),
-        buf("^\\dpkg$",                function (w, c) w:enter_cmd(":websearch dpkg ") end),
-
-        -- Searching
-        key({},          "/",           function (w) w:start_search("/")  end),
-        key({},          "?",           function (w) w:start_search("?") end),
-        key({},          "n",           function (w) w:search(nil, true) end),
-        key({},          "N",           function (w) w:search(nil, false) end),
-
-        -- History
-        buf("^[0-9]*H$",                function (w, b) w:back   (tonumber(string.match(b, "^(%d*)H$") or 1)) end),
-        buf("^[0-9]*L$",                function (w, b) w:forward(tonumber(string.match(b, "^(%d*)L$") or 1)) end),
-        key({},          "b",           function (w) w:back() end),
         key({},          "XF86Back",    function (w) w:back() end),
         key({},          "XF86Forward", function (w) w:forward() end),
-
-        -- Tab
-        key({"Control"}, "Page_Up",     function (w) w:prev_tab() end),
-        key({"Control"}, "Page_Down",   function (w) w:next_tab() end),
-        buf("^[0-9]*gT$",               function (w, b) w:prev_tab(tonumber(string.match(b, "^(%d*)gT$") or 1)) end),
-        buf("^[0-9]*gt$",               function (w, b) w:next_tab(tonumber(string.match(b, "^(%d*)gt$") or 1)) end),
-        buf("^gH$",                     function (w)    w:new_tab(homepage) end),
-        buf("^d$",                      function (w)    w:close_tab() end),
-
-        key({},          "r",           function (w) w:reload() end),
-        buf("^gh$",                     function (w) w:navigate(homepage) end),
-
-        -- Window
-        buf("^ZZ$",                     function (w) w:close_win() end),
-        buf("^D$",                      function (w) w:close_win() end),
-
+        
         -- Link following
-        key({},          "f",           function (w) w:set_mode("follow") end),
+        key({"Mod1"},    "f",           function (w) w:set_mode("follow") end),
 
         -- Bookmarking
-        key({},          "B",           function (w) w:enter_cmd(":bookmark " .. ((w:get_current() or {}).uri or "http://") .. " ") end),
-        buf("^gb$",                     function (w) w:navigate(bookmarks.dump_html()) end),
-        buf("^gB$",                     function (w) w:new_tab (bookmarks.dump_html()) end),
+        key({"Control"}, "d",           function (w) end),
+        key({"Control"}, "b",           function (w) w:navigate(bookmarks.dump_html()) end),
+        key({"Control"}, "B",           function (w) w:new_tab(bookmarks.dump_html()) end),
 
         -- Mouse bindings
         but({},          2,             function (w)
@@ -125,6 +82,10 @@
                                             end
                                         end),
     },
+    
+    normal = {
+    },
+    
     command = {
         key({"Shift"},   "Insert",      function (w) w:insert_cmd(luakit.get_selection()) end),
         key({},          "Up",          function (w) w:cmd_hist_prev() end),
@@ -137,6 +98,9 @@
         key({},          "Up",          function (w) w:srch_hist_prev() end),
         key({},          "Down",        function (w) w:srch_hist_next() end),
     },
+    ["url-entry"] = {
+        key({"Control"}, "l",          function (w) w.ibar.input:set_position(-1); end),
+    },
     insert = { },
 }
 

mercurial