Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 643 lines (496 sloc) 23.156 kB
40a8739 @mason-larobina Add window.lua & webview.lua config files & custom indexes for windows
authored
1 -----------------
2 -- Keybindings --
3 -----------------
4
039f6e9 @mason-larobina Initial config split
authored
5 -- Binding aliases
04ddfcf @mason-larobina Update config/{window,binds}.lua after lousy library changes.
authored
6 local key, buf, but = lousy.bind.key, lousy.bind.buf, lousy.bind.but
7 local cmd, any = lousy.bind.cmd, lousy.bind.any
039f6e9 @mason-larobina Initial config split
authored
8
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
9 -- Util aliases
10 local match, join = string.match, lousy.util.table.join
f8d8249 @mason-larobina Add all other vimperator quickmark features & cmds
authored
11 local strip, split = lousy.util.string.strip, lousy.util.string.split
039f6e9 @mason-larobina Initial config split
authored
12
13 -- Globals or defaults that are used in binds
14 local scroll_step = globals.scroll_step or 20
675d12c @o-jasper Page step as global value
o-jasper authored
15 local page_step = globals.page_step or 1.0
8103e0a @mason-larobina Introduction of a grammar binding which detects "[count]" in buf bind
authored
16 local zoom_step = globals.zoom_step or 0.1
039f6e9 @mason-larobina Initial config split
authored
17
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
18 -- Add binds to a mode
19 function add_binds(mode, binds, before)
20 assert(binds and type(binds) == "table", "invalid binds table type: " .. type(binds))
7db3dd8 @quigybo Let add_binds accept a table listing modes to add binds to
quigybo authored
21 mode = type(mode) ~= "table" and {mode} or mode
22 for _, m in ipairs(mode) do
23 local mdata = get_mode(m)
24 if mdata and before then
25 mdata.binds = join(binds, mdata.binds or {})
26 elseif mdata then
27 mdata.binds = mdata.binds or {}
28 for _, b in ipairs(binds) do table.insert(mdata.binds, b) end
29 else
30 new_mode(m, { binds = binds })
31 end
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
32 end
33 end
34
35 -- Add commands to command mode
36 function add_cmds(cmds, before)
807be6f @mason-larobina Make add_cmds(...) a wrapper around add_binds("command", ...)
authored
37 add_binds("command", cmds, before)
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
38 end
39
a2f4b44 @karottenreibe moved common menu mode binds into helper function
karottenreibe authored
40 -- Adds the default menu widget bindings to a mode
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
41 menu_binds = {
eceb9a0 @mason-larobina Put menu binds in a table.
authored
42 -- Navigate items
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
43 key({}, "j", function (w) w.menu:move_down() end),
44 key({}, "k", function (w) w.menu:move_up() end),
45 key({}, "Down", function (w) w.menu:move_down() end),
46 key({}, "Up", function (w) w.menu:move_up() end),
47 key({}, "Tab", function (w) w.menu:move_down() end),
48 key({"Shift"}, "Tab", function (w) w.menu:move_up() end),
eceb9a0 @mason-larobina Put menu binds in a table.
authored
49 }
a2f4b44 @karottenreibe moved common menu mode binds into helper function
karottenreibe authored
50
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
51 -- Add binds to special mode "all" which adds its binds to all modes.
52 add_binds("all", {
b1e6081 @mason-larobina Comment more bindings
authored
53 key({}, "Escape", "Return to `normal` mode.",
54 function (w) w:set_mode() end),
55
56 key({"Control"}, "[", "Return to `normal` mode.",
57 function (w) w:set_mode() end),
81d80bf @mason-larobina Update button 2 bind to check if clicking in formfield, fixes #12 & #55
authored
58
59 -- Mouse bindings
b1e6081 @mason-larobina Comment more bindings
authored
60 but({}, 8, "Go back.",
61 function (w) w:back() end),
62
63 but({}, 9, "Go forward.",
64 function (w) w:forward() end),
81d80bf @mason-larobina Update button 2 bind to check if clicking in formfield, fixes #12 & #55
authored
65
66 -- Open link in new tab or navigate to selection
b1e6081 @mason-larobina Comment more bindings
authored
67 but({}, 2, [[Open link under mouse cursor in new tab or navigate to the
68 contents of `luakit.selection.primary`.]],
69 function (w, m)
70 -- Ignore button 2 clicks in form fields
71 if not m.context.editable then
72 -- Open hovered uri in new tab
73 local uri = w.view.hovered_uri
74 if uri then
75 w:new_tab(uri, false)
76 else -- Open selection in current tab
77 uri = luakit.selection.primary
6b10aa3 @mason-larobina Change behaviour of middle-click navigation, ignore multi-line "urls"
authored
78 -- Ignore multi-line selection contents
79 if uri and not string.match(uri, "\n.+") then
80 w:navigate(w:search_open(uri))
81 end
b1e6081 @mason-larobina Comment more bindings
authored
82 end
83 end
84 end),
85
86 -- Open link in new tab when Ctrl-clicked.
87 but({"Control"}, 1, "Open link under mouse cursor in new tab.",
88 function (w, m)
51aad4e @mason-larobina Remove w:get_current() func and s/w:get_current()/w.view/g
authored
89 local uri = w.view.hovered_uri
4414b99 @karottenreibe Add bind to open Ctrl-clicked links in new tabs
karottenreibe authored
90 if uri then
91 w:new_tab(uri, false)
92 end
b1e6081 @mason-larobina Comment more bindings
authored
93 end),
1470f78 @karottenreibe added binds for zooming with <Ctrl+MouseWheel>
karottenreibe authored
94
95 -- Zoom binds
b1e6081 @mason-larobina Comment more bindings
authored
96 but({"Control"}, 4, "Increase text zoom level.",
97 function (w, m) w:zoom_in() end),
98
99 but({"Control"}, 5, "Reduce text zoom level.",
100 function (w, m) w:zoom_out() end),
41ac297 @quigybo Add horizontal scrolling binds for Shift+MouseWheel
quigybo authored
101
102 -- Horizontal mouse scroll binds
b1e6081 @mason-larobina Comment more bindings
authored
103 but({"Shift"}, 4, "Scroll left.",
104 function (w, m) w:scroll{ xrel = -scroll_step } end),
105
106 but({"Shift"}, 5, "Scroll right.",
107 function (w, m) w:scroll{ xrel = scroll_step } end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
108 })
109
110 add_binds("normal", {
04ddfcf @mason-larobina Update config/{window,binds}.lua after lousy library changes.
authored
111 -- Autoparse the `[count]` before a binding and re-call the hit function
112 -- with the count removed and added to the opts table.
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
113 any([[Meta-binding to detect the `^[count]` syntax. The `[count]` is parsed
114 and stripped from the internal buffer string and the value assigned to
115 `state.count`. Then `lousy.bind.hit()` is re-called with the modified
116 buffer string & original modifier state.
117
118 #### Example binding
119
120 lousy.bind.key({}, "%", function (w, state)
121 w:scroll{ ypct = state.count }
122 end, { count = 0 })
123
124 This binding demonstrates several concepts. Firstly that you are able to
125 specify per-binding default values of `count`. In this case if the user
126 types `"%"` the document will be scrolled vertically to `0%` (the top).
127
128 If the user types `"100%"` then the document will be scrolled to `100%`
129 (the bottom). All without the need to use `lousy.bind.buf` bindings
130 everywhere and or using a `^(%d*)` pattern prefix on every binding which
131 would like to make use of the `[count]` syntax.]],
132 function (w, m)
133 local count, buf
134 if m.buffer then
135 count = string.match(m.buffer, "^(%d+)")
04ddfcf @mason-larobina Update config/{window,binds}.lua after lousy library changes.
authored
136 end
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
137 if count then
138 buf = string.sub(m.buffer, #count + 1, (m.updated_buf and -2) or -1)
139 local opts = join(m, {count = tonumber(count)})
140 opts.buffer = (#buf > 0 and buf) or nil
141 if lousy.bind.hit(w, m.binds, m.mods, m.key, opts) then
142 return true
143 end
144 end
145 return false
146 end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
147
b1e6081 @mason-larobina Comment more bindings
authored
148 key({}, "i", "Enter `insert` mode.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
149 function (w) w:set_mode("insert") end),
150
b1e6081 @mason-larobina Comment more bindings
authored
151 key({}, ":", "Enter `command` mode.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
152 function (w) w:set_mode("command") end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
153
154 -- Scrolling
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
155 key({}, "j", "Scroll document down.",
156 function (w) w:scroll{ yrel = scroll_step } end),
157
158 key({}, "k", "Scroll document up.",
159 function (w) w:scroll{ yrel = -scroll_step } end),
160
161 key({}, "h", "Scroll document left.",
162 function (w) w:scroll{ xrel = -scroll_step } end),
163
164 key({}, "l", "Scroll document right.",
165 function (w) w:scroll{ xrel = scroll_step } end),
166
167 key({}, "Down", "Scroll document down.",
168 function (w) w:scroll{ yrel = scroll_step } end),
169
170 key({}, "Up", "Scroll document up.",
171 function (w) w:scroll{ yrel = -scroll_step } end),
172
173 key({}, "Left", "Scroll document left.",
174 function (w) w:scroll{ xrel = -scroll_step } end),
175
176 key({}, "Right", "Scroll document right.",
177 function (w) w:scroll{ xrel = scroll_step } end),
178
179 key({}, "^", "Scroll to the absolute left of the document.",
180 function (w) w:scroll{ x = 0 } end),
181
182 key({}, "$", "Scroll to the absolute right of the document.",
183 function (w) w:scroll{ x = -1 } end),
184
185 key({}, "0", "Scroll to the absolute left of the document.",
186 function (w, m)
187 if not m.count then w:scroll{ y = 0 } else return false end
188 end),
189
190 key({"Control"}, "e", "Scroll document down.",
191 function (w) w:scroll{ yrel = scroll_step } end),
192
193 key({"Control"}, "y", "Scroll document up.",
194 function (w) w:scroll{ yrel = -scroll_step } end),
195
196 key({"Control"}, "d", "Scroll half page down.",
197 function (w) w:scroll{ ypagerel = 0.5 } end),
198
199 key({"Control"}, "u", "Scroll half page up.",
200 function (w) w:scroll{ ypagerel = -0.5 } end),
201
202 key({"Control"}, "f", "Scroll page down.",
675d12c @o-jasper Page step as global value
o-jasper authored
203 function (w) w:scroll{ ypagerel = page_step } end),
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
204
205 key({"Control"}, "b", "Scroll page up.",
675d12c @o-jasper Page step as global value
o-jasper authored
206 function (w) w:scroll{ ypagerel = -page_step } end),
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
207
208 key({}, "space", "Scroll page down.",
675d12c @o-jasper Page step as global value
o-jasper authored
209 function (w) w:scroll{ ypagerel = page_step } end),
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
210
211 key({"Shift"}, "space", "Scroll page up.",
675d12c @o-jasper Page step as global value
o-jasper authored
212 function (w) w:scroll{ ypagerel = -page_step } end),
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
213
214 key({}, "BackSpace", "Scroll page up.",
675d12c @o-jasper Page step as global value
o-jasper authored
215 function (w) w:scroll{ ypagerel = -page_step } end),
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
216
217 key({}, "Page_Down", "Scroll page down.",
675d12c @o-jasper Page step as global value
o-jasper authored
218 function (w) w:scroll{ ypagerel = page_step } end),
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
219
220 key({}, "Page_Up", "Scroll page up.",
675d12c @o-jasper Page step as global value
o-jasper authored
221 function (w) w:scroll{ ypagerel = -page_step } end),
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
222
374f7c4 @dbolgheroni Home goes to top, End goes to end.
dbolgheroni authored
223 key({}, "Home", "Go to the top of the document.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
224 function (w) w:scroll{ y = 0 } end),
225
374f7c4 @dbolgheroni Home goes to top, End goes to end.
dbolgheroni authored
226 key({}, "End", "Go to the end of the document.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
227 function (w) w:scroll{ y = -1 } end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
228
229 -- Specific scroll
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
230 buf("^gg$", "Go to the top of the document.",
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
231 function (w, b, m) w:scroll{ ypct = m.count } end, {count=0}),
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
232
233 buf("^G$", "Go to the bottom of the document.",
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
234 function (w, b, m) w:scroll{ ypct = m.count } end, {count=100}),
37a8ae2 @mason-larobina Revert "Finished writing descriptions for a handfull of binds"
authored
235
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
236 buf("^%%$", "Go to `[count]` percent of the document.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
237 function (w, b, m) w:scroll{ ypct = m.count } end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
238
239 -- Zooming
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
240 key({}, "+", "Enlarge text zoom of the current page.",
241 function (w, m) w:zoom_in(zoom_step * m.count) end, {count=1}),
242
243 key({}, "-", "Reduce text zom of the current page.",
244 function (w, m) w:zoom_out(zoom_step * m.count) end, {count=1}),
245
246 key({}, "=", "Reset zoom level.",
247 function (w, m) w:zoom_set() end),
248
b1e6081 @mason-larobina Comment more bindings
authored
249 buf("^z[iI]$", [[Enlarge text zoom of current page with `zi` or `zI` to
250 reduce full zoom.]],
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
251 function (w, b, m)
252 w:zoom_in(zoom_step * m.count, b == "zI")
253 end, {count=1}),
254
b1e6081 @mason-larobina Comment more bindings
authored
255 buf("^z[oO]$", [[Reduce text zoom of current page with `zo` or `zO` to
256 reduce full zoom.]],
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
257 function (w, b, m)
258 w:zoom_out(zoom_step * m.count, b == "zO")
259 end, {count=1}),
260
02a8e45 @mason-larobina Add [count]zz for normal abs zoom & [count]zZ for full content abs zoom
authored
261 -- Zoom reset or specific zoom ([count]zZ for full content zoom)
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
262 buf("^z[zZ]$", [[Set current page zoom to `[count]` percent with
263 `[count]zz`, use `[count]zZ` to set full zoom percent.]],
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
264 function (w, b, m)
265 w:zoom_set(m.count/100, b == "zZ")
266 end, {count=100}),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
267
176430f @karottenreibe added F11 as bind for fullscreen toggling
karottenreibe authored
268 -- Fullscreen
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
269 key({}, "F11", "Toggle fullscreen mode.",
270 function (w) w.win.fullscreen = not w.win.fullscreen end),
176430f @karottenreibe added F11 as bind for fullscreen toggling
karottenreibe authored
271
46aff4a @mason-larobina Update the [pP]* bind comments.
authored
272 -- Open primary selection contents.
8e3e91b @zoqaeski Modified yank/paste bindings to include clipboard.
zoqaeski authored
273 buf("^pp$", [[Open a URL based on the current primary selection contents
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
274 in the current tab.]],
275 function (w)
4b7ccc9 @mason-larobina Silence errors in `p` & `P` binds, notify no selection instead
authored
276 local uri = luakit.selection.primary
277 if not uri then w:notify("No primary selection...") return end
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
278 w:navigate(w:search_open(uri))
279 end),
280
8e3e91b @zoqaeski Modified yank/paste bindings to include clipboard.
zoqaeski authored
281 buf("^pt$", [[Open a URL based on the current primary selection contents
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
282 in `[count=1]` new tab(s).]],
8e3e91b @zoqaeski Modified yank/paste bindings to include clipboard.
zoqaeski authored
283 function (w, b, m)
4b7ccc9 @mason-larobina Silence errors in `p` & `P` binds, notify no selection instead
authored
284 local uri = luakit.selection.primary
285 if not uri then w:notify("No primary selection...") return end
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
286 for i = 1, m.count do w:new_tab(w:search_open(uri)) end
287 end, {count = 1}),
83039fa @mason-larobina Remove wasted space in config/binds.lua
authored
288
8e3e91b @zoqaeski Modified yank/paste bindings to include clipboard.
zoqaeski authored
289 buf("^pw$", [[Open a URL based on the current primary selection contents in
290 a new window.]],
291 function(w, m)
292 local uri = luakit.selection.primary
293 if not uri then w:notify("No primary selection...") return end
294 window.new{w:search_open(uri)}
295 end),
296
46aff4a @mason-larobina Update the [pP]* bind comments.
authored
297 -- Open clipboard contents.
8e3e91b @zoqaeski Modified yank/paste bindings to include clipboard.
zoqaeski authored
298 buf("^PP$", [[Open a URL based on the current clipboard selection contents
299 in the current tab.]],
300 function (w)
301 local uri = luakit.selection.clipboard
302 if not uri then w:notify("Nothing in clipboard...") return end
303 w:navigate(w:search_open(uri))
304 end),
305
306 buf("^PT$", [[Open a URL based on the current clipboard selection contents
307 in `[count=1]` new tab(s).]],
308 function (w, b, m)
309 local uri = luakit.selection.clipboard
310 if not uri then w:notify("Nothing in clipboard...") return end
311 for i = 1, m.count do w:new_tab(w:search_open(uri)) end
312 end, {count = 1}),
313
314 buf("^PW$", [[Open a URL based on the current clipboard selection contents
315 in a new window.]],
46aff4a @mason-larobina Update the [pP]* bind comments.
authored
316 function(w)
8e3e91b @zoqaeski Modified yank/paste bindings to include clipboard.
zoqaeski authored
317 local uri = luakit.selection.clipboard
318 if not uri then w:notify("Nothing in clipboard...") return end
319 window.new{w:search_open(uri)}
320 end),
321
83039fa @mason-larobina Remove wasted space in config/binds.lua
authored
322 -- Yanking
def001c @mason-larobina Use single `y` yank binding for uri
authored
323 key({}, "y", "Yank current URI to primary selection.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
324 function (w)
325 local uri = string.gsub(w.view.uri or "", " ", "%%20")
326 luakit.selection.primary = uri
327 w:notify("Yanked uri: " .. uri)
328 end),
329
8e3e91b @zoqaeski Modified yank/paste bindings to include clipboard.
zoqaeski authored
330 key({}, "Y", "Yank current URI to clipboard.",
331 function (w)
332 local uri = string.gsub(w.view.uri or "", " ", "%%20")
333 luakit.selection.clipboard = uri
334 w:notify("Yanked uri (to clipboard): " .. uri)
335 end),
336
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
337 -- Commands
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
338 key({"Control"}, "a", "Increment last number in URL.",
339 function (w) w:navigate(w:inc_uri(1)) end),
340
341 key({"Control"}, "x", "Decrement last number in URL.",
342 function (w) w:navigate(w:inc_uri(-1)) end),
343
344 key({}, "o", "Open one or more URLs.",
345 function (w) w:enter_cmd(":open ") end),
346
347 key({}, "t", "Open one or more URLs in a new tab.",
348 function (w) w:enter_cmd(":tabopen ") end),
349
350 key({}, "w", "Open one or more URLs in a new window.",
351 function (w) w:enter_cmd(":winopen ") end),
352
353 key({}, "O", "Open one or more URLs based on current location.",
354 function (w) w:enter_cmd(":open " .. (w.view.uri or "")) end),
355
356 key({}, "T",
357 "Open one or more URLs based on current location in a new tab.",
358 function (w) w:enter_cmd(":tabopen " .. (w.view.uri or "")) end),
359
360 key({}, "W",
c498a18 @dbolgheroni Typo.
dbolgheroni authored
361 "Open one or more URLs based on current location in a new window.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
362 function (w) w:enter_cmd(":winopen " .. (w.view.uri or "")) end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
363
364 -- History
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
365 key({}, "H", "Go back in the browser history `[count=1]` items.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
366 function (w, m) w:back(m.count) end),
367
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
368 key({}, "L", "Go forward in the browser history `[count=1]` times.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
369 function (w, m) w:forward(m.count) end),
370
371 key({}, "XF86Back", "Go back in the browser history.",
372 function (w, m) w:back(m.count) end),
373
374 key({}, "XF86Forward", "Go forward in the browser history.",
375 function (w, m) w:forward(m.count) end),
376
377 key({"Control"}, "o", "Go back in the browser history.",
378 function (w, m) w:back(m.count) end),
379
380 key({"Control"}, "i", "Go forward in the browser history.",
381 function (w, m) w:forward(m.count) end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
382
383 -- Tab
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
384 key({"Control"}, "Page_Up", "Go to previous tab.",
385 function (w) w:prev_tab() end),
386
387 key({"Control"}, "Page_Down", "Go to next tab.",
388 function (w) w:next_tab() end),
389
390 key({"Control"}, "Tab", "Go to next tab.",
391 function (w) w:next_tab() end),
392
393 key({"Shift","Control"}, "Tab", "Go to previous tab.",
394 function (w) w:prev_tab() end),
395
396 buf("^gT$", "Go to previous tab.",
397 function (w) w:prev_tab() end),
398
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
399 buf("^gt$", "Go to next tab (or `[count]` nth tab).",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
400 function (w, b, m)
401 if not w:goto_tab(m.count) then w:next_tab() end
402 end, {count=0}),
403
404 buf("^g0$", "Go to first tab.",
405 function (w) w:goto_tab(1) end),
406
407 buf("^g$$", "Go to last tab.",
408 function (w) w:goto_tab(-1) end),
409
410 key({"Control"}, "t", "Open a new tab.",
411 function (w) w:new_tab(globals.homepage) end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
412
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
413 key({"Control"}, "w", "Close current tab.",
414 function (w) w:close_tab() end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
415
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
416 key({}, "d", "Close current tab (or `[count]` tabs).",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
417 function (w, m) for i=1,m.count do w:close_tab() end end, {count=1}),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
418
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
419 key({}, "<", "Reorder tab left `[count=1]` positions.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
420 function (w, m)
421 w.tabs:reorder(w.view, w.tabs:current() - m.count)
422 end, {count=1}),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
423
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
424 key({}, ">", "Reorder tab right `[count=1]` positions.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
425 function (w, m)
426 w.tabs:reorder(w.view,
427 (w.tabs:current() + m.count) % w.tabs:count())
428 end, {count=1}),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
429
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
430 buf("^gH$", "Open homepage in new tab.",
431 function (w) w:new_tab(globals.homepage) end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
432
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
433 buf("^gh$", "Open homepage.",
434 function (w) w:navigate(globals.homepage) end),
435
436 buf("^gy$", "Duplicate current tab.",
437 function (w) w:new_tab(w.view.history or "") end),
438
439 key({}, "r", "Reload current tab.",
440 function (w) w:reload() end),
441
442 key({}, "R", "Reload current tab (skipping cache).",
443 function (w) w:reload(true) end),
444
445 key({"Control"}, "c", "Stop loading the current tab.",
446 function (w) w.view:stop() end),
447
448 key({"Control", "Shift"}, "R", "Restart luakit (reloading configs).",
449 function (w) w:restart() end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
450
451 -- Window
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
452 buf("^ZZ$", "Quit and save the session.",
453 function (w) w:save_session() w:close_win() end),
454
455 buf("^ZQ$", "Quit and don't save the session.",
456 function (w) w:close_win() end),
457
458 buf("^D$", "Quit and don't save the session.",
459 function (w) w:close_win() end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
460
c42ff9a @karottenreibe Sqashed commit of vimperator-like passthrough mode for luakit.
karottenreibe authored
461 -- Enter passthrough mode
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
462 key({"Control"}, "z",
b1e6081 @mason-larobina Comment more bindings
authored
463 "Enter `passthrough` mode, ignores all luakit keybindings.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
464 function (w) w:set_mode("passthrough") end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
465 })
466
c42ff9a @karottenreibe Sqashed commit of vimperator-like passthrough mode for luakit.
karottenreibe authored
467 add_binds("insert", {
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
468 key({"Control"}, "z",
b1e6081 @mason-larobina Comment more bindings
authored
469 "Enter `passthrough` mode, ignores all luakit keybindings.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
470 function (w) w:set_mode("passthrough") end),
c42ff9a @karottenreibe Sqashed commit of vimperator-like passthrough mode for luakit.
karottenreibe authored
471 })
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
472
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
473 readline_bindings = {
474 key({"Shift"}, "Insert",
475 "Insert contents of primary selection at cursor position.",
476 function (w) w:insert_cmd(luakit.selection.primary) end),
477
478 key({"Control"}, "w", "Delete previous word.",
479 function (w) w:del_word() end),
480
481 key({"Control"}, "u", "Delete until beginning of current line.",
482 function (w) w:del_line() end),
483
484 key({"Control"}, "h", "Delete character to the left.",
485 function (w) w:del_backward_char() end),
486
487 key({"Control"}, "d", "Delete character to the right.",
488 function (w) w:del_forward_char() end),
489
490 key({"Control"}, "a", "Move cursor to beginning of current line.",
491 function (w) w:beg_line() end),
492
493 key({"Control"}, "e", "Move cursor to end of current line.",
494 function (w) w:end_line() end),
495
496 key({"Control"}, "f", "Move cursor forward one character.",
497 function (w) w:forward_char() end),
498
499 key({"Control"}, "b", "Move cursor backward one character.",
500 function (w) w:backward_char() end),
501
502 key({"Mod1"}, "f", "Move cursor forward one word.",
503 function (w) w:forward_word() end),
504
505 key({"Mod1"}, "b", "Move cursor backward one word.",
506 function (w) w:backward_word() end),
507 }
508
509 add_binds({"command", "search"}, readline_bindings)
039f6e9 @mason-larobina Initial config split
authored
510
feb8255 @mason-larobina Add tab switching binds with Alt+{1,2,3,...}
authored
511 -- Switching tabs with Mod1+{1,2,3,...}
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
512 mod1binds = {}
feb8255 @mason-larobina Add tab switching binds with Alt+{1,2,3,...}
authored
513 for i=1,10 do
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
514 table.insert(mod1binds,
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
515 key({"Mod1"}, tostring(i % 10), "Jump to tab at index "..i..".",
516 function (w) w.tabs:switch(i) end))
feb8255 @mason-larobina Add tab switching binds with Alt+{1,2,3,...}
authored
517 end
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
518 add_binds("normal", mod1binds)
feb8255 @mason-larobina Add tab switching binds with Alt+{1,2,3,...}
authored
519
039f6e9 @mason-larobina Initial config split
authored
520 -- Command bindings which are matched in the "command" mode from text
521 -- entered into the input bar.
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
522 add_cmds({
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
523 buf("^%S+!",
b1e6081 @mason-larobina Comment more bindings
authored
524 [[Detect bang syntax in `:command!` and recursively calls
525 `lousy.bind.match_cmd(..)` removing the bang from the command string
526 and setting `bang = true` in the bind opts table.]],
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
527 function (w, cmd, opts)
528 local cmd, args = string.match(cmd, "^(%S+)!+(.*)")
529 if cmd then
530 opts = join(opts, { bang = true })
531 return lousy.bind.match_cmd(w, opts.binds, cmd .. args, opts)
532 end
533 end),
534
57fbe0d @mason-larobina Move Control+Enter binding into the add_cmds block.
authored
535 key({"Control"}, "Return",
536 [[Expand `:[tab,win]open example` to `:[tab,win]open www.example.com`.]],
537 function (w)
538 local tokens = split(w.ibar.input.text, "%s+")
539 if string.match(tokens[1], "^:%w*open$") and #tokens == 2 then
540 w:enter_cmd(string.format("%s www.%s.com", tokens[1], tokens[2]))
541 end
542 w:activate()
543 end),
544
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
545 cmd("c[lose]", "Close current tab.",
546 function (w) w:close_tab() end),
547
548 cmd("print", "Print current page.",
549 function (w) w.view:eval_js("print()") end),
479e943 @mason-larobina Detect bangs in commands (I.e. ":command! <args>")
authored
550
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
551 cmd("stop", "Stop loading.",
552 function (w) w.view:stop() end),
553
554 cmd("reload", "Reload page",
555 function (w) w:reload() end),
556
557 cmd("restart", "Restart browser (reload config files).",
558 function (w) w:restart() end),
559
560 cmd("write", "Save current session.",
561 function (w) w:save_session() end),
562
563 cmd("noh[lsearch]", "Clear search highlighting.",
564 function (w) w:clear_search() end),
565
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
566 cmd("back", "Go back in the browser history `[count=1]` items.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
567 function (w, a) w:back(tonumber(a) or 1) end),
568
6369ff3 @mason-larobina Format bind & mode descriptions with markdown
authored
569 cmd("f[orward]", "Go forward in the browser history `[count=1]` items.",
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
570 function (w, a) w:forward(tonumber(a) or 1) end),
571
572 cmd("inc[rease]", "Increment last number in URL.",
573 function (w, a) w:navigate(w:inc_uri(tonumber(a) or 1)) end),
574
575 cmd("o[pen]", "Open one or more URLs.",
576 function (w, a) w:navigate(w:search_open(a)) end),
577
578 cmd("t[abopen]", "Open one or more URLs in a new tab.",
579 function (w, a) w:new_tab(w:search_open(a)) end),
580
581 cmd("w[inopen]", "Open one or more URLs in a new window.",
582 function (w, a) window.new{w:search_open(a)} end),
583
584 cmd({"javascript", "js"}, "Evaluate JavaScript snippet.",
585 function (w, a) w.view:eval_js(a) end),
151102c @benarmston tabfirst and tablast commands and bindings
benarmston authored
586
587 -- Tab manipulation commands
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
588 cmd("tab", "Execute command and open result in new tab.",
589 function (w, a) w:new_tab() w:run_cmd(":" .. a) end),
590
591 cmd("tabd[o]", "Execute command in each tab.",
592 function (w, a) w:each_tab(function (v) w:run_cmd(":" .. a) end) end),
593
594 cmd("tabdu[plicate]", "Duplicate current tab.",
595 function (w) w:new_tab(w.view.history) end),
596
597 cmd("tabfir[st]", "Switch to first tab.",
598 function (w) w:goto_tab(1) end),
599
600 cmd("tabl[ast]", "Switch to last tab.",
601 function (w) w:goto_tab(-1) end),
602
603 cmd("tabn[ext]", "Switch to the next tab.",
604 function (w) w:next_tab() end),
605
606 cmd("tabp[revious]", "Switch to the previous tab.",
607 function (w) w:prev_tab() end),
608
609 cmd("q[uit]", "Close the current window.",
610 function (w, a, o) w:close_win(o.bang) end),
611
612 cmd({"viewsource", "vs"}, "View the source code of the current document.",
613 function (w, a, o) w:toggle_source(not o.bang and true or nil) end),
614
615 cmd({"wqall", "wq"}, "Save the session and quit.",
616 function (w, a, o) w:save_session() w:close_win(o.bang) end),
617
618 cmd("lua", "Evaluate Lua snippet.", function (w, a)
04ca642 @mason-larobina Add lua mode (for continuous lua code execution with history)
authored
619 if a then
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
620 local ret = assert(
621 loadstring("return function(w) return "..a.." end"))()(w)
04ca642 @mason-larobina Add lua mode (for continuous lua code execution with history)
authored
622 if ret then print(ret) end
623 else
624 w:set_mode("lua")
625 end
626 end),
627
4f2914c @mason-larobina Initial commit of luakit://help chrome page
authored
628 cmd("dump", "Dump current tabs html to file.",
629 function (w, a)
630 local fname = string.gsub(w.win.title, '[^%w%.%-]', '_')..'.html' -- sanitize filename
631 local file = a or luakit.save_file("Save file", w.win, xdg.download_dir or '.', fname)
632 if file then
633 local fd = assert(io.open(file, "w"), "failed to open: " .. file)
634 local html = assert(w.view:eval_js("document.documentElement.outerHTML"), "Unable to get HTML")
635 assert(fd:write(html), "unable to save html")
636 io.close(fd)
637 w:notify("Dumped HTML to: " .. file)
638 end
639 end),
19343b3 @mason-larobina Huge bind/script api/layout refactor.
authored
640 })
40a8739 @mason-larobina Add window.lua & webview.lua config files & custom indexes for windows
authored
641
86cca08 @kongo2002 remove ft=lua from modelines
kongo2002 authored
642 -- vim: et:sw=4:ts=8:sts=4:tw=80
Something went wrong with that request. Please try again.