Skip to content

PixelUI.App ​

Main application class managing the UI and event loop. Handles rendering, events, animations, and threading.

Properties ​

NameTypeDescription
windowtableThe terminal window object
boxShrekBoxShrekBox rendering instance
layerLayerText rendering layer
pixelLayerLayerPixel rendering layer
backgroundPixelUI.ColorRoot background color
rootPixelUI.FrameRoot frame container
runningbooleanWhether the application is running
_autoWindowbooleanWhether window was auto-created
_parentTerminaltable?Original terminal before window creation
_focusWidgetPixelUI.Widget?Currently focused widget
_popupWidgetsPixelUI.Widget[]Active popup widgets
_popupLookuptable<PixelUI.Widget,
_animationstableActive animations
_animationTimerinteger?Animation timer ID
_animationIntervalnumberAnimation update interval
_radioGroupstable<string,

Methods ​

getRoot ​

Since: 0.1.0

lua
getRoot()

Returns:

  • PixelUI.Frame

setBackground ​

Since: 0.1.0

lua
setBackground(color)

Parameters:

NameTypeDescription
colorPixelUI.Color

getLayer ​

Since: 0.1.0

lua
getLayer()

Returns:

  • Layer

getPixelLayer ​

Since: 0.1.0

lua
getPixelLayer()

Returns:

  • Layer

createFrame ​

Since: 0.1.0

lua
createFrame(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Frame

createWindow ​

lua
createWindow(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Window

createDialog ​

lua
createDialog(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Dialog

createMsgBox ​

lua
createMsgBox(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.MsgBox

createButton ​

Since: 0.1.0

lua
createButton(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Button

createLabel ​

Since: 0.1.0

lua
createLabel(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Label

createCheckBox ​

Since: 0.1.0

lua
createCheckBox(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.CheckBox

createToggle ​

Since: 0.1.0

lua
createToggle(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Toggle

createTextBox ​

Since: 0.1.0

lua
createTextBox(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.TextBox

createComboBox ​

Since: 0.1.0

lua
createComboBox(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.ComboBox

createTabControl ​

lua
createTabControl(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.TabControl

createContextMenu ​

Since: 0.1.0

lua
createContextMenu(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.ContextMenu

createList ​

Since: 0.1.0

lua
createList(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.List

createTable ​

Since: 0.1.0

lua
createTable(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Table

createTreeView ​

Since: 0.1.0

lua
createTreeView(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.TreeView

createChart ​

Since: 0.1.0

lua
createChart(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Chart

createRadioButton ​

Since: 0.1.0

lua
createRadioButton(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.RadioButton

createProgressBar ​

Since: 0.1.0

lua
createProgressBar(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.ProgressBar

createNotificationToast ​

lua
createNotificationToast(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.NotificationToast

createLoadingRing ​

lua
createLoadingRing(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.LoadingRing

createFreeDraw ​

lua
createFreeDraw(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.FreeDraw

createSlider ​

Since: 0.1.0

lua
createSlider(config)

Parameters:

NameTypeDescription
configPixelUI.WidgetConfig?

Returns:

  • PixelUI.Slider

_ensureAnimationTimer ​

lua
_ensureAnimationTimer()

_updateAnimations ​

lua
_updateAnimations()

_clearAnimations ​

lua
_clearAnimations()

animate ​

Since: 0.1.0

lua
animate(options)

Parameters:

NameTypeDescription
optionsPixelUI.AnimationOptions

Returns:

  • PixelUI.AnimationHandle

_ensureThreadPump ​

lua
_ensureThreadPump()

_cleanupThread ​

lua
_cleanupThread()

_resumeThread ​

lua
_resumeThread()

_serviceThreads ​

lua
_serviceThreads()

_shutdownThreads ​

lua
_shutdownThreads()

spawnThread ​

lua
spawnThread()

getThreads ​

lua
getThreads()

_registerPopup ​

lua
_registerPopup()

_unregisterPopup ​

lua
_unregisterPopup()

_drawPopups ​

lua
_drawPopups()

_dispatchPopupEvent ​

lua
_dispatchPopupEvent()

_registerRadioButton ​

lua
_registerRadioButton()

_unregisterRadioButton ​

lua
_unregisterRadioButton()

_selectRadioInGroup ​

lua
_selectRadioInGroup()

setFocus ​

Since: 0.1.0

lua
setFocus(widget)

Parameters:

NameTypeDescription
widgetPixelUI.Widget?

getFocus ​

Since: 0.1.0

lua
getFocus()

Returns:

  • PixelUI.Widget?

render ​

Since: 0.1.0

lua
render()

step ​

Since: 0.1.0

lua
step(event)

Parameters:

NameTypeDescription
eventstring

run ​

Since: 0.1.0

lua
run()

stop ​

Since: 0.1.0

lua
stop()

Examples ​

Basic
lua
local pixelui = require("pixelui")

-- Create a simple application
local app = pixelui.app({
    background = colors.black
})

-- Add widgets to root frame
app.root:addChild(app:label({
    text = "Hello PixelUI!",
    x = 2, y = 2,
    fg = colors.white
}))

-- Start the application
app:run()
Advanced
lua
local pixelui = require("pixelui")

-- Create application with custom window and border
local app = pixelui.app({
    background = colors.gray,
    rootBorder = {
        color = colors.lightGray,
        sides = { "top", "bottom", "left", "right" },
        thickness = 2
    },
    animationInterval = 0.05
})

-- Create a frame with child widgets
local mainFrame = app:frame({
    x = 2, y = 2,
    width = 30, height = 10,
    bg = colors.black
})
app.root:addChild(mainFrame)

-- Spawn a background thread
app:spawnThread(function(ctx)
    for i = 1, 10 do
        ctx:setMetadata("progress", i * 10)
        ctx:sleep(0.5)
        if ctx:shouldCancel() then return end
    end
end, {
    name = "BackgroundTask",
    onStatus = function(handle, status)
        -- Handle thread status changes
    end
})

app:run()

Released under the MIT License.