Skip to content

Introduction

PyTermGUI offers a markup language complimentary to the other features of the library, named Terminal Inline Markup, or TIM for short. This language is in use in various places within the library, and is supported by pretty much everything we offer that displays text.

from pytermgui import tim

tim.print("[bold lightblue]Hello[/fg italic]!")

tim.print(
    "[bold]TIM[/] supports [italic]macros[/],"
    + " like [!upper]upper[/!] and [bold !gradient(56)]gradient[/!]."
)

tim.print(
    "We also support [skyblue underline ~https://ptg.bczsalba.com]"
    + "terminal hyperlinks[/]!"
)

TIM Example Hello ! TIM  supports  macros , like UPPER and  g r a d i ent . We also support  terminal hyperlinks !

Philosophy

  • Convenience

    Raw ANSI sequences are cumbersome to use and hard to read/write. TIM aims to improve this by assigning easy-to-read names to pretty much all ANSI syntax.

  • Speed

    Since this language is meant to be used in performance-critical applications, it must be pretty fast. As of 16th of July 2022, TIM is magnitudes faster than Rich's own markup language, the only "competition" I know about.

    This is achieved mostly by smart caching routines, as well as a tightly written parsing algorithm.

  • Extensibility

    I like tinkering. I hate using things that are made with the philosophy of "this is what I made, and it's all that you will get.". TIM implements customizability in its alias and macro systems.

  • Convenience & granularity

    Above all, TIM was made to be simple and ergonomic to use. Styles follow their most-commonly used names, and every tag is applied as its own distinct entity, and aren't joined into a set style. This allows you to specifically clear certain tags, while not touching the rest of the style.