Merge branch 'gh-pages' of https://github.com/Pyroxenium/Basalt2 into gh-pages

This commit is contained in:
Robert Jelic
2025-02-25 08:48:45 +01:00
38 changed files with 372 additions and 986 deletions

View File

@@ -11,6 +11,7 @@ and then applies the plugins to the elements. It also provides a way to get elem
|[ElementManager.getElementList](#ElementManager.getElementList)|table|
|[ElementManager.loadElement](#ElementManager.loadElement)|-|
## ElementManager.getAPI(name)
Gets an Plugin API by name

View File

@@ -1,5 +1,5 @@
# BaseElement : PropertySystem
The base class for all UI elements in Basalt
The base class for all UI elements in Basalt. This class provides basic properties and event handling functionality.
## Properties
@@ -14,39 +14,23 @@ The base class for all UI elements in Basalt
|Method|Returns|Description|
|---|---|---|
|[BaseElement.defineEvent](#BaseElement.defineEvent)|-|
|[BaseElement.new](#BaseElement.new)|table|Creates a new BaseElement instance
|[BaseElement.registerEventCallback](#BaseElement.registerEventCallback)|-|
|[BaseElement:destroy](#BaseElement:destroy)|-|Destroys the element and cleans up all references
|[BaseElement:dispatchEvent](#BaseElement:dispatchEvent)|boolean?|Handles all events
|[BaseElement:fireEvent](#BaseElement:fireEvent)|table|Triggers an event and calls all registered callbacks
|[BaseElement:getBaseFrame](#BaseElement:getBaseFrame)|table|Returns the base frame of the element
|[BaseElement:handleEvent](#BaseElement:handleEvent)|boolean?|The default event handler for all events
|[BaseElement:init](#BaseElement:init)|table|Initializes the BaseElement instance
|[BaseElement:isType](#BaseElement:isType)|boolean|Checks if the element is a specific type
|[BaseElement:listenEvent](#BaseElement:listenEvent)|table|Enables or disables event listening for a specific event
|[BaseElement:postInit](#BaseElement:postInit)|table|Post initialization
|[BaseElement:registerCallback](#BaseElement:registerCallback)|table|Registers a callback function
|[BaseElement:updateRender](#BaseElement:updateRender)|-|Requests a render update for this element
## BaseElement.defineEvent()
## BaseElement.new(props, basalt)
Creates a new BaseElement instance
## Protected Functions
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `table` `The` newly created BaseElement instance
### Usage
```lua
local element = BaseElement.new()
```
## BaseElement.registerEventCallback()
|Method|Returns|Description|
|---|---|---|
|[BaseElement:dispatchEvent](#BaseElement:dispatchEvent)|boolean?|Handles all events
|[BaseElement:handleEvent](#BaseElement:handleEvent)|boolean?|The default event handler for all events
|[BaseElement:init](#BaseElement:init)|table|Initializes the BaseElement instance
|[BaseElement:postInit](#BaseElement:postInit)|table|Post initialization
## BaseElement:destroy()
Destroys the element and cleans up all references
@@ -56,16 +40,6 @@ Destroys the element and cleans up all references
element:destroy()
```
## BaseElement:dispatchEvent(event...)
Handles all events
### Parameters
* `event` `string` The event to handle
* `...` *(vararg)* `any` The arguments for the event
### Returns
* `boolean?` `handled` Whether the event was handled
## BaseElement:fireEvent(event, ...)
Triggers an event and calls all registered callbacks
@@ -87,26 +61,6 @@ Returns the base frame of the element
### Returns
* `table` `BaseFrame` The base frame of the element
## BaseElement:handleEvent(event...)
The default event handler for all events
### Parameters
* `event` `string` The event to handle
* `...` *(vararg)* `any` The arguments for the event
### Returns
* `boolean?` `handled` Whether the event was handled
## BaseElement:init(props, basalt)
Initializes the BaseElement instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `table` `self` The initialized instance
## BaseElement:isType(type)
Checks if the element is a specific type
@@ -131,12 +85,6 @@ Enables or disables event listening for a specific event
element:listenEvent("mouse_click", true)
```
## BaseElement:postInit()
Post initialization
### Returns
* `table` `self` The BaseElement instance
## BaseElement:registerCallback(event, callback)
Registers a callback function for an event

View File

@@ -18,65 +18,22 @@ This is the base frame class. It is the root element of all elements and the onl
|Method|Returns|Description|
|---|---|---|
|[BaseFrame.new](#BaseFrame.new)|BaseFrame|Creates a new Frame instance
|[BaseFrame:setCursor](#BaseFrame:setCursor)|-|Sets the cursor position
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[BaseFrame:blit](#BaseFrame:blit)|-|Renders a text with a foreground and background color to the render Object
|[BaseFrame:init](#BaseFrame:init)|table|Initializes the Frame instance
|[BaseFrame:mouse_up](#BaseFrame:mouse_up)|-|
|[BaseFrame:mouse_up](#BaseFrame:mouse_up)|-|Handles mouse up events
|[BaseFrame:multiBlit](#BaseFrame:multiBlit)|-|Renders a multiBlit to the render Object
|[BaseFrame:render](#BaseFrame:render)|-|Renders the Frame
|[BaseFrame:setCursor](#BaseFrame:setCursor)|-|Sets the cursor position
|[BaseFrame:term_resize](#BaseFrame:term_resize)|-|
|[BaseFrame:term_resize](#BaseFrame:term_resize)|-|Resizes the Frame
|[BaseFrame:textBg](#BaseFrame:textBg)|-|Renders a text with a background color to the render Object
|[BaseFrame:textFg](#BaseFrame:textFg)|-|Renders a text with a foreground color to the render Object
## BaseFrame.new()
Creates a new Frame instance
### Returns
* `BaseFrame` `object` The newly created Frame instance
### Usage
```lua
local element = BaseFrame.new()
```
## BaseFrame:blit(x, y, text, fg, bg)
Renders a text with a foreground and background color to the render Object
### Parameters
* `x` `number` The x position to render to
* `y` `number` The y position to render to
* `text` `string` The text to render
* `fg` `string` The foreground color
* `bg` `string` The background color
## BaseFrame:init(props, basalt)
Initializes the Frame instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `table` `self` The initialized instance
## BaseFrame:mouse_up()
## BaseFrame:multiBlit(x, y, width, height, text, fg, bg)
Renders a multiBlit to the render Object
### Parameters
* `x` `number` The x position to render to
* `y` `number` The y position to render to
* `width` `number` The width of the text
* `height` `number` The height of the text
* `text` `string` The text to render
* `fg` `string` The foreground color
* `bg` `string` The background color
## BaseFrame:render()
Renders the Frame
## BaseFrame:setCursor(x, y, blink)
Sets the cursor position
@@ -85,24 +42,4 @@ Sets the cursor position
* `y` `number` The y position to set the cursor to
* `blink` `boolean` Whether the cursor should blink
## BaseFrame:term_resize()
## BaseFrame:textBg(x, y, text, bg)
Renders a text with a background color to the render Object
### Parameters
* `x` `number` The x position to render to
* `y` `number` The y position to render to
* `text` `string` The text to render
* `bg` `colors` The background color
## BaseFrame:textFg(x, y, text, fg)
Renders a text with a foreground color to the render Object
### Parameters
* `x` `number` The x position to render to
* `y` `number` The y position to render to
* `text` `string` The text to render
* `fg` `colors` The foreground color

View File

@@ -1,6 +1,5 @@
# Button : VisualElement
This is the button class. It is a visual element that can be clicked.
@configDescription Standard button element with click handling and state management
The Button is a standard button element with click handling and state management.
## Properties
@@ -8,33 +7,17 @@ This is the button class. It is a visual element that can be clicked.
|---|---|---|---|
|text|string|Button|Button text
## Events
|Event|Parameters|Description|
|---|---|---|
## Functions
|Method|Returns|Description|
|---|---|---|
|[Button.new](#Button.new)|table|Creates a new Button instance
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Button:init](#Button:init)|-|Initializes the Button instance
|[Button:render](#Button:render)|-|Renders the Button
## Button.new()
Creates a new Button instance
### Returns
* `table` `self` The created instance
## Button:init(props, basalt)
Initializes the Button instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
## Button:render()
Renders the Button

View File

@@ -1,5 +1,5 @@
# Checkbox : VisualElement
This is the checkbox class. It is a visual element that can be checked.
The Checkbox is a visual element that can be checked.
## Properties
@@ -12,6 +12,12 @@ This is the checkbox class. It is a visual element that can be checked.
## Functions
|Method|Returns|Description|
|---|---|---|
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Checkbox.new](#Checkbox.new)|Checkbox|Creates a new Checkbox instance
@@ -19,31 +25,4 @@ This is the checkbox class. It is a visual element that can be checked.
|[Checkbox:mouse_click](#Checkbox:mouse_click)|boolean|Handles mouse click events
|[Checkbox:render](#Checkbox:render)|-|Renders the Checkbox
## Checkbox.new()
Creates a new Checkbox instance
### Returns
* `Checkbox` `self` The created instance
## Checkbox:init(props, basalt)
Initializes the Checkbox instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
## Checkbox:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `Clicked` Whether the event was handled
## Checkbox:render()
Renders the Checkbox

View File

@@ -21,42 +21,40 @@ like Frames, BaseFrames, and more.
|Method|Returns|Description|
|---|---|---|
|[Container.new](#Container.new)|Container|Creates a new Container instance
|[Container:addChild](#Container:addChild)|Container|Adds a child to the container
|[Container:blit](#Container:blit)|Container|Draws a line of text and fg and bg as colors
|[Container:callChildrenEvents](#Container:callChildrenEvents)|-|
|[Container:char](#Container:char)|boolean|Handles char events
|[Container:callChildrenEvent](#Container:callChildrenEvent)|boolean|Calls a event on all children
|[Container:clear](#Container:clear)|Container|Clears the container
|[Container:destroy](#Container:destroy)|Container|Destroys the container and its children
|[Container:getChild](#Container:getChild)|Container?|Removes a child from the container
|[Container:handleEvent](#Container:handleEvent)|boolean|Default handler for events
|[Container:init](#Container:init)|-|Initializes the Container instance
|[Container:isChildVisible](#Container:isChildVisible)|boolean|Returns whether a child is visible
|[Container:key](#Container:key)|boolean|Handles key events
|[Container:key_up](#Container:key_up)|boolean|Handles key up events
|[Container:mouse_click](#Container:mouse_click)|boolean|Handles mouse click events
|[Container:mouse_drag](#Container:mouse_drag)|-|
|[Container:mouse_move](#Container:mouse_move)|-|
|[Container:mouse_release](#Container:mouse_release)|-|
|[Container:mouse_scroll](#Container:mouse_scroll)|-|
|[Container:mouse_up](#Container:mouse_up)|boolean|Handles mouse up events
|[Container:multiBlit](#Container:multiBlit)|Container|Draws multiple lines of text, fg and bg strings
|[Container:registerChildEvent](#Container:registerChildEvent)|Container|Registers the children events of the container
|[Container:registerChildrenEvents](#Container:registerChildrenEvents)|Container|Registers the children events of the container
|[Container:removeChild](#Container:removeChild)|Container|Removes a child from the container
|[Container:removeChildrenEvents](#Container:removeChildrenEvents)|Container|Unregisters the children events of the container
|[Container:render](#Container:render)|-|Renders the container
|[Container:sortChildren](#Container:sortChildren)|Container|Sorts the children of the container
|[Container:sortChildrenEvents](#Container:sortChildrenEvents)|Container|Sorts the children events of the container
|[Container:textBg](#Container:textBg)|Container|Draws a line of text and bg as color
|[Container:textFg](#Container:textFg)|Container|Draws a line of text and fg as color
|[Container:unregisterChildEvent](#Container:unregisterChildEvent)|Container|Unregisters the children events of the container
## Container.new()
Creates a new Container instance
### Returns
* `Container` `self` The new container instance
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Container:blit](#Container:blit)|Container|Draws a line of text and fg and bg as colors
|[Container:char](#Container:char)|boolean|Handles char events
|[Container:handleEvent](#Container:handleEvent)|boolean|Default handler for events
|[Container:init](#Container:init)|-|Initializes the Container instance
|[Container:key](#Container:key)|boolean|Handles key events
|[Container:key_up](#Container:key_up)|boolean|Handles key up events
|[Container:mouse_click](#Container:mouse_click)|boolean|Handles mouse click events
|[Container:mouse_drag](#Container:mouse_drag)|boolean|Handles mouse drag events
|[Container:mouse_move](#Container:mouse_move)|boolean|Handles mouse move events
|[Container:mouse_release](#Container:mouse_release)|-|Handles mouse release events
|[Container:mouse_scroll](#Container:mouse_scroll)|boolean|Handles mouse scroll events
|[Container:mouse_up](#Container:mouse_up)|boolean|Handles mouse up events
|[Container:multiBlit](#Container:multiBlit)|Container|Draws multiple lines of text, fg and bg strings
|[Container:render](#Container:render)|-|Renders the container
|[Container:textBg](#Container:textBg)|Container|Draws a line of text and bg as color
|[Container:textFg](#Container:textFg)|Container|Draws a line of text and fg as color
## Container:addChild(child)
Adds a child to the container
@@ -67,29 +65,17 @@ Adds a child to the container
### Returns
* `Container` `self` The container instance
## Container:blit(x, y, text, fg, bg)
Draws a line of text and fg and bg as colors, it is usually used in the render loop
## Container:callChildrenEvent(visibleOnly, event...)
Calls a event on all children
### Parameters
* `x` `number` The x position to draw the text
* `y` `number` The y position to draw the text
* `text` `string` The text to draw
* `fg` `string` The foreground color of the text
* `bg` `string` The background color of the text
### Returns
* `Container` `self` The container instance
## Container:callChildrenEvents()
## Container:char(char)
Handles char events
### Parameters
* `char` `string` The character that was pressed
* `visibleOnly` `boolean` Whether to only call the event on visible children
* `event` `string` The event to call
* `...` *(vararg)* `any` The event arguments
### Returns
* `boolean` `handled` Whether the event was handled
* `table` `child?` The child that handled the event
## Container:clear()
Clears the container
@@ -97,12 +83,6 @@ Clears the container
### Returns
* `Container` `self` The container instance
## Container:destroy()
Destroys the container and its children
### Returns
* `Container` `self` The container instance
## Container:getChild(path)
Removes a child from the container
@@ -112,23 +92,6 @@ Removes a child from the container
### Returns
* `Container?` `self` The container instance
## Container:handleEvent(event...)
Default handler for events
### Parameters
* `event` `string` The event to handle
* `...` *(vararg)* `any` The event arguments
### Returns
* `boolean` `handled` Whether the event was handled
## Container:init(props, basalt)
Initializes the Container instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
## Container:isChildVisible(child)
Returns whether a child is visible
@@ -138,69 +101,6 @@ Returns whether a child is visible
### Returns
* `boolean` `boolean` the child is visible
## Container:key(key)
Handles key events
### Parameters
* `key` `number` The key that was pressed
### Returns
* `boolean` `handled` Whether the event was handled
## Container:key_up(key)
Handles key up events
### Parameters
* `key` `number` The key that was released
### Returns
* `boolean` `handled` Whether the event was handled
## Container:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Container:mouse_drag()
## Container:mouse_move()
## Container:mouse_release()
## Container:mouse_scroll()
## Container:mouse_up(button, x, y)
Handles mouse up events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Container:multiBlit(x, y, width, height, text, fg, bg)
Draws multiple lines of text, fg and bg strings, it is usually used in the render loop
### Parameters
* `x` `number` The x position to draw the text
* `y` `number` The y position to draw the text
* `width` `number` The width of the text
* `height` `number` The height of the text
* `text` `string` The text to draw
* `fg` `string` The foreground color of the text
* `bg` `string` The background color of the text
### Returns
* `Container` `self` The container instance
## Container:registerChildEvent(child, eventName)
Registers the children events of the container
@@ -238,9 +138,6 @@ Unregisters the children events of the container
### Returns
* `Container` `self` The container instance
## Container:render()
Renders the container
## Container:sortChildren()
Sorts the children of the container
@@ -256,30 +153,6 @@ Sorts the children events of the container
### Returns
* `Container` `self` The container instance
## Container:textBg(x, y, text, bg)
Draws a line of text and bg as color, it is usually used in the render loop
### Parameters
* `x` `number` The x position to draw the text
* `y` `number` The y position to draw the text
* `text` `string` The text to draw
* `bg` `color` The background color of the text
### Returns
* `Container` `self` The container instance
## Container:textFg(x, y, text, fg)
Draws a line of text and fg as color, it is usually used in the render loop
### Parameters
* `x` `number` The x position to draw the text
* `y` `number` The y position to draw the text
* `text` `string` The text to draw
* `fg` `color` The foreground color of the text
### Returns
* `Container` `self` The container instance
## Container:unregisterChildEvent(child, eventName)
Unregisters the children events of the container

View File

@@ -14,44 +14,14 @@ This is the dropdown class. It is a visual element that can show a list of selec
|Method|Returns|Description|
|---|---|---|
|[Dropdown.new](#Dropdown.new)|Dropdown|Creates a new Dropdown instance
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Dropdown:init](#Dropdown:init)|Dropdown|Initializes the Dropdown instance
|[Dropdown:mouse_click](#Dropdown:mouse_click)|boolean|Handles mouse click events
|[Dropdown:render](#Dropdown:render)|-|Renders the Dropdown
## Dropdown.new()
Creates a new Dropdown instance
### Returns
* `Dropdown` `self` The newly created Dropdown instance
### Usage
```lua
local dropdown = Dropdown.new()
```
## Dropdown:init(props, basalt)
Initializes the Dropdown instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Dropdown` `self` The initialized instance
## Dropdown:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Dropdown:render()
Renders the Dropdown

View File

@@ -1,31 +1,43 @@
# Flexbox : Container
This is the Flexbox class. It is a container that arranges its children in a flexible layout.
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|flexDirection|string|"row"|The direction of the flexbox layout "row" or "column"
|flexSpacing|number|1|The spacing between flex items
|flexJustifyContent|string|"flex-start"|The alignment of flex items along the main axis
|flexWrap|boolean|false|Whether to wrap flex items onto multiple lines
|flexUpdateLayout|boolean|false|Whether to update the layout of the flexbox
## Functions
|Method|Returns|Description|
|---|---|---|
|[Flexbox.new](#Flexbox.new)|Flexbox|
|[Flexbox:addChild](#Flexbox:addChild)|-|
|[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox|
|[Flexbox:init](#Flexbox:init)|-|
|[Flexbox:removeChild](#Flexbox:removeChild)|-|
|[Flexbox:render](#Flexbox:render)|-|
|[Flexbox:addChild](#Flexbox:addChild)|Flexbox|Adds a child element to the flexbox
|[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox|Adds a new line break to the flexbox.
## Flexbox.new()
Creates a new Flexbox instance
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Flexbox:init](#Flexbox:init)|Flexbox|Initializes the Flexbox instance
|[Flexbox:removeChild](#Flexbox:removeChild)|Flexbox|Removes a child element from the flexbox
|[Flexbox:render](#Flexbox:render)|Flexbox|Renders the flexbox and its children
## Flexbox:addChild(element)
Adds a child element to the flexbox
### Parameters
* `element` `Element` The child element to add
### Returns
* `Flexbox` `object` The newly created Flexbox instance
### Usage
```lua
local element = Flexbox.new("myId", basalt)
```
## Flexbox:addChild()
* `Flexbox` `self` The flexbox instance
## Flexbox:addLineBreak(self)
Adds a new line break to the flexbox.
Adds a new line break to the flexbox
### Parameters
* `self` `Flexbox` The element itself
@@ -33,10 +45,4 @@ Adds a new line break to the flexbox.
### Returns
* `nil` `nil` nil
## Flexbox:init()
## Flexbox:removeChild()
## Flexbox:render()

View File

@@ -5,28 +5,12 @@ This is the frame class. It serves as a grouping container for other elements.
|Method|Returns|Description|
|---|---|---|
|[Frame.new](#Frame.new)|Frame|Creates a new Frame instance
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Frame:init](#Frame:init)|Frame|Initializes the Frame instance
## Frame.new()
Creates a new Frame instance
### Returns
* `Frame` `self` The newly created Frame instance
### Usage
```lua
local frame = Frame.new()
```
## Frame:init(props, basalt)
Initializes the Frame instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Frame` `self` The initialized instance

View File

@@ -0,0 +1,95 @@
# Image : VisualElement
This is the Image element class which can be used to display bimg format images.
The bimg format is a universal ComputerCraft image format.
See: https://github.com/SkyTheCodeMaster/bimg
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|bimg|table|{}|The bimg image data
|currentFrame|number|1|Current animation frame
|metadata|table|{}|Image metadata (version, palette, etc)
## Functions
|Method|Returns|Description|
|---|---|---|
|[Image:getPixelData](#Image:getPixelData)|number?|Gets pixel information at position
|[Image:loadBimg](#Image:loadBimg)|Image|Loads a bimg format image
|[Image:nextFrame](#Image:nextFrame)|Image|Advances to the next frame in the animation
|[Image:setBg](#Image:setBg)|-|Sets background color at position
|[Image:setChar](#Image:setChar)|-|Sets character at position
|[Image:setFg](#Image:setFg)|-|Sets foreground color at position
|[Image:setPixel](#Image:setPixel)|-|Sets all properties at position
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Image:init](#Image:init)|Image|Initializes the Image instance
|[Image:render](#Image:render)|-|Renders the Image
## Image:getPixelData(x, y)
Gets pixel information at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
### Returns
* `number?` `fg` Foreground color
* `number?` `bg` Background color
* `string?` `char` Character at position
## Image:loadBimg(bimgData)
Loads a bimg format image
### Parameters
* `bimgData` `table` The bimg image data
### Returns
* `Image` `self` The Image instance
## Image:nextFrame()
Advances to the next frame in the animation
### Returns
* `Image` `self` The Image instance
## Image:setBg(x, y, color)
Sets background color at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
* `color` `number` Color value (0-15)
## Image:setChar(x, y, char)
Sets character at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
* `char` `string` Single character to set
## Image:setFg(x, y, color)
Sets foreground color at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
* `color` `number` Color value (0-15)
## Image:setPixel(x, y, char, fg, bg)
Sets all properties at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
* `char` `string?` Character to set (optional)
* `fg` `number?` Foreground color (optional)
* `bg` `number?` Background color (optional)

View File

@@ -20,7 +20,13 @@ cursor movement, text manipulation, placeholder text, and input validation.
|Method|Returns|Description|
|---|---|---|
|[Input.new](#Input.new)|Input|Creates a new Input instance
|[Input:updateViewport](#Input:updateViewport)|Input|Updates the input's viewport
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Input:blur](#Input:blur)|-|Handles blur events
|[Input:char](#Input:char)|boolean|Handles char events
|[Input:focus](#Input:focus)|-|Handles focus events
@@ -28,68 +34,11 @@ cursor movement, text manipulation, placeholder text, and input validation.
|[Input:key](#Input:key)|boolean|Handles key events
|[Input:mouse_click](#Input:mouse_click)|boolean|Handles mouse click events
|[Input:render](#Input:render)|-|Renders the input element
|[Input:updateViewport](#Input:updateViewport)|-|Updates the input's viewport
## Input.new()
Creates a new Input instance
### Returns
* `Input` `object` The newly created Input instance
### Usage
```lua
local element = Input.new("myId", basalt)
```
## Input:blur()
Handles blur events
## Input:char(char)
Handles char events
### Parameters
* `char` `string` The character that was typed
### Returns
* `boolean` `handled` Whether the event was handled
## Input:focus()
Handles focus events
## Input:init(props, basalt)
Initializes the Input instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Input` `self` The initialized instance
## Input:key(key)
Handles key events
### Parameters
* `key` `number` The key that was pressed
### Returns
* `boolean` `handled` Whether the event was handled
## Input:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Input:render()
Renders the input element
## Input:updateViewport()
Updates the input's viewport
### Returns
* `Input` `self` The updated instance

View File

@@ -13,39 +13,20 @@ resizes its width based on the text content.
|Method|Returns|Description|
|---|---|---|
|[Label.new](#Label.new)|Label|Creates a new Label instance
|[Label:getWrappedText](#Label:getWrappedText)|table|Gets the wrapped lines of the Label
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Label:init](#Label:init)|Label|Initializes the Label instance
|[Label:render](#Label:render)|-|Renders the Label by drawing its text content
## Label.new()
Creates a new Label instance
### Returns
* `Label` `self` The newly created Label instance
### Usage
```lua
local label = Label.new()
```
## Label:getWrappedText()
Gets the wrapped lines of the Label
### Returns
* `table` `wrappedText` The wrapped lines of the Label
## Label:init(props, basalt)
Initializes the Label instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Label` `self` The initialized instance
## Label:render()
Renders the Label

View File

@@ -23,29 +23,23 @@ custom item rendering, separators, and selection handling.
|Method|Returns|Description|
|---|---|---|
|[List.new](#List.new)|List|Creates a new List instance
|[List:addItem](#List:addItem)|List|Adds an item to the list
|[List:clear](#List:clear)|List|Clears all items from the list
|[List:getSelectedItems](#List:getSelectedItems)|table|Gets the currently selected items
|[List:init](#List:init)|List|Initializes the List instance
|[List:mouse_click](#List:mouse_click)|boolean|Handles mouse click events
|[List:mouse_scroll](#List:mouse_scroll)|boolean|Handles mouse scroll events
|[List:onSelect](#List:onSelect)|List|Registers a callback for the select event
|[List:removeItem](#List:removeItem)|List|Removes an item from the list
|[List:render](#List:render)|-|Renders the list
|[List:scrollToBottom](#List:scrollToBottom)|List|Scrolls the list to the bottom
|[List:scrollToTop](#List:scrollToTop)|List|Scrolls the list to the top
## List.new()
Creates a new List instance
### Returns
* `List` `self` The newly created List instance
## Protected Functions
### Usage
```lua
local list = List.new()
```
|Method|Returns|Description|
|---|---|---|
|[List:init](#List:init)|List|Initializes the List instance
|[List:mouse_click](#List:mouse_click)|boolean|Handles mouse click events
|[List:mouse_scroll](#List:mouse_scroll)|boolean|Handles mouse scroll events
|[List:render](#List:render)|-|Renders the list
## List:addItem(text)
Adds an item to the list
@@ -84,38 +78,6 @@ Gets the currently selected items
local selected = list:getSelectedItems()
```
## List:init(props, basalt)
Initializes the List instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `List` `self` The initialized instance
## List:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The mouse button that was clicked
* `x` `number` The x-coordinate of the click
* `y` `number` The y-coordinate of the click
### Returns
* `boolean` `Whether` the event was handled
## List:mouse_scroll(direction, x, y)
Handles mouse scroll events
### Parameters
* `direction` `number` The direction of the scroll (1 for down, -1 for up)
* `x` `number` The x-coordinate of the scroll
* `y` `number` The y-coordinate of the scroll
### Returns
* `boolean` `Whether` the event was handled
## List:onSelect(callback)
Registers a callback for the select event
@@ -144,9 +106,6 @@ Removes an item from the list
list:removeItem(1)
```
## List:render()
Renders the list
## List:scrollToBottom()
Scrolls the list to the bottom

View File

@@ -12,46 +12,16 @@ Menu items are displayed in a single row and can have custom colors and callback
|Method|Returns|Description|
|---|---|---|
|[Menu.new](#Menu.new)|Menu|Creates a new Menu instance
|[Menu:setItems](#Menu:setItems)|Menu|Sets the menu items and calculates total width
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Menu:init](#Menu:init)|Menu|Initializes the Menu instance
|[Menu:mouse_click](#Menu:mouse_click)|boolean|Handles mouse click events and item selection
|[Menu:render](#Menu:render)|-|Renders the menu horizontally with proper spacing and colors
|[Menu:setItems](#Menu:setItems)|Menu|Sets the menu items and calculates total width
## Menu.new()
Creates a new Menu instance
### Returns
* `Menu` `self` The newly created Menu instance
### Usage
```lua
local menu = Menu.new()
```
## Menu:init(props, basalt)
Initializes the Menu instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Menu` `self` The initialized instance
## Menu:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `Whether` the event was handled
## Menu:render()
Renders the menu
## Menu:setItems(items)
Sets the menu items

View File

@@ -1,50 +1,37 @@
# Program : VisualElement
This is the program class. It provides a program that runs in a window.
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|program|table|nil|The program instance
|path|string|""|The path to the program
|running|boolean|false|Whether the program is running
## Functions
|Method|Returns|Description|
|---|---|---|
|[BasaltProgram.new](#BasaltProgram.new)|-|
|[BasaltProgram:resize](#BasaltProgram:resize)|-|
|[BasaltProgram:resume](#BasaltProgram:resume)|-|
|[BasaltProgram:run](#BasaltProgram:run)|-|
|[BasaltProgram:stop](#BasaltProgram:stop)|-|
|[Program.new](#Program.new)|Program|
|[Program:dispatchEvent](#Program:dispatchEvent)|-|
|[Program:execute](#Program:execute)|-|
|[Program:focus](#Program:focus)|-|
|[Program:init](#Program:init)|-|
|[Program:render](#Program:render)|-|
|[Program:execute](#Program:execute)|Program|Executes a program
## BasaltProgram.new()
## BasaltProgram:resize()
## Protected Functions
## BasaltProgram:resume()
|Method|Returns|Description|
|---|---|---|
|[Program:dispatchEvent](#Program:dispatchEvent)|any|Handles all incomming events
|[Program:focus](#Program:focus)|-|Gets called when the element gets focused
|[Program:init](#Program:init)|Program|Initializes the Program instance
|[Program:render](#Program:render)|-|Renders the program
## BasaltProgram:run()
## Program:execute(path)
Executes a program
## BasaltProgram:stop()
## Program.new()
Creates a new Program instance
### Parameters
* `path` `string` The path to the program
### Returns
* `Program` `object` The newly created Program instance
### Usage
```lua
local element = Program.new("myId", basalt)
```
## Program:dispatchEvent()
## Program:execute()
## Program:focus()
## Program:init()
## Program:render()
* `Program` `self` The Program instance

View File

@@ -14,32 +14,13 @@ with optional percentage display and customizable colors.
|Method|Returns|Description|
|---|---|---|
|[ProgressBar.new](#ProgressBar.new)|ProgressBar|Creates a new ProgressBar instance
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[ProgressBar:init](#ProgressBar:init)|ProgressBar|Initializes the ProgressBar instance
|[ProgressBar:render](#ProgressBar:render)|-|Renders the progress bar with filled portion and optional percentage text
## ProgressBar.new()
Creates a new ProgressBar instance
### Returns
* `ProgressBar` `self` The newly created ProgressBar instance
### Usage
```lua
local progressBar = ProgressBar.new()
```
## ProgressBar:init(props, basalt)
Initializes the ProgressBar instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `ProgressBar` `self` The initialized instance
## ProgressBar:render()
Renders the ProgressBar

View File

@@ -25,25 +25,19 @@ A scrollbar element that can be attached to other elements to control their scro
|Method|Returns|Description|
|---|---|---|
|[Scrollbar.new](#Scrollbar.new)|Scrollbar|Creates a new Scrollbar instance
|[Scrollbar:attach](#Scrollbar:attach)|Scrollbar|
|[Scrollbar:init](#Scrollbar:init)|-|
|[Scrollbar:mouse_click](#Scrollbar:mouse_click)|-|
|[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|-|
|[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|-|
|[Scrollbar:render](#Scrollbar:render)|-|
|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|-|
|[Scrollbar:attach](#Scrollbar:attach)|Scrollbar|Attaches the scrollbar to an element's property
|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|Scrollbar|Updates the attached element's property based on the scrollbar value
## Scrollbar.new()
Creates a new Scrollbar instance
### Returns
* `Scrollbar` `self` The newly created Scrollbar instance
## Protected Functions
### Usage
```lua
local scrollbar = Scrollbar.new()
```
|Method|Returns|Description|
|---|---|---|
|[Scrollbar:init](#Scrollbar:init)|Scrollbar|Initializes the Scrollbar instance
|[Scrollbar:mouse_click](#Scrollbar:mouse_click)|boolean|Handles mouse click events
|[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|boolean|Handles mouse drag events
|[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|boolean|Handles mouse scroll events
|[Scrollbar:render](#Scrollbar:render)|-|Renders the scrollbar
## Scrollbar:attach(element, config)
Attaches the scrollbar to an element's property
@@ -55,16 +49,10 @@ Attaches the scrollbar to an element's property
### Returns
* `Scrollbar` `self` The scrollbar instance
## Scrollbar:init()
## Scrollbar:mouse_click()
## Scrollbar:mouse_drag()
## Scrollbar:mouse_scroll()
## Scrollbar:render()
## Scrollbar:updateAttachedElement()
Updates the attached element's property based on the scrollbar value
### Returns
* `Scrollbar` `self` The scrollbar instance

View File

@@ -22,24 +22,18 @@ with customizable colors and value ranges.
|Method|Returns|Description|
|---|---|---|
|[Slider.new](#Slider.new)|Slider|Creates a new Slider instance
|[Slider:getValue](#Slider:getValue)|number|Gets the current value mapped to the max range
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Slider:init](#Slider:init)|Slider|Initializes the Slider instance
|[Slider:mouse_click](#Slider:mouse_click)|boolean|Updates slider position on mouse click
|[Slider:mouse_scroll](#Slider:mouse_scroll)|-|
|[Slider:mouse_scroll](#Slider:mouse_scroll)|boolean|Handles mouse release events
|[Slider:render](#Slider:render)|-|Renders the slider with track and handle
## Slider.new()
Creates a new Slider instance
### Returns
* `Slider` `self` The newly created Slider instance
### Usage
```lua
local slider = Slider.new()
```
## Slider:getValue()
Gets the current value of the slider
@@ -51,30 +45,4 @@ Gets the current value of the slider
local value = slider:getValue()
```
## Slider:init(props, basalt)
Initializes the Slider instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Slider` `self` The initialized instance
## Slider:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The mouse button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Slider:mouse_scroll()
## Slider:render()
Renders the slider

View File

@@ -20,88 +20,17 @@ row selection, and scrolling capabilities.
|Method|Returns|Description|
|---|---|---|
|[Table.new](#Table.new)|Table|Creates a new Table instance
|[Table:sortData](#Table:sortData)|Table|Sorts the table data by the specified column
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[Table:init](#Table:init)|Table|Initializes the Table instance
|[Table:mouse_click](#Table:mouse_click)|boolean|Handles header clicks for sorting and row selection
|[Table:mouse_scroll](#Table:mouse_scroll)|boolean|Handles scrolling through the table data
|[Table:render](#Table:render)|-|Renders the table with headers, data and scrollbar
|[Table:setColumns](#Table:setColumns)|Table|Sets the table columns configuration
|[Table:setData](#Table:setData)|Table|Sets the table data
|[Table:sortData](#Table:sortData)|Table|Sorts the table data by the specified column
## Table.new()
Creates a new Table instance
### Returns
* `Table` `self` The newly created Table instance
### Usage
```lua
local table = Table.new()
```
## Table:init(props, basalt)
Initializes the Table instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Table` `self` The initialized instance
## Table:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Table:mouse_scroll(direction, x, y)
Handles mouse scroll events
### Parameters
* `direction` `number` The scroll direction (-1 up, 1 down)
* `x` `number` The x position of the scroll
* `y` `number` The y position of the scroll
### Returns
* `boolean` `handled` Whether the event was handled
## Table:render()
Renders the table
## Table:setColumns(columns)
Sets the table columns
### Parameters
* `columns` `table[]` Array of column definitions {name="Name", width=10}
### Returns
* `Table` `self` The Table instance
### Usage
```lua
table:setColumns({{name="ID", width=4}, {name="Name", width=10}})
```
## Table:setData(data)
Sets the table data
### Parameters
* `data` `table[]` Array of row data arrays
### Returns
* `Table` `self` The Table instance
### Usage
```lua
table:setData({{"1", "Item One"}, {"2", "Item Two"}})
```
## Table:sortData(columnIndex)
Sorts the table data by column

View File

@@ -18,19 +18,22 @@ A multi-line text editor component with cursor support and text manipulation fea
|Method|Returns|Description|
|---|---|---|
|[TextBox.new](#TextBox.new)|-|
|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|-|
|[TextBox:char](#TextBox:char)|-|
|[TextBox:getText](#TextBox:getText)|-|
|[TextBox:init](#TextBox:init)|-|
|[TextBox:key](#TextBox:key)|-|
|[TextBox:mouse_click](#TextBox:mouse_click)|-|
|[TextBox:mouse_scroll](#TextBox:mouse_scroll)|-|
|[TextBox:render](#TextBox:render)|-|
|[TextBox:setText](#TextBox:setText)|-|
|[TextBox:updateViewport](#TextBox:updateViewport)|-|
|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|TextBox|Adds a new syntax highlighting pattern
|[TextBox:getText](#TextBox:getText)|string|Gets the text of the TextBox
|[TextBox:setText](#TextBox:setText)|TextBox|Sets the text of the TextBox
|[TextBox:updateViewport](#TextBox:updateViewport)|TextBox|Updates the viewport to keep the cursor in view
## TextBox.new()
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[TextBox:char](#TextBox:char)|boolean|Handles character input
|[TextBox:init](#TextBox:init)|TextBox|Initializes the TextBox instance
|[TextBox:key](#TextBox:key)|boolean|Handles key events
|[TextBox:mouse_click](#TextBox:mouse_click)|boolean|Handles mouse click events
|[TextBox:mouse_scroll](#TextBox:mouse_scroll)|boolean|Handles mouse scroll events
|[TextBox:render](#TextBox:render)|-|Renders the TextBox with syntax highlighting
## TextBox:addSyntaxPattern(pattern, color)
Adds a new syntax highlighting pattern
@@ -39,22 +42,28 @@ Adds a new syntax highlighting pattern
* `pattern` `string` The regex pattern to match
* `color` `colors` The color to apply
## TextBox:char()
### Returns
* `TextBox` `self` The TextBox instance
## TextBox:getText()
Gets the text of the TextBox
## TextBox:init()
### Returns
* `string` `text` The text of the TextBox
## TextBox:key()
## TextBox:setText(text)
Sets the text of the TextBox
## TextBox:mouse_click()
### Parameters
* `text` `string` The text to set
## TextBox:mouse_scroll()
## TextBox:render()
## TextBox:setText()
### Returns
* `TextBox` `self` The TextBox instance
## TextBox:updateViewport()
Updates the viewport to keep the cursor in view
### Returns
* `TextBox` `self` The TextBox instance

View File

@@ -18,27 +18,21 @@ with support for selection and scrolling.
|Method|Returns|Description|
|---|---|---|
|[Tree.new](#Tree.new)|Tree|Creates a new Tree instance
|[Tree:collapseNode](#Tree:collapseNode)|Tree|Collapses a node to hide its children
|[Tree:expandNode](#Tree:expandNode)|Tree|Expands a node to show its children
|[Tree:getNodeSize](#Tree:getNodeSize)|number|Gets the size of the tree
|[Tree:init](#Tree:init)|Tree|Initializes the Tree instance
|[Tree:mouse_click](#Tree:mouse_click)|-|
|[Tree:onSelect](#Tree:onSelect)|Tree|Registers a callback for when a node is selected
|[Tree:render](#Tree:render)|-|
|[Tree:setNodes](#Tree:setNodes)|Tree|Sets the tree nodes and expands the root node
|[Tree:toggleNode](#Tree:toggleNode)|Tree|Toggles between expanded and collapsed state
## Tree.new()
Creates a new Tree instance
### Returns
* `Tree` `self` The newly created Tree instance
## Protected Functions
### Usage
```lua
local tree = Tree.new()
```
|Method|Returns|Description|
|---|---|---|
|[Tree:init](#Tree:init)|Tree|Initializes the Tree instance
|[Tree:mouse_click](#Tree:mouse_click)|boolean|Handles mouse click events for node selection and expansion
|[Tree:mouse_scroll](#Tree:mouse_scroll)|boolean|Handles mouse scroll events for vertical scrolling
|[Tree:render](#Tree:render)|-|Renders the tree with nodes, selection and scrolling
## Tree:collapseNode(node)
Collapses a node
@@ -65,18 +59,6 @@ Gets the size of the tree
* `number` `width` The width of the tree
* `number` `height` The height of the tree
## Tree:init(props, basalt)
Initializes the Tree instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Tree` `self` The initialized instance
## Tree:mouse_click()
## Tree:onSelect(callback)
Registers a callback for when a node is selected
@@ -86,22 +68,6 @@ Registers a callback for when a node is selected
### Returns
* `Tree` `self` The Tree instance
## Tree:render()
## Tree:setNodes(nodes)
Sets the tree nodes
### Parameters
* `nodes` `table[]` Array of node objects
### Returns
* `Tree` `self` The Tree instance
### Usage
```lua
tree:setNodes({{text="Root", children={{text="Child"}}}})
```
## Tree:toggleNode(node)
Toggles a node's expanded state

View File

@@ -32,73 +32,55 @@ and provides core functionality for positioning, sizing, colors, and rendering.
|Event|Parameters|Description|
|---|---|---|
|onMouseClick|`button number, x number, y number`|Fired on mouse click|
|onMouseUp|`button number, x number, y number`|Fired on mouse button release|
|onMouseRelease|`button number, x number, y number`|Fired when mouse leaves while clicked|
|onMouseDrag|`button number, x number, y number`|Fired when mouse moves while clicked|
|onClick|`button, x, y`|Fired on mouse click|
|onMouseUp|`button, x, y`|Fired on mouse button release|
|onRelease|`button, x, y`|Fired when mouse leaves while clicked|
|onDrag|`button, x, y`|Fired when mouse moves while clicked|
|onScroll|`direction, x, y`|Fired on mouse scroll|
|onEnter|`-`|Fired when mouse enters element|
|onLeave|`-`|Fired when mouse leaves element|
|onFocus|`-`|Fired when element receives focus|
|onBlur|`-`|Fired when element loses focus|
|onKey|`key number, code number, isRepeat boolean`|Fired on key press|
|onKeyUp|`key number, code number`|Fired on key release|
|onChar|`char string`|Fired on character input|
|onKey|`key`|Fired on key press|
|onKeyUp|`key`|Fired on key release|
|onChar|`char`|Fired on character input|
## Functions
|Method|Returns|Description|
|---|---|---|
|[VisualElement.new](#VisualElement.new)|VisualElement|Creates a new visual element
|[VisualElement:calculatePosition](#VisualElement:calculatePosition)|number|Calculates the position of the element
|[VisualElement:getAbsolutePosition](#VisualElement:getAbsolutePosition)|number|Returns the absolute position of the element
|[VisualElement:getRelativePosition](#VisualElement:getRelativePosition)|number|Returns the relative position of the element
|[VisualElement:isInBounds](#VisualElement:isInBounds)|boolean|Checks if point is within bounds
## Protected Functions
|Method|Returns|Description|
|---|---|---|
|[VisualElement:blit](#VisualElement:blit)|-|Draws text with both colors
|[VisualElement:blur](#VisualElement:blur)|-|Handles a blur event
|[VisualElement:calculatePosition](#VisualElement:calculatePosition)|-|
|[VisualElement:focus](#VisualElement:focus)|-|Handles a focus event
|[VisualElement:getAbsolutePosition](#VisualElement:getAbsolutePosition)|-|Returns the absolute position of the element
|[VisualElement:getRelativePosition](#VisualElement:getRelativePosition)|number,|Returns the relative position of the element
|[VisualElement:init](#VisualElement:init)|-|Initializes a new visual element with properties
|[VisualElement:isInBounds](#VisualElement:isInBounds)|boolean|Checks if point is within bounds
|[VisualElement:mouse_click](#VisualElement:mouse_click)|boolean|Handles a mouse click event
|[VisualElement:mouse_drag](#VisualElement:mouse_drag)|-|
|[VisualElement:mouse_move](#VisualElement:mouse_move)|-|
|[VisualElement:mouse_drag](#VisualElement:mouse_drag)|boolean|Handles a mouse drag event
|[VisualElement:mouse_move](#VisualElement:mouse_move)|boolean|Handles a mouse move event
|[VisualElement:mouse_release](#VisualElement:mouse_release)|-|Handles a mouse release event
|[VisualElement:mouse_scroll](#VisualElement:mouse_scroll)|-|
|[VisualElement:mouse_scroll](#VisualElement:mouse_scroll)|boolean|Handles a mouse scroll event
|[VisualElement:mouse_up](#VisualElement:mouse_up)|boolean|Handles a mouse up event
|[VisualElement:multiBlit](#VisualElement:multiBlit)|-|Multi-character drawing with colors
|[VisualElement:render](#VisualElement:render)|-|Renders the element
|[VisualElement:setCursor](#VisualElement:setCursor)|-|Sets the cursor position
|[VisualElement:setCursor](#VisualElement:setCursor)|VisualElement|Sets the cursor position
|[VisualElement:textBg](#VisualElement:textBg)|-|Draws text with background color
|[VisualElement:textFg](#VisualElement:textFg)|-|Draws text with foreground color
## VisualElement.new(props, basalt)
Creates a new VisualElement instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
## VisualElement:calculatePosition()
Calculates the position of the element relative to its parent
### Returns
* `VisualElement` `object` The newly created VisualElement instance
### Usage
```lua
local element = VisualElement.new("myId", basalt)
```
## VisualElement:blit(x, y, text, fg, bg)
Draws text with both foreground and background colors
### Parameters
* `x` `number` The x position to draw
* `y` `number` The y position to draw
* `text` `string` The text char to draw
* `fg` `string` The foreground color
* `bg` `string` The background color
## VisualElement:blur()
Handles a blur event
## VisualElement:calculatePosition()
## VisualElement:focus()
Handles a focus event
* `number` `x` The x position
* `number` `y` The y position
## VisualElement:getAbsolutePosition(x?, y?)
Returns the absolute position of the element or the given coordinates.
@@ -107,6 +89,10 @@ Returns the absolute position of the element or the given coordinates.
* `x` *(optional)* `number` x position
* `y` *(optional)* `number` y position
### Returns
* `number` `x` The absolute x position
* `number` `y` The absolute y position
## VisualElement:getRelativePosition(x?, y?)
Returns the relative position of the element or the given coordinates.
@@ -115,14 +101,8 @@ Returns the relative position of the element or the given coordinates.
* `y` *(optional)* `number` y position
### Returns
* `nil` `nil` nil
## VisualElement:init(props, basalt)
Initializes the VisualElement instance
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
* `number` `x` The relative x position
* `number` `y` The relative y position
## VisualElement:isInBounds(x, y)
Checks if the specified coordinates are within the bounds of the element
@@ -134,81 +114,4 @@ Checks if the specified coordinates are within the bounds of the element
### Returns
* `boolean` `isInBounds` Whether the coordinates are within the bounds of the element
## VisualElement:mouse_click(button, x, y)
Handles a mouse click event
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `clicked` Whether the element was clicked
## VisualElement:mouse_drag()
## VisualElement:mouse_move()
## VisualElement:mouse_release(button, x, y)
Handles a mouse release event
### Parameters
* `button` `number` The button that was released
* `x` `number` The x position of the release
* `y` `number` The y position of the release
## VisualElement:mouse_scroll()
## VisualElement:mouse_up(button, x, y)
Handles a mouse up event
### Parameters
* `button` `number` The button that was released
* `x` `number` The x position of the release
* `y` `number` The y position of the release
### Returns
* `boolean` `release` Whether the element was released on the element
## VisualElement:multiBlit(x, y, width, height, text, fg, bg)
Draws multiple characters at once with colors
### Parameters
* `x` `number` The x position to draw
* `y` `number` The y position to draw
* `width` `number` The width of the area to draw
* `height` `number` The height of the area to draw
* `text` `string` The text to draw
* `fg` `string` The foreground color
* `bg` `string` The background color
## VisualElement:render()
Renders the element
## VisualElement:setCursor(x, y, blink)
Sets the cursor position
### Parameters
* `x` `number` The x position of the cursor
* `y` `number` The y position of the cursor
* `blink` `boolean` Whether the cursor should blink
## VisualElement:textBg(x, y, text, bg)
Draws text with background color
### Parameters
* `x` `number` The x position to draw
* `y` `number` The y position to draw
* `text` `string` The text char to draw
* `bg` `color` The background color
## VisualElement:textFg(x, y, text, fg)
Draws text with foreground color
### Parameters
* `x` `number` The x position to draw
* `y` `number` The y position to draw
* `text` `string` The text char to draw
* `fg` `color` The foreground color

View File

@@ -14,6 +14,7 @@ This is Basalt's error handler. All the errors are handled by this module.
|---|---|---|
|[errorHandler.error](#errorHandler.error)|-|
## errorHandler.error(errMsg)
Handles an error

View File

@@ -22,6 +22,7 @@ Logger module for Basalt. Logs messages to the console and optionally to a file.
|[Log.setLogToFile](#Log.setLogToFile)|-|Sets if the logger should log to a file
|[Log.warn](#Log.warn)|-|Sends a warning message
## Log.debug(...)
Sends a debug message to the logger.

View File

@@ -37,6 +37,7 @@ What this code does is it loads basalt into the project, and you can access it b
|[basalt.stop](#basalt.stop)|-|Stops the Basalt runtime
|[basalt.update](#basalt.update)|-|Runs basalt once
## basalt.create(type, properties?)
Creates and returns a new UI element of the specified type.

View File

@@ -17,6 +17,7 @@ with support for sequences, easing functions, and multiple animation types.
|[Animation:sequence](#Animation:sequence)|Animation|Creates a new sequence
|[Animation:start](#Animation:start)|Animation|Starts the animation
## Animation.new(element)
Creates a new Animation

View File

@@ -23,6 +23,7 @@ This is the AnimationInstance class. It represents a single animation instance
|[AnimationInstance:start](#AnimationInstance:start)|AnimationInstance|Starts the animation
|[AnimationInstance:update](#AnimationInstance:update)|boolean|Updates the animation
## AnimationInstance.new(element, animType, args, duration, easing)
Creates a new AnimationInstance

View File

@@ -7,6 +7,7 @@ Adds additional methods for VisualElement when adding animation plugin
|---|---|---|
|[VisualElement:animate](#VisualElement:animate)|Animation|Creates a new animation
## VisualElement:animate()
Creates a new Animation Object

View File

@@ -11,6 +11,7 @@ Benchmark API methods
|[API.start](#API.start)|-|Starts timing a custom operation
|[API.stop](#API.stop)|-|Stops timing and logs results
## API.clear(name)
Clears a specific benchmark

View File

@@ -14,6 +14,7 @@ The following methods are available for BaseElement
|[BaseElement:startProfile](#BaseElement:startProfile)|BaseElement|Starts timing a method call
|[BaseElement:stopBenchmark](#BaseElement:stopBenchmark)|BaseElement|Disables performance measurement for a method
## BaseElement:benchmark(methodName)
Enables benchmarking for a method

View File

@@ -9,6 +9,7 @@ Container benchmarking methods
|[Container:logContainerBenchmarks](#Container:logContainerBenchmarks)|Container|Recursively logs benchmark statistics
|[Container:stopContainerBenchmark](#Container:stopContainerBenchmark)|Container|Recursively stops benchmarking
## Container:benchmarkContainer(methodName)
Enables benchmarking for a container and all its children

View File

@@ -8,6 +8,7 @@ No Description
|[BaseElement.debug](#BaseElement.debug)|-|Enables debugging for this element
|[BaseElement.dumpDebug](#BaseElement.dumpDebug)|-|Dumps debug information
## BaseElement.debug(self, level)
Enables debugging for this element
@@ -35,6 +36,7 @@ Dumps debug information for this element
|[BaseFrame.showDebugLog](#BaseFrame.showDebugLog)|-|Shows the debug log frame
|[BaseFrame.toggleDebugLog](#BaseFrame.toggleDebugLog)|-|Toggles the debug log frame
## BaseFrame.hideDebugLog(self)
Hides the debug log frame
@@ -65,6 +67,7 @@ Toggles the debug log frame
|---|---|---|
|[Container.debugChildren](#Container.debugChildren)|-|Debug container and children
## Container.debugChildren(self, level)
Enables debugging for this container and all its children

View File

@@ -8,3 +8,4 @@ It is used to evaluate expressions in property values and update the element whe
|---|---|---|

View File

@@ -13,6 +13,7 @@ persistent states, computed states, and state sharing between elements.
|[BaseElement:setState](#BaseElement:setState)|BaseElement|Sets a state value
|[BaseElement:shareState](#BaseElement:shareState)|BaseElement|Shares state between elements
## BaseElement:computed(self, key, computeFn)
Creates a computed state that derives its value from other states

View File

@@ -9,6 +9,7 @@ with support for inheritance, named styles, and dynamic theme switching.
|[BaseElement:applyTheme](#BaseElement:applyTheme)|BaseElement|Applies theme styles to the element
|[BaseElement:getTheme](#BaseElement:getTheme)|table|Gets theme properties for the element
## BaseElement:applyTheme(self)
Applies the current theme to this element
@@ -42,6 +43,7 @@ The Theme API provides methods for managing themes globally
|[themeAPI.loadTheme](#themeAPI.loadTheme)|-|Loads theme from JSON file
|[themeAPI.setTheme](#themeAPI.setTheme)|-|Sets a new theme
## themeAPI.getTheme()
Gets the current theme configuration

View File

@@ -7,6 +7,7 @@ The XML plugin provides XML parsing and UI creation from XML markup
|---|---|---|
|[BaseElement:fromXML](#BaseElement:fromXML)|BaseElement|Creates element from XML node
## BaseElement:fromXML(self, node)
Creates an element from an XML node
@@ -29,6 +30,7 @@ Creates an element from an XML node
|---|---|---|
|[Container:loadXML](#Container:loadXML)|Container|Loads UI from XML string
## Container:loadXML(self, content, scope?)
Loads and creates UI elements from XML content
local xml = [[

View File

@@ -30,6 +30,7 @@ It also allows for properties to have custom getters and setters. This is the ba
|[PropertySystem:removeObserver](#PropertySystem:removeObserver)|table|
|[PropertySystem:removeProperty](#PropertySystem:removeProperty)|table|Removes a property from the PropertySystem
## PropertySystem.addSetterHook(hook)
Adds a setter hook to the PropertySystem. Setter hooks are functions that are called before a property is set.

View File

@@ -36,6 +36,7 @@ functionality. It also has a buffer system to reduce the number of calls
|[Render:textBg](#Render:textBg)|Render|
|[Render:textFg](#Render:textFg)|Render|
## Render.new(terminal)
Creates a new Render object