Class: RatatuiRuby::Widgets::Clear

Inherits:
Object
  • Object
show all
Includes:
CoerceableWidget
Defined in:
lib/ratatui_ruby/widgets/clear.rb

Overview

Resets the terminal buffer for a specific area.

Painting in a terminal is additive. New content draws over old content. If the new content has transparency or empty spaces, the old content “bleeds” through. This ruins popups and modals.

This widget wipes the slate clean. It resets all cells in its area to their default state (spaces with default background).

Use it as the first layer in an Overlay stack when building popups. Ensure your floating windows are truly opaque.

Examples

– SPDX-SnippetBegin SPDX-FileCopyrightText: 2026 Kerrick Long SPDX-License-Identifier: MIT-0 ++

# Opaque Popup Construction
Overlay.new(
  layers: [
    MainUI.new,
    Center.new(
      child: Overlay.new(
        layers: [
          Clear.new, # Wipe the area first
          Block.new(title: "Modal", borders: [:all])
        ]
      ),
      width_percent: 50,
      height_percent: 50
    )
  ]
)

# Shortcut: rendering a block directly
Clear.new(block: Block.new(title: "Cleared area", borders: [:all]))

– SPDX-SnippetEnd ++

Instance Method Summary collapse

Methods included from CoerceableWidget

included

Constructor Details

#initialize(block: nil) ⇒ Clear

Creates a new Clear widget.

block

Block widget to render (optional).



61
62
63
# File 'lib/ratatui_ruby/widgets/clear.rb', line 61

def initialize(block: nil)
  super
end