Mist: ANSI Friendly Terminal Toolkit

Hello everyone! I’ve recently refactored mist to be more of a terminal manipulation library. It includes everything from text styling to parsing terminal events.

Short list of features:

  • Text styling (emphasis and coloring)
  • ANSI Aware text transformations (padding, indent, dedent, wrapping, etc.)
  • Terminal control (alternate screen buffer, focus tracking, mouse capture, screen/session state, cursor manipulation support)
  • Convenient TTY context manager
  • Terminal Event Parsing (Key Events, Focus Gain/Lost, Bracketed Paste, Mouse Events)

Please check out the README for more information on the features available! I created this project to learn more about TUI development and saw how deep the rabbit hole really goes. There’s a lot of differences between different terminal emulators, so I’m always open to PRs and to learn more about the topic.

I have some projects that need refactoring to use this! :fire: Great updates!

Awesome! Let me know how it goes. I’ll be opening up a PR to get the latest version into the modular-community channel soon.

I’ve added a few TUI examples leveraging mist for terminal control and mog for terminal styling.

There are gifs of them in action here: GitHub - thatstoasty/banjo: Mojo termios via libc

Examples:

Mist has been updated to support Mojo 0.26.2, no changes of note this time!

Mist has been updated to support Mojo 1.0.0b2. There’s a couple of new Style methods:

def render[T: Writable, W: Writer, //](self, text: T, mut writer: W):
    ...

def render_many[*Ts: Writable](self, *text: *Ts, sep: StringSlice = " ") -> String:
    ...

def render_many[W: Writer, *Ts: Writable](self, *text: *Ts, mut writer: W, sep: StringSlice = " "):
    ...

Now it supports writing directly to a writer instead of producing a String which often is then written to a writer.

And render_many which does the same thing but joins together an arbitrary number of args which it then applies the ANSI style to.

Mist has been updated to support Mojo 1.0! And it’s been split up into three packages to make it lightweight.

Advanced ANSI style, color support, and ansi aware text transformation: GitHub - thatstoasty/mist: Advanced ANSI style & color support for your terminal applications · GitHub
Mojo Termios: GitHub - thatstoasty/mojo-termios: Termios FFI bindings for Mojo. · GitHub
Control your terminal settings and read events: https://github.com/thatstoasty/termctl