rename EDIT → EXTEDIT, EDIT now use prompt
This commit is contained in:
parent
0d5baf6417
commit
6f3fe40a03
2 changed files with 20 additions and 2 deletions
17
bin/rpl
17
bin/rpl
|
@ -20,12 +20,25 @@ class RplRepl
|
||||||
end
|
end
|
||||||
Readline.completion_append_character = ' '
|
Readline.completion_append_character = ' '
|
||||||
|
|
||||||
|
prefill = ''
|
||||||
loop do
|
loop do
|
||||||
|
Readline.pre_input_hook = lambda do
|
||||||
|
return if prefill.empty?
|
||||||
|
|
||||||
|
Readline.refresh_line
|
||||||
|
Readline.insert_text( prefill.to_s )
|
||||||
|
Readline.redisplay
|
||||||
|
end
|
||||||
|
|
||||||
input = Readline.readline( ' ', true )
|
input = Readline.readline( ' ', true )
|
||||||
|
|
||||||
break if input.nil? || input.strip == 'quit'
|
break if input.nil? || input.strip == 'quit'
|
||||||
|
|
||||||
if input.strip == 'history'
|
prefill = ''
|
||||||
|
|
||||||
|
if input.strip == 'edit'
|
||||||
|
prefill = @interpreter.stack.pop.to_s
|
||||||
|
elsif input.strip == 'history'
|
||||||
Readline::HISTORY.each do |line|
|
Readline::HISTORY.each do |line|
|
||||||
pp line
|
pp line
|
||||||
end
|
end
|
||||||
|
@ -62,7 +75,7 @@ options = { run_REPL: ARGV.empty?,
|
||||||
Version = Rpl::VERSION
|
Version = Rpl::VERSION
|
||||||
|
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.on('-s', "--state filename", "persist state in filename (default: #{options[:persistence_filename]}) (will be created if needed)") do |filename|
|
opts.on('-s', '--state filename', "persist state in filename (default: #{options[:persistence_filename]}) (will be created if needed)") do |filename|
|
||||||
options[:persistence_filename] = File.expand_path( filename )
|
options[:persistence_filename] = File.expand_path( filename )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,11 @@ module RplLang
|
||||||
proc {} )
|
proc {} )
|
||||||
|
|
||||||
@dictionary.add_word( ['edit'],
|
@dictionary.add_word( ['edit'],
|
||||||
|
category,
|
||||||
|
'( x -- y ) put first stack object in prompt for modification',
|
||||||
|
proc {} )
|
||||||
|
|
||||||
|
@dictionary.add_word( ['extedit'],
|
||||||
category,
|
category,
|
||||||
'( x -- y ) open object in $EDITOR',
|
'( x -- y ) open object in $EDITOR',
|
||||||
proc do
|
proc do
|
||||||
|
|
Loading…
Reference in a new issue