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:
commit
7ca5facc1c
6 changed files with 13 additions and 13 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue