This commit is contained in:
NoryiE
2025-10-29 17:41:54 +00:00
parent e10f98554c
commit b9c0681695
12 changed files with 6 additions and 381 deletions

View File

@@ -6,60 +6,18 @@ Extends: `Graph`
## Usage ## Usage
```lua ```lua
-- Create a bar chart -- Create a bar chart
```
```lua
local chart = main:addBarChart() local chart = main:addBarChart()
```
```lua
```
```lua
-- Add two data series with different colors -- Add two data series with different colors
```
```lua
chart:addSeries("input", " ", colors.green, colors.green, 5) chart:addSeries("input", " ", colors.green, colors.green, 5)
```
```lua
chart:addSeries("output", " ", colors.red, colors.red, 5) chart:addSeries("output", " ", colors.red, colors.red, 5)
```
```lua
```
```lua
-- Continuously update the chart with random data -- Continuously update the chart with random data
```
```lua
basalt.schedule(function() basalt.schedule(function()
```
```lua
while true do while true do
```
```lua
chart:addPoint("input", math.random(1,100)) chart:addPoint("input", math.random(1,100))
```
```lua
chart:addPoint("output", math.random(1,100)) chart:addPoint("output", math.random(1,100))
```
```lua
sleep(2) sleep(2)
```
```lua
end end
```
```lua
end) end)
``` ```

View File

@@ -6,69 +6,21 @@ Extends: `VisualElement`
## Usage ## Usage
```lua ```lua
-- Create a large welcome message -- Create a large welcome message
```
```lua
local main = basalt.getMainFrame() local main = basalt.getMainFrame()
```
```lua
local title = main:addBigFont() local title = main:addBigFont()
```
```lua
:setPosition(3, 3) :setPosition(3, 3)
```
```lua
:setFontSize(2) -- Makes text twice as large :setFontSize(2) -- Makes text twice as large
```
```lua
:setText("Welcome!") :setText("Welcome!")
```
```lua
:setForeground(colors.yellow) -- Make text yellow :setForeground(colors.yellow) -- Make text yellow
```
```lua
```
```lua
-- For animated text -- For animated text
```
```lua
basalt.schedule(function() basalt.schedule(function()
```
```lua
while true do while true do
```
```lua
title:setForeground(colors.yellow) title:setForeground(colors.yellow)
```
```lua
sleep(0.5) sleep(0.5)
```
```lua
title:setForeground(colors.orange) title:setForeground(colors.orange)
```
```lua
sleep(0.5) sleep(0.5)
```
```lua
end end
```
```lua
end) end)
``` ```

View File

@@ -6,81 +6,24 @@ Extends: `VisualElement`
## Usage ## Usage
```lua ```lua
-- Create a simple action button -- Create a simple action button
```
```lua
local button = parent:addButton() local button = parent:addButton()
```
```lua
:setPosition(5, 5) :setPosition(5, 5)
```
```lua
:setText("Click me!") :setText("Click me!")
```
```lua
:setBackground(colors.blue) :setBackground(colors.blue)
```
```lua
:setForeground(colors.white) :setForeground(colors.white)
```
```lua
```
```lua
-- Add click handling -- Add click handling
```
```lua
button:onClick(function(self, button, x, y) button:onClick(function(self, button, x, y)
```
```lua
-- Change appearance when clicked -- Change appearance when clicked
```
```lua
self:setBackground(colors.green) self:setBackground(colors.green)
```
```lua
self:setText("Success!") self:setText("Success!")
```
```lua
```
```lua
-- Revert after delay -- Revert after delay
```
```lua
basalt.schedule(function() basalt.schedule(function()
```
```lua
sleep(1) sleep(1)
```
```lua
self:setBackground(colors.blue) self:setBackground(colors.blue)
```
```lua
self:setText("Click me!") self:setText("Click me!")
```
```lua
end) end)
```
```lua
end) end)
``` ```

View File

@@ -6,49 +6,16 @@ Extends: `VisualElement`
## Usage ## Usage
```lua ```lua
-- Create a checkbox for a setting -- Create a checkbox for a setting
```
```lua
local checkbox = parent:addCheckBox() local checkbox = parent:addCheckBox()
```
```lua
:setText("Enable Feature") :setText("Enable Feature")
```
```lua
:setCheckedText("✓") :setCheckedText("✓")
```
```lua
:onChange("checked", function(self, checked) :onChange("checked", function(self, checked)
```
```lua
-- React to checkbox state changes -- React to checkbox state changes
```
```lua
if checked then if checked then
```
```lua
-- Handle enabled state -- Handle enabled state
```
```lua
else else
```
```lua
-- Handle disabled state -- Handle disabled state
```
```lua
end end
```
```lua
end) end)
``` ```

View File

@@ -7,73 +7,22 @@ Extends: `DropDown`
## Usage ## Usage
```lua ```lua
-- Create a searchable country selector -- Create a searchable country selector
```
```lua
local combo = main:addComboBox() local combo = main:addComboBox()
```
```lua
:setPosition(5, 5) :setPosition(5, 5)
```
```lua
:setSize(20, 1) -- Height will expand when opened :setSize(20, 1) -- Height will expand when opened
```
```lua
:setItems({ :setItems({
```
```lua
{text = "Germany"}, {text = "Germany"},
```
```lua
{text = "France"}, {text = "France"},
```
```lua
{text = "Spain"}, {text = "Spain"},
```
```lua
{text = "Italy"} {text = "Italy"}
```
```lua
}) })
```
```lua
:setPlaceholder("Select country...") :setPlaceholder("Select country...")
```
```lua
:setAutoComplete(true) -- Enable filtering while typing :setAutoComplete(true) -- Enable filtering while typing
```
```lua
```
```lua
-- Handle selection changes -- Handle selection changes
```
```lua
combo:onChange(function(self, value) combo:onChange(function(self, value)
```
```lua
-- value will be the selected country -- value will be the selected country
```
```lua
basalt.debug("Selected:", value) basalt.debug("Selected:", value)
```
```lua
end) end)
``` ```

View File

@@ -12,85 +12,25 @@ Extends: `VisualElement`
## Usage ## Usage
```lua ```lua
-- Create a display for a custom terminal -- Create a display for a custom terminal
```
```lua
local display = main:addDisplay() local display = main:addDisplay()
```
```lua
:setSize(30, 10) :setSize(30, 10)
```
```lua
:setPosition(2, 2) :setPosition(2, 2)
```
```lua
```
```lua
-- Get the window object for CC API operations -- Get the window object for CC API operations
```
```lua
local win = display:getWindow() local win = display:getWindow()
```
```lua
```
```lua
-- Use standard CC terminal operations -- Use standard CC terminal operations
```
```lua
win.setTextColor(colors.yellow) win.setTextColor(colors.yellow)
```
```lua
win.setBackgroundColor(colors.blue) win.setBackgroundColor(colors.blue)
```
```lua
win.clear() win.clear()
```
```lua
win.setCursorPos(1, 1) win.setCursorPos(1, 1)
```
```lua
win.write("Hello World!") win.write("Hello World!")
```
```lua
```
```lua
-- Or use the helper method -- Or use the helper method
```
```lua
display:write(1, 2, "Direct write", colors.red, colors.black) display:write(1, 2, "Direct write", colors.red, colors.black)
```
```lua
```
```lua
-- Useful for external APIs -- Useful for external APIs
```
```lua
local paintutils = require("paintutils") local paintutils = require("paintutils")
```
```lua
paintutils.drawLine(1, 1, 10, 1, colors.red, win) paintutils.drawLine(1, 1, 10, 1, colors.red, win)
``` ```

View File

