Add berry.ui

2025-10-27 19:19:11 +11:00
parent c71ef0bb73
commit c8723d2a63

57
berry.ui.md Normal file

@@ -0,0 +1,57 @@
Documentation for interfacing with the different UI functions.
## notify
```lua
berry.ui.notify(message, title?, severity?, timeout?)
```
Display a notification in the bottom right corner of the screen.
#### Parameters:
| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `message` | `string` | The message to be displayed | *required* |
| `title` | `string` | The title to be displayed at the top of the notification. | `nil` |
| `severity` | `string` | The severity of the notification. Options: `information`, `warning`, `error` | `information` |
| `timeout` | `number` | How many seconds the notification will be on screen before automatically disappearing. | `5` |
## createAction
```lua
berry.ui.createAction(actionName, func)
```
Create an action and run a function whenever that action occurs in the UI.
#### Parameters:
| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `actionName` | `string` | The name of the new action. You can override an existing action if you want. | *required* |
| `func` | `function` | The function to call when this action occurs. | *required* |
## addBind
```lua
berry.ui.addBind(actionName, key, description, show?)
```
Bind a key to an action.
#### Parameters:
| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `actionName` | `string` | The name of the action you want to bind the key to. | *required* |
| `key` | `string` | The key to bind the action to. You can set this to things like `ctrl+f` or `ctrl+shift+t` to create key sequences. | *required* |
| `description` | `string` | The description to be shown at the bottom of the screen. Leave empty if you will set `show` to `false`. | *required* |
| `show` | `boolean` | Whether or not the show the keybind at the bottom of the screen. | `true` |
## runAction
```lua
berry.ui.runAction(actionName)
```
Run an action.
| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `actionName` | `string` | The action to run. | *required* |
## setTheme
```lua
berry.ui.setTheme(theme)
```
Forcefully change the theme of the UI.
#### Parameters:
| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `theme` | `string` | The name of the theme. | *required* |