RubyText is a curses wrapper. The modern variant is ncurses, and there are also others. This tutorial doesn't cover much of "real" curses, as the aim is to wrap it and make it simpler.
This project is somewhat in its infancy. Once it is a little more mature, I hope to produce an Elixir version. (Elixir is not usually used at the desktop, but it can be.)
Let's start at the beginning with the overused "hello world" example.
Here are some things to notice:
The start method can take a number of parameters, some of which are keyword arguments. If you know curses, some of these will be familiar, while others provide functionality unrelated to what curses provides.
The defaults for STDSCR are as follows:
RubyText.start(:cbreak, :_raw, :_echo, :keypad, log: "/tmp/rubytext.log", fg: White, bg: Blue, scroll: true) # can be abbreviated simply: RubyText.startIf you're a relative curses newbie (like me), you may have some confusion about the cbreak and raw modes. Let's clear it up a little with these four facts.
The standard curses implementation recognizes eight colors: Black, Blue, Cyan, Green, Magenta, Red, White, Yellow. Each of these constants refers to a symbol of the same (lowercased) name. What these colors look like in your own local environment may depend on many factors such as your operating system and terminal driver.
My own environment is iterm on Mac OSX with fairly standard settings. Here is some code that will display all 64 possibilities of foreground/background. (Note that curses seems to "cheat" when these two are the same, presumably to preserve legibility.)
You can use to retrieve characters from the screen as though it were a two-dimensional array. Similarly, = will set characters.
Methods that specify coordinates for points can replace one or more of those coordinates with symbols such as :top, :left, and :center.