Module guih.main_ui

The gui object itself and its manipulation functions

Functions

update (timeout[, visible[, is_child[, data[, block_logic[, block_graphic]]]]]) Internal function used for updating the gui.
log:dump () processes and saves the current log into the GuiH/log.log file
log (message, log_type) logs a message into the GuiH/log.log file
key.held (...) checks for held keys can have any amount of keys inputed for keybindings
async (f[, delay[, error_flag[, debug]]]) schedules a new asynchronous task in the background
schedule (f, delay, error_flag, debug) Alias for main_ui.async
add_listener (filter, f[, name[, debug]]) Makes a new event listener with a custom filter
cause_exeption (err) causes an error stopping the gui
error (err) Alias for main_ui.cause_exeption
is_held (...) Alias for main_ui.key.held
execute ([runtime[, on_event[, before_draw[, after_draw]]]]) This is the main function that you will use to run your application it provides you with 4 functions that it will run as it goes
run (runtime, on_event, before_draw, after_draw) Alias for main_ui.execute()
clear (debug) removes all elements form the gui
load_texture (path) loads a basic .nimg texture or can be used to make texture improters
load_ppm_texture (path) loads a .ppm texture such a texture can be exported from gimp in the raw mode and be displayed ingame
load_cimg_texture (path) loads a .cimg texture .cimg is a space inneficient format made by compec
load_limg_texture (path) loads a .limg texture limg is a format made by Leveloper the developer of LevelOS this loads the first frame in the image file and gives it to you
load_blbfor_texture (path) loads a .bbf texture blbfor aka Blit Byte Format is a compact format developed by me (9551Dev) this loads the first frame in the image file and gives it to you
load_limg_animation (path) loads a .limg texture limg is a format made by Leveloper the developer of LevelOS this loads the entire animation and returns a table with all the frames
load_blbfor_animation (path) loads a .bbf texture blbfor aka Blit Byte Format is a compact format developed by me (9551Dev) this loads the entire animation and returns a table with all the frames
set_event_offset ([horizontal[, vertical]]) Used for calibrating the gui by setting the event offset this doesnt have to be used most of the time as the gui has a build in calibration
get_blit (line, start_x, end_x) allows getting blit data from the screen in a line between 2 points
getSize () returns the width and size of the gui
calibrate () recalibrates to gui to the current window position
text (OBJECT_PROPERTIES) Used for making primite text objects that can then be inputed into more advanced objects these are also objects and you can set their properties.
stop () stops the gui execution
kill () kills the currently running gui instance
async_task.kill () kills the given thread
async_task.alive () checks if the thread is alive
async_task.update (...) Resumes the current thread no matter if paused or not with inputed event
async_task.step (...) Alias for async_task.update()
async_task.pause () pauses the currently running thread
async_task.resume () resumes a currently paused thread
async_task.get_error () returns the error that happened on this thread if any happened
async_task.set_running (state, debug) sets the current thread to state depending on a boolean value
event_listener.kill () kills the current event listener
event_listener.pause () pauses the currently running event listener
event_listener.resume () resumes the currently paused event listener

Tables

term_object The window this gui is attached to
term Alias for main_ui.term_object
elements list of all the elements in the current gui following format main_ui.elements..
gui Alias for main_ui.elements
task_routine a list of all currently running asynchronous tasks indexed by an uuid4
paused_task_routine a list of all currently pasued asynchronous tasks indexed by an uuid4
held_keys a lookup table of all currently held keys (used internally)
event_listeners list of all currently active event listeners
paused_listeners list of all currently paused event listeners
texture_cache a list of already drawn textures used to accelerate redrawing to the same positions masively the table folors this format cache[texture.id] = {tex_data,args={last_draw_arguments}} note that every texture has only 1 place in memory.
new table with all the functions for creating new objects in the UI for reference of what Properites what object needs and what objects are avaible visit objects
create Alias for main_ui.new
api Alias for guih.apis
preset Alias for GuiH.presets
text_object_properties a list of values for creating a primitive text object

Fields

visible sets if the current gui should be visible
id special uuid4 identifier for this gui
update_delay the rate the UI should update the grahics at.
log.error Error Log type used by the main_ui.log function
log.warn Warn Log type used by the main_ui.log function
log.fatal Fatal Log type used by the main_ui.log function
log.success Success Log type used by the main_ui.log function
log.message Message Log type used by the main_ui.log function
log.update Update Log type used by the main_ui.log function
log.info Info Log type used by the main_ui.log function
width the current width of the gui terminal object
height the current height of the gui terminal object
w alias for main_ui.width
h alias for main_ui.height
background the background color for this gui object.
cls sets if the gui should be cleared every frame.
debug Enables all additional debug logs to be shown which is useful for debbugging
event_offset_x horizontal offset of all events used for calibration of the gui
event_offset_y vertical offset of all events used for calibration of the gui
last_error the last error that gui.execute has caught
monitor the type of terminal or a monitor used by the gui if gui is made on an terminal it will be term_object if its on a monitor it will be the monitors name


Functions

update (timeout[, visible[, is_child[, data[, block_logic[, block_graphic]]]]])
Internal function used for updating the gui. I do no reccomend touching this

