Class: LLM::Repl::Window Private
- Inherits:
-
Object
- Object
- LLM::Repl::Window
- Defined in:
- lib/llm/repl/window.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The LLM::Repl::Window class draws the curses screen for the REPL.
Instance Attribute Summary collapse
- #buffer ⇒ LLM::Repl::Buffer readonly private
- #input ⇒ LLM::Repl::Input readonly private
- #status ⇒ LLM::Repl::Status readonly private
Instance Method Summary collapse
- #columns ⇒ Integer private
- #getch ⇒ Object private
- #initialize(repl) ⇒ LLM::Repl::Window constructor private
- #open { ... } ⇒ void private
-
#read_paste ⇒ String
private
Drains all available characters from the terminal input buffer without blocking.
- #redraw ⇒ void private
- #rows ⇒ Integer private
- #scroll_down ⇒ void private
- #scroll_to_bottom ⇒ void private
- #scroll_up ⇒ void private
Constructor Details
#initialize(repl) ⇒ LLM::Repl::Window
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 |
# File 'lib/llm/repl/window.rb', line 25 def initialize(repl) @repl = repl @status = repl.status @buffer = repl.buffer @input = repl.input end |
Instance Attribute Details
#buffer ⇒ LLM::Repl::Buffer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/llm/repl/window.rb', line 15 def buffer @buffer end |
#input ⇒ LLM::Repl::Input (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/llm/repl/window.rb', line 19 def input @input end |
#status ⇒ LLM::Repl::Status (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/llm/repl/window.rb', line 11 def status @status end |
Instance Method Details
#columns ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'lib/llm/repl/window.rb', line 65 def columns Curses.cols end |
#getch ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 |
# File 'lib/llm/repl/window.rb', line 71 def getch Curses.getch end |
#open { ... } ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/llm/repl/window.rb', line 35 def open Curses.init_screen Color.enable Curses.cbreak Curses.noecho Curses.stdscr.keypad(true) Curses.stdscr.nodelay = true yield ensure Curses.close_screen end |
#read_paste ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Drains all available characters from the terminal input
buffer without blocking. Used in place of Curses.getstr
when the paste flag is set, so that a huge multi-line
paste is consumed in a single shot instead of being
processed character-by-character.
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/llm/repl/window.rb', line 82 def read_paste chars = +"" loop do ch = Curses.getch break unless ch and ch != -1 chars << ch end input.paste = false chars end |
#redraw ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
49 50 51 52 53 54 55 |
# File 'lib/llm/repl/window.rb', line 49 def redraw draw_status(offset: input.height + 1) draw_divider(offset: 5) draw_buffer(offset: 0) draw_input Curses.refresh end |
#rows ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 |
# File 'lib/llm/repl/window.rb', line 59 def rows [Curses.lines - (input.height + 4), 1].max end |
#scroll_down ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
101 102 103 |
# File 'lib/llm/repl/window.rb', line 101 def scroll_down buffer.scroll_down end |
#scroll_to_bottom ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
107 108 109 |
# File 'lib/llm/repl/window.rb', line 107 def scroll_to_bottom buffer.scroll_to_bottom end |
#scroll_up ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
95 96 97 |
# File 'lib/llm/repl/window.rb', line 95 def scroll_up buffer.scroll_up(rows) end |