https://github.com/pmunch/termstyle
Easy to use styles for terminal output
https://github.com/pmunch/termstyle
Last synced: about 1 year ago
JSON representation
Easy to use styles for terminal output
- Host: GitHub
- URL: https://github.com/pmunch/termstyle
- Owner: PMunch
- Created: 2018-01-28T13:41:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-02-21T23:49:55.000Z (over 4 years ago)
- Last Synced: 2025-02-11T13:25:05.752Z (over 1 year ago)
- Language: Nim
- Size: 1.95 KB
- Stars: 30
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
termstyle
===========
This module is created to bring extremely easy to use terminal colours and styles.
The official terminal module also does this but requires you to use calls like
``setStyle`` which clutters your input. This module on the other hand just defines
simple, single-word procedures that applies styles to everything that follows.
The most simple example is a regular ``echo`` statement for logging. To style it
with a red text colour simply do:
::
echo red "mystring"
This allows you to easily drop it into any echo statement without trouble.
Similarily to an echo it also takes varargs, so this would also work:
::
echo red("mystring", 42)
It even converts the integer to a string when concatenating just like echo does!
If you want to have multiple colours on a single line you can use multiple of
them and the ``echo`` varargs system:
::
echo red "This is blue: ", blue 42
In case you want to add more styles and don't want to chain them you can of
course also use the ``style`` procedure and combine the various styles:
::
echo style("mystring", termRed & termBlink)
This file is automatically generated from the documentation found in
termstyle.nim. Use ``nim doc2 termstyle.nim`` to get the full documentation.