Skip to main content

core

Core functionality.

local core = require "core"

active_file_dialogs​

(field) active_file_dialogs: table

active_view​

(field) active_view: any

background_threads​

(field) background_threads: integer

(field) blink_start: number|unknown

(field) blink_timer: number|unknown

clip_rect_stack​

(field) clip_rect_stack: table

co_max_time​

(field) co_max_time: number

The maximum time coroutines have to run on a per frame iteration basis. This value is automatically updated on each core.step().


collect_garbage​

(field) collect_garbage: boolean

command_view​

(field) command_view: core.commandview

Command palette and input prompt view. Provides autocomplete, suggestions, and command execution interface.


cursor_change_req​

(field) cursor_change_req: any

cursor_clipboard​

(field) cursor_clipboard: table

cursor_clipboard_whole_line​

(field) cursor_clipboard_whole_line: table

docs​

(field) docs: table

exit_status​

(field) exit_status: integer

The process exit status used when the application quits.


fps​

(field) fps: number

The actual maximum frames per second that can be rendered.


frame_start​

(field) frame_start: number|unknown

init_working_dir​

(field) init_working_dir: string

last_active_view​

(field) last_active_view: any

log_items​

(field) log_items: table

log functions depend on config so initialize after loading config


nag_view​

(field) nag_view: core.nagview

Modal dialog view for confirmations and alerts. Displays a message with buttons, dims the background, and captures focus. Multiple dialogs queue automatically.


next_active_view​

(field) next_active_view: any

plugin_list​

(field) plugin_list: table

prev_window_mode​

(field) prev_window_mode: string|"fullscreen"|"maximized"|"minimized"|"normal"

previous_find​

(field) previous_find: table

previous_replace​

(field) previous_replace: table

project_module_loaded​

(field) project_module_loaded: boolean

projects​

(field) projects: table

quit_request​

(field) quit_request: boolean

recent_projects​

(field) recent_projects: table

redraw​

(field) redraw: boolean

restart_request​

(field) restart_request: boolean

root_view​

(field) root_view: core.rootview

We load core views before plugins that may need them.


status_view​

(field) status_view: core.statusview

Status bar with customizable items displaying document info and system status. Access the global instance via core.status_view.


threads​

(field) threads: table

title_view​

(field) title_view: core.titleview

trusted_projects​

(field) trusted_projects: table

visited_files​

(field) visited_files: table

window​

(field) window: renwindow

Functionality to create and manage windows.


window_mode​

(field) window_mode: string|"fullscreen"|"maximized"|"minimized"|"normal"

window_size​

(field) window_size: table

window_title​

(field) window_title: string

core.ignore_file_rule​

A pre-processed config.ignore_files entry.

match_dir​

(field) match_dir: boolean

Match directories only.


pattern​

(field) pattern: string

A lua pattern.


use_path​

(field) use_path: boolean

Match a full path including path separators, otherwise match filename only.


add_background_thread​

function core.add_background_thread(f: any, weak_ref: any, ...any)
-> unknown

add_plugins​

function core.add_plugins(plugins: any)

Can be called from within plugins; don't insert things lower than your own priority.


add_project​

function core.add_project(project: any)
-> unknown

add_thread​

function core.add_thread(f: any, weak_ref: any, ...any)
-> unknown

function core.blink_reset()

compose_window_title​

function core.compose_window_title(title: any)
-> string

configure_borderless_window​

function core.configure_borderless_window()

confirm_close_docs​

function core.confirm_close_docs(docs: any, close_fn: any, ...any)

current_project​

function core.current_project(filename?: string)
-> project: (core.project)?
2. is_open: boolean
3. belongs: boolean

Get project for currently opened DocView or given filename path. If the given path does not belongs to any of the opened projects a new project object will be created and returned using the directory of the given filename path.

@return project: (core.project)?

@return is_open: boolean — The returned project is open

@return belongs: boolean — The file belongs to the returned project


custom_log​

function core.custom_log(level: any, show: any, backtrace: any, fmt: any, ...any)
-> table

delete_temp_files​

function core.delete_temp_files(dir: any)

deprecation_log​

function core.deprecation_log(kind: string)

Show deprecation notice once per kind.


ensure_user_directory​

function core.ensure_user_directory()
-> boolean
2. unknown

error​

function core.error(...any)
-> table

exit​

function core.exit(quit_fn: any, force: any)

get_ignore_file_rules​

function core.get_ignore_file_rules()
-> core.ignore_file_rule[]

Gets a list of pre-processed config.ignore_files patterns for usage in combination of common.match_ignore_rule()

@return: core.ignore_file_rule[]


get_log​

function core.get_log(i: any)
-> string

get_plugin_details​

function core.get_plugin_details(path: string)
-> boolean|table|nil

get_view_title​

