aboutsummaryrefslogtreecommitdiff
path: root/docs/api
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2021-06-30 03:02:01 -0400
committerjgmdev <jgmdev@gmail.com>2021-07-09 18:33:25 -0400
commit900e9d1422b9b48dcdfdf54b126f1d85f794aad8 (patch)
tree4e9f5b567ce9cf0e5b5ed5ce40b295a2bf34eabe /docs/api
parent18eee34aa9f7aa5b3018d96c2bfdc843f263a635 (diff)
downloadlite-xl-900e9d1422b9b48dcdfdf54b126f1d85f794aad8.tar.gz
lite-xl-900e9d1422b9b48dcdfdf54b126f1d85f794aad8.zip
Namespaced aliases, virtual classes and added missing returns.
Diffstat (limited to 'docs/api')
-rw-r--r--docs/api/process.lua171
-rw-r--r--docs/api/regex.lua4
-rw-r--r--docs/api/renderer.lua24
-rw-r--r--docs/api/system.lua16
4 files changed, 144 insertions, 71 deletions
diff --git a/docs/api/process.lua b/docs/api/process.lua
index 0374c0c6..abba67ae 100644
--- a/docs/api/process.lua
+++ b/docs/api/process.lua
@@ -29,7 +29,13 @@ process.ERROR_TIMEDOUT = -3
---its value is platform dependent, so the value declared on this
---interface does not represents the real one.
---@type integer
-process.ERROR_INVALID = -4
+process.ERROR_INVAL = -4
+
+---Error triggered when no memory is available to allocate the process,
+---its value is platform dependent, so the value declared on this
+---interface does not represents the real one.
+---@type integer
+process.ERROR_NOMEM = -5
---Used for the process:close_stream() method to close stdin.
---@type integer
@@ -51,32 +57,79 @@ process.WAIT_INFINITE = -1
---@type integer
process.WAIT_DEADLINE = -2
+---Used for the process.options stdin, stdout and stderr fields.
+---@type integer
+process.REDIRECT_DEFAULT = 0
+
+---Used for the process.options stdin, stdout and stderr fields.
+---@type integer
+process.REDIRECT_PIPE = 1
+
+---Used for the process.options stdin, stdout and stderr fields.
+---@type integer
+process.REDIRECT_PARENT = 2
+
+---Used for the process.options stdin, stdout and stderr fields.
+---@type integer
+process.REDIRECT_DISCARD = 3
+
+---Used for the process.options stdin, stdout and stderr fields.
+---@type integer
+process.REDIRECT_STDOUT = 4
+
+---@alias process.errortype
+---|>'process.ERROR_PIPE'
+---| 'process.ERROR_WOULDBLOCK'
+---| 'process.ERROR_TIMEDOUT'
+---| 'process.ERROR_INVAL'
+---| 'process.ERROR_NOMEM'
+
+---@alias process.streamtype
+---|>'process.STREAM_STDIN'
+---| 'process.STREAM_STDOUT'
+---| 'process.STREAM_STDERR'
+
+---@alias process.waittype
+---|>'process.WAIT_INFINITE'
+---| 'process.WAIT_DEADLINE'
+
+---@alias process.redirecttype
+---|>'process.REDIRECT_DEFAULT'
+---| 'process.REDIRECT_PIPE'
+---| 'process.REDIRECT_PARENT'
+---| 'process.REDIRECT_DISCARD'
+---| 'process.REDIRECT_STDOUT'
+
---
----Create a new process object
----
----@return process
-function process.new() end
+--- Options that can be passed to process.start()
+---@class process.options
+---@field public timeout number
+---@field public cwd string
+---@field public stdin process.redirecttype
+---@field public stdout process.redirecttype
+---@field public stderr process.redirecttype
+---@field public env table<string, string>
+process.options = {}
---
----Translates an error code into a useful text message
+---Create and start a new process
---
----@param code integer
+---@param command_and_params table First index is the command to execute
+---and subsequente elements are parameters for the command.
+---@param options process.options
---
----@return string
-function process.strerror(code) end
+---@return process | nil
+---@return string errmsg
+---@return process.errortype | integer errcode
+function process:start(command_and_params, options) end
---
----Start a process
+---Translates an error code into a useful text message
---
----@param command_and_params table First index is the command to execute
----and subsequente elements are parameters for the command.
----@param working_directory? string Path where the command will be launched.
----@param deadline? integer Maximum time in milliseconds the
----process is allowed to run on a process:wait(process.WAIT_DEADLINE) call.
+---@param code integer
---
----@return integer|boolean status Negative integer error code if could
----not start or true on success
-function process:start(command_and_params, working_directory, deadline) end
+---@return string | nil
+function process.strerror(code) end
---
---Get the process id.
@@ -85,78 +138,94 @@ function process:start(command_and_params, working_directory, deadline) end
function process:pid() end
---
+---Read from the given stream type, if the process fails with a ERROR_PIPE it is
+---automatically destroyed returning nil along error message and code.
+---
+---@param stream process.streamtype
+---@param len? integer Amount of bytes to read, defaults to 2048.
+---
+---@return string | nil
+---@return string errmsg
+---@return process.errortype | integer errcode
+function process:read(stream, len) end
+
+---
---Read from stdout, if the process fails with a ERROR_PIPE it is
----automatically destroyed, so checking process status with the
----process:running() method would be advised.
+---automatically destroyed returning nil along error message and code.
---
----@param len? integer Amount of bytes to read.
----@param tries? integer Retry reading the given amount of times
----if nothing was read.
+---@param len? integer Amount of bytes to read, defaults to 2048.
---
----@return integer|nil bytes Amount of bytes read or nil if nothing was read.
-function process:read(len, tries) end
+---@return string | nil
+---@return string errmsg
+---@return process.errortype | integer errcode
+function process:read_stdout(len) end
---
---Read from stderr, if the process fails with a ERROR_PIPE it is
----automatically destroyed, so checking process status with the
----process:running() method would be advised.
+---automatically destroyed returning nil along error message and code.
---
----@param len? integer Amount of bytes to read.
----@param tries? integer Retry reading the given amount of times
----if nothing was read.
+---@param len? integer Amount of bytes to read, defaults to 2048.
---
----@return integer|nil bytes Amount of bytes read or nil if nothing was read.
-function process:read_errors(len, tries) end
+---@return string | nil
+---@return string errmsg
+---@return process.errortype | integer errcode
+function process:read_stderr(len) end
---
---Write to the stdin, if the process fails with a ERROR_PIPE it is
----automatically destroyed, so checking process status with the
----process:running() method would be advised.
+---automatically destroyed returning nil along error message and code.
---
---@param data string
---
----@return integer bytes The amount of bytes written or negative integer
----error code: process.ERROR_PIPE, process.ERROR_WOULDBLOCK
+---@return integer | nil bytes The amount of bytes written or nil if error
+---@return string errmsg
+---@return process.errortype | integer errcode
function process:write(data) end
---
---Allows you to close a stream pipe that you will not be using.
---
----@param stream integer Could be one of the following:
----process.STREAM_STDIN, process.STREAM_STDOUT, process.STREAM_STDERR
+---@param stream process.streamtype
---
----@return integer status Negative error code process.ERROR_INVALID if
----process is not running or stream is already closed.
+---@return integer | nil
+---@return string errmsg
+---@return process.errortype | integer errcode
function process:close_stream(stream) end
---
---Wait the specified amount of time for the process to exit.
---
----@param timeout integer Time to wait in milliseconds, if 0, the function
----will only check if process is running without waiting, also the timeout
----can be set to:
---- * process.WAIT_INFINITE - will wait until the process ends
---- * process.WAIT_DEADLINE - will wait until the deadline declared on start()
+---@param timeout integer | process.waittype Time to wait in milliseconds,
+---if 0, the function will only check if process is running without waiting.
---
----@return integer exit_status The process exit status or negative integer
----error code like process.ERROR_TIMEDOUT
+---@return integer | nil exit_status The process exit status or nil on error
+---@return string errmsg
+---@return process.errortype | integer errcode
function process:wait(timeout) end
---
---Sends SIGTERM to the process
---
----@return boolean|integer status Returns true on success or a
----negative integer error code like process.ERROR_INVALID
+---@return boolean | nil
+---@return string errmsg
+---@return process.errortype | integer errcode
function process:terminate() end
---
---Sends SIGKILL to the process
---
----@return boolean|integer status Returns true on success or a
----negative integer error code like process.ERROR_INVALID
+---@return boolean | nil
+---@return string errmsg
+---@return process.errortype | integer errcode
function process:kill() end
---
+---Get the exit code of the process or nil if still running.
+---
+---@return number | nil
+function process:returncode() end
+
+---
---Check if the process is running
---
---@return boolean
diff --git a/docs/api/regex.lua b/docs/api/regex.lua
index d1d7346c..02d8c796 100644
--- a/docs/api/regex.lua
+++ b/docs/api/regex.lua
@@ -30,7 +30,7 @@ regex.NOTEMPTY = 0x00000004
---@type integer
regex.NOTEMPTY_ATSTART = 0x00000008
----@alias RegexModifiers
+---@alias regex.modifiers
---|>'"i"' # Case insesitive matching
---| '"m"' # Multiline matching
---| '"s"' # Match all characters with dot (.) metacharacter even new lines
@@ -39,7 +39,7 @@ regex.NOTEMPTY_ATSTART = 0x00000008
---Compiles a regular expression pattern that can be used to search in strings.
---
---@param pattern string
----@param options? RegexModifiers A string of one or more pattern modifiers.
+---@param options? regex.modifiers A string of one or more pattern modifiers.
---
---@return regex|string regex Ready to use regular expression object or error
---message if compiling the pattern failed.
diff --git a/docs/api/renderer.lua b/docs/api/renderer.lua
index 3a1c6036..bb622131 100644
--- a/docs/api/renderer.lua
+++ b/docs/api/renderer.lua
@@ -7,19 +7,19 @@ renderer = {}
---
---Represents a color used by the rendering functions.
----@class RendererColor
+---@class renderer.color
---@field public r number Red
---@field public g number Green
---@field public b number Blue
---@field public a number Alpha
-RendererColor = {}
+renderer.color = {}
---
---Represent options that affect a font's rendering.
----@class RendererFontOptions
+---@class renderer.fontoptions
---@field public antialiasing "'grayscale'" | "'subpixel'"
---@field public hinting "'slight'" | "'none'" | '"full"'
-RendererFontOptions = {}
+renderer.fontoptions = {}
---
---@class renderer.font
@@ -30,7 +30,7 @@ renderer.font = {}
---
---@param path string
---@param size number
----@param options RendererFontOptions
+---@param options renderer.fontoptions
---
---@return renderer.font
function renderer.font.load(path, size, options) end
@@ -149,7 +149,7 @@ function renderer.set_clip_rect(x, y, width, height) end
---@param y number
---@param width number
---@param height number
----@param color RendererColor
+---@param color renderer.color
function renderer.draw_rect(x, y, width, height, color) end
---
@@ -159,9 +159,11 @@ function renderer.draw_rect(x, y, width, height, color) end
---@param text string
---@param x number
---@param y number
----@param color RendererColor
+---@param color renderer.color
---@param replace renderer.replacements
----@param color_replace RendererColor
+---@param color_replace renderer.color
+---
+---@return number x_subpixel
function renderer.draw_text(font, text, x, y, color, replace, color_replace) end
---
@@ -171,7 +173,9 @@ function renderer.draw_text(font, text, x, y, color, replace, color_replace) end
---@param text string
---@param x number
---@param y number
----@param color RendererColor
+---@param color renderer.color
---@param replace renderer.replacements
----@param color_replace RendererColor
+---@param color_replace renderer.color
+---
+---@return number x_subpixel
function renderer.draw_text_subpixel(font, text, x, y, color, replace, color_replace) end
diff --git a/docs/api/system.lua b/docs/api/system.lua
index df0e711b..a655099b 100644
--- a/docs/api/system.lua
+++ b/docs/api/system.lua
@@ -5,16 +5,16 @@
---@class system
system = {}
----@alias FileInfoType
+---@alias system.fileinfotype
---|>'"file"' # It is a file.
---| '"dir"' # It is a directory.
---
----@class FileInfo
+---@class system.fileinfo
---@field public modified number A timestamp in seconds.
---@field public size number Size in bytes.
----@field public type FileInfoType Type of file
-FileInfo = {}
+---@field public type system.fileinfotype Type of file
+system.fileinfo = {}
---
---Core function used to retrieve the current event been triggered by SDL.
@@ -73,7 +73,7 @@ function system.set_cursor(type) end
---@param title string
function system.set_window_title(title) end
----@alias SystemWindowMode
+---@alias system.windowmode
---|>'"normal"'
---| '"minimized"'
---| '"maximized"'
@@ -82,13 +82,13 @@ function system.set_window_title(title) end
---
---Change the window mode.
---
----@param mode SystemWindowMode
+---@param mode system.windowmode
function system.set_window_mode(mode) end
---
---Retrieve the current window mode.
---
----@return SystemWindowMode mode
+---@return system.windowmode mode
function system.get_window_mode() end
---
@@ -176,7 +176,7 @@ function system.absolute_path(path) end
---
---@param path string Can be a file or a directory path
---
----@return FileInfo|nil info Path details or nil if empty or error.
+---@return system.fileinfo|nil info Path details or nil if empty or error.
---@return string? message Error message in case of error.
function system.get_file_info(path) end