aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb/cmd/show_source.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb/cmd/show_source.rb')
-rw-r--r--lib/irb/cmd/show_source.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/irb/cmd/show_source.rb b/lib/irb/cmd/show_source.rb
index 10463ebf08..49cab43fab 100644
--- a/lib/irb/cmd/show_source.rb
+++ b/lib/irb/cmd/show_source.rb
@@ -2,6 +2,7 @@
require_relative "nop"
require_relative "../source_finder"
+require_relative "../pager"
require_relative "../color"
module IRB
@@ -40,12 +41,16 @@ module IRB
private
def show_source(source)
- puts
- puts "#{bold("From")}: #{source.file}:#{source.first_line}"
- puts
- code = IRB::Color.colorize_code(File.read(source.file))
- puts code.lines[(source.first_line - 1)...source.last_line].join
- puts
+ file_content = IRB::Color.colorize_code(File.read(source.file))
+ code = file_content.lines[(source.first_line - 1)...source.last_line].join
+ content = <<~CONTENT
+
+ #{bold("From")}: #{source.file}:#{source.first_line}
+
+ #{code}
+ CONTENT
+
+ Pager.page_content(content)
end
def bold(str)