deploy: 167fc8ef81
This commit is contained in:
@@ -4,62 +4,62 @@ _A data visualization element that represents numeric data through vertical bars
|
||||
Extends: `Graph`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a bar chart
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local chart = main:addBarChart()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Add two data series with different colors
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addSeries("input", " ", colors.green, colors.green, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addSeries("output", " ", colors.red, colors.red, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Continuously update the chart with random data
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -4,71 +4,71 @@ _A specialized text element that renders characters in larger sizes using Wojbie
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a large welcome message
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local main = basalt.getMainFrame()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local title = main:addBigFont()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPosition(3, 3)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setFontSize(2) -- Makes text twice as large
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setText("Welcome!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setForeground(colors.yellow) -- Make text yellow
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- For animated text
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
title:setForeground(colors.yellow)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(0.5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
title:setForeground(colors.orange)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(0.5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -4,83 +4,83 @@ _A clickable interface element that triggers actions when pressed. Supports text
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a simple action button
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local button = parent:addButton()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPosition(5, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setText("Click me!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setBackground(colors.blue)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setForeground(colors.white)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Add click handling
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
button:onClick(function(self, button, x, y)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Change appearance when clicked
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
self:setBackground(colors.green)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
self:setText("Success!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Revert after delay
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
self:setBackground(colors.blue)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
self:setText("Click me!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -4,51 +4,51 @@ _A toggleable UI element that can be checked or unchecked. Displays different te
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a checkbox for a setting
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local checkbox = parent:addCheckBox()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setText("Enable Feature")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setCheckedText("✓")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:onChange("checked", function(self, checked)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- React to checkbox state changes
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
if checked then
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Handle enabled state
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
else
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Handle disabled state
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ Adds an item to the Collection
|
||||
* `Collection` `self` The Collection instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Collection:addItem("New Item")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
Collection:addItem({text="Item", callback=function() end})
|
||||
```
|
||||
|
||||
@@ -62,7 +62,7 @@ Removes an item from the Collection
|
||||
* `Collection` `self` The Collection instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Collection:removeItem(1)
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ Clears all items from the Collection
|
||||
* `Collection` `self` The Collection instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Collection:clear()
|
||||
```
|
||||
|
||||
@@ -86,7 +86,7 @@ Gets the currently selected items
|
||||
* `table` `selected` Collection of selected items
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
local selected = Collection:getSelectedItems()
|
||||
```
|
||||
|
||||
@@ -105,7 +105,7 @@ Gets the index of the first selected item
|
||||
* `index` `The` index of the first selected item, or nil if none selected
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
local index = Collection:getSelectedIndex()
|
||||
```
|
||||
|
||||
@@ -134,6 +134,6 @@ Registers a callback for the select event
|
||||
* `Collection` `self` The Collection instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Collection:onSelect(function(index, item) print("Selected item:", index, item) end)
|
||||
```
|
||||
|
||||
@@ -5,75 +5,75 @@ _Supports auto-completion, custom styling, and both single and multi-selection m
|
||||
Extends: `DropDown`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a searchable country selector
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local combo = main:addComboBox()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPosition(5, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setSize(20, 1) -- Height will expand when opened
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setItems({
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
{text = "Germany"},
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
{text = "France"},
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
{text = "Spain"},
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
{text = "Italy"}
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
})
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPlaceholder("Select country...")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setAutoComplete(true) -- Enable filtering while typing
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Handle selection changes
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
combo:onChange(function(self, value)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- value will be the selected country
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.debug("Selected:", value)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,87 +10,87 @@ _The Display maintains its own terminal buffer and can be manipulated using fami
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a display for a custom terminal
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local display = main:addDisplay()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setSize(30, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPosition(2, 2)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Get the window object for CC API operations
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local win = display:getWindow()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Use standard CC terminal operations
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.setTextColor(colors.yellow)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.setBackgroundColor(colors.blue)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.clear()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.setCursorPos(1, 1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.write("Hello World!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Or use the helper method
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
display:write(1, 2, "Direct write", colors.red, colors.black)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Useful for external APIs
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local paintutils = require("paintutils")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
paintutils.drawLine(1, 1, 10, 1, colors.red, win)
|
||||
```
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ _A collapsible selection menu that expands to show multiple options when clicked
|
||||
|
||||
Extends: `List`
|
||||
|
||||
## Usage
|
||||
## Examples (Executable)
|
||||
```lua run
|
||||
-- Create a styled dropdown menu
|
||||
local dropdown = main:addDropDown()
|
||||
|
||||
@@ -5,31 +5,31 @@ _The flexbox element adds the following properties to its children:_
|
||||
Extends: `Container`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local flex = main:addFlexbox({background=colors.black, width=30, height=10})
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1) -- The flex-grow property defines the ability for a flex item to grow if necessary.
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
flex:addButton():setFlexShrink(1) -- The flex-shrink property defines the ability for a flex item to shrink if necessary.
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
flex:addButton():setFlexBasis(1) -- The flex-basis property defines the default size of an element before the remaining space is distributed.
|
||||
```
|
||||
|
||||
|
||||
@@ -4,47 +4,47 @@ _This is the base class for all graph elements. It is a point based graph._
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local graph = main:addGraph()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:addSeries("input", " ", colors.green, colors.green, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:addSeries("output", " ", colors.red, colors.red, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
graph:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
graph:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -4,46 +4,46 @@ _The Line Chart element visualizes data series as connected line graphs. It plot
|
||||
Extends: `Graph`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local chart = main:addLineChart()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:addSeries("input", " ", colors.green, colors.green, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:addSeries("output", " ", colors.red, colors.red, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -42,7 +42,7 @@ Registers a callback for the select event
|
||||
* `List` `self` The List instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
list:onSelect(function(index, item) print("Selected item:", index, item) end)
|
||||
```
|
||||
|
||||
@@ -71,6 +71,6 @@ Scrolls to make a specific item visible
|
||||
* `List` `self` The List instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
list:scrollToItem(5)
|
||||
```
|
||||
|
||||
@@ -5,15 +5,15 @@ _with optional percentage display and customizable colors._
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local progressBar = main:addProgressBar()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
progressBar:setDirection("up")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
progressBar:setProgress(50)
|
||||
```
|
||||
|
||||
|
||||
@@ -34,6 +34,6 @@ Gets the current value of the slider
|
||||
* `number` `value` The current value (0 to max)
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
local value = slider:getValue()
|
||||
```
|
||||
|
||||
@@ -4,15 +4,15 @@ _This is the table class. It provides a sortable data grid with customizable col
|
||||
Extends: `Collection`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local people = container:addTable():setWidth(40)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
people:setColumns({{name="Name",width=12}, {name="Age",width=10}, {name="Country",width=15}})
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
people:addRow("Alice", 30, "USA"):addRow("Bob", 25, "UK")
|
||||
```
|
||||
|
||||
@@ -66,7 +66,7 @@ Adds a new row to the table
|
||||
* `Table` `self` The Table instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
table:addRow("Alice", 30, "USA")
|
||||
```
|
||||
|
||||
@@ -150,7 +150,7 @@ Set data with automatic formatting
|
||||
* `Table` `self` The Table instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
table:setData({{...}}, {[1] = tostring, [2] = function(age) return age.."y" end})
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user