From 3aa5c1e97dc8efd15d15056b36d40ea26dec337b Mon Sep 17 00:00:00 2001 From: NoryiE Date: Tue, 18 Feb 2025 18:14:43 +0000 Subject: [PATCH] deploy: d1bdd9ad3c01c11e4b27359276800b6713c6cc53 --- .github/workflows/deploy.yml | 66 --------------------- .nojekyll | 0 docs/references/elements/BaseElement.md | 3 +- docs/references/elements/BaseFrame.md | 6 ++ docs/references/elements/Container.md | 15 +++++ docs/references/elements/Input.md | 1 + docs/references/elements/Scrollbar.md | 70 +++++++++++++++++++++++ docs/references/elements/TextBox.md | 3 +- docs/references/elements/Tree.md | 6 +- docs/references/elements/VisualElement.md | 13 ++++- docs/references/main.md | 26 +++++---- docs/references/plugins/reactive.md | 10 ++++ docs/references/render.md | 3 + 13 files changed, 140 insertions(+), 82 deletions(-) delete mode 100644 .github/workflows/deploy.yml create mode 100644 .nojekyll create mode 100644 docs/references/elements/Scrollbar.md diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 8fcd5aa..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,66 +0,0 @@ -# Sample workflow for building and deploying a VitePress site to GitHub Pages -# -name: Deploy VitePress site to Pages - -on: - # Runs on pushes targeting the `main` branch. Change this to `master` if you're - # using the `master` branch as the default branch. - push: - branches: [gh-pages] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: pages - cancel-in-progress: false - -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Not needed if lastUpdated is not enabled - # - uses: pnpm/action-setup@v3 # Uncomment this block if you're using pnpm - # with: - # version: 9 # Not needed if you've set "packageManager" in package.json - # - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm # or pnpm / yarn - - name: Setup Pages - uses: actions/configure-pages@v4 - - name: Install dependencies - run: npm ci # or pnpm install / yarn install / bun install - - name: Build with VitePress - run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: docs/.vitepress/dist - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - needs: build - runs-on: ubuntu-latest - name: Deploy - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/references/elements/BaseElement.md b/docs/references/elements/BaseElement.md index cc1119b..c09f096 100644 --- a/docs/references/elements/BaseElement.md +++ b/docs/references/elements/BaseElement.md @@ -28,12 +28,13 @@ The base class for all UI elements in Basalt |[BaseElement:registerCallback](#BaseElement:registerCallback)|table|Registers a callback function |[BaseElement:updateRender](#BaseElement:updateRender)|-|Requests a render update for this element -## BaseElement.listenTo(class, eventName) +## BaseElement.listenTo(class, eventName, event?) Registers an event that this class can listen to ### Parameters * `class` `table` The class to add the event to * `eventName` `string` The name of the event to register +* `event` *(optional)* `string` The event to handle ### Usage ```lua diff --git a/docs/references/elements/BaseFrame.md b/docs/references/elements/BaseFrame.md index 4fcbda5..6fc8e91 100644 --- a/docs/references/elements/BaseFrame.md +++ b/docs/references/elements/BaseFrame.md @@ -21,9 +21,11 @@ This is the base frame class. It is the root element of all elements and the onl |[BaseFrame.new](#BaseFrame.new)|BaseFrame|Creates a new Frame instance |[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: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: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 @@ -58,6 +60,8 @@ Initializes the Frame 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 @@ -81,6 +85,8 @@ 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 diff --git a/docs/references/elements/Container.md b/docs/references/elements/Container.md index 2bf50de..bf67094 100644 --- a/docs/references/elements/Container.md +++ b/docs/references/elements/Container.md @@ -22,6 +22,7 @@ like Frames, BaseFrames, and more. |[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:clear](#Container:clear)|Container|Clears the container |[Container:destroy](#Container:destroy)|Container|Destroys the container and its children @@ -32,6 +33,10 @@ like Frames, BaseFrames, and more. |[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 @@ -72,6 +77,8 @@ Draws a line of text and fg and bg as colors, it is usually used in the render l ### Returns * `Container` `self` The container instance +## Container:callChildrenEvents() + ## Container:char(char) Handles char events @@ -157,6 +164,14 @@ Handles mouse click events ### 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 diff --git a/docs/references/elements/Input.md b/docs/references/elements/Input.md index d3c2fa6..d572889 100644 --- a/docs/references/elements/Input.md +++ b/docs/references/elements/Input.md @@ -14,6 +14,7 @@ cursor movement, text manipulation, placeholder text, and input validation. |placeholderColor|color|gray|Color of the placeholder text |focusedColor|color|blue|Background color when input is focused |pattern|string?|nil|Regular expression pattern for input validation +|cursorColor|number|nil|Color of the cursor ## Functions diff --git a/docs/references/elements/Scrollbar.md b/docs/references/elements/Scrollbar.md new file mode 100644 index 0000000..49eb965 --- /dev/null +++ b/docs/references/elements/Scrollbar.md @@ -0,0 +1,70 @@ +# Scrollbar : VisualElement +A scrollbar element that can be attached to other elements to control their scroll properties + +## Properties + +|Property|Type|Default|Description| +|---|---|---|---| +|value|number|0|Current scroll value +|min|number|0|Minimum scroll value +|max|number|100|Maximum scroll value +|step|number|1|Step size for scroll operations +|dragMultiplier|number|1|How fast the scrollbar moves when dragging +|symbol|string|"|" Symbol used for the scrollbar handle +|backgroundSymbol|string|"\127"|Symbol used for the scrollbar background +|symbolBackgroundColor|color|black|Background color of the scrollbar handle +|backgroundSymbol|string|"\127"|Symbol used for the scrollbar background +|attachedElement|table?|nil|The element this scrollbar is attached to +|attachedProperty|string?|nil|The property being controlled +|minValue|number|function|0|Minimum value or function that returns it +|maxValue|number|function|100|Maximum value or function that returns it +|orientation|string|vertical|Orientation of the scrollbar ("vertical" or "horizontal") +|handleSize|number|2|Size of the scrollbar handle in characters + +## Functions + +|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.new() +Creates a new Scrollbar instance + +### Returns +* `Scrollbar` `self` The newly created Scrollbar instance + +### Usage + ```lua +local scrollbar = Scrollbar.new() +``` + +## Scrollbar:attach(element, config) +Attaches the scrollbar to an element's property + +### Parameters +* `element` `BaseElement` The element to attach to +* `config` `table` Configuration {property = "propertyName", min = number|function, max = number|function} + +### Returns +* `Scrollbar` `self` The scrollbar instance + +## Scrollbar:init() + +## Scrollbar:mouse_click() + +## Scrollbar:mouse_drag() + +## Scrollbar:mouse_scroll() + +## Scrollbar:render() + +## Scrollbar:updateAttachedElement() + + diff --git a/docs/references/elements/TextBox.md b/docs/references/elements/TextBox.md index 75e94a3..9dbbadf 100644 --- a/docs/references/elements/TextBox.md +++ b/docs/references/elements/TextBox.md @@ -12,6 +12,7 @@ A multi-line text editor component with cursor support and text manipulation fea |scrollY|number|0|Vertical scroll offset |editable|boolean|true|Whether text can be edited |syntaxPatterns|table|{}|Syntax highlighting patterns +|cursorColor|number|nil|Color of the cursor ## Functions @@ -36,7 +37,7 @@ Adds a new syntax highlighting pattern ### Parameters * `pattern` `string` The regex pattern to match -* `color` `color` The color to apply +* `color` `colors` The color to apply ## TextBox:char() diff --git a/docs/references/elements/Tree.md b/docs/references/elements/Tree.md index 9b8be77..488ada8 100644 --- a/docs/references/elements/Tree.md +++ b/docs/references/elements/Tree.md @@ -9,7 +9,8 @@ with support for selection and scrolling. |nodes|table|{}|The tree structure containing node objects with {text, children} properties |selectedNode|table?|nil|Currently selected node |expandedNodes|table|{}|Table of nodes that are currently expanded -|scrollOffset|number|0|Current scroll position +|scrollOffset|number|0|Current vertical scroll position +|horizontalOffset|number|0|Current horizontal scroll position |nodeColor|color|white|Color of unselected nodes |selectedColor|color|lightBlue|Background color of selected node @@ -20,6 +21,7 @@ with support for selection and scrolling. |[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)|-| |[Tree:init](#Tree:init)|Tree|Initializes the Tree instance |[Tree:mouse_click](#Tree:mouse_click)|-| |[Tree:mouse_scroll](#Tree:mouse_scroll)|-| @@ -57,6 +59,8 @@ Expands a node ### Returns * `Tree` `self` The Tree instance +## Tree:getNodeSize() + ## Tree:init(props, basalt) Initializes the Tree instance diff --git a/docs/references/elements/VisualElement.md b/docs/references/elements/VisualElement.md index 7c7b0df..97a4a3b 100644 --- a/docs/references/elements/VisualElement.md +++ b/docs/references/elements/VisualElement.md @@ -14,6 +14,7 @@ and provides core functionality for positioning, sizing, colors, and rendering. |background|color|black|The background color |foreground|color|white|The text/foreground color |clicked|boolean|false|Whether the element is currently clicked +|hover|boolean|false|Whether the mouse is currently hover over the element (Craftos-PC only) |backgroundEnabled|boolean|true|Whether to render the background |focused|boolean|false|Whether the element has input focus |visible|boolean|true|Whether the element is visible @@ -53,7 +54,10 @@ and provides core functionality for positioning, sizing, colors, and rendering. |[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_release](#VisualElement:mouse_release)|boolean|Handles a mouse release event +|[VisualElement:mouse_drag](#VisualElement:mouse_drag)|-| +|[VisualElement:mouse_move](#VisualElement:mouse_move)|-| +|[VisualElement:mouse_release](#VisualElement:mouse_release)|-|Handles a mouse release event +|[VisualElement:mouse_scroll](#VisualElement:mouse_scroll)|-| |[VisualElement:mouse_up](#VisualElement:mouse_up)|boolean|Handles a mouse up event |[VisualElement:render](#VisualElement:render)|-|Renders the element |[VisualElement:setCursor](#VisualElement:setCursor)|-|Sets the cursor position @@ -136,6 +140,10 @@ Handles a mouse click event ### 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 @@ -144,8 +152,7 @@ Handles a mouse release event * `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:mouse_scroll() ## VisualElement:mouse_up(button, x, y) Handles a mouse up event diff --git a/docs/references/main.md b/docs/references/main.md index 8e595b0..15a72b8 100644 --- a/docs/references/main.md +++ b/docs/references/main.md @@ -30,12 +30,12 @@ What this code does is it loads basalt into the project, and you can access it b |[basalt.getAPI](#basalt.getAPI)|table|Returns a Plugin API |[basalt.getElementManager](#basalt.getElementManager)|table|Returns the element manager |[basalt.getMainFrame](#basalt.getMainFrame)|BaseFrame|Gets or creates the main frame -|[basalt.removeSchedule](#basalt.removeSchedule)|-|Removes a scheduled update +|[basalt.removeSchedule](#basalt.removeSchedule)|boolean|Removes a scheduled update |[basalt.run](#basalt.run)|-|Starts the Basalt runtime -|[basalt.scheduleUpdate](#basalt.scheduleUpdate)|number|Schedules a function to be updated +|[basalt.schedule](#basalt.schedule)|thread|Schedules a function to run in a coroutine |[basalt.setActiveFrame](#basalt.setActiveFrame)|-|Sets the active frame |[basalt.stop](#basalt.stop)|-|Stops the Basalt runtime -|[basalt.update](#basalt.update)|-|Updates all scheduled functions +|[basalt.update](#basalt.update)|-|Runs basalt once ## basalt.create(type, properties?) Creates and returns a new UI element of the specified type. @@ -94,11 +94,14 @@ Gets or creates the main frame local frame = basalt.getMainFrame() ``` -## basalt.removeSchedule(id) +## basalt.removeSchedule(func) Removes a scheduled update ### Parameters -* `id` `number` The schedule ID to remove +* `func` `thread` The scheduled function to remove + +### Returns +* `boolean` `success` Whether the scheduled function was removed ### Usage ```lua @@ -117,14 +120,14 @@ basalt.run() basalt.run(false) ``` -## basalt.scheduleUpdate(func) -Schedules a function to be updated +## basalt.schedule(func) +Schedules a function to run in a coroutine ### Parameters * `func` `function` The function to schedule ### Returns -* `number` `Id` The schedule ID +* `thread` `func` The scheduled function ### Usage ```lua @@ -150,8 +153,11 @@ Stops the Basalt runtime basalt.stop() ``` -## basalt.update() -Updates all scheduled functions +## basalt.update(...) +Runs basalt once + +### Parameters +* `...` *(vararg)* `any` The event to run with ### Usage ```lua diff --git a/docs/references/plugins/reactive.md b/docs/references/plugins/reactive.md index e69de29..f8eabdc 100644 --- a/docs/references/plugins/reactive.md +++ b/docs/references/plugins/reactive.md @@ -0,0 +1,10 @@ +# Reactive +This module provides reactive functionality for elements, it adds no new functionality for elements. +It is used to evaluate expressions in property values and update the element when the expression changes. + +## Functions + +|Method|Returns|Description| +|---|---|---| + + diff --git a/docs/references/render.md b/docs/references/render.md index 60e5cb8..5cd76d8 100644 --- a/docs/references/render.md +++ b/docs/references/render.md @@ -31,6 +31,7 @@ functionality. It also has a buffer system to reduce the number of calls |[Render:rectOverlaps](#Render:rectOverlaps)|boolean| |[Render:render](#Render:render)|Render| |[Render:setCursor](#Render:setCursor)|Render| +|[Render:setSize](#Render:setSize)|-| |[Render:text](#Render:text)|Render| |[Render:textBg](#Render:textBg)|Render| |[Render:textFg](#Render:textFg)|Render| @@ -171,6 +172,8 @@ Sets the cursor position ### Returns * `nil` `nil` nil +## Render:setSize() + ## Render:text(x, y, text) Blits text to the screen