Wed, 01 Sep 2010 03:53:30 +0100
Initial commit of default luakit config from 2010.08.30
0
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 | ----------------- |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 | -- Keybindings -- |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | ----------------- |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | binds = {} |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | -- Binding aliases |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | local key, buf, but, cmd = lousy.bind.key, lousy.bind.buf, lousy.bind.but, lousy.bind.cmd |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 | -- Globals or defaults that are used in binds |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 | local scroll_step = globals.scroll_step or 20 |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 | local zoom_step = globals.zoom_step or 0.1 |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 | local homepage = globals.homepage or "http://luakit.org" |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 | -- Add key bindings to be used across all windows in the given modes. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 | binds.mode_binds = { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 | -- buf(Pattern, function (w, buffer, opts) .. end, opts), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 | -- key({Modifiers}, Key name, function (w, opts) .. end, opts), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 | -- but({Modifiers}, Button num, function (w, opts) .. end, opts), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 | all = { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 | key({}, "Escape", function (w) w:set_mode() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 | key({"Control"}, "[", function (w) w:set_mode() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 | but({}, 8, function (w) w:back() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 | but({}, 9, function (w) w:forward() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 | }, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 | normal = { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 | key({}, "i", function (w) w:set_mode("insert") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 | key({}, ":", function (w) w:set_mode("command") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 | -- Scrolling |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 | key({}, "j", function (w) w:scroll_vert("+"..scroll_step.."px") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 | key({}, "k", function (w) w:scroll_vert("-"..scroll_step.."px") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 | key({}, "h", function (w) w:scroll_horiz("-"..scroll_step.."px") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 | key({}, "l", function (w) w:scroll_horiz("+"..scroll_step.."px") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 | key({"Control"}, "d", function (w) w:scroll_page(0.5) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 | key({"Control"}, "u", function (w) w:scroll_page(-0.5) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 | key({"Control"}, "f", function (w) w:scroll_page(1.0) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 | key({"Control"}, "b", function (w) w:scroll_page(-1.0) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 | buf("^gg$", function (w) w:scroll_vert("0%") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 | buf("^G$", function (w) w:scroll_vert("100%") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 | buf("^[\-\+]?[0-9]+[%%G]$", function (w, b) w:scroll_vert(string.match(b, "^([\-\+]?%d+)[%%G]$") .. "%") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 | -- Traditional scrolling commands |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 | key({}, "Down", function (w) w:scroll_vert("+"..scroll_step.."px") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 | key({}, "Up", function (w) w:scroll_vert("-"..scroll_step.."px") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 | key({}, "Left", function (w) w:scroll_horiz("-"..scroll_step.."px") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 | key({}, "Right", function (w) w:scroll_horiz("+"..scroll_step.."px") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 | key({}, "Page_Down", function (w) w:scroll_page(1.0) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 | key({}, "Page_Up", function (w) w:scroll_page(-1.0) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 | key({}, "Home", function (w) w:scroll_vert("0%") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 | key({}, "End", function (w) w:scroll_vert("100%") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 | -- Zooming |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 | buf("^z0$", function (w) w:zoom_reset() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 | buf("^zI$", function (w) w:zoom_in(zoom_step) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 | buf("^zO$", function (w) w:zoom_out(zoom_step) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 | key({"Control"}, "+", function (w) w:zoom_in(zoom_step) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 | key({"Control"}, "-", function (w) w:zoom_out(zoom_step) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 | -- Clipboard |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 | key({}, "p", function (w) w:navigate(luakit.get_selection()) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 | key({}, "P", function (w) w:new_tab(luakit.get_selection()) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 | buf("^yy$", function (w) luakit.set_selection((w:get_current() or {}).uri or "") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 | buf("^yt$", function (w) luakit.set_selection(w.win.title) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 | -- Commands |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 | buf("^o$", function (w, c) w:enter_cmd(":open ") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 | buf("^t$", function (w, c) w:enter_cmd(":tabopen ") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 | buf("^w$", function (w, c) w:enter_cmd(":winopen ") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 | buf("^O$", function (w, c) w:enter_cmd(":open " .. ((w:get_current() or {}).uri or "")) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 | buf("^T$", function (w, c) w:enter_cmd(":tabopen " .. ((w:get_current() or {}).uri or "")) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 | buf("^W$", function (w, c) w:enter_cmd(":winopen " .. ((w:get_current() or {}).uri or "")) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 | buf("^,g$", function (w, c) w:enter_cmd(":websearch google ") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 | -- Debian search shorcut access |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 | buf("^\\dbug$", function (w, c) w:enter_cmd(":websearch debbugs ") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 | buf("^\\dpts$", function (w, c) w:enter_cmd(":websearch dpts ") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 | buf("^\\dpkg$", function (w, c) w:enter_cmd(":websearch dpkg ") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 | -- Searching |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 | key({}, "/", function (w) w:start_search("/") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 | key({}, "?", function (w) w:start_search("?") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 | key({}, "n", function (w) w:search(nil, true) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 | key({}, "N", function (w) w:search(nil, false) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 | -- History |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 | buf("^[0-9]*H$", function (w, b) w:back (tonumber(string.match(b, "^(%d*)H$") or 1)) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 | buf("^[0-9]*L$", function (w, b) w:forward(tonumber(string.match(b, "^(%d*)L$") or 1)) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 | key({}, "b", function (w) w:back() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 | key({}, "XF86Back", function (w) w:back() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 | key({}, "XF86Forward", function (w) w:forward() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 | -- Tab |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 | key({"Control"}, "Page_Up", function (w) w:prev_tab() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 | key({"Control"}, "Page_Down", function (w) w:next_tab() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 | buf("^[0-9]*gT$", function (w, b) w:prev_tab(tonumber(string.match(b, "^(%d*)gT$") or 1)) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 | buf("^[0-9]*gt$", function (w, b) w:next_tab(tonumber(string.match(b, "^(%d*)gt$") or 1)) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 | buf("^gH$", function (w) w:new_tab(homepage) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 | buf("^d$", function (w) w:close_tab() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 | key({}, "r", function (w) w:reload() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 | buf("^gh$", function (w) w:navigate(homepage) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 | -- Window |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 | buf("^ZZ$", function (w) w:close_win() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 | buf("^D$", function (w) w:close_win() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 | -- Link following |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 | key({}, "f", function (w) w:set_mode("follow") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 | -- Bookmarking |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 | key({}, "B", function (w) w:enter_cmd(":bookmark " .. ((w:get_current() or {}).uri or "http://") .. " ") end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 | buf("^gb$", function (w) w:navigate(bookmarks.dump_html()) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 | buf("^gB$", function (w) w:new_tab (bookmarks.dump_html()) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 | -- Mouse bindings |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 | but({}, 2, function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 | -- Open hovered uri in new tab |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 | local uri = w:get_current().hovered_uri |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 | if uri then w:new_tab(uri) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 | else -- Open selection in current tab |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 | uri = luakit.get_selection() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 | if uri then w:get_current().uri = uri end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 | end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 | }, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 | command = { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 | key({"Shift"}, "Insert", function (w) w:insert_cmd(luakit.get_selection()) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 | key({}, "Up", function (w) w:cmd_hist_prev() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 | key({}, "Down", function (w) w:cmd_hist_next() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 | key({}, "Tab", function (w) w:cmd_completion() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 | key({"Control"}, "w", function (w) w:del_word() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 | key({"Control"}, "u", function (w) w:del_line() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 | }, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 | search = { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 | key({}, "Up", function (w) w:srch_hist_prev() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 | key({}, "Down", function (w) w:srch_hist_next() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 | }, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 | insert = { }, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 | } |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 | -- Command bindings which are matched in the "command" mode from text |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 | -- entered into the input bar. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 | binds.commands = { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
146 | -- cmd({Command, Alias1, ...}, function (w, arg, opts) .. end, opts), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
147 | cmd({"open", "o" }, function (w, a) w:navigate(a) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
148 | cmd({"tabopen", "t" }, function (w, a) w:new_tab(a) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 | cmd({"winopen", "w" }, function (w, a) window.new{a} end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
150 | cmd({"back" }, function (w, a) w:back(tonumber(a) or 1) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
151 | cmd({"forward", "f" }, function (w, a) w:forward(tonumber(a) or 1) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
152 | cmd({"scroll" }, function (w, a) w:scroll_vert(a) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
153 | cmd({"quit", "q" }, function (w) luakit.quit() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
154 | cmd({"close", "c" }, function (w) w:close_tab() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
155 | cmd({"websearch", "ws" }, function (w, e, s) w:websearch(e, s) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
156 | cmd({"reload", }, function (w) w:reload() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
157 | cmd({"viewsource", "vs" }, function (w) w:toggle_source(true) end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
158 | cmd({"viewsource!", "vs!"}, function (w) w:toggle_source() end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
159 | cmd({"bookmark", "bm" }, function (w, a) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
160 | local args = lousy.util.string.split(a) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
161 | local uri = table.remove(args, 1) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
162 | bookmarks.add(uri, args) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
163 | end), |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
164 | } |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
165 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
166 | -- Helper functions which are added to the window struct |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
167 | binds.helper_methods = { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
168 | -- Navigate current view or open new tab |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
169 | navigate = function (w, uri, view) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
170 | if not view then view = w:get_current() end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
171 | if view then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
172 | view.uri = uri |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
173 | else |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
174 | return w:new_tab(uri) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
175 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
176 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
177 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
178 | -- search engine wrapper |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
179 | websearch = function (w, args) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
180 | local sep = string.find(args, " ") |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
181 | local engine = string.sub(args, 1, sep-1) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
182 | local search = string.sub(args, sep+1) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
183 | search = string.gsub(search, "^%s*(.-)%s*$", "%1") |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
184 | if not search_engines[engine] then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
185 | return error("No matching search engine found: " .. engine) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
186 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
187 | local uri = string.gsub(search_engines[engine], "{%d}", search) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
188 | return w:navigate(uri) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
189 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
190 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
191 | -- Tab traversing functions |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
192 | next_tab = function (w, n) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
193 | w.tabs:switch((((n or 1) + w.tabs:current() -1) % w.tabs:count()) + 1) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
194 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
195 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
196 | prev_tab = function (w, n) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
197 | w.tabs:switch(((w.tabs:current() - (n or 1) -1) % w.tabs:count()) + 1) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
198 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
199 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
200 | goto_tab = function (w, n) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
201 | w.tabs:switch(n) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
202 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
203 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
204 | -- If argument is form-active or root-active, emits signal. Ignores all |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
205 | -- other signals. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
206 | emit_form_root_active_signal = function (w, s) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
207 | if s == "form-active" then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
208 | w:get_current():emit_signal("form-active") |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
209 | elseif s == "root-active" then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
210 | w:get_current():emit_signal("root-active") |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
211 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
212 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
213 | } |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
214 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
215 | -- Insert webview method lookup on window structure |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
216 | table.insert(window.indexes, 1, function (w, k) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
217 | -- Lookup bind helper method |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
218 | return binds.helper_methods[k] |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
219 | end) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
220 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
221 | -- vim: et:sw=4:ts=8:sts=4:tw=80 |