Parameters:

  • timeout number
  • visible boolean (optional)
  • is_child boolean (optional)
  • data table data passed from the previous run. used for reccursive updating of child objects (optional)
  • block_logic boolean sets if the updater should update the states of elements (optional)
  • block_graphic boolean sets if the updater should update the graphics on the screen (optional)
log:dump ()
processes and saves the current log into the GuiH/log.log file

Returns:

    table resulting log
log (message, log_type)
logs a message into the GuiH/log.log file

Parameters:

  • message string message to get written into the log file
  • log_type number type to use. these can be got by doing main_ui.log. (ex. error)
key.held (...)
checks for held keys can have any amount of keys inputed for keybindings

Parameters:

  • ... number keys to check for

Returns:

  1. boolean are_pressed returns true if all the current keys are pressed down
  2. boolean are_held returns true if all the keys have been pressed down for at least 1 second
async (f[, delay[, error_flag[, debug]]])
schedules a new asynchronous task in the background

Parameters:

  • f function the function to run asynchronously
  • delay number the amount of time in seconds to wait before starting up this task (optional)
  • error_flag boolean should an exeption happen if this task errors (optional)
  • debug boolean enables useful things like error and state logging (optional)

Returns:

    guih.SCHEDULED_THREAD bunch of functions you can use to pause/kill/revive and manipulate this thread
schedule (f, delay, error_flag, debug)
Alias for main_ui.async

Parameters:

  • f
  • delay
  • error_flag
  • debug

See also:

add_listener (filter, f[, name[, debug]])
Makes a new event listener with a custom filter

Parameters:

  • filter string/table the filter used for this event listener
  • f function function triggered by the event_listener
  • name allows you to select a custom name for the listener (optional)
  • debug boolean enables a bunch of logs that might be useful (optional)

Returns:

    guih.EVENT_LISTENER bunch of useful functions you can use to pause/kill/revive and manipulate this listener
cause_exeption (err)
causes an error stopping the gui

Parameters:

  • err string the error to cause
error (err)
Alias for main_ui.cause_exeption

Parameters:

  • err

See also:

is_held (...)
Alias for main_ui.key.held

Parameters:

  • ...

See also:

execute ([runtime[, on_event[, before_draw[, after_draw]]]])
This is the main function that you will use to run your application it provides you with 4 functions that it will run as it goes

Parameters:

  • runtime function as long as this function runs the gui will run too. you can use it to add custom code to your gui wihnout using scripts but putting it in the main loop itself (optional)
  • on_event function this function gets ran when an event happens that updates the gui. it gets passed the GUI_WINDOW,EVENT (optional)
  • before_draw function this function gets called before the gui gets drawn so you can use it for some update code. it gets passed only the GUI_WINDOW (optional)
  • after_draw function this function gets called after the gui gets drawn so you can use it to overlay your own things on top of the gui (optional)

Returns:

    string the error that caused the gui to stop. you can use error(main_ui.execute(),0) to get normal error messages
run (runtime, on_event, before_draw, after_draw)
Alias for main_ui.execute()

Parameters:

  • runtime
  • on_event
  • before_draw
  • after_draw

See also:

clear (debug)
removes all elements form the gui

Parameters:

  • debug boolean
load_texture (path)
loads a basic .nimg texture or can be used to make texture improters

Parameters:

  • path

See also:

load_ppm_texture (path)
loads a .ppm texture such a texture can be exported from gimp in the raw mode and be displayed ingame

Parameters:

  • path string the path to the image file

Returns:

    guih.texture the loaded texture
load_cimg_texture (path)
loads a .cimg texture .cimg is a space inneficient format made by compec

Parameters:

  • path string the path to the image file

Returns:

    guih.texture the loaded texture
load_limg_texture (path)
loads a .limg texture limg is a format made by Leveloper the developer of LevelOS this loads the first frame in the image file and gives it to you

Parameters:

  • path string the path to the image file

Returns:

  1. guih.texture the loaded texture
  2. guih.texture_array all of the images in the file put in a table
load_blbfor_texture (path)
loads a .bbf texture blbfor aka Blit Byte Format is a compact format developed by me (9551Dev) this loads the first frame in the image file and gives it to you

Parameters:

  • path string the path to the image file

Returns:

  1. guih.texture the loaded texture
  2. guih.texture_array all of the images in the file put in a table
load_limg_animation (path)
loads a .limg texture limg is a format made by Leveloper the developer of LevelOS this loads the entire animation and returns a table with all the frames

Parameters:

  • path string the path to the image file

Returns:

    guih.texture_array
load_blbfor_animation (path)
loads a .bbf texture blbfor aka Blit Byte Format is a compact format developed by me (9551Dev) this loads the entire animation and returns a table with all the frames

Parameters:

  • path string the path to the image file

Returns:

    guih.texture_array
set_event_offset ([horizontal[, vertical]])
Used for calibrating the gui by setting the event offset this doesnt have to be used most of the time as the gui has a build in calibration

Parameters:

  • horizontal number the x axis offset (optional)
  • vertical number the y axis offset (optional)