@@ -5,6 +5,9 @@ Extends: `List`
## Examples (Executable) ## Examples (Executable)
```lua run ```lua run
local basalt = require("basalt")
local main = basalt.getMainFrame()
-- Create a styled dropdown menu -- Create a styled dropdown menu
local dropdown = main:addDropDown() local dropdown = main:addDropDown()
:setPosition(5, 5) :setPosition(5, 5)
@@ -38,6 +41,8 @@ selectedForeground = colors.white
dropdown:onChange(function(self, value) dropdown:onChange(function(self, value)
basalt.debug("Selected:", value) basalt.debug("Selected:", value)
end) end)
basalt.run()
``` ```
## Table Types ## Table Types

View File

@@ -1,35 +1,18 @@
# FlexBox # FlexBox
_This is the FlexBox class. It is a container that arranges its children in a flexible layout._ _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` Extends: `Container`
## Usage ## Usage
```lua ```lua
local flex = main:addFlexbox({background=colors.black, width=30, height=10}) local flex = main:addFlexbox({background=colors.black, width=30, height=10})
```
```lua
flex:addButton():setFlexGrow(1) flex:addButton():setFlexGrow(1)
```
```lua
flex:addButton():setFlexGrow(1) flex:addButton():setFlexGrow(1)
```
```lua
flex:addButton():setFlexGrow(1) 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. 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. 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. flex:addButton():setFlexBasis(1) -- The flex-basis property defines the default size of an element before the remaining space is distributed.
``` ```

View File

@@ -6,45 +6,15 @@ Extends: `VisualElement`
## Usage ## Usage
```lua ```lua
local graph = main:addGraph() local graph = main:addGraph()
```
```lua
:addSeries("input", " ", colors.green, colors.green, 10) :addSeries("input", " ", colors.green, colors.green, 10)
```
```lua
:addSeries("output", " ", colors.red, colors.red, 10) :addSeries("output", " ", colors.red, colors.red, 10)
```
```lua
```
```lua
basalt.schedule(function() basalt.schedule(function()
```
```lua
while true do while true do
```
```lua
graph:addPoint("input", math.random(1,100)) graph:addPoint("input", math.random(1,100))
```
```lua
graph:addPoint("output", math.random(1,100)) graph:addPoint("output", math.random(1,100))
```
```lua
sleep(2) sleep(2)
```
```lua
end end
```
```lua
end) end)
``` ```

View File

@@ -6,44 +6,14 @@ Extends: `Graph`
## Usage ## Usage
```lua ```lua
local chart = main:addLineChart() local chart = main:addLineChart()
```
```lua
:addSeries("input", " ", colors.green, colors.green, 10) :addSeries("input", " ", colors.green, colors.green, 10)
```
```lua
:addSeries("output", " ", colors.red, colors.red, 10) :addSeries("output", " ", colors.red, colors.red, 10)
```
```lua
```
```lua
basalt.schedule(function() basalt.schedule(function()
```
```lua
while true do while true do
```
```lua
chart:addPoint("input", math.random(1,100)) chart:addPoint("input", math.random(1,100))
```
```lua
chart:addPoint("output", math.random(1,100)) chart:addPoint("output", math.random(1,100))
```
```lua
sleep(2) sleep(2)
```
```lua
end end
```
```lua
end) end)
``` ```

View File

@@ -7,13 +7,7 @@ Extends: `VisualElement`
## Usage ## Usage
```lua ```lua
local progressBar = main:addProgressBar() local progressBar = main:addProgressBar()
```
```lua
progressBar:setDirection("up") progressBar:setDirection("up")
```
```lua
progressBar:setProgress(50) progressBar:setProgress(50)
``` ```

View File

@@ -6,13 +6,7 @@ Extends: `Collection`
## Usage ## Usage
```lua ```lua
local people = container:addTable():setWidth(40) local people = container:addTable():setWidth(40)
```
```lua
people:setColumns({{name="Name",width=12}, {name="Age",width=10}, {name="Country",width=15}}) people:setColumns({{name="Name",width=12}, {name="Age",width=10}, {name="Country",width=15}})
```
```lua
people:addRow("Alice", 30, "USA"):addRow("Bob", 25, "UK") people:addRow("Alice", 30, "USA"):addRow("Bob", 25, "UK")
``` ```