From 211e953db7775a1192a5535041e9abb7588bc5fa Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Tue, 12 Aug 2025 00:57:42 +0530 Subject: Move generated api reference dir --- Makefile | 7 + TODO.org | 3 +- doc/index.html | 1228 ------------------------------------------- doc/ldoc.css | 304 ----------- doc/symbols.json | 1 - docs/api/index.html | 1312 ++++++++++++++++++++++++++++++++++++++++++++++ docs/api/ldoc.css | 304 +++++++++++ docs/api/symbols.json | 1 + flake.nix | 4 +- lua/null-browser/api.lua | 2 +- 10 files changed, 1629 insertions(+), 1537 deletions(-) delete mode 100644 doc/index.html delete mode 100644 doc/ldoc.css delete mode 100644 doc/symbols.json create mode 100644 docs/api/index.html create mode 100644 docs/api/ldoc.css create mode 100644 docs/api/symbols.json diff --git a/Makefile b/Makefile index 1272245..74aea05 100644 --- a/Makefile +++ b/Makefile @@ -46,9 +46,16 @@ check: fmt clang-tidy --config-file=.clang-tidy ./src/**/*.{hpp,cpp} docs: + # API reference pages ldoc -p null-browser -t "Null browser api" \ --merge --ignore --lls \ + --dir ./docs/api \ ./lua/null-browser/ + # Symbols json + ldoc --merge --ignore --lls \ + ./lua/null-browser/ \ + --dir ./docs/api \ + --filter ldoc_json_filter.lua; # appimage: # nix bundle --bundler github:ralismark/nix-appimage diff --git a/TODO.org b/TODO.org index c49e456..8ca498b 100644 --- a/TODO.org +++ b/TODO.org @@ -19,7 +19,7 @@ - [X] Vertical tabline ui - [ ] Document events and event opts - [ ] Update all api to use opts table pattern -- [ ] Install doc/ in build +- [ ] Install docs/ and assets/ in build - [ ] web.keymap.configure_mode(modename, { passthrough = false }) - [ ] Fullscreen - [ ] Zoom in/out/reset @@ -27,6 +27,7 @@ - [ ] Api for enabling rpc api in view - [ ] Make the asset/config/lua paths readable via lua - [ ] json encode/decode +- [ ] Fix path to symbols.json in web.help.get_items (use docs path) ** Bugs - [ ] Closing webview should close devtools window diff --git a/doc/index.html b/doc/index.html deleted file mode 100644 index f357409..0000000 --- a/doc/index.html +++ /dev/null @@ -1,1228 +0,0 @@ - - - - - Null browser api - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module web

-

-

- - -

Functions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 (view_id)Close view
web.view.create (url)Create a new view with a url
web.view.current ()Get current view id
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, view_id)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)Relaod a given view
web.view.expose (name, action, opts)Expose a lua function inside a view (Only works with decorations)
web.view.open_devtools (view_id)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, view_id)Go back in history for given view
web.history.forward (count, view_id)Go forward in history for given view
web.search.set_text (text, view_id)Search text inside a view
web.search.reset (view_id)Reset searched text in a view (Same as web.search.set_text(''))
web.search.get_text ()Get the last searched text
web.search.next (view_id)Highlight next search term for the last searched text
web.search.previous (view_id)Highlight previous search term for the last searched text
web.view.scroll (deltax, deltay, view_id)TODO: Document
web.view.scroll_to_top (view_id)TODO: Document
web.view.scroll_to_bottom (view_id)TODO: Document
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
-

Tables

- - - - - -
WebOptsMaps to values defined in ./src/Configuration.hpp
-

Fields

