| schedule (fn) |
Schedule a function to be called on next tick (qt+libuv event loop) |
| web.keymap.set (mode, key, action) |
Add a keymap |
| web.keymap.set_mode (mode) |
Set the current keymap mode |
| web.keymap.get_mode () |
Get the current keymap mode |
| web.view.close (opts) |
Close view |
| web.view.create (url) |
Create a new view with a url |
| web.view.current () |
Get current view id |
| web.view.current_url () |
Get current url |
| web.view.list () |
Get a list of views in the current window |
| web.view.select (view_id) |
Select a view in current window |
| web.view.set_url (url, opts) |
Set url of a given view |
| web.view.set_html (html, opts) |
Set html inside the page for a given view |
| web.view.run_js (js, opts) |
Run js in a view |
| web.view.reload (opts) |
Reload a given view |
| web.view.expose (name, action, opts) |
Expose a lua function inside a view (Only works with decorations) |
| web.view.open_devtools (opts) |
Open devtools window for the view |
| web.view.current_index () |
Get current view index |
| web.event.add_listener (events, opts) |
Listen to events from the browser |
| set (key, value) |
Set configuration options |
| get (key) |
Get configuration value |
| web.history.back (count, opts) |
Go back in history for given view |
| web.history.forward (count, opts) |
Go forward in history for given view |
| web.search.set_text (text, opts) |
Search text inside a view |
| web.search.reset (opts) |
Reset searched text in a view (Same as web.search.set_text('')) |
| web.search.get_text () |
Get the last searched text |
| web.search.next (opts) |
Highlight next search term for the last searched text |
| web.search.previous (opts) |
Highlight previous search term for the last searched text |
| web.view.scroll (deltax, deltay, opts) |
TODO: Document |
| web.view.scroll_to_top (opts) |
TODO: Document |
| web.view.scroll_to_bottom (opts) |
TODO: Document |
| web.help.get_items () |
Get a list of items for help |
| web.help.show (item, opts) |
Open help docs for a given item |
| print (value) |
Print a lua object to inspect |
| web.json.encode (obj, opts) |
Encodes lua object as json into a string |
| web.json.decode (json_str, opts) |
Decodes a string into a lua object |
| web.utils.string_trim (str) |
Trim whitespace from start and end of a string |
| web.utils.table_merge (tbl) |
Merge multiple tables |
| web.utils.table_keys (tbl) |
Get keys of a table |
| web.utils.equals (a, b) |
Check if 2 values are deeply equal |
| web.utils.table_contains (tbl, value) |
Check if table contains given value |
-
schedule (fn)
-
Schedule a function to be called on next tick (qt+libuv event loop)
Parameters:
- fn
fun
():nil Function to call
-
web.keymap.set (mode, key, action)
-
Add a keymap
Parameters:
- mode
string Keymap mode ("i", "n", ...)
- key
string Key sequence (Eg: `j`)
- action
function
Function to run when keymap is triggered
Usage:
web.keymap.set('n', 'o', function()
web.view.create('https://google.com')
end)
-
web.keymap.set_mode (mode)
-
Set the current keymap mode
Parameters:
- mode
string
The keymap mode to set
Usage:
web.keymap.set_mode('n') web.keymap.set_mode('i')
-
web.keymap.get_mode ()
-
Get the current keymap mode
Usage:
local current_mode = web.keymap.get_mode()
-
web.view.close (opts)
-
Close view
Parameters:
- opts Options
- view
number? View id (default = 0)
Usage:
web.view.close() web.view.close({ view = 3 })
-
web.view.create (url)
-
Create a new view with a url
Parameters:
- url
string Url to open in the new view
Usage:
web.view.create('https://duckduckgo.com') web.view.create()
-
web.view.current ()
-
Get current view id
Returns:
number
_id Current view id
Usage:
local view_id = web.view.current()
-
web.view.current_url ()
-
Get current url
Returns:
string
Current view url
Usage:
local url = web.view.current_url()
-
web.view.list ()
-
Get a list of views in the current window
Returns:
table
List of views
Usage:
local views = web.view.list()
print(views[1].url, views[1].title, views[1].id)
-
web.view.select (view_id)
-
Select a view in current window
Parameters:
- view_id
number
View id to select
Usage:
web.view.select(3)
-
web.view.set_url (url, opts)
-
Set url of a given view
Parameters:
- url
string
Url to open
- opts Options
- view
number? View id (default = 0)
Usage:
web.view.set_url('https://foobar.com')
web.view.set_url('https://foobar.com', { view = 3 })
-
web.view.set_html (html, opts)
-
Set html inside the page for a given view
Parameters:
- html
string HTML string
- opts? table Options
- view
number? View id (default = 0)
Usage:
web.view.set_html('<h2>HJello</h2>')
web.view.set_html('<h2>HJello</h2>', { view = 3 })
-
web.view.run_js (js, opts)
-
Run js in a view
Parameters:
- js
string
JS string
- opts Options
- view
number? View id (default = 0)
- on_result
? fun(v: any): nil Callback with serialized result of evaluation
Usage:
web.view.run_js('console.log(42)')
web.view.run_js('console.log(42)', { view = 3 }) web.view.run_js('2 * 3', {
on_result = function(result)
print(result * 7)
end,
})
-
web.view.reload (opts)
-
Reload a given view
Parameters:
- opts Options
- view
number? View id (default = 0)
Usage:
web.view.reload()
web.view.reload({ view = 3 })
-
web.view.expose (name, action, opts)
-
Expose a lua function inside a view (Only works with decorations)
Parameters:
- name
string Func name
- action
fun(table):nil Action to call when function is invoked in view
- opts Options
- view
number? View id (default = 0)
Usage:
web.view.expose('tabSelect', function(args)
web.view.select(tonumber(args.view))
end)
_nullbrowser.rpc.tabSelect({ view: 5 })
-
web.view.open_devtools (opts)
-
Open devtools window for the view
Parameters:
- opts Options
- view
number? View id (default = 0)
Usage:
web.view.open_devtools() web.view.open_devtools(5)
-
web.view.current_index ()
-
Get current view index
Returns:
number
|nil index Current view index
Usage:
local index = web.view.current_index()
-
web.event.add_listener (events, opts)
-
Listen to events from the browser
Parameters:
- events
string
|table Event or events to listen to
- opts Options
- callback
fun(opts:any):nil Callback called when that event occurs
See also:
Usage:
web.event.add_listener('UrlChanged', {
callback = function(opts)
print(opts.url, opts.view, opts.win)
end,
})
-
set (key, value)
-
Set configuration options
Parameters:
- key
string
The name of the configuration
- value
nil
|string|boolean|number Configuration value
See also:
Usage:
web.set('new_view_url', 'https://duckduckgo.com')
web.opts.new_view_url = 'https://duckduckgo.com'
-
get (key)
-
Get configuration value
Parameters:
- key
string
The name of the configuration
See also:
Usage:
local url = web.get('new_view_url')
-
web.history.back (count, opts)
-
Go back in history for given view
Parameters:
- count
number? Number of history items to go back in (default = 1)
- opts Options
- view
number? View id (default = 0)
Usage:
web.history.back(2, { view = 3 })
-
web.history.forward (count, opts)
-
Go forward in history for given view
Parameters:
- count
number? Number of history items to go forward in (default = 1)
- opts Options
- view
number? View id (default = 0)
Usage:
web.history.forward(2, { view = 3 })
-
web.search.set_text (text, opts)
-
Search text inside a view
Parameters:
- text
string? Text to search
- opts Options
- view
number? View id (default = 0)
Usage:
web.search.set_text('whatever') web.search.set_text('whatever', { view = 5 })
-
web.search.reset (opts)
-
Reset searched text in a view (Same as web.search.set_text(''))
Parameters:
- opts Options
- view
number? View id (default = 0)
Usage:
web.search.reset() web.search.reset({ view = 5 })
-
web.search.get_text ()
-
Get the last searched text
Usage:
local text = web.search.get_text()
-
web.search.next (opts)
-
Highlight next search term for the last searched text
Parameters:
- opts Options
- view
number? View id (default = 0)
Usage:
web.search.next() web.search.next({ view = 5 })
-
web.search.previous (opts)
-
Highlight previous search term for the last searched text
Parameters:
- opts Options
- view
number? View id (default = 0)
Usage:
web.search.previous() web.search.previous(5)
-
web.view.scroll (deltax, deltay, opts)
-
TODO: Document
Parameters:
- deltax
number
- deltay
number
- opts Options
- view
number? View id (default = 0)
-
web.view.scroll_to_top (opts)
-
TODO: Document
Parameters:
- opts Options
- view
number? View id (default = 0)
-
web.view.scroll_to_bottom (opts)
-
TODO: Document
Parameters:
- opts Options
- view
number? View id (default = 0)
-
web.help.get_items ()
-
Get a list of items for help
Returns:
table
help_items List of help item names
-
web.help.show (item, opts)
-
Open help docs for a given item
Parameters:
- item
string
Help item name
- opts Options
- view
number? View id (default = 0)
-
print (value)
-
Print a lua object to inspect
Parameters:
-
web.json.encode (obj, opts)
-
Encodes lua object as json into a string
Parameters:
- obj
any
Value to encode into json string
- opts Options
- indent
boolean? Whether to enable indentation (default: false)
Returns:
string
-
web.json.decode (json_str, opts)
-
Decodes a string into a lua object
Parameters:
- json_str
string
Json string to decode
- opts Options
- null
any? What to use as null value (default: nil)
Returns:
any
-
web.utils.string_trim (str)
-
Trim whitespace from start and end of a string
Parameters:
Returns:
string
-
web.utils.table_merge (tbl)
-
Merge multiple tables
Parameters:
Returns:
table
-
web.utils.table_keys (tbl)
-
Get keys of a table
Parameters:
Returns:
table
-
web.utils.equals (a, b)
-
Check if 2 values are deeply equal
Parameters:
Returns:
boolean
-
web.utils.table_contains (tbl, value)
-
Check if table contains given value
Parameters:
Returns:
boolean