Terminal screen size detection for Linux, MacOS, or Windows.
This is a port of Piotr Murach's TTY::Screen from ruby to mruby.
gcc or clang, bison, and ruby.
By default, the build_config.rb
will attempt to use clang unless you are on windows.
rake compile
to compile mruby with TTY:Screen modules includedmruby/bin/mirb
to start the mruby interactive shell- Try the commands in the usage section
TTY::Screen allows you to detect terminal screen size by calling the size
method which returns a [height, width] tuple.
TTY::Screen.size # => [51, 280]
Terminal width:
TTY::Screen.width # => 280
TTY::Screen.columns # => 280
TTY::Screen.cols # => 280
Terminal height:
TTY::Screen.height # => 51
TTY::Screen.rows # => 51
TTY::Screen.lines # => 51
Add this line to your application's mrbgem.rake file:
spec.add_dependency 'mruby-tty-screen', github: 'jeremyjung/mruby-tty-screen'
Windows does not include any of the mruby dependencies (ruby, gcc, bison) so they'll need to be installed.
- Install rubyinstaller 2.4.3-2 (x64)
- When the MSYS2 command prompt appears, hit enter to install default toolchain
- After installation is complete, open a terminal and go to the mruby-tty-screen directory
- Run
ridk enable
- Run
pacman -S bison
- Run
rake compile
Note that any time you open a terminal, you must run ridk enable
before attempting to run rake compile
in Windows or the compilation will fail.
mruby has no stubbing library that would allow the porting of existing tests.
All private class methods were changed to public as mruby does not support them.
All references to jruby were removed.
Keyword arguments are unsupported in mruby so they were changed to a hash parameter.
All require statements were removed as mruby is compiled.
Fiddle code was changed to native C as mruby does not include fiddle.
Removed references to SystemCallError which do not exist in the mruby-process gem.
Remove dependencies on mruby-io-console (sys/wait.h does not exist) and mruby-process (sys/ioctl.h does not exist) on windows.
- Fork it ( https://github.com/jeremyjung/mruby-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
Copyright (c) 2014-2018 Piotr Murach. See LICENSE for further details.