Cross platform terminal library rust

Overview

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.

Comments
  • Added basic trait implementations to all Commands

    Added basic trait implementations to all Commands

    Added a small set of reasonable trait implementations (Debug, Copy, Clone, PartialEq, and Eq) to all of the commands. The largest command is a pair of u16, so they're easily copyable.

    opened by Lucretiel 23
  • Don't write on stdout if all commands are queued for stderr

    Don't write on stdout if all commands are queued for stderr

    When using the Command API and the alternate screen, I'd like to only use stderr for all displays in order to precisely decide what I write on stdout.

    It looks like it's almost possible but there are still some chars written on stdout even if I only queue on stderr.

    I suspect this is related to the few places where there are calls to write_cout without the first argument.

    Could we fix this ? Is it already in process ?

    It's possible a few API would have to change, for example for the alternate screen.

    opened by Canop 23
  • Windows 10 / PowerShell Issues

    Windows 10 / PowerShell Issues

    I'm on Windows 10 and running my app in PowerShell console.

    My app reacts to Enter key (char 13), and it triggers the reaction immediately after the start. I tracked down the problem to the fact that it's processing the Enter key that I was using to invoke the command from the cli.

    I.e.:

    1. I type .\target\debug\myapp.exe
    2. I press "Enter" key.
    3. My app starts and immediately triggers "Enter" key handler (cauisng it to quit in my case).

    I expect step 3 to be "My app starts and waits for input".

    I tried both sync and async input - the behaviour is the same.

    I'm using fixes branch.

    opened by MOZGIII 19
  • Async reader doesn't produce MouseEvents

    Async reader doesn't produce MouseEvents

    • Platform: macOS
    • It works when I replace input.read_async(); with input.read_sync();
    • Run, click with the mouse and ...
    Screen Shot 2019-10-03 at 11 54 40

    examples/foo.rs:

    use crossterm_input::{InputEvent, KeyEvent, MouseEvent, RawScreen, Result, TerminalInput};
    
    fn main() -> Result<()> {
        let input = TerminalInput::new();
        let _raw = RawScreen::into_raw_mode()?;
    
        let mut reader = input.read_async();
        input.enable_mouse_mode()?;
    
        loop {
            if let Some(event) = reader.next() {
                match event {
                    InputEvent::Keyboard(KeyEvent::Esc) => break,
                    InputEvent::Keyboard(KeyEvent::Enter) => println!("Enter"),
                    InputEvent::Mouse(mouse) => {
                        match mouse {
                            MouseEvent::Press(_, x, y) => println!("Press: {}x{}", x, y),
                            MouseEvent::Hold(x, y) => println!("Move: {}x{}", x, y),
                            MouseEvent::Release(x, y) => println!("Release: {}x{}", x, y),
                            _ => {}
                        };
                    }
                    _ => {}
                };
            }
        }
    
        input.disable_mouse_mode()?;
        Ok(())
    }
    
    in_progress 
    opened by zrzka 18
  • Flickering while writing

    Flickering while writing

    In Reedline we are experimenting with having a secondary prompt on the right to present information to the user. This is an example of how it looks now Animation2

    However, if the prompt in the left ends with a newline, everything after the prompt flickers. Like this Animation3

    Is there any recommendations that you have to avoid this type of flickering?

    opened by elferherrera 17
  • Upgrading from 0.10.x to 0.12.x break input

    Upgrading from 0.10.x to 0.12.x break input

    Hi all,

    We use crossterm in nushell in a few different places, and have generally been pretty happy with it. Recently, I tried to update from 0.10.x to 0.12.x. While the API changes were easy to fix, the result was a system that no longer worked.

    Does someone have a minute to look over https://github.com/nushell/nushell/blob/master/src/fuzzysearch.rs and let me know why it doesn't work in 0.12.x (ignoring the slight API differences)

    Here are some of the issues we see with 0.12.x when we try it:

    • Hitting enter on a selection doesn't work
    • After fuzzy search runs, input is eaten about every other character, so you can't type in the nushell prompt correctly anymore
    opened by jntrnr 16
  • Input Expansion

    Input Expansion

    This is a tracking issue for the work what still needs to be done for reading input.

    • [X] Reading Keys Presses This feature should porovide support for the following Key Events - winapi example code. - Special key combinations
    • [X] Mouse Events (example) - Allow to capture mouse down, up and hold events. - Allow seeing which mouse button is pressed.
    • [X] cleaning up old threads
    • [x] Testing
    enhancement 
    opened by TimonPost 16
  • Make read sync block for windows systems

    Make read sync block for windows systems

    The documentation of TerminalInput states for TerminalInput::read_sync:

    Readings will be blocking calls.

    On windows this will resolve in call to ReadConsoleInput and according to MSDN it blocks.

    The function does not return until at least one input record has been read.

    But there is a problematic fast return, causing ReadConsoleInput not to be called.

    https://github.com/TimonPost/crossterm/blob/8223cc9e4a5e35e15a0287bd9d8aa53dc84d1c34/crossterm_winapi/src/console.rs#L170-L173

    Also some events return None, even though further events can be received:

    https://github.com/TimonPost/crossterm/blob/8223cc9e4a5e35e15a0287bd9d8aa53dc84d1c34/crossterm_input/src/input/windows_input.rs#L230-L233

    While this is valid behaviour for iterators, this causes early returns when iterating with for or while. This should be either changed or documented.

    bug difficulty: medium 
    opened by matprec 15
  • Performance Enhancement

    Performance Enhancement

    Task Description

    Crossterm flushes the buffer each time action with an ANSI-code is performed. This is not realistic in the case of moving the cursor a lot and meanwhile print characters. When calling those types of functions a lot, cross-term might behave a bit slow.

    • Flushing is done here
    • Locking on stdout is done as well on each ANSI write to the terminal, however, flushing is way more performance bottleneck then the lock.

    Task TODO

    • [ ] Research if it is possible to let the user control the flushing so that the user can control when to flush the ANSI-commands to the terminal. Issue #167 can be related to this issue. More explanation about this in the comments.
    • [ ] If we found out a way to make ANSI-codes more performant, we are left with one problem. WINAPI. The nice think about ANSI codes is that you can queue them up somewhere and push them into the stdout later on. With WinApi the user interacts directly with the terminal, and you can't queue them in the same way of ANSI-codes.

    Example of what I mean:

    winapi scenario of moving the cursor

    Move cursor (10.10)
    println!("abc");
    Move cursor (10,10)
    

    ansi scenario to move the cursor

    println!("\x1B[{10};{10}H abc \x1B[{5};{5}H");
    

    As you can see, in the case of ANSI codes we can store the codes and text of the user inside on string, however, with WinApi we don't store actions inside a string. But those are calls that need to be made to the console individually.

    Somehow, we need to be able to store those WinApi commands in order ass well. So that if the user does a manual flush to the terminal, in the case of windows, we walk through all the WinApi commands queued and execute those, as well print the user input, done between those two cursor move events.

    Notice

    I do notice, Linux is way faster with console actions than windows is. I am not sure whether this is the problem of rust using winapi to write to the console window, winapi ANSI interpretation layer, crossterm performance issue. Windows is often forgotten in the Rust library, and would not be amazed if there is some performance issue there somewhere. But this needs to be proven of course.

    enhancement help wanted difficulty: hard 
    opened by TimonPost 15
  • EventStream::drop dead lock fix

    EventStream::drop dead lock fix

    Description

    • There was a dead lock in the EventStream::drop implementation (thanks for the discovery @udoprog!)

    Changes

    • Introduced Waker which kind of mimicks upcoming mio (0.7) Waker
      • Allows us to remove self pipe trick, etc. and do it via Evented on UNIX
      • Waker is clonable, shareable, sendable, ...
    • Implemented for both Windows & UNIX

    Tests

    • Tested on UNIX only

    Alternative

    This is an alternative to the #328 PR.

    What's better?

    • No public reexports of CancelRx, ...
    • No warnings for unused imports, dead code, ...
    • Completely hidden and not visible in the internal API until event-stream is enabled

    What's worse?

    • Not sure if it's a good idea to hide it in this way = removing it from the poll_internal argument
    opened by zrzka 14
  • Input Rewrite

    Input Rewrite

    Note, this design is not accurate anymore. Please have a look further into the discussion.

    New

    • Introduced the things discussed here. It already addresses some of your comments. There is still some work left for this to be finished. I would like to hear your ideas on how to future envolve this?
    • Removes Terminalnput because it would become boilerplate code.
    • Introduces: ~EventChannel~, ~EventConsumer~, EventPool, ~EventIterator~, EventSource.
    • ~Allows iterating specific events.~
    • Allows swapping out event source (testing)
    • ~Introduces a single producer multiple consumer idea for input sharing~

    usage example

    use crossterm::{event_stream, poll_event, RawScreen};
    
    fn main () {
        let r = RawScreen::into_raw_mode().unwrap();
    
        let mut stream = event_stream();
    
        while true {
            poll_event();
    
            for event in stream.key_events() {
                println!("{:?}", event);
            }
        }
    }
    

    ~## Area of Discussion:~

    ~- Should we store local cache in EventStream? The idea behind this is that when reading from the channel we drain the events at the same time? When we read we can store them locally so that we can consume them later on and no events will be lost when for example the user uses InputStream::key_events first and then InputStream::events().~ ~- Should the poll function only read a single event or read everything available in the buffers.~

    ~## Todo~

    • [ ] implement mouse event enable/disable
    • [ ] implement read line
    • [ ] More tests
    • [ ] Documentation

    ~## Diagram:~

    image

    Definitions

    SPMC

    ~I use shrev EventChannel for this, this channel can have multiple readers and a single writer. This is exactly what we want. I tried with normal MPMC channels before, but this didn't work out well. It required a lot of manual thread-safe work like putting everything in arc, mutexes, etc.~

    Event Pool

    EventPool

    • It is stored statically in with lazy static, there should only be one instance of this pool. ~- It is the owner of the SPMC channel.~
    • It is the only one allowed to grant read/write access to the owned event channel. ~- It can create multiple consumers and a single producer. ~
    • Access to EventPool is secured with RwLock. Therefore consumers can be created while a write lock is obtained. ~- Behaves similar to Stdin~
    • Only reads a single input event on poll. This allows the user to create its own async wrapper. The

    ~EventPoolReadLock~

    ~- Provides read access to the EventPool~

    EventPoolWriteLock

    • Provides write access to EventPool

    ~event_stream~

    ~-A static function that returns an event stream that can be used to read input events with.~

    poll_event

    ~A static function that polls for input from the underlying input source. An input event will be replicated to all consumers aka streams if an input event has occurred. This poll function will block read for a single keypress.~

    Input Source

    InputPool has one input source. This input source can be anything. In the tests I use the FakeInputSource, this allows us to fake input data, this might be useful for the user as well for testing it's application.

    • An input source does a block read for one key event.
    • Input source is called by InputPool::poll()

    The PR contains three input sources: TtyEventSource, WinApiEventSource, FakeEventSource

    ~### Event Stream~

    ~- Has it's own SPMC consumer, can't write, only read.~ ~- It can iterate specifically over certain events, like a mouse, keyboard. This is a great feature I like to support. Because most often people only want to read for up, down, left, right arrows for example.~

    opened by TimonPost 14
  • Bracketed paste doesn't work on windows

    Bracketed paste doesn't work on windows

    as the title says, trying to use bracketed paste on windows , just yields a series of Event::char

    This works on termwiz though, so its probably something missing we can copy over

    opened by sigmaSd 0
  • Replace mio polling with filedescriptor's poll()

    Replace mio polling with filedescriptor's poll()

    Dince mio doesn't handle ptys correctly macOS, use filedescriptor's poll() which falls back to select().

    This PR replaces #711.

    Fixes #500, unblocks #407.

    Implementation notes

    Since poll() doesn't support waking from signals or otherwise, I create two unix socket pairs, one which is written to on SIGWINCH and one which is used by the Waker, and poll on those as well as the tty fd.

    opened by yyogo 5
  • Usage of `by_ref` in `queue!` breaks dynamic dispatch

    Usage of `by_ref` in `queue!` breaks dynamic dispatch

    Suppose I have the following function:

    fn render_1 <W: Write> (out: &mut W) -> Result<()> {
      queue!(out, MoveTo(2, 3), Print("foo"))
    }
    

    I want to remove the generic W and replace it with a trait object using dyn.

    fn render_2 (out: &mut dyn Write) -> Result<()> {
      queue!(out, MoveTo(2, 3), Print("foo"))
    }
    

    The latter form fails with the following error:

    error: the `by_ref` method cannot be invoked on a trait object
      --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/crossterm-0.25.0/src/macros.rs:63:20
       |
    58 |   macro_rules! queue {
       |   ------------------ in this expansion of `queue!`
    ...
    63 |           Ok($writer.by_ref())
       |                      ^^^^^^
       |
      ::: crates/common/lib_tui.rs:32:5
       |
    32 | /     queue!(out,
    33 | |         ResetColor,
    34 | |         SetForegroundColor(bg),
    35 | |         MoveTo(col1, row1),
    36 | |         Print("▄".repeat(cols as usize)),
    37 | |         ResetColor, SetBackgroundColor(bg)
    38 | |     )?;
       | |_____- in this macro invocation
       |
       = note: you need `&mut dyn std::io::Write` instead of `&dyn std::io::Write`
    

    I can't completely wrap my head around Write::by_ref or its usage in the queue! macro. The comment says This allows the macro to take both mut impl Write and &mut impl Write. This looks like it's breaking dynamic dispatch entirely, for the sake of saving a & token? Can someone please explain?

    What I want to achieve is define a trait Widget which supports dyn (i.e. has no generic methods of its own); for this, its render method must be like render_2 and not like render_1.

    opened by egasimus 5
  • Add a function for checking keyboard enhancement support

    Add a function for checking keyboard enhancement support

    This follows the Kitty documentation's recommended way to check for progressive keyboard enhancement: query the flags and then query the primary device attributes (which is broadly supported). If we receive the response to the flags query, we return the flags. Otherwise, the terminal must not support progressive keyboard enhancement.

    Closes #717

    opened by the-mikedavis 0
  • Allow for ringing the terminal bell

    Allow for ringing the terminal bell

    Is your feature request related to a problem? Please describe. There is no command for ringing the terminal bell, at least not from what I can find.

    Describe the solution you'd like I would like to see a queue-able and executable command added that rings the terminal bell.

    Describe alternatives you've considered in any I could ring the terminal bell manually by printing the relevant escape code, but isn't that what crossterm tries to avoid?

    Additional context https://en.wikipedia.org/wiki/Bell_character

    opened by CenTdemeern1 0
  • A way to change the input stream for event::read and event::poll

    A way to change the input stream for event::read and event::poll

    Is your feature request related to a problem? Please describe. I have an issue where my program uses a piped stdin, I want to manually open tty as a file and give that to crossterm for event handling though it does not seem possible at the moment. I also tried overriding stdin with the stdio_override crate which also did not work.

    To clarify my use case - this was so that I could perform automated integration testing of my event handling implementation

    Describe the solution you'd like To be able to specify an input source for event::read and event::poll. Or a global override for the source of events.

    Not sure if this is possible. Haven't had the chance to dive deep into the crossterm code yet.

    opened by dmaahs2017 2
Releases(0.25)
  • 0.25(Aug 10, 2022)

    BREAKING: Copy trait is removed from Event, you can keep it by removing the "bracked-paste" feature flag. However, this flag might be standardized in the future. We removed the Copy from Event because the new Paste event, which contains a pasted string into the terminal, which is a non-copy string.

    • Add the ability to paste a string in into the terminal and fetch the pasted string via events (see Event::Paste and EnableBracketedPaste).
    • Add support for functional key codes from kitty keyboard protocol. Try out by PushKeyboardEnhancementFlags. This protocol allows for:
      • See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/#modifiers
      • Press, Repeat, and Release event kinds for kitty-enabled terminals.
      • SUPER, HYPER, META modifiers.
      • Media keycodes
      • Right/left SHIFT, Control, Alt, Super, Hyper, Meta
      • IsoLevel3Shift, IsoLevel5Shift
      • Capslock, scroll lock, numlock
      • Printscreen, pauze, menue, keyboard begin.
    • Create SetStyle command to allow setting various styling in one command.
    • Terminal Focus events (see Event::FocusGained and Event::FocusLost), WINDOWS ONLY.
    Source code(tar.gz)
    Source code(zip)
  • 0.24(Jul 2, 2022)

    • Add DoubleUnderlined, Undercurled, Underdots the text, Underdotted, Underdashes, Underdashed attributes and allow coloring their foreground/background color.
    • Fix windows unicode character parsing, this fixed various key combinations and support typing unicode characters.
    • Consistency and better documentation on mouse cursor operations (BREAKING CHANGE).
      • MoveTo, MoveToColumn, MoveToRow are 0-based. (left top most cell is 0,0). Moving like this is absolute
      • MoveToNextLine, MoveToPreviousLine, MoveUp, MoveDown, MoveRight, MoveLeft are 1-based,. Moving like this is relative. Moving 1 left means moving 1 left. Moving 0 to the left is not possible, wikipedia states that most terminals will just default to 1.
    • terminal::size returns error when previously it returned (0,0).
    • Remove println from serialization code.
    • Fix the mouse up for the middle and right buttons.
    • Fix escape codes on Git-Bash + Windows Terminal / Alacritty / WezTerm.
    • Add support for cursor keys in application mode.
    Source code(tar.gz)
    Source code(zip)
  • 0.23(Feb 6, 2022)

    • Update dependencies.
    • Add 0 check for all cursor functions to prevent undefined behaviour.
    • Add CSIu key parsing for unix.
    • Improve control character window key parsing supporting (e.g. CTRL [ and ])
    • Update library to 2021 edition.
    Source code(tar.gz)
    Source code(zip)
  • 0.22(Feb 6, 2022)

    • Update yanked version crossterm-winapi and move to crossterm-winapi 0.9.0.
    • Changed panic to error when calling disable-mouse capture without setting it first.
    • Update bitflags dependency.
    Source code(tar.gz)
    Source code(zip)
  • 0.21(Feb 6, 2022)

    • Expose is_raw function.
    • Add 'purge' option on unix system, this clears the entire screen buffer.
    • Improve serialisation for color enum values.
    Source code(tar.gz)
    Source code(zip)
  • 0.20(Jun 10, 2021)

    • Update from signal-hook with 'mio-feature flag' to signal-hook-mio 0.2.1.
    • Manually implements Eq, PartialEq and Hash for KeyEvent improving equality checks and hash calculation.
    • crossterm::ErrorKind to io::Error.
    • Added Cursor Shape Support.
    • Add support for function keys F13...F20.
    • Support taking any Display in SetTitle command.
    • Remove lazy_static dependency.
    • Remove extra Clone bounds in the style module.
    • Add MoveToRow command.
    • Remove writer parameter from execute_winapi
    Source code(tar.gz)
    Source code(zip)
  • 0.19(Jun 10, 2021)

    • Use single thread for async event reader.
    • Patch timeout handling for event polling this was not working correctly.
    • Add unix support for more key combinations mainly complex ones with ALT/SHIFT/CTRL.
    • Derive PartialEq and Eq for ContentStyle
    • Fix windows resize event size, this used to be the buffer size but is screen size now.
    • Change Command::ansi_code to Command::write_ansi, this way the ansi code will be written to given formatter.
    Source code(tar.gz)
    Source code(zip)
  • 0.18(Sep 24, 2020)

    • Fix get position bug
    • Fix windows 8 or lower write to user-given stdout instead of stdout.
    • Make MoveCursor(Left/Right/Up/Dow) command with input 0 not move.
    • Switch to futures-core to reduce dependencies.
    • Command API restricts to only accept std::io::Write
    • Make supports_ansi public
    • Implement ALT + numbers windows systems.
    Source code(tar.gz)
    Source code(zip)
  • 0.17.7(Jul 20, 2020)

  • 0.17.6(Jul 6, 2020)

    • Add functionality to retrieve color based on passed ansi code.
    • Switch from 'futures' to 'futures-util' crate to reduce dependency count
    • Mio 0.7 update
    • signal-hook update
    • Make windows raw_mode act on CONIN$
    • Added From<(u8, u8, u8)> Trait to Color::Rgb Enum
    • Implement Color::try_from()
    • Implement styler traits for &'a str
    Source code(tar.gz)
    Source code(zip)
  • 0.17.5(May 23, 2020)

  • 0.17.4(May 18, 2020)

  • 0.17.3(May 18, 2020)

  • 0.17(Mar 24, 2020)

    • Impl Display for MoveToColumn, MoveToNextLine, MoveToPreviousLine
    • Make unix event reader always use /dev/tty.
    • Direct write command ansi_codes into formatter instead of double allocation.
    • Add NONE flag to KeyModifiers
    • Add support for converting chars to StylizedContent
    • Make terminal size function fallback to STDOUT_FILENO if /dev/tty is missing.
    Source code(tar.gz)
    Source code(zip)
  • 0.15(Jan 29, 2020)

    • Fix CTRL + J key combination. This used to return an ENTER event.
    • Add a generic implementation Command for &T: Command. This allows commands to be queued by reference, as well as by value.
    • Remove unnecessary Clone trait bounds from StyledContent.
    • Add StyledContent::style_mut.
    • Handle error correctly for execute! and queue!.
    • Fix minor syntax bug in execute! and queue!.
    • Change ContentStyle::apply to take self by value instead of reference, to prevent an unnecessary extra clone.
    • Added basic trait implementations (Debug, Clone, Copy, etc) to all of the command structs
    • ResetColor uses &'static str instead of String
    Source code(tar.gz)
    Source code(zip)
  • 0.14.2(Jan 11, 2020)

  • 0.14.1(Jan 11, 2020)

    • Made windows cursor position relative to the window instead absolute to the screen buffer windows.
    • Fix windows bug with queue macro were it consumed a type and required an type to be Copy.
    Source code(tar.gz)
    Source code(zip)
  • 0.14(Dec 16, 2019)

    • Replace the input module with brand new event module
      • Terminal Resize Events
      • Advanced modifier (SHIFT | ALT | CTRL) support for both mouse and key events and
      • futures Stream (feature 'event-stream')
      • Poll/read API
      • It's highly recommended to read the Upgrade from 0.13 to 0.14 documentation
    • Replace docs/UPGRADE.md with the Upgrade Paths documentation
    • Add MoveToColumn, MoveToPreviousLine, MoveToNextLine commands
    • Merge screen module into terminal
      • Remove screen::AlternateScreen
      • Remove screen::Rawscreen
        • Move and rename Rawscreen::into_raw_mode and Rawscreen::disable_raw_mode to terminal::enable_raw_mode and terminal::disable_raw_mode
      • Move screen::EnterAlternateScreen and screen::LeaveAlternateScreen to terminal::EnterAlternateScreen and terminal::LeaveAlternateScreen
      • Replace utils::Output command with style::Print command
    • Fix enable/disable mouse capture commands on Windows
    • Allow trailing comma queue! & execute! macros
    Source code(tar.gz)
    Source code(zip)
  • 0.13.2(Nov 4, 2019)

    • New input::stop_reading_thread() function
      • Temporary workaround for the UNIX platform to stop the background reading thread and close the file descriptor
      • This function will be removed in the next version
    Source code(tar.gz)
    Source code(zip)
  • 0.13.1(Nov 4, 2019)

  • 0.13(Nov 2, 2019)

    • Remove Crossterm type
    • Remove TerminalCursor, TerminalColor, Terminal
    • Remove cursor(), color() , terminal()
    • Remove re-exports at root, accessible via module::types (cursor::MoveTo)
    • input module
      • Derive 'Copy' for 'KeyEvent'
      • Add the EnableMouseCapture and EnableMouseCapture commands
    • cursor module
      • Introduce static function crossterm::cursor::position in place of TerminalCursor::pos
      • Rename Goto to MoveTo
      • Rename Up to MoveLeft
      • Rename Right to MoveRight
      • Rename Down to MoveDown
      • Rename BlinkOn to EnableBlinking
      • Rename BlinkOff to DisableBlinking
      • Rename ResetPos to ResetPosition
      • Rename SavePos to SavePosition
    • terminal
      • Introduce static function crossterm::terminal::size in place of Terminal::size
      • Introduce static function crossterm::terminal::exit in place of Terminal::exit
    • style module
      • Rename ObjectStyle to ContentStyle. Now full names are used for methods
      • Rename StyledObject to StyledContent and made members private
      • Rename PrintStyledFont to PrintStyledContent
      • Rename attr method to attribute.
      • Rename Attribute::NoInverse to NoReverse
      • Update documentation
      • Made Colored private, user should use commands instead
      • Rename SetFg -> SetForegroundColor
      • Rename SetBg -> SetBackgroundColor
      • Rename SetAttr -> SetAttribute
      • Rename ContentStyle::fg_color -> ContentStyle::foreground_color
      • Rename ContentStyle::bg_color -> ContentStyle::background_color
      • Rename ContentStyle::attrs -> ContentStyle::attributes
    • Improve documentation
    • Unix terminal size calculation with TPUT
    Source code(tar.gz)
    Source code(zip)
  • 0.12.0(Oct 21, 2019)

    • Following crates are deprecated and no longer maintained
      • crossterm_cursor
      • crossterm_input
      • crossterm_screen
      • crossterm_style
      • crossterm_terminal
      • crossterm_utils

    crossterm_cursor 0.4.0

    • Internal refactoring (PR #2)
      • Improved public documentation
      • sys module is no longer public
    • Fixed examples link (PR #6)
    • Sync documentation style (PR #7)
    • Removed all references to the crossterm book (PR #8)
    • Replaced RAW_MODE_ENABLED with is_raw_mode_enabled (PR #9)
    • Use SyncReader & InputEvent::CursorPosition for pos_raw() (PR #10)

    crossterm_input 0.5.0

    • Internal refactoring (PR #3)
      • Removed unsafe static mut
      • Documentation update
      • Remove all references to the crossterm book
    • Sync documentation style (PR #4)
    • Sync SyncReader::next() Windows and UNIX behavior (PR #5)
    • Remove all references to the crossterm book (PR #6)
    • Mouse coordinates synchronized with the cursor (PR #7)
      • Upper/left reported as (0, 0)
    • Fixed bug that read sync didn't block (Windows) (PR #8)
    • Refactored UNIX readers (PR #9)
      • AsyncReader produces mouse events
      • One reading thread per application, not per AsyncReader
      • Cursor position no longer consumed by another AsyncReader
      • Implemented sync reader for read_char (requires raw mode)
      • Fixed SIGTTIN when executed under the LLDB
      • Added mio for reading from FD and more efficient polling (UNIX only)
    • Sync UNIX and Windows vertical mouse position (PR #11)
      • Top is always reported as 0

    crossterm_screen 0.3.2

    • to_alternate switch back to main screen if it fails to switch into raw mode (PR #4)
    • Improve the documentation (PR #5)
      • Public API
      • Include the book content in the documentation
    • Remove all references to the crossterm book (PR #6)
    • New commands introduced (PR #7)
      • EnterAlternateScreen
      • LeaveAlternateScreen
    • Sync Windows and UNIX raw mode behavior (PR #8)

    crossterm_style 0.5.2

    • Refactoring (PR #2)
      • Added unit tests
      • Restructured files
      • Improved documentation and added book page to lib.rs
      • Fixed bug with SetBg command, WinApi logic
      • Fixed bug with StyledObject, used stdout for resetting terminal color
      • Introduced ResetColor command
    • Sync documentation style (PR #3)
    • Remove all references to the crossterm book (PR #4)
    • Windows 7 grey/white foreground/intensity swapped (PR #5)

    crossterm_terminal 0.3.2

    • Removed crossterm_cursor::sys dependency (PR #2)
    • Internal refactoring & documentation (PR #3)
    • Removed all references to the crossterm book (PR #4)

    crossterm_utils 0.4.0

    • Add deprecation note (PR #3)
    • Remove all references to the crossterm book (PR #4)
    • Remove unsafe static mut (PR #5)
      • sys::unix::RAW_MODE_ENABLED replaced with sys::unix::is_raw_mode_enabled() (breaking)
      • New lazy_static dependency

    crossterm_winapi 0.3.0

    • Make read sync block for windows systems (PR #2)
    Source code(tar.gz)
    Source code(zip)
  • 0.11.1(Sep 25, 2019)

  • 0.11.0(Sep 24, 2019)

    Changes crossterm 0.11.0

    As preparation for crossterm 0.1.0 we have moved crossterm to an organization called 'crossterm-rs'.

    Code Quality

    Important Changes

    • Return written bytes: return-written-bytes
    • Added derives: Debug for ObjectStyle debug-derive, Serialize/Deserialize for key events serde
    • Improved error handling:
      • Return crossterm::Result from all api's: return_crossterm_result
        • TerminalCursor::pos() returns Result<(u16, u16)>
        • Terminal::size() returns Result<(u16, u16)>
        • TerminalCursor::move_* returns crossterm::Result
        • ExecutableCommand::queue returns crossterm::Result
        • QueueableCommand::queue returns crossterm::Result
        • get_available_color_count returns no result
        • RawScreen::into_raw_mode returns crossterm::Result instead of io::Result
        • RawScreen::disable_raw_mode returns crossterm::Result instead of io::Result
        • AlternateScreen::to_alternate returns crossterm::Result instead of io::Result
        • TerminalInput::read_line returns crossterm::Result instead of io::Result
        • TerminalInput::read_char returns crossterm::Result instead of io::Result
        • Maybe I forgot something, a lot of functions have changed
      • Removed all unwraps/expects from library
    • Added KeyEvent::Enter and KeyEvent::Tab: added-key-event-enter, added-key-event-tab
    • Synced set/get terminal size behaviour: fixed-get-set-terminal-size
    • Method renames:
      • AsyncReader::stop_reading() to stop()
      • RawScreen::disable_raw_mode_on_drop to keep_raw_mode_on_drop
      • TerminalCursor::reset_position() to restore_position()
      • Command::get_anis_code() to ansi_code()
      • available_color_count to available_color_count()
      • Terminal::terminal_size to Terminal::size
      • Console::get_handle to Console::handle
    • All i16 values for indexing: set size, set cursor pos, scrolling synced to u16 values
    • Command API takes mutable self instead of self
    Source code(tar.gz)
    Source code(zip)
  • 0.9.6(Jun 15, 2019)

  • 0.9.5(May 20, 2019)

  • 0.9.4(May 15, 2019)

    • Reset foreground and background color individually. PR
    • Backtap input support. PR
    • Corrected white/grey and added dark grey.
    • Fixed getting cursor position with raw screen enabled. PR
    • Removed one redundant stdout lock
    Source code(tar.gz)
    Source code(zip)
  • 0.9.0(May 15, 2019)

    This release is all about moving to a stabilized API for 1.0.

    • Major refactor and cleanup.
    • Improved performance;
      • No locking when writing to stdout.
      • UNIX doesn't have any dynamic dispatch anymore.
      • Windows has improved the way to check if ANSI modes are enabled.
      • Removed lot's of complex API calls: from_screen, from_output
      • Removed Arc<TerminalOutput> from all internal Api's.
    • Removed termios dependency for UNIX systems.
    • Upgraded deps.
    • Removed about 1000 lines of code
      • TerminalOutput
      • Screen
      • unsafe code
      • Some duplicated code introduced by a previous refactor.
    • Raw modes UNIX systems improved
    • Added NoItalic attribute
    Source code(tar.gz)
    Source code(zip)
    crossterm-0.9.0.zip(156.91 KB)
  • 0.8.0(May 15, 2019)

  • 0.7.0(May 15, 2019)

Owner
crossterm-rs
Orginization that cares about terminal UI libraries.
crossterm-rs
Cross-platform terminal screen clearing library

ClearScreen Cross-platform terminal screen clearing library. API documentation. Dual-licensed with Apache 2.0 and MIT. Uses Caretaker Maintainership.

null 23 Dec 30, 2022
Alacritty - A fast, cross-platform, OpenGL terminal emulator

Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows.

Alacritty 43.8k Dec 31, 2022
Cross-platform terminal program to download IEEE journals

IEEE Journal Downloader A cross-platform terminal program which tries to download every article in a specified journal and merge the documents into on

Fong Chien Yoong 18 Jul 23, 2022
Native cross-platform full feature terminal-based sequence editor for git interactive rebase.

Native cross-platform full feature terminal-based sequence editor for git interactive rebase.

Tim Oram 1.2k Jan 2, 2023
Simple macros to write colored and formatted text to a terminal. Based on `termcolor`, thus also cross-platform.

Bunt: simple macro-based terminal colors and styles bunt offers macros to easily print colored and formatted text to a terminal. It is just a convenie

Lukas Kalbertodt 202 Dec 22, 2022
glicol cli: cross-platform music live coding in terminal

glicol-cli What's this? It's a command line interface that you can use for music live coding with Glicol. It watches a file changes and then update th

Glicol 70 Apr 14, 2023
Cross-platform WebView library in Rust for Tauri.

Cross-platform WebView rendering library in Rust that supports all major desktop platforms like Windows, macOS, and Linux. Overview Wry connects the w

Tauri 2.2k Jan 9, 2023
A new pure-Rust library for cross-platform low-level access to USB devices.

nusb A new pure-Rust library for cross-platform low-level access to USB devices. Documentation Compared to rusb and libusb Pure Rust, no dependency on

Kevin Mehall 23 Oct 30, 2023
General purpose cross-platform GIS-rendering library written in Rust

Galileo is a general purpose cross-platform geo-rendering library. Web examples Raster tile layer (OSM) Vector tile layer (Maplibre) Use buttons at th

Maxim 16 Dec 15, 2023
A cross-platform library for retrieving information about connected devices.

Devices devices is a cross-platform library for retrieving information about connected devices. Combined with a library like sysinfo, a more or less c

Hank Jordan 4 Jan 8, 2023
Rusty fast cross-platform 2D drawing library

Bly Rusty fast cross-platform 2D graphics library Concept Easy to use Bly is easy to use and yet can be called from various windowing libraries using

null 4 Feb 27, 2023
Rust-battery - Rust crate providing cross-platform information about the notebook batteries.

battery Rust crate providing cross-platform information about the notebook batteries. Table of contents Overview Supported platforms Install Examples

svartalf 326 Dec 21, 2022
Cross-platform Rust rewrite of the GNU coreutils

Cross-platform Rust rewrite of the GNU coreutils

null 13k Jan 8, 2023
A cross platform, rust implementation for the Tegra X1 bootROM exploit

Switcheroo A CLI and GUI for the RCM BootRom exploit (Fusée Gelée exploit for Nintendo Switch) Only works on unpatched Switches: https://ismyswitchpat

Ethan Budd 35 Nov 5, 2022
Write Cross-platform application with React-like decralative UI framework and scalable ECS architecture all in Rust.

bevy_dioxus Dioxus Plugin for Bevy Write Cross-platform application with React-like decralative UI framework and scalable ECS architecture all in Rust

Junichi Sugiura 269 Dec 29, 2022
Rust-based language and runtime for cross-platform app development

Pax Pax is a cross-platform rendering engine & Rust framework for interactive graphics, animations, and GUIs. Pax extends the Rust programming languag

Pax 75 Dec 19, 2022
Safe Unix shell-like parameter expansion/variable substitution via cross-platform CLI or Rust API

Safe Unix shell-like parameter expansion/variable substitution for those who need a more powerful alternative to envsubst but don't want to resort to

Isak Wertwein 4 Oct 4, 2022
A pure Rust, cross-platform soundboard app

afx This thing is my attempt at a soundboard program. afx.mp4 Why? I tried some prior art and decided that none of the existing options fit my needs.

Andrew Kvapil 11 Dec 15, 2022
An experimental cross-platform UI framework in rust.

Cross-platform UI framework in Rust with Easy functional composasbles Flexible state management Desktop and mobile support Accessibility Native skia r

null 76 Feb 6, 2023