From 208202db9cba6ddf0713a70e7122c69a53b1f2aa Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 19 Apr 2025 21:29:38 +0530 Subject: Add web.search.get_text and prefill current search text --- config.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'config.lua') diff --git a/config.lua b/config.lua index 145d7a7..50f4fe4 100644 --- a/config.lua +++ b/config.lua @@ -1,5 +1,8 @@ print('hello starting up...') +local dmenu = require 'null-browser.extras.dmenu' +local history = require 'null-browser.extras.history' + --- @type table web = web --- @type table @@ -19,9 +22,6 @@ web.set('close_window_when_no_views', true) web.set('user_agent', 'MacOS | Safari - $500 edition') web.set('downloads_dir', os.getenv('HOME') .. '/Downloads/firefox') -local dmenu = require 'null-browser.extras.dmenu' -local history = require 'null-browser.extras.history' - web.event.add_listener('UrlChanged', { callback = function(opts) print('url change', web.inspect(opts)); @@ -41,12 +41,13 @@ local function to_url(url) return "https://" .. trim(url) end -web.keymap.set('n', '', function() web.search.set_text('') end) +-- Search +web.keymap.set('n', '', function() web.search.reset() end) web.keymap.set('n', 'n', function() web.search.next() end) web.keymap.set('n', '', function() web.search.previous() end) web.keymap.set('n', '', function() - dmenu.input({ prompt = 'Search:' }, function(err, input) - if err or not input then return end + dmenu.input({ prompt = 'Search:', input = web.search.get_text() }, function(err, input) + if err then return end web.search.set_text(input) end) end) -- cgit v1.3.1