function core.get_view_title(view: any)
-> string

get_views_referencing_doc​

function core.get_views_referencing_doc(doc: any)
-> table

init​

function core.init()

is_project_trusted​

function core.is_project_trusted(project: any)
-> boolean

load_plugins​

function core.load_plugins()
-> boolean
2. table

log​

function core.log(...any)
-> table

log_quiet​

function core.log_quiet(...any)
-> table

normalize_to_project_dir​

function core.normalize_to_project_dir(path: any)

on_error​

function core.on_error(err: any)

on_event​

function core.on_event(type: any, ...any)
-> boolean

open_audio​

function core.open_audio(path?: string)
-> core.audioview

Open the audio player, optionally scanning a directory or playing a file. Reuses the existing player tab. An empty path skips the default directory.

@return: core.audioview


open_directory_dialog​

function core.open_directory_dialog(window: renwindow, callback: fun(status: "accept"|"cancel"|"error"|"unknown", result: string|string[]|nil), options?: system.dialogoptions.opendirectory)

Open the system directory picker.

Returns immediately. The callback will be called with the result.

@param window: renwindow — Functionality to create and manage windows.

@param options?: system.dialogoptions.opendirectory


open_doc​

function core.open_doc(filename: any)
-> unknown

open_file​

function core.open_file(filename: string)
-> core.audioview|core.docview|core.imageview

Opens the given file path in the root view. Supported images and audio open in their respective views; other files open as text. Media files are never read into a document before dispatching.

@param filename: string — Path to the file to open

@return: core.audioview|core.docview|core.imageview


open_file_dialog​

function core.open_file_dialog(window: renwindow, callback: fun(status: "accept"|"cancel"|"error"|"unknown", result: string|string[]|nil), options?: system.dialogoptions.openfile)

Open the system file picker.

Returns immediately. The callback will be called with the result.

@param window: renwindow — Functionality to create and manage windows.

@param options?: system.dialogoptions.openfile


open_image​

function core.open_image(filename: string)
-> image_view: (core.imageview)?

@return image_view: (core.imageview)?


open_markdown​

function core.open_markdown(filename: string)
-> markdown_view: (core.markdownview)?

@return markdown_view: (core.markdownview)?


open_project​

function core.open_project(project: any)

parse_plugin_details​

function core.parse_plugin_details(path: any, file: any, mod_version_regex: any, priority_regex: any)
-> boolean|table

pop_clip_rect​

function core.pop_clip_rect()

project_absolute_path​

function core.project_absolute_path(path: any)

prompt_project_trust​

function core.prompt_project_trust(project: any, options: any, callback: any)
-> boolean

push_clip_rect​

function core.push_clip_rect(x: any, y: any, w: any, h: any)

quit​

function core.quit(force: any, exit_code: any)

reload_absolute_module​

function core.reload_absolute_module(filename: any)
-> boolean
2. unknown|nil

reload_module​

function core.reload_module(name: any)

remove_project​

function core.remove_project(project: any, force: any)
-> boolean|unknown

request_cursor​

function core.request_cursor(value: any)

restart​

function core.restart()

root_project​

function core.root_project()
-> unknown

legacy interface


run​

function core.run()

Set up the run-loop state. Called once from C (SDL_AppInit → init_lua_state) via the init_code that also calls core.init(). SDL_AppIterate then drives the loop by calling core.run_step() on every frame.


run_step​

function core.run_step()
-> true: boolean

Execute one frame of the main loop.

Called by C's SDL_AppIterate on every frame.

@return true: boolean — to keep running, false to quit or restart.


save_file_dialog​

function core.save_file_dialog(window: renwindow, callback: fun(status: "accept"|"cancel"|"error"|"unknown", result: string|string[]|nil), options?: system.dialogoptions.savefile)

Open the system save file picker.

Returns immediately. The callback will be called with the result.

@param window: renwindow — Functionality to create and manage windows.

@param options?: system.dialogoptions.savefile


set_active_view​

function core.set_active_view(view: any)

set_project​

function core.set_project(project: any)
-> unknown

set_visited​

function core.set_visited(filename: any)

show_title_bar​

function core.show_title_bar(show: any)

step​

function core.step(next_frame_time: any)
-> boolean

temp_filename​

function core.temp_filename(ext: any, dir: any)
-> unknown

trust_project​

function core.trust_project(project: any)
-> boolean|string

try​

function core.try(fn: any, ...any)
-> boolean
2. unknown

update_window_state​

function core.update_window_state()
-> "fullscreen"|"maximized"|"minimized"|"normal"

Refresh the native mode without losing the windowed restore state.

return #1:
| "normal"
| "minimized"
| "maximized"
| "fullscreen"

warn​

function core.warn(...any)
-> table

write_init_project_module​

function core.write_init_project_module(init_filename: any)