frame (cellium v0.1.0)

View Source

Frame widget module for rendering rectangular containers with borders and titles.

This module provides a container widget that draws a border around its contents and a title in the top border. The frame can contain child widgets and renders with different border styles depending on focus state.

Usage

Basic frame as a container:

{frame, [{id, my_frame}, {title, "My Frame"}, {size, 10}, {color, yellow}], [
    {text_input, [{id, input1}, {expand, true}]}
]}

Empty decorative frame:

frame:new(decorative_frame, 20, 5)

Properties

  • width (integer): Width of the frame in characters.
  • height (integer): Height of the frame in characters.
  • orientation (atom): Layout orientation for children. Default: vertical
  • padding (map): Inner padding. Default: 1 on all sides
  • type: Set to container (can hold child widgets)
  • color (atom): Border color
  • title (string): Title text to display in the top border
  • title_align (atom): Alignment of the title: left, center, right. Default: left

Border Styles

  • Unfocused: Square/single-line border (┌─┐│└┘)
  • Focused or child has focus: Double-line border (╔═╗║╚╝)

Container Behavior

The frame is a container widget, so:

  • It can have children specified in the DSL
  • The layout system calculates dimensions for children
  • Default padding of 1 character on all sides
  • Children are laid out vertically by default

Example

{frame, [{id, input_frame}, {title, "Details"}, {size, 5}, {color, cyan}], [
    {text_input, [{id, ti1}, {wrap, true}, {expand, true}]}
]}

Summary

Functions

Creates a new frame with default dimensions (0x0).

Creates a new frame with specified dimensions.

Renders the frame border and title.

Functions

new(Id)

-spec new(term()) -> map().

Creates a new frame with default dimensions (0x0).

new(Id, Width, Height)

-spec new(term(), non_neg_integer(), non_neg_integer()) -> map().

Creates a new frame with specified dimensions.

The frame is a container that can hold child widgets. Children are laid out vertically with 1 character padding on all sides.

render(Widget, Buffer)

-spec render(map(), map()) -> map().

Renders the frame border and title.

Border style changes based on focus:

  • Focused or child has focus: double-line border
  • Unfocused: square/single-line border