Git Product home page Git Product logo

sanguine's Introduction

sanguine

Create dynamic, performant TUI applications in Rust.

Sanguine was created from the need for a library tailored for window/layout-based TUI applications such as text editors and terminal multiplexers. The Rust ecosystem contains many great crates for building TUI apps, but many are geared towards smaller applications and don't easily allow for complex layouts to be modified at runtime.

Sanguine implements a tree-based layout API that can be updated at runtime, with a simple, custom constraint algorithm geared towards rendering to the terminal. Layout results are cached between renders for performance, and are only recomputed when the layout is changed. Widgets can be nested and mouse events are handled properly for widgets at any depth - widgets only need to handle mouse events based on local position. Widgets can optionally specify a cursor location to allow for implementations of text editor windows and more.

It is built on top of Termwiz' BufferedTerminal, which optimizes terminal writes to maximize performance.

Features:

  • Dynamic, Tree-based layout API
  • Extensible widget trait
  • First-class mouse events support
    • Automatic propagation
    • Hover and click support
  • Global and widget-local event handlers
  • Generic API
    • Custom user event type for message passing
    • Custom state type for core app state
  • Focus
    • Switch focus by direction or directly

Demo

SanguineDemoMenu.mp4
Demo Usage
$ git clone [email protected]:willothy/sanguine.git

$ cd sanguine

$ cargo run --example demo

Keymaps:

  • Control + q: Quit
  • Shift + Tab: Cycle focus
  • Shift + Up/Down/Left/Right: Switch focus by direction
  • Up/Down/Left/Right: Switch menu item
  • Enter: Select menu item

sanguine's People

Contributors

willothy avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.