All Projects → crossterm-rs → Crossterm

crossterm-rs / Crossterm

Licence: mit
Cross platform terminal library rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Crossterm

Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (-94.82%)
Mutual labels:  terminal, console, color, cursor
Chalk
🖍 Terminal string styling done right
Stars: ✭ 17,566 (+1617.11%)
Mutual labels:  terminal, console, color
C Sharp Console Gui Framework
A GUI framework for C# console applications
Stars: ✭ 838 (-18.08%)
Mutual labels:  terminal, console, tui
Mordant
Full-featured text styling for Kotlin command-line applications
Stars: ✭ 382 (-62.66%)
Mutual labels:  terminal, console, color
Closestx11color
Find the closest xterm-256 colors (between 0 and 255) to an arbitrary HTML hexa color (e.g. #ABCDEF)
Stars: ✭ 13 (-98.73%)
Mutual labels:  terminal, console, color
Mitype
Typing speed test in terminal
Stars: ✭ 241 (-76.44%)
Mutual labels:  terminal, console, cross-platform
Stig
TUI and CLI for the BitTorrent client Transmission
Stars: ✭ 360 (-64.81%)
Mutual labels:  terminal, console, tui
Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (-83.09%)
Mutual labels:  terminal, console, tui
Gradient String
🌈 Beautiful color gradients in terminal output
Stars: ✭ 476 (-53.47%)
Mutual labels:  terminal, console, color
Termenv
Advanced ANSI style & color support for your terminal applications
Stars: ✭ 555 (-45.75%)
Mutual labels:  terminal, console, tui
Clui
Command Line User Interface (Console UI inspired by TurboVision)
Stars: ✭ 561 (-45.16%)
Mutual labels:  terminal, console, tui
S Tui
Terminal-based CPU stress and monitoring utility
Stars: ✭ 2,825 (+176.15%)
Mutual labels:  terminal, console, tui
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: ✭ 2,623 (+156.4%)
Mutual labels:  terminal, console, tui
Finalcut
A text-based widget toolkit
Stars: ✭ 244 (-76.15%)
Mutual labels:  terminal, console, tui
Php Console Spinner
Colorful highly configurable spinner for php cli applications (suitable for async apps)
Stars: ✭ 225 (-78.01%)
Mutual labels:  terminal, console, color
Csconsoleformat
.NET C# library for advanced formatting of console output [Apache]
Stars: ✭ 296 (-71.07%)
Mutual labels:  terminal, console, cross-platform
Htop
htop is an interactive text-mode process viewer for Unix systems. It aims to be a better 'top'.
Stars: ✭ 5,626 (+449.95%)
Mutual labels:  terminal, console, tui
Bottom
Yet another cross-platform graphical process/system monitor.
Stars: ✭ 3,182 (+211.05%)
Mutual labels:  terminal, tui, cross-platform
Smenu
smenu started as a lightweight and flexible terminal menu generator, but quickly evolved into a powerful and versatile CLI selection tool for interactive or scripting use.
Stars: ✭ 1,906 (+86.31%)
Mutual labels:  terminal, console, tui
Pulsemixer
CLI and curses mixer for PulseAudio
Stars: ✭ 441 (-56.89%)
Mutual labels:  terminal, console, tui

Donate Travis Latest Version MIT docs Lines of Code Join us on Discord

Cross-platform Terminal Manipulation Library

Crossterm is a pure-rust, terminal manipulation library that makes it possible to write cross-platform text-based interfaces (see features). It supports all UNIX and Windows terminals down to Windows 7 (not all terminals are tested, see Tested Terminals for more info).

Table of Contents

Features

  • Cross-platform
  • Multi-threaded (send, sync)
  • Detailed documentation
  • Few dependencies
  • Full control over writing and flushing output buffer
  • Is tty
  • Cursor
    • Move the cursor N times (up, down, left, right)
    • Move to previous / next line
    • Move to column
    • Set/get the cursor position
    • Store the cursor position and restore to it later
    • Hide/show the cursor
    • Enable/disable cursor blinking (not all terminals do support this feature)
  • Styled output
    • Foreground color (16 base colors)
    • Background color (16 base colors)
    • 256 (ANSI) color support (Windows 10 and UNIX only)
    • RGB color support (Windows 10 and UNIX only)
    • Text attributes like bold, italic, underscore, crossed, etc
  • Terminal
    • Clear (all lines, current line, from cursor down and up, until new line)
    • Scroll up, down
    • Set/get the terminal size
    • Exit current process
    • Alternate screen
    • Raw screen
    • Set terminal title
    • Enable/disable line wrapping
  • Event
    • Input Events
    • Mouse Events (press, release, position, button, drag)
    • Terminal Resize Events
    • Advanced modifier (SHIFT | ALT | CTRL) support for both mouse and key events and
    • futures Stream (feature 'event-stream')
    • Poll/read API

Tested Terminals

  • Console Host
    • Windows 10 (Pro)
    • Windows 8.1 (N)
  • Ubuntu Desktop Terminal
    • Ubuntu 17.10
    • Pop!_OS ( Ubuntu ) 20.04
  • (Arch, Manjaro) KDE Konsole
  • (Arch) Kitty
  • Linux Mint
  • OpenSuse/Linux Alacritty

This crate supports all UNIX terminals and Windows terminals down to Windows 7; however, not all of the terminals have been tested. If you have used this library for a terminal other than the above list without issues, then feel free to add it to the above list - I really would appreciate it!

Getting Started

see the examples directory and documentation for more advanced examples.

Click to show Cargo.toml.
[dependencies]
crossterm = "0.18"

use std::io::{stdout, Write};

use crossterm::{
    execute,
    style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor},
    ExecutableCommand, Result,
    event,
};

fn main() -> Result<()> {
    // using the macro
    execute!(
        stdout(),
        SetForegroundColor(Color::Blue),
        SetBackgroundColor(Color::Red),
        Print("Styled text here."),
        ResetColor
    )?;

    // or using functions
    stdout()
        .execute(SetForegroundColor(Color::Blue))?
        .execute(SetBackgroundColor(Color::Red))?
        .execute(Print("Styled text here."))?
        .execute(ResetColor)?;
    
    Ok(())
}

Checkout this list with all possible commands.

Feature Flags

To optional feature flags.

[dependencies.crossterm]
version = "0.17"
features = ["event-stream"] 
Feature Description
event-stream futures::Stream producing Result<Event>.

Dependency Justification

Dependency Used for Included
bitflags KeyModifiers, those are differ based on input. always
parking_lot locking RwLocks with a timeout, const mutexes. always
libc UNIX terminal_size/raw modes/set_title and several other lowlevel functionality. UNIX only
Mio event readiness polling, waking up poller UNIX only
signal-hook signalhook is used to handle terminal resize SIGNAL with Mio. UNIX only
winapi Used for low-level windows system calls which ANSI codes can't replace windows only
futures Can be used to for async stream of events only with a feature flag
serde Se/dese/realizing of events only with a feature flag

Other Resources

Used By

Contributing

We highly appreciate when anyone contributes to this crate. Before you do, please, read the Contributing guidelines.

Authors

  • Timon Post - Project Owner & creator

License

This project, crossterm and all its sub-crates: crossterm_screen, crossterm_cursor, crossterm_style, crossterm_input, crossterm_terminal, crossterm_winapi, crossterm_utils are licensed under the MIT License - see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].