Class: RatatuiRuby::Terminal::Viewport

Inherits:
Object
  • Object
show all
Defined in:
lib/ratatui_ruby/terminal/viewport.rb

Overview

Viewport configuration for terminal initialization.

Determines how RatatuiRuby interacts with the terminal:

  • Fullscreen: Uses alternate screen, clears on exit (default)

  • Inline: Fixed-height region, persists in scrollback after exit

Example

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

# Fullscreen (default behavior)
RatatuiRuby.run { |tui| ... }

# Inline with 8 lines
RatatuiRuby.run(viewport: :inline, height: 8) { |tui| ... }

– SPDX-SnippetEnd ++

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, height: nil) ⇒ Viewport

Creates a new viewport configuration.

type

Symbol representing viewport type (:fullscreen or :inline).

height

Integer height in lines (required for :inline, ignored for :fullscreen).

Most developers use fullscreen or inline factory methods instead.



63
64
65
# File 'lib/ratatui_ruby/terminal/viewport.rb', line 63

def initialize(type:, height: nil)
  super
end

Class Method Details

.fullscreenObject

Creates a fullscreen viewport (alternate screen).



46
47
48
# File 'lib/ratatui_ruby/terminal/viewport.rb', line 46

def self.fullscreen
  new(type: :fullscreen)
end

.inline(height) ⇒ Object

Creates an inline viewport with the given height.



52
53
54
# File 'lib/ratatui_ruby/terminal/viewport.rb', line 52

def self.inline(height)
  new(type: :inline, height:)
end

Instance Method Details

#fullscreen?Boolean

Returns true if this is a fullscreen viewport.

Returns:

  • (Boolean)


69
70
71
# File 'lib/ratatui_ruby/terminal/viewport.rb', line 69

def fullscreen?
  type == :fullscreen
end

#inline?Boolean

Returns true if this is an inline viewport.

Returns:

  • (Boolean)


75
76
77
# File 'lib/ratatui_ruby/terminal/viewport.rb', line 75

def inline?
  type == :inline
end