celina

Celina CLI Library

A powerful Terminal User Interface library for Nim, inspired by Ratatui. Provides high-performance, type-safe components for building interactive terminal applications with both synchronous and asynchronous support.

Basic Usage:

import pkg/celina

proc main() =
  var app = newApp()
  app.run()

when isMainModule:
  main()

Async Usage (requires Chronos and -d:asyncBackend=chronos):

import pkg/celina

proc main() {.async.} =
  var app = newAsyncApp()
  await app.runAsync()

when isMainModule:
  waitFor main()

Procs

proc celinaVersion(): string {....raises: [], tags: [], forbids: [].}
Get the library version string
proc quickRun(eventHandler: proc (event: Event): bool;
              renderHandler: proc (buffer: var Buffer); config: AppConfig = AppConfig(
    title: "Celina App", alternateScreen: true, mouseCapture: false,
    rawMode: true, windowMode: false, targetFps: 60)) {.
    ...raises: [ValueError, Exception, TerminalError, CatchableError],
    tags: [TimeEffect, WriteIOEffect, RootEffect, ReadIOEffect], forbids: [].}

Quick way to run a simple CLI application

Example:

quickRun(
  eventHandler = proc(event: Event): bool =
    case event.kind
    of EventKind.Key:
      if event.key.code == KeyCode.Char and event.key.char == "q":
        return false
    else: discard
    return true,
  
  renderHandler = proc(buffer: var Buffer) =
    buffer.clear()
    let area = buffer.area
    buffer.setString(10, area.height div 2, "Press 'q' to quit", defaultStyle())
)

Exports

