mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Add Pry::Terminal.height! (only used once)
This commit is contained in:
parent
1053e3e169
commit
9d20a96613
2 changed files with 8 additions and 4 deletions
|
@ -27,8 +27,7 @@ class Pry::Pager
|
|||
end
|
||||
|
||||
def self.page_size
|
||||
rows = Pry::Terminal.screen_size
|
||||
@page_size ||= (rows && rows.first || 27)
|
||||
@page_size ||= Pry::Terminal.height!
|
||||
end
|
||||
|
||||
def initialize(text)
|
||||
|
|
|
@ -13,15 +13,20 @@ class Pry::Terminal
|
|||
end
|
||||
|
||||
# Return a screen size or a default if that fails.
|
||||
def size! default = [25, 80]
|
||||
def size! default = [27, 80]
|
||||
screen_size || default
|
||||
end
|
||||
|
||||
# Return a screen width or the default if that fails.
|
||||
def width! default = 80
|
||||
def width!
|
||||
size![1]
|
||||
end
|
||||
|
||||
# Return a screen height or the default if that fails.
|
||||
def height!
|
||||
size![0]
|
||||
end
|
||||
|
||||
def actual_screen_size
|
||||
# The best way, if possible (requires non-jruby ≥1.9 or io-console gem)
|
||||
screen_size_according_to_io_console or
|
||||
|
|
Loading…
Add table
Reference in a new issue