celina/widgets/text

Text widget for Celina CLI library

This module provides text rendering widgets with various alignment and styling options.

Types

Alignment = enum
  Left, Center, Right
Text alignment options
Text = ref object of Widget
  content*: string
  style*: Style
  alignment*: Alignment
  wrap*: Wrap
Simple text widget
Wrap = enum
  NoWrap, WordWrap, CharWrap
Text wrapping options

Procs

proc boldText(content: string; alignment: Alignment = Left): Text {....raises: [],
    tags: [], forbids: [].}
Create bold text
proc colorText(content: string; color: Color; alignment: Alignment = Left): Text {.
    ...raises: [], tags: [], forbids: [].}
Create colored text
proc newText(content: string; style: Style = defaultStyle();
             alignment: Alignment = Left; wrap: Wrap = NoWrap): Text {.
    ...raises: [], tags: [], forbids: [].}
Create a new Text widget
proc styledText(content: string; fg: Color; bg: Color = Reset;
                modifiers: set[StyleModifier] = {}; alignment: Alignment = Left): Text {.
    ...raises: [], tags: [], forbids: [].}
Create text with full styling
proc text(content: string; style: Style = defaultStyle();
          alignment: Alignment = Left; wrap: Wrap = NoWrap): Text {....raises: [],
    tags: [], forbids: [].}
Convenience constructor for Text widget
proc withAlignment(widget: Text; alignment: Alignment): Text {....raises: [],
    tags: [], forbids: [].}
Create a copy with different alignment
proc withStyle(widget: Text; style: Style): Text {....raises: [], tags: [],
    forbids: [].}
Create a copy with different style
proc withWrap(widget: Text; wrap: Wrap): Text {....raises: [], tags: [],
    forbids: [].}
Create a copy with different wrap mode

Methods

method getMinSize(widget: Text): Size {....raises: [], tags: [], forbids: [].}
Get minimum size for text widget
method getPreferredSize(widget: Text; available: Size): Size {.
    ...raises: [Exception], tags: [RootEffect], forbids: [].}
Get preferred size for text widget
method render(widget: Text; area: Rect; buf: var Buffer) {....raises: [], tags: [],
    forbids: [].}
Render the text widget