get_blit (line, start_x, end_x)
allows getting blit data from the screen in a line between 2 points

Parameters:

  • line number the line to get the blit data on
  • start_x number the x to start getting the blit from
  • end_x number the x to stop getting the blit from

Returns:

  1. string characters
  2. string text color
  3. string background color
getSize ()
returns the width and size of the gui

Returns:

  1. number the width of the gui
  2. number the height of the gui
calibrate ()
recalibrates to gui to the current window position
text (OBJECT_PROPERTIES)
Used for making primite text objects that can then be inputed into more advanced objects these are also objects and you can set their properties. which you can find at primitive.object.text.properties

Parameters:

  • OBJECT_PROPERTIES table the properties to create text with

Returns:

    guih.primitive.text

See also:

stop ()
stops the gui execution
kill ()
kills the currently running gui instance
async_task.kill ()
kills the given thread

Returns:

    boolean true/nil returns true of successful
async_task.alive ()
checks if the thread is alive

Returns:

    boolean the state of the thread
async_task.update (...)
Resumes the current thread no matter if paused or not with inputed event

Parameters:

  • ... Event data. the same as with os.queueEvent(...)

Returns:

  1. boolean was the task updated successfuly
  2. boolean was the thread resumed correctly
  3. string possible error if the thread died on the resume (in that case the second return will be false)
async_task.step (...)
Alias for async_task.update()

Parameters:

  • ...

See also:

async_task.pause ()
pauses the currently running thread

Returns:

    boolean was the task paused successfuly
async_task.resume ()
resumes a currently paused thread

Returns:

    boolean was the task resumed successfuly
async_task.get_error ()
returns the error that happened on this thread if any happened

Returns:

    string error message
async_task.set_running (state, debug)
sets the current thread to state depending on a boolean value

Parameters:

  • state boolean selects if you want to pause or resume the current thread
  • debug boolean enables bunch of logs useful for debugging purposes
event_listener.kill ()
kills the current event listener
event_listener.pause ()
pauses the currently running event listener
event_listener.resume ()
resumes the currently paused event listener

Tables

term_object
The window this gui is attached to
term
Alias for main_ui.term_object

See also:

elements
list of all the elements in the current gui following format main_ui.elements..
gui
Alias for main_ui.elements

See also:

task_routine
a list of all currently running asynchronous tasks indexed by an uuid4
paused_task_routine
a list of all currently pasued asynchronous tasks indexed by an uuid4
held_keys
a lookup table of all currently held keys (used internally)
event_listeners
list of all currently active event listeners
paused_listeners
list of all currently paused event listeners
texture_cache
a list of already drawn textures used to accelerate redrawing to the same positions masively the table folors this format cache[texture.id] = {tex_data,args={last_draw_arguments}} note that every texture has only 1 place in memory.
new
table with all the functions for creating new objects in the UI for reference of what Properites what object needs and what objects are avaible visit objects

See also:

create
Alias for main_ui.new

See also:

api
Alias for guih.apis

See also:

preset
Alias for GuiH.presets

See also:

text_object_properties
a list of values for creating a primitive text object

Fields:

  • text the text this object will represted
  • x the x positions to draw the text at (optional)
  • y the y positions to draw the text at (optional)
  • centered should the text be centered (default in the middle of the entire screen) (optional)
  • offset_x the x offset to draw the text at (optional)
  • offset_y the y offset to draw the text at (optional)
  • blit the blit data to draw the text with (optional)
  • transparent should the text have transparent background (default false) (optional)
  • bg the background color to draw the text with (optional)
  • fg the foreground color to draw the text with (optional)
  • width the width to center the text between. can be used to centering text within a box. default is fullscreen (optional)
  • height the height to center the text between. can be used to centering text within a box. default is fullscreen (optional)

Fields

visible
sets if the current gui should be visible
id
special uuid4 identifier for this gui
update_delay
the rate the UI should update the grahics at. default: 0.05
log.error
Error Log type used by the main_ui.log function

See also:

log.warn
Warn Log type used by the main_ui.log function

See also:

log.fatal
Fatal Log type used by the main_ui.log function

See also:

log.success
Success Log type used by the main_ui.log function

See also:

log.message
Message Log type used by the main_ui.log function

See also:

log.update
Update Log type used by the main_ui.log function

See also:

log.info
Info Log type used by the main_ui.log function

See also:

width
the current width of the gui terminal object
height
the current height of the gui terminal object
w
alias for main_ui.width

See also:

h
alias for main_ui.height

See also:

background
the background color for this gui object. used for clearing when updating the gui defaults to the current terminal color or black
cls
sets if the gui should be cleared every frame. this is already done for the main gui no matter the value this value only makes effect on child GUI's and their elements
debug
Enables all additional debug logs to be shown which is useful for debbugging
event_offset_x
horizontal offset of all events used for calibration of the gui
event_offset_y
vertical offset of all events used for calibration of the gui
last_error
the last error that gui.execute has caught
monitor
the type of terminal or a monitor used by the gui if gui is made on an terminal it will be term_object if its on a monitor it will be the monitors name
generated by LDoc 1.4.6 Last updated 2022-06-23 16:51:50