2021-06-25 08:25:05 +02:00
|
|
|
---@meta
|
|
|
|
|
|
|
|
---
|
|
|
|
---Utilites for managing current window, files and more.
|
|
|
|
---@class system
|
|
|
|
system = {}
|
|
|
|
|
2021-06-30 09:02:01 +02:00
|
|
|
---@alias system.fileinfotype
|
2022-11-30 06:11:13 +01:00
|
|
|
---| "file" # It is a file.
|
|
|
|
---| "dir" # It is a directory.
|
2021-06-25 08:25:05 +02:00
|
|
|
|
|
|
|
---
|
2021-06-30 09:02:01 +02:00
|
|
|
---@class system.fileinfo
|
2021-06-25 08:25:05 +02:00
|
|
|
---@field public modified number A timestamp in seconds.
|
|
|
|
---@field public size number Size in bytes.
|
2021-06-30 09:02:01 +02:00
|
|
|
---@field public type system.fileinfotype Type of file
|
2022-11-24 04:38:06 +01:00
|
|
|
---@field public symlink boolean The directory is a symlink. This field is only set on Linux and on directories.
|
2021-06-25 08:25:05 +02:00
|
|
|
|
|
|
|
---
|
|
|
|
---Core function used to retrieve the current event been triggered by SDL.
|
|
|
|
---
|
|
|
|
---The following is a list of event types emitted by this function and
|
|
|
|
---the arguments for each of them if applicable.
|
|
|
|
---
|
|
|
|
---Window events:
|
|
|
|
--- * "quit"
|
2022-11-24 04:38:06 +01:00
|
|
|
--- * "resized" -> width, height (in points)
|
2021-06-25 08:25:05 +02:00
|
|
|
--- * "exposed"
|
|
|
|
--- * "minimized"
|
|
|
|
--- * "maximized"
|
|
|
|
--- * "restored"
|
|
|
|
--- * "focuslost"
|
|
|
|
---
|
|
|
|
---File events:
|
|
|
|
--- * "filedropped" -> filename, x, y
|
|
|
|
---
|
|
|
|
---Keyboard events:
|
|
|
|
--- * "keypressed" -> key_name
|
|
|
|
--- * "keyreleased" -> key_name
|
|
|
|
--- * "textinput" -> text
|
2022-11-24 04:38:06 +01:00
|
|
|
--- * "textediting" -> text, start, length
|
2021-06-25 08:25:05 +02:00
|
|
|
---
|
|
|
|
---Mouse events:
|
|
|
|
--- * "mousepressed" -> button_name, x, y, amount_of_clicks
|
|
|
|
--- * "mousereleased" -> button_name, x, y
|
|
|
|
--- * "mousemoved" -> x, y, relative_x, relative_y
|
2022-11-24 04:38:06 +01:00
|
|
|
--- * "mousewheel" -> y, x
|
2021-06-25 08:25:05 +02:00
|
|
|
---
|
2022-12-20 09:30:58 +01:00
|
|
|
---Touch events:
|
|
|
|
--- * "touchpressed" -> x, y, finger_id
|
|
|
|
--- * "touchreleased" -> x, y, finger_id
|
|
|
|
--- * "touchmoved" -> x, y, distance_x, distance_y, finger_id
|
|
|
|
---
|
2021-06-25 08:25:05 +02:00
|
|
|
---@return string type
|
|
|
|
---@return any? arg1
|
|
|
|
---@return any? arg2
|
|
|
|
---@return any? arg3
|
|
|
|
---@return any? arg4
|
|
|
|
function system.poll_event() end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Wait until an event is triggered.
|
|
|
|
---
|
|
|
|
---@param timeout number Amount of seconds, also supports fractions
|
|
|
|
---of a second, eg: 0.01
|
|
|
|
---
|
|
|
|
---@return boolean status True on success or false if there was an error.
|
|
|
|
function system.wait_event(timeout) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Change the cursor type displayed on screen.
|
|
|
|
---
|
2022-11-30 06:11:13 +01:00
|
|
|
---@param type string | "arrow" | "ibeam" | "sizeh" | "sizev" | "hand"
|
2021-06-25 08:25:05 +02:00
|
|
|
function system.set_cursor(type) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Change the window title.
|
|
|
|
---
|
|
|
|
---@param title string
|
|
|
|
function system.set_window_title(title) end
|
|
|
|
|
2021-06-30 09:02:01 +02:00
|
|
|
---@alias system.windowmode
|
2022-11-30 06:11:13 +01:00
|
|
|
---| "normal"
|
|
|
|
---| "minimized"
|
|
|
|
---| "maximized"
|
|
|
|
---| "fullscreen"
|
2021-06-25 08:25:05 +02:00
|
|
|
|
|
|
|
---
|
|
|
|
---Change the window mode.
|
|
|
|
---
|
2021-06-30 09:02:01 +02:00
|
|
|
---@param mode system.windowmode
|
2021-06-25 08:25:05 +02:00
|
|
|
function system.set_window_mode(mode) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Retrieve the current window mode.
|
|
|
|
---
|
2021-06-30 09:02:01 +02:00
|
|
|
---@return system.windowmode mode
|
2021-06-25 08:25:05 +02:00
|
|
|
function system.get_window_mode() end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Toggle between bordered and borderless.
|
|
|
|
---
|
|
|
|
---@param bordered boolean
|
|
|
|
function system.set_window_bordered(bordered) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---When then window is run borderless (without system decorations), this
|
|
|
|
---function allows to set the size of the different regions that allow
|
|
|
|
---for custom window management.
|
|
|
|
---
|
|
|
|
---@param title_height number
|
2022-11-24 04:38:06 +01:00
|
|
|
---@param controls_width number Width of window controls (maximize,minimize and close buttons, etc).
|
2021-06-25 08:25:05 +02:00
|
|
|
---@param resize_border number The amount of pixels reserved for resizing
|
|
|
|
function system.set_window_hit_test(title_height, controls_width, resize_border) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Get the size and coordinates of the window.
|
|
|
|
---
|
|
|
|
---@return number width
|
|
|
|
---@return number height
|
|
|
|
---@return number x
|
|
|
|
---@return number y
|
|
|
|
function system.get_window_size() end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Sets the size and coordinates of the window.
|
|
|
|
---
|
|
|
|
---@param width number
|
|
|
|
---@param height number
|
|
|
|
---@param x number
|
|
|
|
---@param y number
|
|
|
|
function system.set_window_size(width, height, x, y) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Check if the window currently has focus.
|
|
|
|
---
|
|
|
|
---@return boolean
|
|
|
|
function system.window_has_focus() end
|
|
|
|
|
2022-11-24 04:38:06 +01:00
|
|
|
---
|
|
|
|
---Gets the mode of the window.
|
|
|
|
---
|
|
|
|
---@return system.windowmode
|
|
|
|
function system.get_window_mode() end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Sets the position of the IME composition window.
|
|
|
|
---
|
|
|
|
---@param x number
|
|
|
|
---@param y number
|
|
|
|
---@param width number
|
|
|
|
---@param height number
|
|
|
|
function system.set_text_input_rect(x, y, width, height) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Clears any ongoing composition on the IME
|
|
|
|
function system.clear_ime() end
|
|
|
|
|
2022-09-29 17:31:55 +02:00
|
|
|
---
|
|
|
|
---Raise the main window and give it input focus.
|
|
|
|
---Note: may not always be obeyed by the users window manager.
|
|
|
|
function system.raise_window() end
|
|
|
|
|
2021-06-25 08:25:05 +02:00
|
|
|
---
|
|
|
|
---Opens a message box to display an error message.
|
|
|
|
---
|
|
|
|
---@param title string
|
|
|
|
---@param message string
|
|
|
|
function system.show_fatal_error(title, message) end
|
|
|
|
|
2022-11-24 04:38:06 +01:00
|
|
|
---
|
|
|
|
---Deletes an empty directory.
|
|
|
|
---
|
|
|
|
---@param path string
|
|
|
|
---@return boolean success True if the operation suceeded, false otherwise
|
|
|
|
---@return string? message An error message if the operation failed
|
|
|
|
function system.rmdir(path) end
|
|
|
|
|
2021-06-25 08:25:05 +02:00
|
|
|
---
|
|
|
|
---Change the current directory path which affects relative file operations.
|
|
|
|
---This function raises an error if the path doesn't exists.
|
|
|
|
---
|
|
|
|
---@param path string
|
|
|
|
function system.chdir(path) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Create a new directory, note that this function doesn't recursively
|
|
|
|
---creates the directories on the given path.
|
|
|
|
---
|
|
|
|
---@param directory_path string
|
|
|
|
---
|
|
|
|
---@return boolean created True on success or false on failure.
|
2022-11-24 04:38:06 +01:00
|
|
|
---@return string? message The error message if the operation failed.
|
2021-06-25 08:25:05 +02:00
|
|
|
function system.mkdir(directory_path) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Gets a list of files and directories for a given path.
|
|
|
|
---
|
|
|
|
---@param path string
|
|
|
|
---
|
|
|
|
---@return table|nil list List of directories or nil if empty or error.
|
|
|
|
---@return string? message Error message in case of error.
|
|
|
|
function system.list_dir(path) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Converts a relative path from current directory to the absolute one.
|
|
|
|
---
|
|
|
|
---@param path string
|
|
|
|
---
|
2022-11-24 04:38:06 +01:00
|
|
|
---@return string? abspath
|
2021-06-25 08:25:05 +02:00
|
|
|
function system.absolute_path(path) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Get details about a given file or path.
|
|
|
|
---
|
|
|
|
---@param path string Can be a file or a directory path
|
|
|
|
---
|
2021-06-30 09:02:01 +02:00
|
|
|
---@return system.fileinfo|nil info Path details or nil if empty or error.
|
2021-06-25 08:25:05 +02:00
|
|
|
---@return string? message Error message in case of error.
|
|
|
|
function system.get_file_info(path) end
|
|
|
|
|
2022-11-24 04:38:06 +01:00
|
|
|
|
|
|
|
---@alias system.fstype
|
|
|
|
---| "ext2/ext3"
|
|
|
|
---| "nfs"
|
|
|
|
---| "fuse"
|
|
|
|
---| "smb"
|
|
|
|
---| "smb2"
|
|
|
|
---| "reiserfs"
|
|
|
|
---| "tmpfs"
|
|
|
|
---| "ramfs"
|
|
|
|
---| "ntfs"
|
|
|
|
|
|
|
|
---
|
|
|
|
---Gets the filesystem type of a path.
|
|
|
|
---Note: This only works on Linux.
|
|
|
|
---
|
|
|
|
---@param path string Can be path to a directory or a file
|
|
|
|
---
|
|
|
|
---@return system.fstype
|
|
|
|
function system.get_fs_type(path) end
|
|
|
|
|
|
|
|
|
2021-06-25 08:25:05 +02:00
|
|
|
---
|
|
|
|
---Retrieve the text currently stored on the clipboard.
|
|
|
|
---
|
|
|
|
---@return string
|
|
|
|
function system.get_clipboard() end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Set the content of the clipboard.
|
|
|
|
---
|
|
|
|
---@param text string
|
|
|
|
function system.set_clipboard(text) end
|
|
|
|
|
2022-02-04 20:43:42 +01:00
|
|
|
---
|
2022-11-24 04:38:06 +01:00
|
|
|
---Get the process id of lite-xl itself.
|
2022-02-04 20:43:42 +01:00
|
|
|
---
|
|
|
|
---@return integer
|
|
|
|
function system.get_process_id() end
|
|
|
|
|
2021-06-25 08:25:05 +02:00
|
|
|
---
|
|
|
|
---Get amount of iterations since the application was launched
|
|
|
|
---also known as SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency()
|
|
|
|
---
|
|
|
|
---@return number
|
|
|
|
function system.get_time() end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Sleep for the given amount of seconds.
|
|
|
|
---
|
|
|
|
---@param seconds number Also supports fractions of a second, eg: 0.01
|
|
|
|
function system.sleep(seconds) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Similar to os.execute() but does not return the exit status of the
|
|
|
|
---executed command and executes the process in a non blocking way by
|
|
|
|
---forking it to the background.
|
2022-11-24 04:38:06 +01:00
|
|
|
---Note: Do not use this function, use the Process API instead.
|
2021-06-25 08:25:05 +02:00
|
|
|
---
|
2022-11-24 04:38:06 +01:00
|
|
|
---@deprecated
|
2021-06-25 08:25:05 +02:00
|
|
|
---@param command string The command to execute.
|
|
|
|
function system.exec(command) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Generates a matching score depending on how well the value of the
|
|
|
|
---given needle compares to that of the value in the haystack.
|
|
|
|
---
|
|
|
|
---@param haystack string
|
|
|
|
---@param needle string
|
|
|
|
---@param file boolean Reverse the algorithm to prioritize the end
|
|
|
|
---of the haystack, eg: with a haystack "/my/path/to/file" and a needle
|
|
|
|
---"file", will get better score than with this option not set to true.
|
|
|
|
---
|
|
|
|
---@return integer score
|
|
|
|
function system.fuzzy_match(haystack, needle, file) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Change the opacity (also known as transparency) of the window.
|
|
|
|
---
|
|
|
|
---@param opacity number A value from 0.0 to 1.0, the lower the value
|
|
|
|
---the less visible the window will be.
|
2022-11-24 04:38:06 +01:00
|
|
|
---@return boolean success True if the operation suceeded.
|
2021-06-25 08:25:05 +02:00
|
|
|
function system.set_window_opacity(opacity) end
|
2022-11-24 04:38:06 +01:00
|
|
|
|
|
|
|
---
|
|
|
|
---Loads a lua native module using the default Lua API or lite-xl native plugin API.
|
|
|
|
---Note: Never use this function directly.
|
|
|
|
---
|
|
|
|
---@param name string the name of the module
|
|
|
|
---@param path string the path to the shared library file
|
|
|
|
---@return number nargs the return value of the entrypoint
|
|
|
|
function system.load_native_plugin(name, path) end
|
|
|
|
|
|
|
|
---
|
|
|
|
---Compares two paths in the order used by TreeView.
|
|
|
|
---
|
|
|
|
---@param path1 string
|
|
|
|
---@param path2 string
|
|
|
|
---@return boolean compare_result True if path1 < path2
|
2022-11-30 06:11:13 +01:00
|
|
|
function system.path_compare(path1, path2) end
|
|
|
|
|
|
|
|
|
|
|
|
return system
|