diff --git a/docs/references/elementManager.md b/docs/references/elementManager.md index daccefc..4e0278d 100644 --- a/docs/references/elementManager.md +++ b/docs/references/elementManager.md @@ -60,7 +60,7 @@ Loads an element by name. This will load the element and apply any plugins to it * `name` `string` The name of the element to load ### Usage -```lua run +```lua ElementManager.loadElement("Button") ``` @@ -116,7 +116,7 @@ Checks if an element is loaded Clears the global cache (_G) ### Usage -```lua run +```lua ElementManager.clearGlobalCache() ``` diff --git a/docs/references/elements/BarChart.md b/docs/references/elements/BarChart.md index b7f5813..5982b32 100644 --- a/docs/references/elements/BarChart.md +++ b/docs/references/elements/BarChart.md @@ -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) ``` diff --git a/docs/references/elements/BigFont.md b/docs/references/elements/BigFont.md index 9fa380e..cabdb84 100644 --- a/docs/references/elements/BigFont.md +++ b/docs/references/elements/BigFont.md @@ -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) ``` diff --git a/docs/references/elements/Button.md b/docs/references/elements/Button.md index a9f9ae4..cd55d48 100644 --- a/docs/references/elements/Button.md +++ b/docs/references/elements/Button.md @@ -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) ``` diff --git a/docs/references/elements/CheckBox.md b/docs/references/elements/CheckBox.md index bc8c0f3..d5f8d68 100644 --- a/docs/references/elements/CheckBox.md +++ b/docs/references/elements/CheckBox.md @@ -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) ``` diff --git a/docs/references/elements/Collection.md b/docs/references/elements/Collection.md index ce2a1e3..8294bb2 100644 --- a/docs/references/elements/Collection.md +++ b/docs/references/elements/Collection.md @@ -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) ``` diff --git a/docs/references/elements/ComboBox.md b/docs/references/elements/ComboBox.md index 51de986..0e3082e 100644 --- a/docs/references/elements/ComboBox.md +++ b/docs/references/elements/ComboBox.md @@ -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) ``` diff --git a/docs/references/elements/Display.md b/docs/references/elements/Display.md index 6512603..703e702 100644 --- a/docs/references/elements/Display.md +++ b/docs/references/elements/Display.md @@ -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) ``` diff --git a/docs/references/elements/DropDown.md b/docs/references/elements/DropDown.md index 39cabd1..3904ec7 100644 --- a/docs/references/elements/DropDown.md +++ b/docs/references/elements/DropDown.md @@ -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() diff --git a/docs/references/elements/FlexBox.md b/docs/references/elements/FlexBox.md index 5a8094f..6336518 100644 --- a/docs/references/elements/FlexBox.md +++ b/docs/references/elements/FlexBox.md @@ -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. ``` diff --git a/docs/references/elements/Graph.md b/docs/references/elements/Graph.md index 7c3cebf..8c0bbdd 100644 --- a/docs/references/elements/Graph.md +++ b/docs/references/elements/Graph.md @@ -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) ``` diff --git a/docs/references/elements/LineChart.md b/docs/references/elements/LineChart.md index 3e50bda..42096f4 100644 --- a/docs/references/elements/LineChart.md +++ b/docs/references/elements/LineChart.md @@ -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) ``` diff --git a/docs/references/elements/List.md b/docs/references/elements/List.md index 40f83be..ab560a7 100644 --- a/docs/references/elements/List.md +++ b/docs/references/elements/List.md @@ -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) ``` diff --git a/docs/references/elements/ProgressBar.md b/docs/references/elements/ProgressBar.md index ac7e1d7..9983f1f 100644 --- a/docs/references/elements/ProgressBar.md +++ b/docs/references/elements/ProgressBar.md @@ -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) ``` diff --git a/docs/references/elements/Slider.md b/docs/references/elements/Slider.md index c45e5b0..e3bb015 100644 --- a/docs/references/elements/Slider.md +++ b/docs/references/elements/Slider.md @@ -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() ``` diff --git a/docs/references/elements/Table.md b/docs/references/elements/Table.md index 5a4388b..297970f 100644 --- a/docs/references/elements/Table.md +++ b/docs/references/elements/Table.md @@ -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}) ``` diff --git a/docs/references/errorManager.md b/docs/references/errorManager.md index e9c7fb6..dcf14f9 100644 --- a/docs/references/errorManager.md +++ b/docs/references/errorManager.md @@ -15,6 +15,6 @@ Handles an error * `errMsg` `string` The error message ### Usage -```lua run +```lua errorHandler.error("An error occurred") ``` diff --git a/docs/references/log.md b/docs/references/log.md index aabde54..39c325d 100644 --- a/docs/references/log.md +++ b/docs/references/log.md @@ -25,7 +25,7 @@ Sets if the logger should log Sends a debug message to the logger. ### Usage -```lua run +```lua Log.debug("This is a debug message") ``` @@ -34,7 +34,7 @@ Log.debug("This is a debug message") Sends an info message to the logger. ### Usage -```lua run +```lua Log.info("This is an info message") ``` @@ -43,7 +43,7 @@ Log.info("This is an info message") Sends a warning message to the logger. ### Usage -```lua run +```lua Log.warn("This is a warning message") ``` @@ -52,6 +52,6 @@ Log.warn("This is a warning message") Sends an error message to the logger. ### Usage -```lua run +```lua Log.error("This is an error message") ``` diff --git a/docs/references/main.md b/docs/references/main.md index 7bd311b..e2f7ef5 100644 --- a/docs/references/main.md +++ b/docs/references/main.md @@ -5,7 +5,7 @@ _Before you can access Basalt, you need to add the following code on top of your _What this code does is it loads basalt into the project, and you can access it by using the variable defined as "basalt"._ ## Usage -```lua run +```lua local basalt = require("basalt") ``` @@ -49,7 +49,7 @@ Creates and returns a new UI element of the specified type. * `table` `element` The created element instance ### Usage -```lua run +```lua local button = basalt.create("Button") ``` @@ -177,7 +177,7 @@ Registers a callback function for a specific event * `callback` `function` The callback function to execute when the event occurs ### Usage -```lua run +```lua basalt.onEvent("mouse_click", function(button, x, y) basalt.debug("Clicked at", x, y) end) ``` @@ -200,7 +200,7 @@ Triggers a custom event and calls all registered callbacks * `eventName` `string` The name of the event to trigger ### Usage -```lua run +```lua basalt.triggerEvent("custom_event", "data1", "data2") ``` @@ -213,11 +213,11 @@ Requires specific elements and validates they are available * `autoLoad` *(optional)* `boolean` Whether to automatically load missing elements (default: false) ### Usage -```lua run +```lua basalt.requireElements({"Button", "Label", "Slider"}) ``` -```lua run +```lua basalt.requireElements("Button", true) ``` @@ -232,7 +232,7 @@ Loads a manifest file that describes element requirements and configuration * `table` `manifest` The loaded manifest data ### Usage -```lua run +```lua basalt.loadManifest("myapp.manifest") ``` @@ -245,11 +245,11 @@ Installs an element interactively or from a specified source * `source` *(optional)* `string` Optional source URL or path ### Usage -```lua run +```lua basalt.install("Slider") ``` -```lua run +```lua basalt.install("Slider", "https://example.com/slider.lua") ``` @@ -261,6 +261,6 @@ Configures the ElementManager (shortcut to elementManager.configure) * `config` `table` Configuration options ### Usage -```lua run +```lua basalt.configure({allowRemoteLoading = true, useGlobalCache = true}) ``` diff --git a/docs/references/plugins/animation.md b/docs/references/plugins/animation.md index 8b8bcd8..af3fc19 100644 --- a/docs/references/plugins/animation.md +++ b/docs/references/plugins/animation.md @@ -74,7 +74,7 @@ Registers a new animation type * `handlers` `table` Table containing start, update and complete handlers ### Usage -```lua run +```lua Animation.registerAnimation("fade", {start=function(anim) end, update=function(anim,progress) end}) ``` diff --git a/docs/references/plugins/benchmark.md b/docs/references/plugins/benchmark.md index 2621baf..1a46c5d 100644 --- a/docs/references/plugins/benchmark.md +++ b/docs/references/plugins/benchmark.md @@ -42,7 +42,7 @@ Enables benchmarking for a method * `BaseElement` `self` The element instance ### Usage -```lua run +```lua element:benchmark("render") ``` @@ -99,7 +99,7 @@ Enables benchmarking for a container and all its children * `Container` `self` The container instance ### Usage -```lua run +```lua container:benchmarkContainer("render") ``` diff --git a/docs/references/plugins/reactive.md b/docs/references/plugins/reactive.md index 523e04e..3116657 100644 --- a/docs/references/plugins/reactive.md +++ b/docs/references/plugins/reactive.md @@ -3,18 +3,18 @@ _This module provides reactive functionality for elements, it adds no new functi _It is used to evaluate expressions in property values and update the element when the expression changes._ ## Usage -```lua run +```lua local button = main:addButton({text="Exit"}) ``` -```lua run +```lua button:setX("{parent.x - 12}") ``` -```lua run +```lua button:setBackground("{self.clicked and colors.red or colors.green}") ``` -```lua run +```lua button:setWidth("{#self.text + 2}") ```