# Usage

colorin uses ANSI escape sequences internally to format, color and apply other options to the output displayed in text terminals.

Typical usage involves creating an instance of :py:class:colorin.cli.Display class, and tell it what to do with your text. For example, let's suppose you want to print "Hello world!" in green and "Bye world!" in red:

#! /usr/bin/env python

from colorin.cli import Display

screen = Display()
screen.color("Hello world!", "Green")
screen.color("Bye world!", "Red")


## Foreground and background colors

In the code example above, we just specified the foreground color for the text. You can use the same method, :py:meth:colorin.cli.Display.color(), to add a background color. The following code will print a white text on a yellow background:

#! /usr/bin/env python

from colorin.cli import Display

screen = Display()
screen.color("Warning!", "White", "Yellow")


The set of colors available for both, text foreground and background, is limited to the following list: Black, Red, Green, Yellow, Blue, Magenta, Cyan and White.

## Bold text

There are two methods to print bold strings: :py:meth:colorin.cli.Display.color() and :py:meth:colorin.cli.Display.bold(). Use the former if you want to print a bold colored string, and the latter to print a bold string with your terminal's default foreground color:

#! /usr/bin/env python

from colorin.cli import Display

screen = Display()
screen.color("I'm bold and green", "Green", bold=True)
screen.bold("I'm just bold")

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.