diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-08-04 22:37:49 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-08-05 10:01:06 +0530 |
| commit | e6d09718e62c89055d38274e1fa7b42daea6e555 (patch) | |
| tree | dfe86cf8678b2e7522f850916e020055b403b391 /lua | |
| parent | c7e105ee4254d00f591c4c002f32c223f4c2448a (diff) | |
| download | null-browser-e6d09718e62c89055d38274e1fa7b42daea6e555.tar.gz null-browser-e6d09718e62c89055d38274e1fa7b42daea6e555.zip | |
Update hints to go back to normal mode when matching is over
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/null-browser/extras/hints.lua | 26 | ||||
| -rw-r--r-- | lua/null-browser/extras/statusline.lua | 2 |
2 files changed, 16 insertions, 12 deletions
diff --git a/lua/null-browser/extras/hints.lua b/lua/null-browser/extras/hints.lua index f2ee21b..33d4564 100644 --- a/lua/null-browser/extras/hints.lua +++ b/lua/null-browser/extras/hints.lua @@ -7,15 +7,15 @@ local hints = { local js_setup_code = '' function hints.init(on_ready) - hints.load_finder_js(function() - web.keymap.set(hints.config.mode, '<Esc>', function() - hints.stop() - end) + web.keymap.set(hints.config.mode, '<Esc>', function() + hints.stop() + end) + hints._load_hints_js(function() web.event.add_listener('KeyPressed', { callback = function(event) if web.keymap.get_mode() == hints.config.mode then - hints.filter_key(event.key) + hints._filter_key(event.key) end end, }) @@ -28,7 +28,7 @@ function hints.start(selector, new_view) local open_in_new_view = new_view and 'true' or 'false' web.view.run_js( js_setup_code .. - ";_nullbrowser.finder.start('" .. + ";_nullbrowser.hints.start('" .. selector .. "', " .. open_in_new_view .. @@ -40,17 +40,21 @@ function hints.start(selector, new_view) end) end -function hints.filter_key(key) - web.view.run_js("_nullbrowser.finder.filterOutByKey('" .. key .. "')") +function hints._filter_key(key) + web.view.run_js("_nullbrowser.hints.filterOutByKey('" .. key .. "')", { + on_result = function(end_of_matches) + if end_of_matches then hints.stop() end + end, + }) end function hints.stop() web.keymap.set_mode('n') - web.view.run_js('_nullbrowser.finder.stop()') + web.view.run_js('_nullbrowser.hints.stop()') end -function hints.load_finder_js(on_ready) - web.uv.fs_open('./assets/javascript/finder.js', 'r', 438, function(err, file) +function hints._load_hints_js(on_ready) + web.uv.fs_open('./assets/javascript/hints.js', 'r', 438, function(err, file) if err then return end if not file then return {} end local stat = assert(web.uv.fs_fstat(file)) diff --git a/lua/null-browser/extras/statusline.lua b/lua/null-browser/extras/statusline.lua index bcaaea2..b23c3a6 100644 --- a/lua/null-browser/extras/statusline.lua +++ b/lua/null-browser/extras/statusline.lua @@ -9,7 +9,7 @@ local statusline = { }, mode_styles = { n = 'background-color: #007070; color: white;', - i = 'background-color: #e06c75; color: white;', + i = 'background-color: #f04750; color: white;', f = 'background-color: #51e980; color: #333;', }, segments = { |
