view (cellium v0.1.0)

View Source

View server responsible for rendering the widget tree to the terminal.

This gen_server manages the rendering lifecycle, including:

  • Loading and applying CSS stylesheets
  • Calculating layouts from widget trees
  • Dirty checking to avoid unnecessary redraws
  • Handling terminal resizes
  • Managing the double-buffered rendering system

The view uses a dirty-checking optimization where it only re-renders when:

  • The root widget tree has changed
  • The terminal has been resized
  • A forced redraw is requested

Rendering Pipeline

  1. Widget tree → Layout calculation → CSS styling → Buffer rendering → Terminal output

Double Buffering

The underlying terminal backend maintains front and back buffers, only sending diff updates to the terminal for changed cells.

Summary

Functions

Returns the current root widget tree.

Sets the root widget tree and triggers a render if it has changed.

Forces an immediate re-render regardless of dirty state.

Functions

code_change(OldVsn, State, Extra)

get_root_widget()

Returns the current root widget tree.

handle_call/3

handle_cast(Msg, State)

handle_info/2

init/1

set_root_widget(RootWidget)

Sets the root widget tree and triggers a render if it has changed.

start_link()

terminate(Reason, State)

update_now()

Forces an immediate re-render regardless of dirty state.