summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-24 02:26:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-24 02:26:22 +0000
commitc03c03cc11ca59dd8e93e769297f99aaf0826652 (patch)
tree931b2af0b2b7ad5cc6a76ef042bc524e0a0f08ed /lib
parent43e64b85852e72b1e7f28bdd0f33eaec57b906c8 (diff)
lib/irb.rb: highlight exceptions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/irb.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/irb.rb b/lib/irb.rb
index 183ad813ee..ff793dcd64 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -520,13 +520,14 @@ module IRB
end
end
end
- print "Traceback (most recent call last):\n"
+ attr = STDOUT.tty? ? ATTR_TTY : ATTR_PLAIN
+ print "#{attr[1]}Traceback#{attr[]} (most recent call last):\n"
unless lasts.empty?
puts lasts.reverse
printf "... %d levels...\n", levels if levels > 0
end
puts messages.reverse
- print exc.class, ": ", exc, "\n"
+ print "#{attr[1]}#{exc.class} (#{attr[4]}#{exc}#{attr[0, 1]})#{attr[]}\n"
print "Maybe IRB bug!\n" if irb_bug
end
end
@@ -674,6 +675,11 @@ module IRB
end
format("#<%s: %s>", self.class, ary.join(", "))
end
+
+ ATTR_TTY = "\e[%sm"
+ def ATTR_TTY.[](*a) self % a.join(";"); end
+ ATTR_PLAIN = ""
+ def ATTR_PLAIN.[](*) self; end
end
def @CONF.inspect