Reply::Reader
Inherits Reference < Object
Reader for your REPL.
Create a subclass of it and override methods to customize behavior.
class MyReader < Reply::Reader
def prompt(io, line_number, color)
io << "reply> "
end
end
Run the REPL with run:
reader = MyReader.new
reader.run do |expression|
# Eval expression here
puts " => #{expression}"
end
Or with read_next:
loop do
expression = reader.read_next
break unless expression
# Eval expression here
puts " => #{expression}"
end
Constructors
Instance methods
Override to integrate auto-completion.
current_word is picked following word_delimiters.
It expects to return Tuple with:
- a title :
String - the auto-completion results :
Array(String)
default: {"", [] of String}
Override to customize how entry is displayed.
Entry is split in two (entry_matched + entry_remaining). entry_matched correspond
to the part already typed when auto-completion was triggered.
default: entry_matched bright + entry_remaining normal.
Override to customize how the selected entry is displayed.
default: entry bright on dark grey
Override to customize how title is displayed.
default: title underline + ":"
Override to retrigger auto completion when condition is met.
default: false
Override this method to makes the interface continue on multiline, depending of the expression.
default: false
Override with true to disable the reverse i-search (ctrl-r).
default: true (disabled) if history_file not set.
Override to set the entire documentation for an autocompletion entry.
If not nil, the documentation is shown in its own alternate screen when alt-d is pressed.
default: nil
Override to set the documentation summary for an autocompletion entry.
If not nil, the summary is shown below the prompt, only one line is currently supported
default: first line of documentation.
Override to enable reformatting after submitting.
default: unchanged expression
Override to enable expression highlighting.
default: uncolored expression
Override to indicate the Path|String|IO where the history is saved. If nil, the history is not persistent.
default: nil
Override to return the expected indentation level in function of expression before cursor.
default: 0
Override to customize the prompt.
Toggle the colorization following color.
default: $:001>
Override to enable line re-indenting.
This methods is called each time a character is entered.
You should return either:
nil: keep the line as itInt32value: re-indent the line by an amount equal to the returned value, relatively toindentation_level. (0 to followindentation_level)
See example/crystal_repl.
default: nil
Override to select which expression is saved in history.
default: !expression.blank?