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

Merge pull request #2042 from pry/terminal-refactoring

terminal: rename 'bang' methods to normal ones
This commit is contained in:
Kyrylo Silin 2019-05-19 11:31:54 +03:00 committed by GitHub
commit 7ca5facc1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 13 deletions

View file

@ -11,7 +11,7 @@ class Pry
def self.default(_output, value, pry_instance)
pry_instance.pager.open do |pager|
pager.print pry_instance.config.output_prefix
pp(value, pager, Pry::Terminal.width! - 1)
pp(value, pager, Pry::Terminal.width - 1)
end
end

View file

@ -5,7 +5,7 @@ class Pry
def self.tablify_or_one_line(heading, things, config = Pry.config)
plain_heading = Pry::Helpers::Text.strip_color(heading)
attempt = Table.new(things, column_count: things.size)
if attempt.fits_on_line?(Terminal.width! - plain_heading.size - 2)
if attempt.fits_on_line?(Terminal.width - plain_heading.size - 2)
"#{heading}: #{attempt}\n"
else
"#{heading}: \n#{tablify_to_screen_width(things, { indent: ' ' }, config)}\n"
@ -16,10 +16,10 @@ class Pry
options ||= {}
things = things.compact
if (indent = options[:indent])
usable_width = Terminal.width! - indent.size
usable_width = Terminal.width - indent.size
tablify(things, usable_width, config).to_s.gsub(/^/, indent)
else
tablify(things, Terminal.width!, config).to_s
tablify(things, Terminal.width, config).to_s
end
end

View file

@ -394,7 +394,7 @@ class Pry
line_to_measure = Pry::Helpers::Text.strip_color(prompt) << code
whitespace = ' ' * overhang
cols = Terminal.width!
cols = Terminal.width
lines = cols == 0 ? 1 : (line_to_measure.length / cols + 1).to_i
if Helpers::Platform.windows_ansi?

View file

@ -88,11 +88,11 @@ class Pry
private
def height
@height ||= Pry::Terminal.height!
@height ||= Pry::Terminal.height
end
def width
@width ||= Pry::Terminal.width!
@width ||= Pry::Terminal.width
end
end

View file

@ -300,7 +300,7 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
trap :WINCH do
begin
Readline.set_screen_size(*Terminal.size!)
Readline.set_screen_size(*Terminal.size)
rescue StandardError => e
warn "\nPry.auto_resize!'s Readline.set_screen_size failed: #{e}"
end

View file

@ -12,18 +12,18 @@ class Pry
end
# Return a screen size or a default if that fails.
def size!(default = [27, 80])
def size(default = [27, 80])
screen_size || default
end
# Return a screen width or the default if that fails.
def width!
size![1]
def width
size[1]
end
# Return a screen height or the default if that fails.
def height!
size![0]
def height
size[0]
end
def actual_screen_size