Permalink
Browse files

printing current line

  • Loading branch information...
1 parent 7fc02c9 commit 464e1a9968ffb800336ca3950a8ed7a911af34ed @jugyo committed Oct 8, 2010
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/ir_b.rb
View
@@ -27,6 +27,22 @@ def self.start_session(binding)
module IrB
class << self
def -(_binding)
+ file = _binding.eval '__FILE__'
+ ir_b_line = _binding.eval '__LINE__'
+ puts "#{file}:#{ir_b_line} \e[90mtxmt://open/?url=file://#{ File.expand_path file }&line=#{ ir_b_line }\e[0m"
+
+ File.open(file).each_with_index do |line, index|
+ line_n = index + 1
+ next unless line_n > (ir_b_line - 6)
+ break if line_n > (ir_b_line + 5)
+ if line_n == ir_b_line
+ color = "\e[100m"
+ else
+ color = "\e[90m"
+ end
+ puts color + "#{line_n.to_s.rjust(5)}: #{line.strip} \e[0m"
+ end
+
IRB.start_session(_binding)
end
end

0 comments on commit 464e1a9

Please sign in to comment.