TTY::Screen
Terminal screen size detection that works on Linux, macOS and Windows systems and supports Ruby MRI, JRuby, TruffleRuby and Rubinius interpreters.
TTY::Screen provides a terminal screen size detection component for the TTY toolkit.
Installation
Add this line to your application's Gemfile:
gem "tty-screen"And then execute:
$ bundle
Or install it yourself as:
$ gem install tty-screen
1. Usage
Use the size method to detect terminal screen size. It will result in
a [height, width] array:
TTY::Screen.size # => [51, 280]Use the width, columns or cols method to detect terminal screen width:
TTY::Screen.width # => 280
TTY::Screen.columns # => 280
TTY::Screen.cols # => 280Use the height, lines or rows method to detect terminal screen height:
TTY::Screen.height # => 51
TTY::Screen.lines # => 51
TTY::Screen.rows # => 51Development
After checking out the repo, run bin/setup to install dependencies.
Then, run rake spec to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
Contributing
- Fork it ( https://github.com/piotrmurach/tty-screen/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the TTY::Screen project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Copyright
Copyright (c) 2014 Piotr Murach. See LICENSE.txt for further details.
