Table of Contents

  1. NAME

Terminal::ANSI::OO -- Object-oriented interface to Terminal::ANSI

use Terminal::ANSI::OO :t;

put t.clear-screen;
put t.red ~ "red" ~ t.text-reset;
put t.bright-blue ~ "bright blue" ~ t.text-reset;
put t.color(1) ~ 'color 1';
put t.color(0,0,255) ~ 'blue';
put t.bg-color(255,0,0) ~ 'red bg';

Terminal::ANSI::OO provides an OO interface to Terminal::ANSI. An object can return all of the escape codes, rather then printing them to stdout. Passing ":t" will create and store such an object in the "t" variable.

All of the functions in Terminal::ANSI are available as methods, as well as t.$color, t.bright-$color, and t.bg-$color, where $color is one of: black, red, green, yellow, blue, magenta, cyan, or white.

Also t.color(N) and t.bg-color(N) (where N is between 0 and 255), will return the escape code for changing to color N.

Also t.color(R,G,B) and t.bg-color(R,G,B) (where R,G,B are between 0 and 255), will return the escape code for changing to rgb color R,G,B.

About this wiki

commit 476bea0d7603bb654f6781437724bcaadf3e0262
Author: Xliff <clifton.wood@gmail.com>
Date:   2022-07-15T14:22:21-04:00

- Replaces references to .reset-text with .text-reset in the docs

Signed-off-by: Brian Duggan <bduggan@matatu.org>
Clone this wiki
https://git.sr.ht/~bduggan/raku-terminal-ansi (read-only)
git@git.sr.ht:~bduggan/raku-terminal-ansi (read/write)