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 | -- luakit mode configuration -- |
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 | -- Table of modes and their callback hooks |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | modes = {} |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | -- Currently active mode hooks |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | local current |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 | -- Update a modes hook table with new hooks |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 | function new_mode(mode, hooks) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 | modes[mode] = lousy.util.table.join(modes[mode] or {}, hooks) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 | -- Attach window & input bar signals for mode hooks |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 | window.init_funcs.modes_setup = function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 | -- Calls the `enter` and `leave` mode hooks. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 | w.win:add_signal("mode-changed", function (_, mode) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 | -- Call the last modes `leave` hook. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 | if current and current.leave then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 | current.leave(w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 | -- Update window binds |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 | w:update_binds(mode) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 | -- Get new modes functions |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 | current = modes[mode] |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 | if not current then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 | error("changed to un-handled mode: " .. mode) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 | -- Call new modes `enter` hook. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 | if current.enter then current.enter(w) end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 | end) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 | -- Calls the `changed` hook on input widget changed. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 | w.ibar.input:add_signal("changed", function() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 | local text = w.ibar.input.text |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 | if current and current.changed then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 | current.changed(w, text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 | end) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 | -- Calls the `activate` hook on input widget activate. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 | w.ibar.input:add_signal("activate", function() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 | local text = w.ibar.input.text |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 | if current and current.activate then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 | current.activate(w, text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 | end) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 | -- Add mode related window methods |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 | for name, func in pairs({ |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 | set_mode = function (w, name) lousy.mode.set(w.win, name) end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 | get_mode = function (w) return lousy.mode.get(w.win) end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 | is_mode = function (w, name) return name == w:get_mode() end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 | }) do window.methods[name] = func end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 | -- Setup normal mode |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 | new_mode("normal", { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 | enter = function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 | local i, p = w.ibar.input, w.ibar.prompt |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 | i:hide() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 | p:hide() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 | }) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 | -- Setup insert mode |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 | new_mode("insert", { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 | enter = function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 | local i, p = w.ibar.input, w.ibar.prompt |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 | i:hide() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 | i.text = "" |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 | p.text = "-- INSERT --" |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 | p:show() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 | 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 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 | -- Setup command mode |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 | new_mode("command", { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 | enter = function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 | local i, p = w.ibar.input, w.ibar.prompt |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 | p:hide() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 | i.text = ":" |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 | i:show() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 | i:focus() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 | i:set_position(-1) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 | changed = function (w, text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 | -- Auto-exit command mode if user backspaces ":" in the input bar. |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 | if not string.match(text, "^:") then w:set_mode() end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 | activate = function (w, text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 | w:cmd_hist_add(text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 | w:match_cmd(string.sub(text, 2)) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 | w:set_mode() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 | 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 | |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 | -- Setup search mode |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 | new_mode("search", { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 | enter = function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 | -- Clear old search state |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 | w.search_state = {} |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 | local i, p = w.ibar.input, w.ibar.prompt |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 | p:hide() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 | p.text = "" |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 | i.text = "/" |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 | i:show() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 | leave = function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 | -- Check if search was aborted and return to original position |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 | local s = w.search_state |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 | if s.marker then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 | w:get_current():set_scroll_vert(s.marker) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 | s.marker = nil |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 | changed = function (w, text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 | -- Check that the first character is '/' or '?' and update search |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 | if string.match(text, "^[\?\/]") then |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 | w:search(string.sub(text, 2), (string.sub(text, 1, 1) == "/")) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 | else |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 | w:clear_search() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 | w:set_mode() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 | end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 | activate = function (w, text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 | w.search_state.marker = nil |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 | w:srch_hist_add(text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 | w:set_mode() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 | -- Ghost the search term in the prompt |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 | local p = w.ibar.prompt |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 | p.text = lousy.util.escape(text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 | p:show() |
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 | }) |
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 | -- Setup follow mode |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 | new_mode("follow", { |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 | enter = function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 | local i, p = w.ibar.input, w.ibar.prompt |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
146 | w:eval_js_from_file(lousy.util.find_data("scripts/follow.js")) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
147 | w:eval_js("clear(); show_hints();") |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
148 | p.text = "Follow:" |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 | p:show() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
150 | i.text = "" |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
151 | i:show() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
152 | i:focus() |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
153 | i:set_position(-1) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
154 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
155 | leave = function (w) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
156 | if w.eval_js then w:eval_js("clear();") end |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
157 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
158 | changed = function (w, text) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
159 | local ret = w:eval_js(string.format("update(%q);", text)) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
160 | w:emit_form_root_active_signal(ret) |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
161 | end, |
98e4b0c9fcac
Initial commit of default luakit config from 2010.08.30
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
162 | }) |