Skip to content

piotrmurach/tty-screen

Repository files navigation

TTY Toolkit logo

TTY::Screen

Gem Version Actions CI Build status Code Climate Coverage Status

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     # => 280

Use the height, lines or rows method to detect terminal screen height:

TTY::Screen.height  # => 51
TTY::Screen.lines   # => 51
TTY::Screen.rows    # => 51

Development

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

  1. Fork it ( https://github.com/piotrmurach/tty-screen/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. 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.