class TTY::Prompt::Multiline
A prompt responsible for multi line user input
@api private
Constants
- HELP
Public Class Methods
new(prompt, **options)
click to toggle source
Calls superclass method
# File lib/tty/prompt/multiline.rb, line 14 def initialize(prompt, **options) super @help = options[:help] || self.class::HELP @first_render = true @lines_count = 0 end
Public Instance Methods
help(value = (not_set = true))
click to toggle source
Provide help information
@return [String]
@api public
# File lib/tty/prompt/multiline.rb, line 26 def help(value = (not_set = true)) return @help if not_set @help = value end
keyreturn(*)
click to toggle source
# File lib/tty/prompt/multiline.rb, line 36 def keyreturn(*) @lines_count += 1 end
Also aliased as: keyenter
process_input(question)
click to toggle source
# File lib/tty/prompt/multiline.rb, line 55 def process_input(question) @prompt.print(question) @lines = read_input @input = "#{@lines.first.strip} ..." unless @lines.first.to_s.empty? if Utils.blank?(@input) && default? @input = default @lines = default end @evaluator.(@lines) end
read_input()
click to toggle source
# File lib/tty/prompt/multiline.rb, line 32 def read_input @prompt.read_multiline end
refresh(lines, lines_to_clear)
click to toggle source
# File lib/tty/prompt/multiline.rb, line 66 def refresh(lines, lines_to_clear) size = @lines_count + lines_to_clear + 1 @prompt.clear_lines(size) end
render_question()
click to toggle source
# File lib/tty/prompt/multiline.rb, line 41 def render_question header = ["#{@prefix}#{message} "] if !echo? header elsif @done header << @prompt.decorate(@input.to_s, @active_color) elsif @first_render header << @prompt.decorate(help, @help_color) @first_render = false end header << "\n" header.join end