- - - - - - - - - - - - - - - - - -
_G.__internalsInternal api (unstable)
optsAPI for configuring browser options
uvluv api (https://github.com/luvit/luv/blob/master/docs.md)
inspectReturns human-readable string representation of Lua tables (https://github.com/kikito/inspect.lua)
- -
-
- - -

Functions

- -
-
- - 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') -- Set to normal mode
    -web.keymap.set_mode('i') -- Set to insert mode
    -
- -
-
- - web.keymap.get_mode () -
-
- Get the current keymap mode - - - - - - -

Usage:

-
    -
    local current_mode = web.keymap.get_mode()
    -
- -
-
- - web.view.close (view_id) -
-
- Close view - - -

Parameters:

-
    -
  • view_id - ? number View id to close -
  • -
- - - - -

Usage:

-
    -
    web.view.close()  -- Close current view in active window
    -web.view.close(3) -- Close view with id 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') -- Opens url in new view
    -web.view.create() -- Opens new_view_url by default
    -
- -
-
- - web.view.current () -
-
- Get current view id - - - -

Returns:

-
    - - number - _id Current view id -
- - - -

Usage:

-
    -
    local view_id = web.view.current()
    -
- -
-
- - 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) -- Select view with id 3
    -
- -
-
- - web.view.set_url (url, view_id) -
-
- Set url of a given view - - -

Parameters:

-
    -
  • url - string - Url to open -
  • -
  • view_id - number - View id to select -
  • -
- - - - -

Usage:

-
    -
    web.view.set_url('https://foobar.com')
    -web.view.set_url('https://foobar.com', 3) -- Set url for view with id 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 -
    • -
    -
- - - - -

Usage:

-
    -
    web.view.set_html('<h2>HJello</h2>')
    -web.view.set_html('<h2>HJello</h2>', { view = 3 }) -- Set html for view with id 3
    -
- -
-
- - web.view.run_js (js, opts) -
-
- Run js in a view - - -

Parameters:

-
    -
  • js - string - HTML string -
  • -
  • opts - ? RunJSOpts Options -
  • -
- - - - -

Usage:

-
    -
    web.view.run_js('console.log(42)')
    -web.view.run_js('console.log(42)', { view = 3 }) -- Set html for view with id 3
    -
- -
-
- - web.view.reload (opts) -
-
- Relaod a given view - - -

Parameters:

-
    -
  • opts - ? ReloadOpts Options -
  • -
- - - - -

Usage:

-
    -
    web.view.reload()
    -web.view.reload({ view = 3 }) -- Reload view with id 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 - ExposeOpts? Options -
  • -
- - - - -

Usage:

-
    -
  • web.view.expose('tabSelect', function(args)
    -  web.view.select(tonumber(args.view))
    -end)
  • -
  • -- In javascript
    -_nullbrowser.rpc.tabSelect({ view: 5 })
  • -
- -
-
- - web.view.open_devtools (view_id) -
-
- Open devtools window for the view - - -

Parameters:

-
    -
  • view_id - number - Id of the view -
  • -
- - - - -

Usage:

-
    -
    web.view.open_devtools() -- Open devtools window for current view
    -web.view.open_devtools(5) -- Open devtools window for view id 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 -
    • -
    -
- - - - -

Usage:

-
    -
    web.event.add_listener('UrlChanged', {
    -  callback = function(opts)
    -    print(opts.url, opts.tab, 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')
    --- Can also be written as
    -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, view_id) -
-
- Go back in history for given view - - -

Parameters:

-
    -
  • count - number? Number of history items to go back in (default = 1) -
  • -
  • view_id - number - Id of the view -
  • -
- - - - -

Usage:

-
    -
    web.history.back(2, 3) -- Go back 2 history items for view id 3
    -
- -
-
- - web.history.forward (count, view_id) -
-
- Go forward in history for given view - - -

Parameters:

-
    -
  • count - number? Number of history items to go forward in (default = 1) -
  • -
  • view_id - number - Id of the view -
  • -
- - - - -

Usage:

-
    -
    web.history.forward(2, 3) -- Go forward 2 history items for view id 3
    -
- -
-
- - web.search.set_text (text, view_id) -
-
- Search text inside a view - - -

Parameters:

-
    -
  • text - string? Text to search -
  • -
  • view_id - number - Id of the view -
  • -
- - - - -

Usage:

-
    -
    web.search.set_text('whatever') -- Search in current view
    -web.search.set_text('whatever', 5) -- Search in view id 5
    -
- -
-
- - web.search.reset (view_id) -
-
- Reset searched text in a view (Same as web.search.set_text('')) - - -

Parameters:

-
    -
  • view_id - number - Id of the view -
  • -
- - - - -

Usage:

-
    -
    web.search.reset() -- Reset search state for current view
    -web.search.reset(5) -- Reset search state for view id 5
    -
- -
-
- - web.search.get_text () -
-
- Get the last searched text - - - - - - -

Usage:

-
    -
    local text = web.search.get_text()
    -
- -
-
- - web.search.next (view_id) -
-
- Highlight next search term for the last searched text - - -

Parameters:

-
    -
  • view_id - number - Id of the view -
  • -
- - - - -

Usage:

-
    -
    web.search.next() -- Next search result in current view
    -web.search.next(5) -- Next search result in view id 5
    -
- -
-
- - web.search.previous (view_id) -
-
- Highlight previous search term for the last searched text - - -

Parameters:

-
    -
  • view_id - number - Id of the view -
  • -
- - - - -

Usage:

-
    -
    web.search.previous() -- Previous search result in current view
    -web.search.previous(5) -- Previous search result in view id 5
    -
- -
-
- - web.view.scroll (deltax, deltay, view_id) -
-
- TODO: Document - - -

Parameters:

-
    -
  • deltax - -
  • -
  • deltay - -
  • -
  • view_id - -
  • -
- - - - - -
-
- - web.view.scroll_to_top (view_id) -
-
- TODO: Document - - -

Parameters:

-
    -
  • view_id - -
  • -
- - - - - -
-
- - web.view.scroll_to_bottom (view_id) -
-
- TODO: Document - - -

Parameters:

-
    -
  • view_id - -
  • -
- - - - - -
-
- - 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:

-
    -
  • a - any - -
  • -
  • b - any - -
  • -
- -

Returns:

-
    - - boolean - -
- - - - -
-
-

Tables

- -
-
- - WebOpts -
-
- Maps to values defined in ./src/Configuration.hpp - - -

Fields:

-
    -
  • app_data_dir - string (readonly) Directory where app data is stored -
  • -
  • close_window_when_no_views - boolean If true, when the last tab in a window is closed, the window closes (default: true) -
  • -
  • config_dir - string (readonly) Directory where app config is stored -
  • -
  • downloads_dir - string Directory where downloaded files go -
  • -
  • new_view_url - string URL used when view url is not specified (default: 'https://duckduckgo.com') -
  • -
  • permissions_persistance - 'always'|'session'|'never' How to persist choices for permissions (default: 'always') -
  • -
  • user_agent - string User agent sent by the browser -
  • -
- - - - - -
-
-

Fields

- -
-
- - _G.__internals -
-
- Internal api (unstable) - - - - - - - -
-
- - opts -
-
- API for configuring browser options - - - - - -

See also:

- - -

Usage:

-
    -
    web.opts.new_view_url = 'https://duckduckgo.com'
    -
- -
-
- - uv -
-
- luv api (https://github.com/luvit/luv/blob/master/docs.md) - - - - - - - -
-
- - inspect -
-
- Returns human-readable string representation of Lua tables (https://github.com/kikito/inspect.lua) - - -
    -
  • value - any - -
  • -
- - - - - -
-
- - -
-
-
-generated by LDoc 1.5.0 -Last updated 1980-01-01 00:00:00 -
-
- - diff --git a/doc/ldoc.css b/doc/ldoc.css deleted file mode 100644 index f945ae7..0000000 --- a/doc/ldoc.css +++ /dev/null @@ -1,304 +0,0 @@ -/* BEGIN RESET - -Copyright (c) 2010, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.8.2r1 -*/ -html { - color: #000; - background: #FFF; -} -body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { - margin: 0; - padding: 0; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -fieldset,img { - border: 0; -} -address,caption,cite,code,dfn,em,strong,th,var,optgroup { - font-style: inherit; - font-weight: inherit; -} -del,ins { - text-decoration: none; -} -li { - margin-left: 20px; -} -caption,th { - text-align: left; -} -h1,h2,h3,h4,h5,h6 { - font-size: 100%; - font-weight: bold; -} -q:before,q:after { - content: ''; -} -abbr,acronym { - border: 0; - font-variant: normal; -} -sup { - vertical-align: baseline; -} -sub { - vertical-align: baseline; -} -legend { - color: #000; -} -input,button,textarea,select,optgroup,option { - font-family: inherit; - font-size: inherit; - font-style: inherit; - font-weight: inherit; -} -input,button,textarea,select {*font-size:100%; -} -/* END RESET */ - -body { - margin-left: 1em; - margin-right: 1em; - font-family: arial, helvetica, geneva, sans-serif; - background-color: #ffffff; margin: 0px; -} - -code, tt { font-family: monospace; font-size: 1.1em; } -span.parameter { font-family:monospace; } -span.parameter:after { content:":"; } -span.types:before { content:"("; } -span.types:after { content:")"; } -.type { font-weight: bold; font-style:italic } - -body, p, td, th { font-size: .95em; line-height: 1.2em;} - -p, ul { margin: 10px 0 0 0px;} - -strong { font-weight: bold;} - -em { font-style: italic;} - -h1 { - font-size: 1.5em; - margin: 20px 0 20px 0; -} -h2, h3, h4 { margin: 15px 0 10px 0; } -h2 { font-size: 1.25em; } -h3 { font-size: 1.15em; } -h4 { font-size: 1.06em; } - -a:link { font-weight: bold; color: #004080; text-decoration: none; } -a:visited { font-weight: bold; color: #006699; text-decoration: none; } -a:link:hover { text-decoration: underline; } - -hr { - color:#cccccc; - background: #00007f; - height: 1px; -} - -blockquote { margin-left: 3em; } - -ul { list-style-type: disc; } - -p.name { - font-family: "Andale Mono", monospace; - padding-top: 1em; -} - -pre { - background-color: rgb(245, 245, 245); - border: 1px solid #C0C0C0; /* silver */ - padding: 10px; - margin: 10px 0 10px 0; - overflow: auto; - font-family: "Andale Mono", monospace; -} - -pre.example { - font-size: .85em; -} - -table.index { border: 1px #00007f; } -table.index td { text-align: left; vertical-align: top; } - -#container { - margin-left: 1em; - margin-right: 1em; - background-color: #f0f0f0; -} - -#product { - text-align: center; - border-bottom: 1px solid #cccccc; - background-color: #ffffff; -} - -#product big { - font-size: 2em; -} - -#main { - background-color: #f0f0f0; - border-left: 2px solid #cccccc; -} - -#navigation { - float: left; - width: 14em; - vertical-align: top; - background-color: #f0f0f0; - overflow: visible; -} - -#navigation h2 { - background-color:#e7e7e7; - font-size:1.1em; - color:#000000; - text-align: left; - padding:0.2em; - border-top:1px solid #dddddd; - border-bottom:1px solid #dddddd; -} - -#navigation ul -{ - font-size:1em; - list-style-type: none; - margin: 1px 1px 10px 1px; -} - -#navigation li { - text-indent: -1em; - display: block; - margin: 3px 0px 0px 22px; -} - -#navigation li li a { - margin: 0px 3px 0px -1em; -} - -#content { - margin-left: 14em; - padding: 1em; - width: 700px; - border-left: 2px solid #cccccc; - border-right: 2px solid #cccccc; - background-color: #ffffff; -} - -#about { - clear: both; - padding: 5px; - border-top: 2px solid #cccccc; - background-color: #ffffff; -} - -@media print { - body { - font: 12pt "Times New Roman", "TimeNR", Times, serif; - } - a { font-weight: bold; color: #004080; text-decoration: underline; } - - #main { - background-color: #ffffff; - border-left: 0px; - } - - #container { - margin-left: 2%; - margin-right: 2%; - background-color: #ffffff; - } - - #content { - padding: 1em; - background-color: #ffffff; - } - - #navigation { - display: none; - } - pre.example { - font-family: "Andale Mono", monospace; - font-size: 10pt; - page-break-inside: avoid; - } -} - -table.module_list { - border-width: 1px; - border-style: solid; - border-color: #cccccc; - border-collapse: collapse; -} -table.module_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #cccccc; -} -table.module_list td.name { background-color: #f0f0f0; min-width: 200px; } -table.module_list td.summary { width: 100%; } - - -table.function_list { - border-width: 1px; - border-style: solid; - border-color: #cccccc; - border-collapse: collapse; -} -table.function_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #cccccc; -} -table.function_list td.name { background-color: #f0f0f0; min-width: 200px; } -table.function_list td.summary { width: 100%; } - -ul.nowrap { - overflow:auto; - white-space:nowrap; -} - -dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} -dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} -dl.table h3, dl.function h3 {font-size: .95em;} - -/* stop sublists from having initial vertical space */ -ul ul { margin-top: 0px; } -ol ul { margin-top: 0px; } -ol ol { margin-top: 0px; } -ul ol { margin-top: 0px; } - -/* make the target distinct; helps when we're navigating to a function */ -a:target + * { - background-color: #FF9; -} - - -/* styles for prettification of source */ -pre .comment { color: #558817; } -pre .constant { color: #a8660d; } -pre .escape { color: #844631; } -pre .keyword { color: #aa5050; font-weight: bold; } -pre .library { color: #0e7c6b; } -pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; } -pre .string { color: #8080ff; } -pre .number { color: #f8660d; } -pre .function-name { color: #60447f; } -pre .operator { color: #2239a8; font-weight: bold; } -pre .preprocessor, pre .prepro { color: #a33243; } -pre .global { color: #800080; } -pre .user-keyword { color: #800080; } -pre .prompt { color: #558817; } -pre .url { color: #272fc2; text-decoration: underline; } - diff --git a/doc/symbols.json b/doc/symbols.json deleted file mode 100644 index 8766314..0000000 --- a/doc/symbols.json +++ /dev/null @@ -1 +0,0 @@ -["_G.__internals","schedule","web.keymap.set","web.keymap.set_mode","web.keymap.get_mode","web.view.close","web.view.create","web.view.current","web.view.list","web.view.select","web.view.set_url","web.view.set_html","web.view.run_js","web.view.reload","web.view.expose","web.view.open_devtools","web.view.current_index","web.event.add_listener","set","get","WebOpts","opts","web.history.back","web.history.forward","web.search.set_text","web.search.reset","web.search.get_text","web.search.next","web.search.previous","web.view.scroll","web.view.scroll_to_top","web.view.scroll_to_bottom","uv","inspect","web.utils.string_trim","web.utils.table_merge","web.utils.table_keys","web.utils.equals","web.utils.table_contains"] \ No newline at end of file diff --git a/docs/api/index.html b/docs/api/index.html new file mode 100644 index 0000000..fa2ab5a --- /dev/null +++ b/docs/api/index.html @@ -0,0 +1,1312 @@ + + + + + Null browser api + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module web

+

+

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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 (view_id)Close view
web.view.create (url)Create a new view with a url
web.view.current ()Get current view id
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, view_id)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)Relaod a given view
web.view.expose (name, action, opts)Expose a lua function inside a view (Only works with decorations)
web.view.open_devtools (view_id)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, view_id)Go back in history for given view
web.history.forward (count, view_id)Go forward in history for given view
web.search.set_text (text, view_id)Search text inside a view
web.search.reset (view_id)Reset searched text in a view (Same as web.search.set_text(''))
web.search.get_text ()Get the last searched text
web.search.next (view_id)Highlight next search term for the last searched text
web.search.previous (view_id)Highlight previous search term for the last searched text
web.view.scroll (deltax, deltay, view_id)TODO: Document
web.view.scroll_to_top (view_id)TODO: Document
web.view.scroll_to_bottom (view_id)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
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
+

Tables

+ + + + + +
WebOptsMaps to values defined in ./src/Configuration.hpp
+

Fields

+ + + + + + + + + + + + + + + + + +
_G.__internalsInternal api (unstable)
optsAPI for configuring browser options
uvluv api (https://github.com/luvit/luv/blob/master/docs.md)
inspectReturns human-readable string representation of Lua tables (https://github.com/kikito/inspect.lua)
+ +
+
+ + +

Functions

+ +
+
+ + 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') -- Set to normal mode
    +web.keymap.set_mode('i') -- Set to insert mode
    +
+ +
+
+ + web.keymap.get_mode () +
+
+ Get the current keymap mode + + + + + + +

Usage:

+
    +
    local current_mode = web.keymap.get_mode()
    +
+ +
+
+ + web.view.close (view_id) +
+
+ Close view + + +

Parameters:

+
    +
  • view_id + ? number View id to close +
  • +
+ + + + +

Usage:

+
    +
    web.view.close()  -- Close current view in active window
    +web.view.close(3) -- Close view with id 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') -- Opens url in new view
    +web.view.create() -- Opens new_view_url by default
    +
+ +
+
+ + web.view.current () +
+
+ Get current view id + + + +

Returns:

+
    + + number + _id Current view id +
+ + + +

Usage:

+
    +
    local view_id = web.view.current()
    +
+ +
+
+ + 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) -- Select view with id 3
    +
+ +
+
+ + web.view.set_url (url, view_id) +
+
+ Set url of a given view + + +

Parameters:

+
    +
  • url + string + Url to open +
  • +
  • view_id + number + View id to select +
  • +
+ + + + +

Usage:

+
    +
    web.view.set_url('https://foobar.com')
    +web.view.set_url('https://foobar.com', 3) -- Set url for view with id 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 +
    • +
    +
+ + + + +

Usage:

+
    +
    web.view.set_html('<h2>HJello</h2>')
    +web.view.set_html('<h2>HJello</h2>', { view = 3 }) -- Set html for view with id 3
    +
+ +
+
+ + web.view.run_js (js, opts) +
+
+ Run js in a view + + +

Parameters:

+
    +
  • js + string + HTML string +
  • +
  • opts + ? RunJSOpts Options +
  • +
+ + + + +

Usage:

+
    +
    web.view.run_js('console.log(42)')
    +web.view.run_js('console.log(42)', { view = 3 }) -- Set html for view with id 3
    +
+ +
+
+ + web.view.reload (opts) +
+
+ Relaod a given view + + +

Parameters:

+
    +
  • opts + ? ReloadOpts Options +
  • +
+ + + + +

Usage:

+
    +
    web.view.reload()
    +web.view.reload({ view = 3 }) -- Reload view with id 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 + ExposeOpts? Options +
  • +
+ + + + +

Usage:

+
    +
  • web.view.expose('tabSelect', function(args)
    +  web.view.select(tonumber(args.view))
    +end)
  • +
  • -- In javascript
    +_nullbrowser.rpc.tabSelect({ view: 5 })
  • +
+ +
+
+ + web.view.open_devtools (view_id) +
+
+ Open devtools window for the view + + +

Parameters:

+
    +
  • view_id + number + Id of the view +
  • +
+ + + + +

Usage:

+
    +
    web.view.open_devtools() -- Open devtools window for current view
    +web.view.open_devtools(5) -- Open devtools window for view id 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 +
    • +
    +
+ + + + +

Usage:

+
    +
    web.event.add_listener('UrlChanged', {
    +  callback = function(opts)
    +    print(opts.url, opts.tab, 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')
    +-- Can also be written as
    +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, view_id) +
+
+ Go back in history for given view + + +

Parameters:

+
    +
  • count + number? Number of history items to go back in (default = 1) +
  • +
  • view_id + number + Id of the view +
  • +
+ + + + +

Usage:

+
    +
    web.history.back(2, 3) -- Go back 2 history items for view id 3
    +
+ +
+
+ + web.history.forward (count, view_id) +
+
+ Go forward in history for given view + + +

Parameters:

+
    +
  • count + number? Number of history items to go forward in (default = 1) +
  • +
  • view_id + number + Id of the view +
  • +
+ + + + +

Usage:

+
    +
    web.history.forward(2, 3) -- Go forward 2 history items for view id 3
    +
+ +
+
+ + web.search.set_text (text, view_id) +
+
+ Search text inside a view + + +

Parameters:

+
    +
  • text + string? Text to search +
  • +
  • view_id + number + Id of the view +
  • +
+ + + + +

Usage:

+
    +
    web.search.set_text('whatever') -- Search in current view
    +web.search.set_text('whatever', 5) -- Search in view id 5
    +
+ +
+
+ + web.search.reset (view_id) +
+
+ Reset searched text in a view (Same as web.search.set_text('')) + + +

Parameters:

+
    +
  • view_id + number + Id of the view +
  • +
+ + + + +

Usage:

+
    +
    web.search.reset() -- Reset search state for current view
    +web.search.reset(5) -- Reset search state for view id 5
    +
+ +
+
+ + web.search.get_text () +
+
+ Get the last searched text + + + + + + +

Usage:

+
    +
    local text = web.search.get_text()
    +
+ +
+
+ + web.search.next (view_id) +
+
+ Highlight next search term for the last searched text + + +

Parameters:

+
    +
  • view_id + number + Id of the view +
  • +
+ + + + +

Usage:

+
    +
    web.search.next() -- Next search result in current view
    +web.search.next(5) -- Next search result in view id 5
    +
+ +
+
+ + web.search.previous (view_id) +
+
+ Highlight previous search term for the last searched text + + +

Parameters:

+
    +
  • view_id + number + Id of the view +
  • +
+ + + + +

Usage:

+
    +
    web.search.previous() -- Previous search result in current view
    +web.search.previous(5) -- Previous search result in view id 5
    +
+ +
+
+ + web.view.scroll (deltax, deltay, view_id) +
+
+ TODO: Document + + +

Parameters:

+
    +
  • deltax + +
  • +
  • deltay + +
  • +
  • view_id + +
  • +
+ + + + + +
+
+ + web.view.scroll_to_top (view_id) +
+
+ TODO: Document + + +

Parameters:

+
    +
  • view_id + +
  • +
+ + + + + +
+
+ + web.view.scroll_to_bottom (view_id) +
+
+ TODO: Document + + +

Parameters:

+
    +
  • view_id + +
  • +
+ + + + + +
+
+ + web.help.get_items () +
+
+ Get a list of items for help + + + + + + + +
+
+ + web.help.show (item, opts) +
+
+ Open help docs for a given item + + +

Parameters:

+
    +
  • item + string + +
  • +
  • opts +
      +
    • view + number? +
    • +
    +
+ + + + + +
+
+ + 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:

+
    +
  • a + any + +
  • +
  • b + any + +
  • +
+ +

Returns:

+
    + + boolean + +
+ + + + +
+
+ + web.utils.table_contains (tbl, value) +
+
+ Check if table contains given value + + +

Parameters:

+
    +
  • tbl + table + +
  • +
  • value + any + +
  • +
+ +

Returns:

+
    + + boolean + +
+ + + + +
+
+

Tables

+ +
+
+ + WebOpts +
+
+ Maps to values defined in ./src/Configuration.hpp + + +

Fields:

+
    +
  • app_data_dir + string (readonly) Directory where app data is stored +
  • +
  • close_window_when_no_views + boolean If true, when the last tab in a window is closed, the window closes (default: true) +
  • +
  • config_dir + string (readonly) Directory where app config is stored +
  • +
  • downloads_dir + string Directory where downloaded files go +
  • +
  • new_view_url + string URL used when view url is not specified (default: 'https://duckduckgo.com') +
  • +
  • permissions_persistance + 'always'|'session'|'never' How to persist choices for permissions (default: 'always') +
  • +
  • user_agent + string User agent sent by the browser +
  • +
+ + + + + +
+
+

Fields

+ +
+
+ + _G.__internals +
+
+ Internal api (unstable) + + + + + + + +
+
+ + opts +
+
+ API for configuring browser options + + + + + +

See also:

+ + +

Usage:

+
    +
    web.opts.new_view_url = 'https://duckduckgo.com'
    +
+ +
+
+ + uv +
+
+ luv api (https://github.com/luvit/luv/blob/master/docs.md) + + + + + + + +
+
+ + inspect +
+
+ Returns human-readable string representation of Lua tables (https://github.com/kikito/inspect.lua) + + +
    +
  • value + any + +
  • +
+ + + + + +
+
+ + +
+
+
+generated by LDoc 1.5.0 +Last updated 1980-01-01 00:00:00 +
+
+ + diff --git a/docs/api/ldoc.css b/docs/api/ldoc.css new file mode 100644 index 0000000..f945ae7 --- /dev/null +++ b/docs/api/ldoc.css @@ -0,0 +1,304 @@ +/* BEGIN RESET + +Copyright (c) 2010, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.8.2r1 +*/ +html { + color: #000; + background: #FFF; +} +body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { + margin: 0; + padding: 0; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +fieldset,img { + border: 0; +} +address,caption,cite,code,dfn,em,strong,th,var,optgroup { + font-style: inherit; + font-weight: inherit; +} +del,ins { + text-decoration: none; +} +li { + margin-left: 20px; +} +caption,th { + text-align: left; +} +h1,h2,h3,h4,h5,h6 { + font-size: 100%; + font-weight: bold; +} +q:before,q:after { + content: ''; +} +abbr,acronym { + border: 0; + font-variant: normal; +} +sup { + vertical-align: baseline; +} +sub { + vertical-align: baseline; +} +legend { + color: #000; +} +input,button,textarea,select,optgroup,option { + font-family: inherit; + font-size: inherit; + font-style: inherit; + font-weight: inherit; +} +input,button,textarea,select {*font-size:100%; +} +/* END RESET */ + +body { + margin-left: 1em; + margin-right: 1em; + font-family: arial, helvetica, geneva, sans-serif; + background-color: #ffffff; margin: 0px; +} + +code, tt { font-family: monospace; font-size: 1.1em; } +span.parameter { font-family:monospace; } +span.parameter:after { content:":"; } +span.types:before { content:"("; } +span.types:after { content:")"; } +.type { font-weight: bold; font-style:italic } + +body, p, td, th { font-size: .95em; line-height: 1.2em;} + +p, ul { margin: 10px 0 0 0px;} + +strong { font-weight: bold;} + +em { font-style: italic;} + +h1 { + font-size: 1.5em; + margin: 20px 0 20px 0; +} +h2, h3, h4 { margin: 15px 0 10px 0; } +h2 { font-size: 1.25em; } +h3 { font-size: 1.15em; } +h4 { font-size: 1.06em; } + +a:link { font-weight: bold; color: #004080; text-decoration: none; } +a:visited { font-weight: bold; color: #006699; text-decoration: none; } +a:link:hover { text-decoration: underline; } + +hr { + color:#cccccc; + background: #00007f; + height: 1px; +} + +blockquote { margin-left: 3em; } + +ul { list-style-type: disc; } + +p.name { + font-family: "Andale Mono", monospace; + padding-top: 1em; +} + +pre { + background-color: rgb(245, 245, 245); + border: 1px solid #C0C0C0; /* silver */ + padding: 10px; + margin: 10px 0 10px 0; + overflow: auto; + font-family: "Andale Mono", monospace; +} + +pre.example { + font-size: .85em; +} + +table.index { border: 1px #00007f; } +table.index td { text-align: left; vertical-align: top; } + +#container { + margin-left: 1em; + margin-right: 1em; + background-color: #f0f0f0; +} + +#product { + text-align: center; + border-bottom: 1px solid #cccccc; + background-color: #ffffff; +} + +#product big { + font-size: 2em; +} + +#main { + background-color: #f0f0f0; + border-left: 2px solid #cccccc; +} + +#navigation { + float: left; + width: 14em; + vertical-align: top; + background-color: #f0f0f0; + overflow: visible; +} + +#navigation h2 { + background-color:#e7e7e7; + font-size:1.1em; + color:#000000; + text-align: left; + padding:0.2em; + border-top:1px solid #dddddd; + border-bottom:1px solid #dddddd; +} + +#navigation ul +{ + font-size:1em; + list-style-type: none; + margin: 1px 1px 10px 1px; +} + +#navigation li { + text-indent: -1em; + display: block; + margin: 3px 0px 0px 22px; +} + +#navigation li li a { + margin: 0px 3px 0px -1em; +} + +#content { + margin-left: 14em; + padding: 1em; + width: 700px; + border-left: 2px solid #cccccc; + border-right: 2px solid #cccccc; + background-color: #ffffff; +} + +#about { + clear: both; + padding: 5px; + border-top: 2px solid #cccccc; + background-color: #ffffff; +} + +@media print { + body { + font: 12pt "Times New Roman", "TimeNR", Times, serif; + } + a { font-weight: bold; color: #004080; text-decoration: underline; } + + #main { + background-color: #ffffff; + border-left: 0px; + } + + #container { + margin-left: 2%; + margin-right: 2%; + background-color: #ffffff; + } + + #content { + padding: 1em; + background-color: #ffffff; + } + + #navigation { + display: none; + } + pre.example { + font-family: "Andale Mono", monospace; + font-size: 10pt; + page-break-inside: avoid; + } +} + +table.module_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.module_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.module_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.module_list td.summary { width: 100%; } + + +table.function_list { + border-width: 1px; + border-style: solid; + border-color: #cccccc; + border-collapse: collapse; +} +table.function_list td { + border-width: 1px; + padding: 3px; + border-style: solid; + border-color: #cccccc; +} +table.function_list td.name { background-color: #f0f0f0; min-width: 200px; } +table.function_list td.summary { width: 100%; } + +ul.nowrap { + overflow:auto; + white-space:nowrap; +} + +dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} +dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} +dl.table h3, dl.function h3 {font-size: .95em;} + +/* stop sublists from having initial vertical space */ +ul ul { margin-top: 0px; } +ol ul { margin-top: 0px; } +ol ol { margin-top: 0px; } +ul ol { margin-top: 0px; } + +/* make the target distinct; helps when we're navigating to a function */ +a:target + * { + background-color: #FF9; +} + + +/* styles for prettification of source */ +pre .comment { color: #558817; } +pre .constant { color: #a8660d; } +pre .escape { color: #844631; } +pre .keyword { color: #aa5050; font-weight: bold; } +pre .library { color: #0e7c6b; } +pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; } +pre .string { color: #8080ff; } +pre .number { color: #f8660d; } +pre .function-name { color: #60447f; } +pre .operator { color: #2239a8; font-weight: bold; } +pre .preprocessor, pre .prepro { color: #a33243; } +pre .global { color: #800080; } +pre .user-keyword { color: #800080; } +pre .prompt { color: #558817; } +pre .url { color: #272fc2; text-decoration: underline; } + diff --git a/docs/api/symbols.json b/docs/api/symbols.json new file mode 100644 index 0000000..aa356c5 --- /dev/null +++ b/docs/api/symbols.json @@ -0,0 +1 @@ +["_G.__internals","schedule","web.keymap.set","web.keymap.set_mode","web.keymap.get_mode","web.view.close","web.view.create","web.view.current","web.view.list","web.view.select","web.view.set_url","web.view.set_html","web.view.run_js","web.view.reload","web.view.expose","web.view.open_devtools","web.view.current_index","web.event.add_listener","set","get","WebOpts","opts","web.history.back","web.history.forward","web.search.set_text","web.search.reset","web.search.get_text","web.search.next","web.search.previous","web.view.scroll","web.view.scroll_to_top","web.view.scroll_to_bottom","web.help.get_items","web.help.show","uv","inspect","web.utils.string_trim","web.utils.table_merge","web.utils.table_keys","web.utils.equals","web.utils.table_contains"] \ No newline at end of file diff --git a/flake.nix b/flake.nix index 95c7cb7..8125465 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ lua-libluv = pkgs.callPackage (import ./nix/libluv.nix) { inherit (myPkgs) libuv luajit; }; - # dkjson = pkgs.luajitPackages.dkjson; + dkjson = pkgs.luajitPackages.dkjson; luassert = pkgs.luajitPackages.luassert; # lua-busted = pkgs.luajitPackages.busted; }; @@ -28,7 +28,7 @@ luajit libuv lua-libluv - # dkjson + dkjson luassert # lua-busted diff --git a/lua/null-browser/api.lua b/lua/null-browser/api.lua index 4da1124..e06691e 100644 --- a/lua/null-browser/api.lua +++ b/lua/null-browser/api.lua @@ -362,7 +362,7 @@ web.decorations.right = create_decoration_api('right') --- Get a list of items for help function web.help.get_items() -- TODO: Use proper path from build - local file, _ = io.open('./doc/symbols.json', 'r') + local file, _ = io.open('./docs/api/symbols.json', 'r') if file then local contents, _ = file:read('a') return web.json.decode(contents) -- cgit v1.3.1