58 get_mode = function (w) return lousy.mode.get(w.win) end, |
58 get_mode = function (w) return lousy.mode.get(w.win) end, |
59 is_mode = function (w, name) return name == w:get_mode() end, |
59 is_mode = function (w, name) return name == w:get_mode() end, |
60 }) do window.methods[name] = func end |
60 }) do window.methods[name] = func end |
61 |
61 |
62 -- Setup normal mode |
62 -- Setup normal mode |
63 new_mode("normal", { |
63 new_mode("key", { |
64 enter = function (w) |
64 enter = function (w) |
65 local i, p = w.ibar.input, w.ibar.prompt |
65 local i, p = w.ibar.input, w.ibar.prompt |
66 i:hide() |
66 i:hide() |
67 p:hide() |
67 p:hide() |
68 end, |
68 end, |
69 }) |
69 }) |
70 |
70 |
71 -- Setup insert mode |
71 -- Setup insert mode |
72 new_mode("insert", { |
72 new_mode("normal", { |
73 enter = function (w) |
73 enter = function (w) |
74 local i, p = w.ibar.input, w.ibar.prompt |
74 local i, p = w.ibar.input, w.ibar.prompt |
75 i:hide() |
75 i:hide(); |
76 i.text = "" |
76 i.text = "" |
77 p.text = "-- INSERT --" |
77 p:hide(); |
78 p:show() |
78 p.text = "" |
79 end, |
79 end, |
80 }) |
80 }) |
|
81 |
|
82 new_mode("url-entry", { |
|
83 enter = function (w) |
|
84 local i, p = w.ibar.input, w.ibar.prompt; |
|
85 p.text = "Open:"; |
|
86 p:show(); |
|
87 i.text = (w:get_current() or {}).uri or ""; |
|
88 i:show(); |
|
89 i:focus(); |
|
90 i:select_region(0); |
|
91 end; |
|
92 activate = function (w, url) |
|
93 w:navigate(url); |
|
94 w:set_mode(); |
|
95 end; |
|
96 }); |
|
97 |
|
98 new_mode("web-search", { |
|
99 enter = function (w) |
|
100 local i, p = w.ibar.input, w.ibar.prompt; |
|
101 p.text = "Open:"; |
|
102 p:show(); |
|
103 i.text = (w:get_current() or {}).uri or ""; |
|
104 i:show(); |
|
105 i:focus(); |
|
106 i:set_position(-1); |
|
107 end; |
|
108 activate = function (w, url) |
|
109 w:navigate(url); |
|
110 w:set_mode(); |
|
111 end; |
|
112 }); |
81 |
113 |
82 -- Setup command mode |
114 -- Setup command mode |
83 new_mode("command", { |
115 new_mode("command", { |
84 enter = function (w) |
116 enter = function (w) |
85 local i, p = w.ibar.input, w.ibar.prompt |
117 local i, p = w.ibar.input, w.ibar.prompt |