Position, size, position, isValid, contains, rect, size, shrink, isValid, contains, union, $, right, center, Area, $, Size, -, isEmpty, Rect, pos, area, area, expand, shrink, intersects, bottom, +, intersection, $, rect, indigo, color256, grayscale, toAnsiCode, ==, withModifiers, ColorKind, $, Style, $, deepSkyBlue, hotPink, toAnsiCode, bold, color256, reversed, hsv, Color, rgb, hsvToRgb, ColorValue, withBg, style, ==, withFg, brightColors, color, default, rgb, salmon, teal, addModifier, italic, violet, cubeColor, toAnsiSequence, RgbColor, crimson, limeGreen, withBg, $, style, ==, defaultColor, orange, lerp, underline, toAnsiCode, defaultStyle, withFg, darkColors, resetSequence, gold, toBgAnsiCode, lerp, StyleModifier, rgb, toAnsiCode, removeModifier, pastels, diff, clear, []=, isEmpty, isValidPos, fill, Buffer, ==, cell, Cell, ==, setString, merge, setRunes, isValidPos, setString, []=, $, $, [], runeWidth, runesWidth, width, cell, merge, newBuffer, cell, toStrings, setString, resize, setRunes, setString, newBuffer, [], readKeyInput, readKey, truncateUtf8, Utf8ValidationResult, MouseEventKind, KeyCode, buildUtf8String, validateUtf8Sequence, KeyModifier, pollKey, waitForKey, initSignalHandling, waitForAnyKey, pollEvents, Event, resizeDetected, checkResize, MouseButton, KeyEvent, utf8CharLength, MouseEvent, hasInput, utf8ByteLength, isUtf8ContinuationByte, EventKind, min, twoColumnPercent, withMargins, fill, percentage, Constraint, evenSplit, LayoutSolver, withMargin, Layout, length, layout, vertical, max, threeRow, twoColumn, ConstraintKind, $, split, Direction, ratio, horizontal, $, render, setCursorStyle, setupWithMouse, cleanup, enableRawMode, isRawMode, saveCursor, withTerminal, drawWithCursor, showCursor, disableAlternateScreen, getSize, clearToEndOfLine, clearLine, isAlternateScreen, clearScreen, TerminalError, updateSize, draw, restoreCursor, clearToStartOfLine, getTerminalSize, Terminal, withTerminal, moveCursorRight, moveCursorUp, moveCursorLeft, renderCell, disableMouse, setup, enableAlternateScreen, moveCursorDown, disableRawMode, setCursorPos, isMouseEnabled, renderFull, setCursorPos, hideCursor, getTerminalSizeOrDefault, enableMouse, newTerminal, setupWithHiddenCursor, getArea, moveCursor, EventError, tryRecover, ensureNotNil, newTerminalError, newLayoutError, checkSystemCall, checkSystemCallVoid, newRenderError, TerminalError, ensure, newEventError, tryIO, RenderError, LayoutError, newBufferError, withResource, withErrorContext, withContext, BufferError, debugLog, checkForLeaks, getStats, ResourceId, ==, getGlobalResourceManager, acquire, newResourceGuard, initGlobalResourceManager, isValid, withManagedResource, newResourceManager, $, ResourceType, release, withResourceGuard, touchResource, globalResourceManager, release, ResourceState, getResourceInfo, getResourceStats, clear, ResourceGuard, cleanupAllResources, hash, ResourceManager, ResourceInfo, unregisterResource, get, newResourcePool, registerResource, cleanupLeakedResources, getAllResources, ResourcePool, CursorUpSeq, RenderBatch, ClearScreenSeq, AlternateScreenEnter, enableMouseMode, applyTerminalConfig, generateRenderBatch, CursorStyleBlinkingBlock, CursorStyleBlinkingUnderline, getRawModeConfig, ClearToEndOfLineSeq, CursorRightSeq, makeCursorPositionSeq, makeCursorPositionSeq, ClearToStartOfLineSeq, MouseSequences, disableMouseMode, AnsiSequence, ShowCursorSeq, buildDifferentialOutput, CursorStyleSteadyUnderline, AlternateScreenExit, MouseMode, getCursorStyleSeq, CursorStyleSteadyBlock, CursorStyle, RestoreCursorSeq, CursorLeftSeq, parseMouseEvent, isTerminalInteractive, calculateRenderMetrics, supportsAnsi, CursorState, buildFullRenderOutput, buildOutputWithCursor, RenderMetrics, RenderCommandKind, CursorStyleDefault, CursorStyleBlinkingBar, CursorDownSeq, makeCursorMoveSeq, optimizeRenderBatch, getTerminalSizeFromSystem, buildOutputString, SaveCursorSeq, getTerminalCapabilities, HideCursorSeq, addCommand, TerminalConfig, RenderCommand, getTerminalSizeWithFallback, CursorStyleSteadyBar, ClearLineSeq, calculateSimpleDiff, getWindows, getWindow, setCursorStyle, isCursorVisible, newApp, setTargetFps, getFocusedWindow, addWindow, getCursorStyle, App, getWindowInfo, setCursor, onEvent, showCursor, removeWindow, getTargetFps, setCursorPos, enableWindowMode, getFocusedWindowId, run, focusWindow, resetCursor, quit, hideCursor, getCurrentFps, onRender, AppConfig, setCursor, getCursorPos, handleWindowEvent, getWindowCount, Renderer, render, setString, clear, showCursor, renderDiff, getCursorManager, isCursorVisible, forceRender, getBuffer, hideCursor, resize, newRenderer, resize, setCursor, getCursorPos, setCursor, setCursorStyle, newCursorManager, isVisible, setPosition, styleChanged, hide, setStyle, updateLastStyle, CursorState, CursorManager, reset, setPosition, show, getStyle, getState, hasPosition, getPosition, getRemainingFrameTime, getTargetFps, AsyncPerfMonitor, getFrameTimeout, endFrame, setTargetFps, getStats, newFpsMonitor, newAsyncPerfMonitor, shouldRender, getEventRate, getCurrentFps, FpsMonitor, recordFrame, startFrame, getFrameTime, PerfStats, recordEvent, getFPS, WindowState, render, WindowEvent, render, setBorder, destroyWindowManager, defaultBorder, move, WindowKeyHandler, ==, getVisibleWindows, Window, defaultBorderChars, dispatchEvent, setKeyHandler, stopPropagation, WindowBorder, hide, $, removeWindow, getContentBuffer, WindowManager, bringToFront, handleEvent, focusWindow, destroyWindow, findWindowAt, addWindow, newWindow, getWindow, setResizeHandler, resize, restore, WindowInfo, sendToBack, setArea, setEventHandler, setTitle, EventHandler, WindowMouseHandler, maximize, show, dispatchResize, WindowId, preventDefault, clearEventHandlers, minimize, toWindowInfo, WindowEventHandler, handleWindowEvent, newWindowManager, BorderChars, setMouseHandler, getContentSize, getFocusedWindow, WindowResizeHandler, EventPhase, registerFD, asyncBackend, sleepMs, hasChronos, unregisterFD, hasAsyncDispatch, hasAsyncSupport, hasAsyncSupport, hasChronos, hasAsyncDispatch