Terminal text color printing and styling for GJS.
Print text and images in terminal with Ink using up to 16 million colors palette!
Just download this repository contents to /usr/share/gjs-1.0/ink
folder.
git clone https://github.com/Rafostar/ink.git /usr/share/gjs-1.0/ink
Alternatively download it to ink
folder in any other location and export that location path with GJS_PATH
environment variable.
Instructions how to use with full list of available options and functions can be found in wiki.
Here are some usage examples for each included module. More can be found inside examples folder in this repository.
gjs ./examples/basic.js
const { Ink } = imports.ink;
let printer = new Ink.Printer({
font: Ink.Font.BOLD,
color: Ink.Color.GREEN,
background: Ink.Color.DEFAULT
});
printer.print('Hello World');
gjs ./examples/advanced.js
const { Ink } = imports.ink;
let green = new Ink.Printer({
color: Ink.Color.GREEN
});
let blinkYellow = new Ink.Printer({
font: Ink.Font.BLINK,
color: Ink.colorFromHex('#ffff00')
});
let bgLightBlue = new Ink.Printer({
font: [
Ink.Font.BOLD,
Ink.Font.ITALIC,
Ink.Font.UNDERLINE
],
color: Ink.Color.RED,
background: Ink.Color.LIGHT_BLUE
});
green.print('green text in stdout');
green.printerr('green text in stderr');
bgLightBlue.print('light blue background');
blinkYellow.print('blinking text');
let various = new Ink.Printer({
color: Ink.Color.VARIOUS
});
various.print('various color');
various.print('other color');
various.print('yet another various color');
various.print(['supports', 'printing', 'arrays', 'and' , 'multiple', 'arguments', '!']);
various.font = [Ink.Font.UNDERLINE];
various.print('printer', 'values', 'may', 'be', 'changed', 'at', 'runtime');
let lightMagenta = new Ink.Printer({
color: Ink.Color.LIGHT_MAGENTA
});
lightMagenta.print(
`This single
text is printed
in multiple lines`
);
various.color = Ink.Color.LIGHT_BROWN;
bgLightBlue.font.push(Ink.Font.REVERSE);
print(
green.getPainted('can also return'),
various.getPainted('painted text'),
bgLightBlue.getPainted('for use with standard "print()"')
);
gjs ./examples/mario.js
const { Ink, Photo } = imports.ink;
let scanner = new Photo.Scanner({ size_y: 16 });
let image = scanner.scan('./examples/mario.png');
let printer = new Ink.Printer();
printer.print(image);
If you like my work please support it by buying me a cup of coffee :-)