binds.lua

Wed, 01 Sep 2010 04:03:42 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 01 Sep 2010 04:03:42 +0100
changeset 2
1e9553b2f9a2
parent 1
4d7540af8518
permissions
-rw-r--r--

Add note about required patch

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
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
13 local homepage = globals.homepage or "http://google.co.uk/"
0
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 = {
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
21 key({}, "Escape", function (w) w:set_mode("normal") end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
22 key({"Control"}, "e", function (w) w:set_mode("command") end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
23 key({"Control"}, "n", function (w) w:set_mode("normal") end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
24
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
25 key({"Control"}, "x", function (w) w:close_tab() end),
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
27 key({"Control"}, "c", function (w) if w:get_mode() ~= "normal" then w:set_mode("normal"); end end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
28
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
29 -- Location
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
30 key({"Control"}, "t", function (w) w:new_tab(homepage); end),
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
32 -- Location
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
33 key({"Control"}, "l", function (w) w:set_mode("url-entry"); end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
34
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
35 -- Web search
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
36 key({"Control"}, "k", function (w) w:enter_cmd(":websearch google ") end);
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
37
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
38 -- Back and forth
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
39 key({"Mod1"}, "Left", function (w) w:back() end);
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
40 key({"Mod1"}, "Right", function (w) w:forward() end);
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
41
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
42 -- Tab/buffer switching
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
43 key({"Mod1"}, ".", function (w) w:next_tab(1) end);
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
44 key({"Mod1"}, ",", function (w) w:prev_tab(1) end);
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
45 key({"Control"}, "Page_Up", function (w) w:prev_tab() end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
46 key({"Control"}, "Page_Down", function (w) w:next_tab() end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
47
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
48 key({"Control"}, "p", function (w) w:navigate(luakit.get_selection("c")) end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
49 key({"Control"}, "P", function (w) w:new_tab(luakit.get_selection("c")) end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
50 key({"Control"}, "y", function (w) luakit.set_selection((w:get_current() or {}).uri or "", "c") end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
51 key({"Control"}, "Y", function (w) luakit.set_selection(w.win.title, "c") end),
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
53 key({"Control"}, "r", function (w) w:reload() end),
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
55 key({"Mod1"}, "Home", function (w) w:navigate(homepage) end);
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
56
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 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
58 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
59
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
60 but({}, 8, function (w) w:back() end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
61 but({}, 9, function (w) w:forward() end),
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 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
64 key({}, "XF86Forward", function (w) w:forward() end),
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
65
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 -- Link following
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
67 key({"Mod1"}, "f", function (w) w:set_mode("follow") end),
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 -- Bookmarking
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
70 key({"Control"}, "d", function (w) end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
71 key({"Control"}, "b", function (w) w:navigate(bookmarks.dump_html()) end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
72 key({"Control"}, "B", function (w) w:new_tab(bookmarks.dump_html()) end),
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 -- Mouse bindings
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 but({}, 2, function (w)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 -- 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
77 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
78 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
79 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
80 uri = luakit.get_selection()
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 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
82 end
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 end),
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 },
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
85
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
86 normal = {
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
87 },
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
88
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 command = {
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 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
91 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
92 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
93 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
94 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
95 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
96 },
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 search = {
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98 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
99 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
100 },
1
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
101 ["url-entry"] = {
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
102 key({"Control"}, "l", function (w) w.ibar.input:set_position(-1); end),
4d7540af8518 Initial set of changes to make 'insert' mode 'normal', eradicate 'command' mode and adjust key bindings appropriately (following common binding patterns from other browsers, and in places the nano text editor)
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
103 },
0
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104 insert = { },
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 }
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 -- 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
108 -- entered into the input bar.
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 binds.commands = {
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 -- 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125 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
126 bookmarks.add(uri, args)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 end),
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 }
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 -- 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
131 binds.helper_methods = {
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 -- 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
133 navigate = function (w, uri, view)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 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
135 if view then
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 view.uri = uri
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 else
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 return w:new_tab(uri)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 end
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 end,
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 -- search engine wrapper
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143 websearch = function (w, args)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 local sep = string.find(args, " ")
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145 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
146 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
147 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
148 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
149 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
150 end
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 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
152 return w:navigate(uri)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
153 end,
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
155 -- Tab traversing functions
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
156 next_tab = function (w, n)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
157 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
158 end,
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 prev_tab = function (w, n)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 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
162 end,
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 goto_tab = function (w, n)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 w.tabs:switch(n)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 end,
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 -- 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
169 -- other signals.
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
170 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
171 if s == "form-active" then
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
172 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
173 elseif s == "root-active" then
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
174 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
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
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
179 -- 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
180 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
181 -- Lookup bind helper method
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
182 return binds.helper_methods[k]
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
183 end)
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
184
98e4b0c9fcac Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
185 -- vim: et:sw=4:ts=8:sts=4:tw=80

mercurial