diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2018-11-11 16:05:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-11 16:05:48 +0800 |
commit | d5c071fcd59da0ea97ca4c9224bd81f66ea32634 (patch) | |
tree | 28cee347fb98332c8b37e66678be0faa32df63bf | |
parent | e138cb3d0a21848f959ce18e9e585f74c4c25abb (diff) | |
parent | cf2189351a5112ad2754d05c5d572133ab752554 (diff) | |
download | pry-d5c071fcd59da0ea97ca4c9224bd81f66ea32634.tar.gz |
Merge pull request #1857 from r-obert/syntax-highlightable-prompt.rb
fix syntax highlighting of prompt.rb on Github & multiple editors
-rw-r--r-- | lib/pry/commands/change_prompt.rb | 2 | ||||
-rw-r--r-- | lib/pry/prompt.rb | 39 |
2 files changed, 26 insertions, 15 deletions
diff --git a/lib/pry/commands/change_prompt.rb b/lib/pry/commands/change_prompt.rb index 746cbbc3..68ae0af0 100644 --- a/lib/pry/commands/change_prompt.rb +++ b/lib/pry/commands/change_prompt.rb @@ -28,7 +28,7 @@ class Pry::Command::ChangePrompt < Pry::ClassCommand "#{bold(name)}#{red(' (selected)') if _pry_.prompt == prompt[:value]}\n" + prompt[:description] end - output.puts(prompts.join("\n")) + output.puts(prompts.join("\n" * 2)) end def change_prompt(prompt) diff --git a/lib/pry/prompt.rb b/lib/pry/prompt.rb index e00c5c38..f8c0bde2 100644 --- a/lib/pry/prompt.rb +++ b/lib/pry/prompt.rb @@ -90,11 +90,10 @@ class Pry end end - add(:default, <<DESC) do |context, nesting, _pry_, sep| -The default Pry prompt. Includes information about the current expression -number, evaluation context, and nesting level, plus a reminder that you're -using Pry. -DESC + add 'default', + "The default Pry prompt. Includes information about the current expression \n" \ + "number, evaluation context, and nesting level, plus a reminder that you're \n" \ + 'using Pry.' do |context, nesting, _pry_, sep| format( "[%<in_count>s] %<name>s(%<context>s)%<nesting>s%<separator>s ", in_count: _pry_.input_ring.count, @@ -105,14 +104,20 @@ DESC ) end - add(:simple, "A simple `>>`.\n", ['>> ', ' | ']) do |_, _, _, sep| + add( + 'simple', + "A simple `>>`.", + ['>> ', ' | '] + ) do |_, _, _, sep| sep end - add(:nav, <<DESC, %w[> *]) do |context, nesting, _pry_, sep| -A prompt that displays the binding stack as a path and includes information -about #{Helpers::Text.bold('_in_')} and #{Helpers::Text.bold('_out_')}. -DESC + add( + 'nav', + "A prompt that displays the binding stack as a path and includes information \n" \ + "about #{Helpers::Text.bold('_in_')} and #{Helpers::Text.bold('_out_')}.", + %w[> *] + ) do |context, nesting, _pry_, sep| tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval('self')) } format( "[%<in_count>s] (%<name>s) %<tree>s: %<stack_size>s%<separator>s ", @@ -124,9 +129,11 @@ DESC ) end - add(:shell, <<DESC, %w[$ *]) do |context, nesting, _pry_, sep| -A prompt that displays `$PWD` as you change it. -DESC + add( + 'shell', + 'A prompt that displays `$PWD` as you change it.', + %w[$ *] + ) do |context, nesting, _pry_, sep| format( "%<name>s %<context>s:%<pwd>s %<separator>s ", name: prompt_name(_pry_.config.prompt_name), @@ -136,6 +143,10 @@ DESC ) end - add(:none, 'Wave goodbye to the Pry prompt.', Array.new(2)) { '' } + add( + 'none', + 'Wave goodbye to the Pry prompt.', + Array.new(2) + ) { '' } end end |