Skip to content

Instantly share code, notes, and snippets.

@jbbarth
Last active August 29, 2015 14:25
Show Gist options
  • Save jbbarth/6793347b404b3559e189 to your computer and use it in GitHub Desktop.
Save jbbarth/6793347b404b3559e189 to your computer and use it in GitHub Desktop.
#type "a", "b", "c", "Enter", "a", "TAB":
% crystal test.cr
> abc
you typed: abc
> a
autocompleting on: "a"
line_buffer is: "abc\n"
# sample code for showing Readline.line_buffer is not updated realtime
require "readline"
Readline.autocomplete do |text|
print! "\nautocompleting on: #{text.inspect}\n"
print! "line_buffer is: #{Readline.line_buffer.inspect}\n"
[] of String
end
loop do
input = Readline.readline("> ")
print! "you typed: #{input}\n" unless input.nil?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment