aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-07-26 00:39:23 +0530
committerAkshay Nair <phenax5@gmail.com>2025-07-26 00:39:23 +0530
commit3f56d76a2b0d528c05ab8d0a38059ca82ba90952 (patch)
treedaae7849815c122803f8ddd08cbfcb87552eab8a /init.lua
parent031b22e0bb0f1d132731aea3776917731a8ab4ce (diff)
downloadnull-browser-3f56d76a2b0d528c05ab8d0a38059ca82ba90952.tar.gz
null-browser-3f56d76a2b0d528c05ab8d0a38059ca82ba90952.zip
Add set_html for views + example use with decorations
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/init.lua b/init.lua
index b16b08a..6e45040 100644
--- a/init.lua
+++ b/init.lua
@@ -61,21 +61,25 @@ web.event.add_listener('NotificationReceived', {
end,
})
+local start_clock = function(win_id)
+ local timer = web.uv.new_timer()
+ timer:start(500, 500, function()
+ local view = web.decorations.bottom.view({ win = win_id })
+ if view ~= nil then
+ local time = os.date("%X", os.time())
+ web.view.set_html('Time: ' .. time, { view = view })
+ end
+ end)
+end
+
-- Decorations config
web.event.add_listener('WinCreated', {
callback = function(event)
web.decorations.bottom.enable({ win = event.win_id })
- local timer = web.uv.new_timer()
- timer:start(100, 0, function()
- local view = web.decorations.bottom.view({ win = event.win_id })
- print('>>> view', view)
- if view ~= nil then
- web.view.set_url('https://google.com', view)
- end
- timer:close()
- end)
+ start_clock(event.win_id)
end,
})
+
web.keymap.set('n', '<space>gg', function()
if web.decorations.bottom.is_enabled({ win = 0 }) then
web.decorations.bottom.disable({ win = 0 })