1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

ls output colors can be configured using, e.g Pry.config.ls.local_var_color = :red.

This commit is contained in:
John Mair 2011-09-08 03:39:22 +12:00
parent 0eca0f1aa9
commit 740e2d0773
3 changed files with 25 additions and 26 deletions

View file

@ -32,6 +32,8 @@
* cd command now supports complex syntax: cd ../@y/y/../z
* JRuby is no longer a 2nd class citizen, almost full JRuby support, passing 100% tests
* added Pry::NAV_PROMPT (great new navigation prompt, per robgleeson) and Pry::SIMPLE_PRINT for simple (IRB-style) print output (just using inspect)
* _pry_ now passed as 3rd parameter to :before_session hook
* ls colors now configurable via Pry.config.ls.local_var_color = :bright_red etc
*/7/2011 version 0.9.3
* cat --ex (cats 5 lines above and below line in file where exception was raised)

View file

@ -22,18 +22,18 @@ class Pry
def ls_color_map
{
"local variables" => :bright_red,
"instance variables" => :bright_blue,
"class variables" => :blue,
"global variables" => :bright_magenta,
"just singleton methods" => :green,
"public methods" => :green,
"private methods" => :green,
"protected methods" => :green,
"public instance methods" => :bright_green,
"private instance methods" => :bright_green,
"protected instance methods" => :bright_green,
"constants" => :red
"local variables" => Pry.config.ls.local_var_color,
"instance variables" => Pry.config.ls.instance_var_color,
"class variables" => Pry.config.ls.class_var_color,
"global variables" => Pry.config.ls.global_var_color,
"just singleton methods" => Pry.config.ls.method_color,
"public methods" => Pry.config.ls.method_color,
"private methods" => Pry.config.ls.method_color,
"protected methods" => Pry.config.ls.method_color,
"public instance methods" => Pry.config.ls.instance_method_color,
"private instance methods" => Pry.config.ls.instance_method_color,
"protected instance methods" => Pry.config.ls.instance_method_color,
"constants" => Pry.config.ls.constant_color
}
end
end
@ -198,7 +198,7 @@ Shows local and instance variables by default.
if !v.first.empty?
text << "#{k}:\n--\n"
filtered_list = v.first.grep options[:grep]
text << text().bright_green(filtered_list.join(" "))
text << text().send(ls_color_map[k], (filtered_list.join(" ")))
text << "\n\n"
end
end

View file

@ -95,17 +95,6 @@ class Pry
new(options).repl(target)
end
# A custom version of `Kernel#pretty_inspect`.
# This method should not need to be accessed directly.
# @param obj The object to view.
# @return [String] The string representation of `obj`.
def self.view(obj)
obj.pretty_inspect
rescue NoMethodError
"unknown"
end
# A version of `Pry.view` that clips the output to `max_size` chars.
# In case of > `max_size` chars the `#<Object...> notation is used.
# @param obj The object to view.
@ -199,7 +188,6 @@ class Pry
config.plugins ||= OpenStruct.new
config.plugins.enabled = true
config.plugins.strict_loading = true
config.requires ||= []
config.should_load_requires = true
@ -212,6 +200,15 @@ class Pry
config.control_d_handler = DEFAULT_CONTROL_D_HANDLER
config.memory_size = 100
Pry.config.ls ||= OpenStruct.new
Pry.config.ls.local_var_color = :bright_red
Pry.config.ls.instance_var_color = :bright_blue
Pry.config.ls.class_var_color = :blue
Pry.config.ls.global_var_color = :bright_magenta
Pry.config.ls.method_color = :green
Pry.config.ls.instance_method_color = :bright_green
Pry.config.ls.constant_color = :yellow
end
# Set all the configurable options back to their default values