RemiCharms

RemiCharms is an interface to libcurses for Crystal. It provides both a raw, low-level interface to libcurses via C bindings, and a more higher-level interface.

It is intended to be a bit easier to use than straight-up ncurses bindings. It is based on cl-charms, a similar interface to ncurses for Common Lisp.

Currently, the low-level interface (the NCurses module) is pretty close to ncurses itself. The high-level interface can be used directly alongside the low-level interface for those instances where the high level interface is missing functionality.

API documentation can be found here.

Wanna support Remilia? Buy me a coffee on Ko-Fi, or support her through Liberapay.

Buy Me a Coffee at ko-fi.com Donate using Liberapay

How do I get set up?

You will need Fossil installed to clone this repo. You will also need Shards v0.17.1 or later. If you have an earlier version of Shards, you will need to to build the latest version manually.

Add this to your shard.yml file:

dependencies:
  remicharms:
    fossil: https://chiselapp.com/user/MistressRemilia/repository/remicharms/

Usage

The examples folder has more examples. API documentation can be found here.

require "./src/remicharms"

RemiCharms.withCurses do |stdwin|
  RemiCharms.echoing = false
  RemiCharms.inputMode = RemiCharms::InputMode::CBreak
  stdwin.nonBlocking = true

  lastTime = Time.unix(0)
  width = 0
  height = 0
  x = 0
  y = 0
  message = "Hello, world!"

  loop do
    c = stdwin.getChar!
    break if c == 'q'

    stdwin.refresh

    width, height = stdwin.size
    if (Time.local - lastTime).total_milliseconds >= 469
      stdwin.clear
      x = Random.rand(width - message.size)
      y = Random.rand(height)
      stdwin.write(message, x, y)
      lastTime = Time.local
    else
      sleep 10.milliseconds
    end
  end
end

Important Note

The high level API swaps the X and Y arguments to any function that uses them. It also swaps the top/bottom and left/right arguments to the border drawing functions.

Style info

I use a somewhat non-standard style for my code.

How do I contribute?

  1. Go to https://chiselapp.com/user/MistressRemilia/repository/remicharms/ and clone the Fossil repository.
  2. Create a new branch for your feature.
  3. Push locally to the new branch.
  4. Create a bundle with Fossil that contains your changes.
  5. Get in contact with me.

Contributors

Links and Licenses

RemiCurses is under the GNU Affero General Public License version 3.