From 0e95e99e72237058465959d55b77750a9d7c1bef Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 19 Apr 2025 17:56:03 +0530 Subject: Add web.search and search text implemnetation --- TODO.org | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'TODO.org') diff --git a/TODO.org b/TODO.org index 96e9eb4..bf2511e 100644 --- a/TODO.org +++ b/TODO.org @@ -1,6 +1,6 @@ ** Usable - [ ] Tests for api -- [ ] Search text in page +- [X] Search text in page - [ ] Dev tools - [ ] Fullscreen - [ ] Zoom in/out @@ -10,6 +10,7 @@ - [ ] Notifications ** Bugs +- [ ] INVESTIGATE: segfault on api module error - [ ] INVESTIGATE: Check why urlchanged doesnt fire for first url open - [ ] INVESTIGATE: Segfault on close - [ ] INVESTIGATE: Errors in keymap/thread segfaults @@ -84,4 +85,30 @@ web.history.back(1, { win = 1 }) -- Back for current view in win 1 web.keymap.set('n', '', ..., { view = 1 }) -- Set keymap for view 1 web.keymap.set('n', '', ..., { win = 1 }) -- Set keymap for win 1 web.opt.new_tab_url = 'https://duckduckgo.com' + +-- Search api +web.search.set_search_text('whatever') +web.search.next() +web.search.prev() +web.search.get_search_text() +web.search.current() +web.search.total() + +web.keymap.set('n', '/', function() + dmenu.input({ prompt = 'Search:' }, function(err, input) + if err or not input then return end + web.search.set_search_text(input) + end) +end) +web.keymap.set('n', 'n', function() web.search.next() end) +web.keymap.set('n', 'p', function() web.search.prev() end) + +web.event.add_listener('SearchChanged', { + callback = function() + local label = + web.search.get_search_text() .. ': ' .. web.search.current() .. '/' .. web.search.total() + -- CALL notify-send + -- OR inject js into view to show ui + end, +}) #+end_src -- cgit v1.3.1