Class: LLM::Repl::Input Private

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/repl/input.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::Input class manages the editable input line shown at the bottom of the REPL.

Constant Summary collapse

UP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Curses::Key::UP
DOWN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Curses::Key::DOWN
ENTER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[Curses::Key::ENTER, 10, 13]
BACKSPACE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[Curses::Key::BACKSPACE, 127]
EOF =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[nil, 4]

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ LLM::Repl::Input

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.

Parameters:

  • provider (String, Symbol)


18
19
20
21
# File 'lib/llm/repl/input.rb', line 18

def initialize(provider)
  @provider = provider
  @buffer = +""
end

Instance Method Details

#readline(window) ⇒ 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.

Parameters:

Returns:

  • (String, nil)


26
27
28
29
30
31
32
33
34
# File 'lib/llm/repl/input.rb', line 26

def readline(window)
  catch(:done) do
    @buffer.clear
    loop do
      on_char(window, window.getch)
      window.redraw
    end
  end
end

#to_sString

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.

Returns:

  • (String)


38
39
40
# File 'lib/llm/repl/input.rb', line 38

def to_s
  "> #{@buffer}"
end