tuicrown

Source   Edit  

🌈 TuiCrown 👑

https://github.com/pysan3/tuicrown

Tuicrown is a Nim library for rich text and beautiful formatting in the terminal.

This library also provides top level aliases such as print, input for ease of use.

input

The following code-block is not accurate due to reStructuredText constraints.

var prog = input("[yellow]Nim :crown:[yellow] or [blue]Python :snake:[/]?")

print

Example:

import tuicrown
print("[green]Hello Nim![/]")
print(true, false, 100, 0.001, 1e-6)
print("[yellow]Nim :crown:[yellow] or [blue]Python :snake:[/]?")

Examples and Tests

Example usages are listed in https://github.com/pysan3/tuicrown/tree/main/tests . If you have more interests on the syntax, take a look there.

Lets

gConsoleErr = newTuiConsole(newTuiConsoleOptions(true, 2, false, false, true,
    true, false, false, false), "auto", stderr, -1, -1)
Global console object writing to stderr. Source   Edit  
gConsoleOut = newTuiConsole(newTuiConsoleOptions(true, 2, false, false, true,
    true, false, false, false), "auto", stdout, -1, -1)
Global console object used for print. Source   Edit  

Procs

proc einfo(args: varargs[string, `$`]) {.
    ...raises: [KeyError, Exception, ValueError, OSError, IOError],
    tags: [RootEffect, ReadEnvEffect, WriteEnvEffect, WriteIOEffect],
    forbids: [].}
print to stderr but prefixed with [green]Info:[/]. Source   Edit  
proc eprint(args: varargs[string, `$`]) {.
    ...raises: [KeyError, Exception, ValueError, OSError, IOError],
    tags: [RootEffect, ReadEnvEffect, WriteEnvEffect, WriteIOEffect],
    forbids: [].}
print to stderr with style parsing. Values will be space separated. Source   Edit  
proc error(args: varargs[string, `$`]) {.
    ...raises: [KeyError, Exception, ValueError, OSError, IOError],
    tags: [RootEffect, ReadEnvEffect, WriteEnvEffect, WriteIOEffect],
    forbids: [].}
print to stderr but prefixed with [red]ERROR:[/]. Source   Edit  
proc ewarn(args: varargs[string, `$`]) {.
    ...raises: [KeyError, Exception, ValueError, OSError, IOError],
    tags: [RootEffect, ReadEnvEffect, WriteEnvEffect, WriteIOEffect],
    forbids: [].}
print to stderr but prefixed with [yellow]Warning:[/]. Source   Edit  
proc flush(args: varargs[string, `$`]) {.
    ...raises: [KeyError, Exception, ValueError, OSError, IOError],
    tags: [RootEffect, ReadEnvEffect, WriteEnvEffect, WriteIOEffect],
    forbids: [].}
print to stdout but without a newline. Source   Edit  
proc info(args: varargs[string, `$`]) {....raises: [KeyError, Exception,
    ValueError, OSError, IOError], tags: [RootEffect, ReadEnvEffect,
    WriteEnvEffect, WriteIOEffect], forbids: [].}
print to stdout but prefixed with [green]Info:[/]. Source   Edit  
proc input(args: varargs[string, `$`]): string {.
    ...raises: [KeyError, Exception, ValueError, OSError, IOError], tags: [
    RootEffect, ReadEnvEffect, WriteEnvEffect, WriteIOEffect, ReadIOEffect],
    forbids: [].}
Asks for user input from stdin with prompt colored with TuiCrown.

var prog = input("[yellow]Nim :crown:[yellow] or [blue]Python :snake:[/]?")

Source   Edit  
proc rror(args: varargs[string, `$`]) {....raises: [KeyError, Exception,
    ValueError, OSError, IOError], tags: [RootEffect, ReadEnvEffect,
    WriteEnvEffect, WriteIOEffect], forbids: [].}

print to stdout but prefixed with [red]ERROR:[/].

Error but to stdout -> rror

Source   Edit  
proc warn(args: varargs[string, `$`]) {....raises: [KeyError, Exception,
    ValueError, OSError, IOError], tags: [RootEffect, ReadEnvEffect,
    WriteEnvEffect, WriteIOEffect], forbids: [].}
print to stdout but prefixed with [yellow]Warning:[/]. Source   Edit