rename EDIT → EXTEDIT, EDIT now use prompt

This commit is contained in:
Gwenhael Le Moine 2022-10-05 15:22:15 +02:00
parent 0d5baf6417
commit 6f3fe40a03
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
2 changed files with 20 additions and 2 deletions

17
bin/rpl
View file

@ -20,12 +20,25 @@ class RplRepl
end
Readline.completion_append_character = ' '
prefill = ''
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 )
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|
pp line
end
@ -62,7 +75,7 @@ options = { run_REPL: ARGV.empty?,
Version = Rpl::VERSION
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 )
end

View file

@ -31,6 +31,11 @@ module RplLang
proc {} )
@dictionary.add_word( ['edit'],
category,
'( x -- y ) put first stack object in prompt for modification',
proc {} )
@dictionary.add_word( ['extedit'],
category,
'( x -- y ) open object in $EDITOR',
proc do