mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
added input_array data to DEFAULT_PROMPT, e.g [1] pry(main)>
This commit is contained in:
parent
db649858af
commit
173e593375
1 changed files with 25 additions and 25 deletions
50
lib/pry.rb
50
lib/pry.rb
|
@ -60,42 +60,23 @@ class Pry
|
||||||
|
|
||||||
# The default prompt; includes the target and nesting level
|
# The default prompt; includes the target and nesting level
|
||||||
DEFAULT_PROMPT = [
|
DEFAULT_PROMPT = [
|
||||||
proc { |target_self, nest_level, _|
|
proc { |target_self, nest_level, pry|
|
||||||
if nest_level == 0
|
if nest_level == 0
|
||||||
"pry(#{Pry.view_clip(target_self)})> "
|
"[#{pry.input_array.size}] pry(#{Pry.view_clip(target_self)})> "
|
||||||
else
|
else
|
||||||
"pry(#{Pry.view_clip(target_self)}):#{nest_level}> "
|
"[#{pry.input_array.size}] pry(#{Pry.view_clip(target_self)}):#{nest_level}> "
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
proc { |target_self, nest_level, _|
|
proc { |target_self, nest_level, pry|
|
||||||
if nest_level == 0
|
if nest_level == 0
|
||||||
"pry(#{Pry.view_clip(target_self)})* "
|
"[#{pry.input_array.size}] pry(#{Pry.view_clip(target_self)})* "
|
||||||
else
|
else
|
||||||
"pry(#{Pry.view_clip(target_self)}):#{nest_level}* "
|
"[#{pry.input_array.size}] pry(#{Pry.view_clip(target_self)}):#{nest_level}* "
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
# Deal with the ^D key being pressed, different behaviour in
|
|
||||||
# different cases:
|
|
||||||
# 1) In an expression - behave like `!` command (clear input buffer)
|
|
||||||
# 2) At top-level session - behave like `exit command (break out of repl loop)
|
|
||||||
# 3) In a nested session - behave like `cd ..` (pop a binding)
|
|
||||||
DEFAULT_CONTROL_D_HANDLER = proc do |eval_string, _pry_|
|
|
||||||
if !eval_string.empty?
|
|
||||||
# clear input buffer
|
|
||||||
eval_string.replace("")
|
|
||||||
elsif _pry_.binding_stack.one?
|
|
||||||
# ^D at top-level breaks out of loop
|
|
||||||
_pry_.binding_stack.clear
|
|
||||||
throw(:breakout)
|
|
||||||
else
|
|
||||||
# otherwise just pops a binding
|
|
||||||
_pry_.binding_stack.pop
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# A simple prompt - doesn't display target or nesting level
|
# A simple prompt - doesn't display target or nesting level
|
||||||
SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
|
SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
|
||||||
|
|
||||||
|
@ -117,6 +98,25 @@ class Pry
|
||||||
end,
|
end,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Deal with the ^D key being pressed, different behaviour in
|
||||||
|
# different cases:
|
||||||
|
# 1) In an expression - behave like `!` command (clear input buffer)
|
||||||
|
# 2) At top-level session - behave like `exit command (break out of repl loop)
|
||||||
|
# 3) In a nested session - behave like `cd ..` (pop a binding)
|
||||||
|
DEFAULT_CONTROL_D_HANDLER = proc do |eval_string, _pry_|
|
||||||
|
if !eval_string.empty?
|
||||||
|
# clear input buffer
|
||||||
|
eval_string.replace("")
|
||||||
|
elsif _pry_.binding_stack.one?
|
||||||
|
# ^D at top-level breaks out of loop
|
||||||
|
_pry_.binding_stack.clear
|
||||||
|
throw(:breakout)
|
||||||
|
else
|
||||||
|
# otherwise just pops a binding
|
||||||
|
_pry_.binding_stack.pop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
DEFAULT_SYSTEM = proc do |output, cmd, _|
|
DEFAULT_SYSTEM = proc do |output, cmd, _|
|
||||||
if !system(cmd)
|
if !system(cmd)
|
||||||
output.puts "Error: there was a problem executing system command: #{cmd}"
|
output.puts "Error: there was a problem executing system command: #{cmd}"
|
||||||
|
|
Loading…
Reference in a new issue