Skip to content

Commit

Permalink
Change size from ioctl to allocate and read window buffer with fewer …
Browse files Browse the repository at this point in the history
…objects
  • Loading branch information
piotrmurach committed Dec 5, 2023
1 parent f2b07f4 commit fbdd4e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed
* Change the ioctl system call support check to use the output method
* Change size from ioctl to extract window buffer format and length to constants
* Change size from ioctl to allocate and read window buffer with fewer objects

### Fixed
* Fix ioctl call test to stub terminal size encoding for big-endian systems
Expand Down
6 changes: 3 additions & 3 deletions lib/tty/screen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ def size_from_io_console(verbose: false)
#
# @api private
def size_from_ioctl
buffer = ([0] * TIOCGWINSZ_BUF_LEN).pack(TIOCGWINSZ_BUF_FMT)
buffer = Array.new(TIOCGWINSZ_BUF_LEN, 0).pack(TIOCGWINSZ_BUF_FMT)

if ioctl?(TIOCGWINSZ, buffer) ||
ioctl?(TIOCGWINSZ_PPC, buffer) ||
ioctl?(TIOCGWINSZ_SOL, buffer)

rows, cols, = buffer.unpack(TIOCGWINSZ_BUF_FMT)[0..1]
return [rows, cols] if nonzero_column?(cols)
rows, cols, = buffer.unpack(TIOCGWINSZ_BUF_FMT)
[rows, cols] if nonzero_column?(cols)
end
end

Expand Down

0 comments on commit fbdd4e3

Please sign in to comment.