deploy: 7099b5c548
This commit is contained in:
@@ -6,60 +6,18 @@ Extends: `Graph`
|
||||
## Usage
|
||||
```lua
|
||||
-- Create a bar chart
|
||||
```
|
||||
|
||||
```lua
|
||||
local chart = main:addBarChart()
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Add two data series with different colors
|
||||
```
|
||||
|
||||
```lua
|
||||
chart:addSeries("input", " ", colors.green, colors.green, 5)
|
||||
```
|
||||
|
||||
```lua
|
||||
chart:addSeries("output", " ", colors.red, colors.red, 5)
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Continuously update the chart with random data
|
||||
```
|
||||
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua
|
||||
chart:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua
|
||||
chart:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -6,69 +6,21 @@ Extends: `VisualElement`
|
||||
## Usage
|
||||
```lua
|
||||
-- Create a large welcome message
|
||||
```
|
||||
|
||||
```lua
|
||||
local main = basalt.getMainFrame()
|
||||
```
|
||||
|
||||
```lua
|
||||
local title = main:addBigFont()
|
||||
```
|
||||
|
||||
```lua
|
||||
:setPosition(3, 3)
|
||||
```
|
||||
|
||||
```lua
|
||||
:setFontSize(2) -- Makes text twice as large
|
||||
```
|
||||
|
||||
```lua
|
||||
:setText("Welcome!")
|
||||
```
|
||||
|
||||
```lua
|
||||
:setForeground(colors.yellow) -- Make text yellow
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- For animated text
|
||||
```
|
||||
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua
|
||||
title:setForeground(colors.yellow)
|
||||
```
|
||||
|
||||
```lua
|
||||
sleep(0.5)
|
||||
```
|
||||
|
||||
```lua
|
||||
title:setForeground(colors.orange)
|
||||
```
|
||||
|
||||
```lua
|
||||
sleep(0.5)
|
||||
```
|
||||
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -6,81 +6,24 @@ Extends: `VisualElement`
|
||||
## Usage
|
||||
```lua
|
||||
-- Create a simple action button
|
||||
```
|
||||
|
||||
```lua
|
||||
local button = parent:addButton()
|
||||
```
|
||||
|
||||
```lua
|
||||
:setPosition(5, 5)
|
||||
```
|
||||
|
||||
```lua
|
||||
:setText("Click me!")
|
||||
```
|
||||
|
||||
```lua
|
||||
:setBackground(colors.blue)
|
||||
```
|
||||
|
||||
```lua
|
||||
:setForeground(colors.white)
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Add click handling
|
||||
```
|
||||
|
||||
```lua
|
||||
button:onClick(function(self, button, x, y)
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Change appearance when clicked
|
||||
```
|
||||
|
||||
```lua
|
||||
self:setBackground(colors.green)
|
||||
```
|
||||
|
||||
```lua
|
||||
self:setText("Success!")
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Revert after delay
|
||||
```
|
||||
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua
|
||||
sleep(1)
|
||||
```
|
||||
|
||||
```lua
|
||||
self:setBackground(colors.blue)
|
||||
```
|
||||
|
||||
```lua
|
||||
self:setText("Click me!")
|
||||
```
|
||||
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -6,49 +6,16 @@ Extends: `VisualElement`
|
||||
## Usage
|
||||
```lua
|
||||
-- Create a checkbox for a setting
|
||||
```
|
||||
|
||||
```lua
|
||||
local checkbox = parent:addCheckBox()
|
||||
```
|
||||
|
||||
```lua
|
||||
:setText("Enable Feature")
|
||||
```
|
||||
|
||||
```lua
|
||||
:setCheckedText("✓")
|
||||
```
|
||||
|
||||
```lua
|
||||
:onChange("checked", function(self, checked)
|
||||
```
|
||||
|
||||
```lua
|
||||
-- React to checkbox state changes
|
||||
```
|
||||
|
||||
```lua
|
||||
if checked then
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Handle enabled state
|
||||
```
|
||||
|
||||
```lua
|
||||
else
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Handle disabled state
|
||||
```
|
||||
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -7,73 +7,22 @@ Extends: `DropDown`
|
||||
## Usage
|
||||
```lua
|
||||
-- Create a searchable country selector
|
||||
```
|
||||
|
||||
```lua
|
||||
local combo = main:addComboBox()
|
||||
```
|
||||
|
||||
```lua
|
||||
:setPosition(5, 5)
|
||||
```
|
||||
|
||||
```lua
|
||||
:setSize(20, 1) -- Height will expand when opened
|
||||
```
|
||||
|
||||
```lua
|
||||
:setItems({
|
||||
```
|
||||
|
||||
```lua
|
||||
{text = "Germany"},
|
||||
```
|
||||
|
||||
```lua
|
||||
{text = "France"},
|
||||
```
|
||||
|
||||
```lua
|
||||
{text = "Spain"},
|
||||
```
|
||||
|
||||
```lua
|
||||
{text = "Italy"}
|
||||
```
|
||||
|
||||
```lua
|
||||
})
|
||||
```
|
||||
|
||||
```lua
|
||||
:setPlaceholder("Select country...")
|
||||
```
|
||||
|
||||
```lua
|
||||
:setAutoComplete(true) -- Enable filtering while typing
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Handle selection changes
|
||||
```
|
||||
|
||||
```lua
|
||||
combo:onChange(function(self, value)
|
||||
```
|
||||
|
||||
```lua
|
||||
-- value will be the selected country
|
||||
```
|
||||
|
||||
```lua
|
||||
basalt.debug("Selected:", value)
|
||||
```
|
||||
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -12,85 +12,25 @@ Extends: `VisualElement`
|
||||
## Usage
|
||||
```lua
|
||||
-- Create a display for a custom terminal
|
||||
```
|
||||
|
||||
```lua
|
||||
local display = main:addDisplay()
|
||||
```
|
||||
|
||||
```lua
|
||||
:setSize(30, 10)
|
||||
```
|
||||
|
||||
```lua
|
||||
:setPosition(2, 2)
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Get the window object for CC API operations
|
||||
```
|
||||
|
||||
```lua
|
||||
local win = display:getWindow()
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Use standard CC terminal operations
|
||||
```
|
||||
|
||||
```lua
|
||||
win.setTextColor(colors.yellow)
|
||||
```
|
||||
|
||||
```lua
|
||||
win.setBackgroundColor(colors.blue)
|
||||
```
|
||||
|
||||
```lua
|
||||
win.clear()
|
||||
```
|
||||
|
||||
```lua
|
||||
win.setCursorPos(1, 1)
|
||||
```
|
||||
|
||||
```lua
|
||||
win.write("Hello World!")
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Or use the helper method
|
||||
```
|
||||
|
||||
```lua
|
||||
display:write(1, 2, "Direct write", colors.red, colors.black)
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
-- Useful for external APIs
|
||||
```
|
||||
|
||||
```lua
|
||||
local paintutils = require("paintutils")
|
||||
```
|
||||
|
||||
```lua
|
||||
paintutils.drawLine(1, 1, 10, 1, colors.red, win)
|
||||
```
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ Extends: `List`
|
||||
|
||||
## Examples (Executable)
|
||||
```lua run
|
||||
local basalt = require("basalt")
|
||||
local main = basalt.getMainFrame()
|
||||
|
||||
-- Create a styled dropdown menu
|
||||
local dropdown = main:addDropDown()
|
||||
:setPosition(5, 5)
|
||||
@@ -38,6 +41,8 @@ selectedForeground = colors.white
|
||||
dropdown:onChange(function(self, value)
|
||||
basalt.debug("Selected:", value)
|
||||
end)
|
||||
|
||||
basalt.run()
|
||||
```
|
||||
|
||||
## Table Types
|
||||
|
||||
@@ -1,35 +1,18 @@
|
||||
# FlexBox
|
||||
_This is the FlexBox class. It is a container that arranges its children in a flexible layout._
|
||||
_The flexbox element adds the following properties to its children:_
|
||||
|
||||
Extends: `Container`
|
||||
|
||||
## Usage
|
||||
```lua
|
||||
local flex = main:addFlexbox({background=colors.black, width=30, height=10})
|
||||
```
|
||||
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
The flexbox element adds the following properties to its children:
|
||||
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1) -- The flex-grow property defines the ability for a flex item to grow if necessary.
|
||||
```
|
||||
|
||||
```lua
|
||||
flex:addButton():setFlexShrink(1) -- The flex-shrink property defines the ability for a flex item to shrink if necessary.
|
||||
```
|
||||
|
||||
```lua
|
||||
flex:addButton():setFlexBasis(1) -- The flex-basis property defines the default size of an element before the remaining space is distributed.
|
||||
```
|
||||
|
||||
|
||||
@@ -6,45 +6,15 @@ Extends: `VisualElement`
|
||||
## Usage
|
||||
```lua
|
||||
local graph = main:addGraph()
|
||||
```
|
||||
|
||||
```lua
|
||||
:addSeries("input", " ", colors.green, colors.green, 10)
|
||||
```
|
||||
|
||||
```lua
|
||||
:addSeries("output", " ", colors.red, colors.red, 10)
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua
|
||||
graph:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua
|
||||
graph:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -6,44 +6,14 @@ Extends: `Graph`
|
||||
## Usage
|
||||
```lua
|
||||
local chart = main:addLineChart()
|
||||
```
|
||||
|
||||
```lua
|
||||
:addSeries("input", " ", colors.green, colors.green, 10)
|
||||
```
|
||||
|
||||
```lua
|
||||
:addSeries("output", " ", colors.red, colors.red, 10)
|
||||
```
|
||||
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua
|
||||
chart:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua
|
||||
chart:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -7,13 +7,7 @@ Extends: `VisualElement`
|
||||
## Usage
|
||||
```lua
|
||||
local progressBar = main:addProgressBar()
|
||||
```
|
||||
|
||||
```lua
|
||||
progressBar:setDirection("up")
|
||||
```
|
||||
|
||||
```lua
|
||||
progressBar:setProgress(50)
|
||||
```
|
||||
|
||||
|
||||
@@ -6,13 +6,7 @@ Extends: `Collection`
|
||||
## Usage
|
||||
```lua
|
||||
local people = container:addTable():setWidth(40)
|
||||
```
|
||||
|
||||
```lua
|
||||
people:setColumns({{name="Name",width=12}, {name="Age",width=10}, {name="Country",width=15}})
|
||||
```
|
||||
|
||||
```lua
|
||||
people:addRow("Alice", 30, "USA"):addRow("Bob", 25, "UK")
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user