term_app v0.1.2

Functional term/console app environment

Build Status Version License

Term_app

Term_app is a minimal functional term/console app environment for Crystal.

It is closely related to shards Terminfo and Tput:

Terminfo parses terminfo files into instances of Terminfo::Data or custom classes.

Tput uses Terminfo data and additional methods to configure itself for outputting correct terminal sequences.

Term_app uses Tput and implements a completely usable term/console environment. It sets up event handlers, keys and mouse listeners, and everything else needed to provide a minimal working application.

It is implemented natively and does not depend on ncurses or other external library.

Installation

Add the dependency to shard.yml:

dependencies:
  term_app:
    github: crystallabs/term_app
    version: 0.1.2

Usage in a nutshell

Here is a basic example that starts the application, waits for keypresses or pasted data, prints the received content, and then sets the cursor at screen position x = 10, y = 10:

require "term_app"

my = TermApp::Data.new

my.input.on(TermApp::DataEvent) { |e|
  my.tput.print e.data[...e.len]
  my.tput.sety 10
  my.tput.setx 10
}

sleep 10

API documentation

Run crystal docs as usual, then open file docs/index.html.

Also, see examples in the directory examples/.

Testing

Run crystal spec as usual.

Also, see examples in the directory examples/.

Thanks

Other projects

List of interesting or similar projects in no particular order:

Repository

term_app

Owner
Statistic
  • 6
  • 1
  • 0
  • 0
  • 1
  • about 4 years ago
  • November 30, 2019
License

Other

Links
Synced at

Sun, 05 May 2024 07:03:38 GMT

Languages