crossterm-rs/crossterm

Cross-platform Terminal Manipulation Library

a simple terminal editor for both unix and windows clients

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
    • Tested Terminals
  • Getting Started
    • Feature Flags
  • Other Resources
  • Used By
  • Contributing

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) 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.

Checkout this list with all possible commands.

Feature Flags

Feature Description
event-stream futures::Stream producing Result<Event>.
serde Se/dese/rializing of events.

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-core For async stream of events only with event-stream feature flag
serde Se/dese/rializing of events only with serde feature flag

Other Resources

  • API documentation
  • Deprecated examples repository

Used By

  • Broot
  • Cursive
  • TUI
  • Rust-sloth
  • Rusty-rain

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.

Issues

Collection of the latest Issues

rosvall

rosvall

Comment Icon0

Colored and styled underlines are quite useful for error/typo highlighting in text editors, and it's a feature I miss in helix, which uses on crossterm for terminal IO.

While not a "standard" feature, a bunch of widely used terminal emulator have implemented support (All VTE-based, iterm2, alacritty, kitty), or are working on it (MS Terminal, konsole).

Screenshot from a VTE-based terminal emulator: Screenshot_2022-04-27_14-45-45

dnlmlr

dnlmlr

Comment Icon0

Describe the bug There is some weird behavior with git-bash running in terminal emulators other than the included mingw terminal. Somehow the escape codes are not properly accepted by the terminals and printed to the screen instead. This does not happen for the mingw terminal included with the git-bash installation.

I was able to track this down to the ENABLE_VIRTUAL_TERMINAL_PROCESSING console mode flag not being set. The reason why it is not set can be found in ansi_support.rs where it is only enforced when the TERM envvar is unset or equal to dumb due to the OR short-circuiting.

The git-bash mingw terminal apparently works without ENABLE_VIRTUAL_TERMINAL_PROCESSING, but every other terminal emulator I've tried needs this to work even when runing the git-bash shell. On the other hand on the mingw terminal emulator it simply fails by returning 0 for the GetConsoleMode & SetConsoleMode, so nothing breaks when attempting to set it there.

Suggested Fix Switching around the sides of the OR in the previously mentioned ansi_support.rs should fix the problem without introducing incompatibilities as far as I can tell.

to

This should first try to set ENABLE_VIRTUAL_TERMINAL_PROCESSING (fixing this issue). If that fails, like with the git-bash included mingw terminal, it falls back to checking for the dumb TERM envvar instead of the other way around.

To Reproduce Steps to reproduce the behavior:

  1. Create an empty project and add crossterm
  2. Add the following code to main execute!(stdout(), Clear(ClearType::CurrentLine),).unwrap(); and build
  3. Run the resulting executable (not cargo run, that works) using git-bash in Windows Terminal, Alacritty or WezTerm

Expected behavior The given code clears the current line without anything else, so nothing should be printed.

Actual behavior Visible output to the terminal in the form of ←[2K which seems to be the escape code, as well as the [2K for clearing the line

OS

  • Windows 10

Terminal/Console

  • Windows Terminal
  • Alacritty
  • WezTerm
andreytkachenko

andreytkachenko

Comment Icon1

May be my question is not addressed correctly, just close issue. I working on WASI based plugin system. And for terminal applications such as helix I think the best approach would be just compile applications like sidetree to WASM and communicate through stdin/stdout. Most of such programs are based on TUI which is based on crossterm, but inside crossterm there are some ioctl calls (to get terminal size, cursor position and other). Is it possible to add some WASM backend which would communicate through stdin/stdout like SSH, or has some backend trait and make generalized version of crossterm?

Vonr

Vonr

Comment Icon0

Is your feature request related to a problem? Please describe. I am trying to create a simple command line utility to draw a box with contents and questions in it which the user can directly input into.

However, in an attempt to not let the box be redirected, I have decided to use eprintln!() to print out the box and its contents. This works fine when redirecting to some programs, such as cat, but on others, such as rev, crossterm::cursor::position() fails as the written characters used to find the cursor position are also redirected to the program.

This effectively renders my utility is unusable or extremely tedious to use for scripting.

Describe the solution you'd like I would like to be able to get the position of the cursor in stderr, currently I have implemented a hackfix in my fork of crossterm here where I changed line 32 of src/cursor/sys/unix.rs from

to

However, this is far from ideal as this breaks normal behavior and I am unable to come up with a solution that is cross-platform.

That said, I also have no intention of supporting Windows in my utility as I am deeply unfamiliar with their scripting.

Describe alternatives you've considered in any I have created a fork of crossterm for personal use with a hackfix and used it in my Cargo.toml as a temporary workaround until a proper solution is implemented or found.

Cl00e9ment

Cl00e9ment

Comment Icon1

Describe the bug EnableBlinking and DisableBlinking don't work in the GNOME terminal.

Proposition The control sequences for enabling/disabling blinking (\x1b[?12h and \x1b[?12l) don't seem to work in some terminals, however the control sequences that set the shape and the blinking state at the same time (\x1b[x q, with x an integer) are working.

Also, SetCursorShape modify the blinking state with an hard-coded value (block is steady, and underline and line are blinking).

Since the EnableBlinking and DisableBlinking commands are not working in some terminals and that SetCursorShape modify the blinking state with an hard-coded value, why not choosing the cursor shape and blinking state at the same time and making: EnableBlinking, DisableBlinking and SetCursorShape deprecated?

We can imagine a SetCursorStyle command that look like this:

Note that I'm using the \x1b[?12h and \x1b[?12l control sequences as a fail-over, in case \x1b[x q isn't supported. If you think that it's a good idea, I can make the PR.

OS

  • Manjaro Linux

Terminal/Console

  • GNOME Terminal 3.42.2 for GNOME 41
SenojLuap

SenojLuap

Comment Icon2

Describe the bug In the module documentation for crossterm::event, it makes the statement "Make sure to enable raw mode in order for keyboard events to work properly", however that pages does not exist

To Reproduce n/a

Expected behavior Unclear. If the page exists, but has been moved, the link should be updated to the new location. If the 'raw mode' is no longer relevant, then the comment should be removed.

OS n/a

Terminal/Console n/a

Cl00e9ment

Cl00e9ment

Comment Icon7

Currently, it's possible to modify the cursor shape and whether it's blinking or not, but the previous state can't be restored. A function that can retrieve the cursor style would be useful, because one could save the old style and restore it when the program exits, so users can keep their terminal the way they prefer it.

I don't know if this is possible. For now, I forked the project and I've a proof of concept that works only on Xterm compatible terminals using DECRQSS with DECSCUSR (see this).

What works:

  • GNOME Terminal (Manjaro Linux)
  • Xterm (Manjaro Linux)

What doesn't:

  • CLion terminal (Manjaro Linux)
  • cmd.exe (Windows 10)
  • PowerSheel (Windows 10)
  • iTerm2 (macOS)

I've 2 questions:

  • Do anyone know how to implement something like that on other terminals?
  • If it's not possible to make it work on other terminals, should this be included in crossterm?
coloradocolby

coloradocolby

Comment Icon4

Is your feature request related to a problem? Please describe. caveat: I'm relatively new to rust, and by extension crossterm, so it's possible this feature already exists, however I haven't been able to find any examples in the documentation.

I'm working on a TUI application using tui and crossterm under the hood. As part of my application, I'm hoping to allow for users to pipe in a particular parameter. An example would look like

cat foo.txt | my_app or a slightly different example cat foo.txt | xargs my_app -p

Each time I attempt to do this I hit the following error: Custom { kind: Other, error: "Failed to initialize input reader" }

I believe this is happening because stdin is no longer a tty? I'm a little unsure on that.

Is what I'm trying to accomplish possible, or is this a limitation of crossterm? If it is (or is not) possible, would someone mind giving me a small primer on how/why? I'm super keen on understanding this problem space better.

Describe the solution you'd like All I want is to allow users to pipe in an argument via stdin to my application.

Describe alternatives you've considered in any As stated above, I've tried using xargs in hopes that that might resolve the issue but i'm still not having success.

Additional context Here is my main fn if that helps conceptualize

markus-bauer

markus-bauer

Comment Icon0

Problem

This issue came out of https://github.com/crossterm-rs/crossterm/issues/635.

Let's say you're reading events using poll and are only interested in mouse clicks. At the moment any mouse movement will send an event and cause poll to return. This makes poll useless, since it will always immediately return as long as the mouse is being moved.

Solution

The user should be able to define which events are being reported and which are being ignored. For example, Curses has the function mousemask: https://manpages.debian.org/bullseye/ncurses-doc/mousemask.3ncurses.en.html

As was mentioned in https://github.com/crossterm-rs/crossterm/issues/635#issuecomment-1055152689, some of this is already handled, just not exposed: https://github.com/crossterm-rs/crossterm/blob/9bc5cd3527a2d26caa6e2ccdc499beb4764fca95/src/event.rs#L241-L254

EvanTheProgrammer

EvanTheProgrammer

Comment Icon4

Describe the bug Receiving keys in terminal dose not work on Linux Mint or Ubuntu 20.04

To Reproduce Steps to reproduce the behavior:

  1. Have this code

  2. Run cargo run in a Linux terminal that i mentioned above.

  3. Press the q key.

  4. See error

Expected behavior The program exits / The program responds to the key.

OS Ubuntu 20.04

Terminal/Console Linux Mint GUI Terminal / SSH connection on Ubuntu Server through Termius.

ivanceras

ivanceras

Comment Icon10

Describe the bug

I experience a significant performance slowdown in my TUI framework. The detailed issue is filed here

To Reproduce Steps to reproduce the behavior:

  1. Checkout titk TUI repo https://github.com/ivanceras/titik
  2. Run the demo example with crossterm 0.18.0
  • cargo run --release --example demo
  1. Interact with the TUI such as the tabs and textarea and notice how snappy it is.
  2. Run the demo example with crossterm 0.23.0
  • cargo run --release --example demo --no-default-features --features crossterm_new
  1. Notice the mouse clicks on the tabs takes longer to respond

Expected behavior A clear and concise description of what you expected to happen.

OS

  • Linux(ubuntu 20.04)

Terminal/Console

  • Gnome Terminal, the default terminal.
wags-1314

wags-1314

Comment Icon4

I am using crossterm to make a text editor of sorts. I am switching into raw mode and simply echoing the keypresses. Here is my code:

When I enter control+M I get Key(KeyEvent { code: Enter, modifiers: NONE }) instead of Key(KeyEvent { code: Char('m'), modifiers: CONTROL }). How do I make this happen?

chenxiaolong

chenxiaolong

Comment Icon2

Describe the bug

After version 0.23, it seems that MoveToColumn(0) no longer has any effect. I did a git bisect between 0.22 and 0.23 and it seems the problem was introduced in commit 9a50fd2ce2701bb15f58722495024937143ad34d. I suspect it's due to this check:

https://github.com/crossterm-rs/crossterm/blob/9a50fd2ce2701bb15f58722495024937143ad34d/src/cursor.rs#L137-L139

To Reproduce

Small reproducer:

On Windows and Linux, the output is:

Expected behavior

Prior to version 0.23, the output was:

(hello being overwritten due to moving the cursor to the leftmost column)

OS

Windows 10 21H2; Fedora 35

Terminal/Console

Windows Terminal on Windows; Alacritty on Linux

markus-bauer

markus-bauer

Comment Icon7

Background

I was using Print to display the characters of a string one by one, instead of printing the entire string at once. This made me realize that using a lot of Print commands in a cycle is much slower than expected.

Problem

The flamegraph shows that most of the time is spent on core::fmt::write, which is called here (and in other commands): https://github.com/crossterm-rs/crossterm/blob/9a50fd2ce2701bb15f58722495024937143ad34d/src/style.rs#L401

It's known that the write macro (and all string formatting in rust) is considerably slower than writing directly: https://github.com/rust-lang/rust/issues/10761 https://github.com/rust-lang/rust/issues/76490

The issue is that style::Print doesn't actually need the macro because it doesn't format the string. I suspect that a lot of the commands could avoid the macro and just write the string directly.

Note, that there was a proposed change to the format macro that addresses this case (but it seems to be dead): https://github.com/rust-lang/rust/pull/76531

Apparently even creating a string with consecutive push_str() is faster than formatting: https://github.com/rust-lang/rust-clippy/issues/6926

I want to make it clear that it's just an assumption that avoiding the macro will improve performance. Unfortunately the crossterm codebase is designed so much around fmt that I found it difficult to test. The only quick test I could come up with is to just replicate the core issue. The code below writes a character n times to stdout, using either Print, write!, or write_all. It looks like it's up to 2x as fast without the macro, but the results are inconsistent between runs.

elferherrera

elferherrera

Comment Icon16

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?

IsotoxalDev

IsotoxalDev

Comment Icon0

The logo is hardly visible in github dark mode. append #gh-light-mode-only after the image link to make the image appear only on light mode similarly use this #gh-dark-mode-only for dark mode

wendajiang

wendajiang

Comment Icon3

Describe the solution you'd like for example, I want do something when I press up a key(e.g. 'h')

Describe alternatives you've considered in any different KeyCode into KeyCodeDown and KeyCodeUp if it needn't backforward compatible

carrascomj

carrascomj

Comment Icon0

Is your feature request related to a problem? Please describe.

In some TUI applications (like a text editor), the window title might be modified to display some information (see for example https://github.com/helix-editor/helix/issues/928) and that's already implemented here. However, it is desirable to also revert it back to what it was in the first place, but there's no option to get the title to store it before setting it.

Describe the solution you'd like

As an user, I would like to have a title getter function, complementary to SetTitle and in the same fashion as size.

Describe alternatives you've considered in any The user could always interact with the lower-level underlying libraries and that would require to handle different platforms, which I guess it is not desirable. I think it makes sense to provide the Getter/Setter pair.

Additional context Anything else?

Berrysoft

Berrysoft

Comment Icon0

I see that EventStream is using std::thread and std::sync::mpsc at now. It is of course an improvement according to #448. However, I'd like to suggest a possible improvement, with the usage of spawn and channels in specific async runtime, for example, tokio or async-std. Therefore, the async runtime could manage the event stream thread.

The replacement in tokio is spawn and mpsc.

The replacement in async-std is spawn and channel.

Both of them should be drop-in replacement, rewritting some functions to async ones. I'd like to open a pull request later, trying to add the implementation as an optional feature, and keep the original implementation as a fallback one.

stefnotch

stefnotch

Comment Icon0

Is your feature request related to a problem? Please describe. I was writing a little application using Visual Studio Code on Windows 10. To get nicer graphics, I used Unicode characters such as . Then, I changed the terminal type in the launch.json file to "integrated". This causes the characters to become garbled for some reason. Setting the terminal to "external" also reproduces the same issue.

image

Funnily enough, manually opening a cmd window and starting the program from there works flawlessly.

Describe the solution you'd like Something along the lines of https://stackoverflow.com/a/17177904/3492994

Describe alternatives you've considered in any Tell people to please not use a horribly outdated terminal

Sample project cross-unicode.zip

tobiasvl

tobiasvl

Comment Icon0

Describe the bug If the cursor is hidden when clearing the terminal, it's shown again.

To Reproduce Steps to reproduce the behavior:

  1. execute!(stdout, Hide);
  2. execute!(stdout, Clear(ClearType::All));
  3. See the cursor

Expected behavior I wouldn't expect clearing the terminal to show the hidden cursor.

OS Linux Subsystem for Windows (Ubuntu)

Terminal/Console Linux Subsystem for Windows terminal

and-nissa

and-nissa

Comment Icon5

Describe the bug hi all, i noticed that using crossterm::cursor::MoveToPreviousLine and her sister command to move 0 lines moves the cursor by 1 line.

To Reproduce Cargo.toml

main.rs

Expected behavior shouldn't these only reset the column position? the documentation says that these commands "move the terminal cursor {up/down} the given number of lines...", but that given number is 0.

OS x86_64-unknown-linux-gnu

Terminal/Console xterm

also this is my first opened issue, sorry if i messed anything up! i hope this is helpful in some way <3

ggoraa

ggoraa

Comment Icon0

Describe the bug Instead of displaying at least NONE + Left for Cmd + Left, it throws some gibberish

To Reproduce Steps to reproduce the behavior:

  1. Run this code:

  2. Type for example Cmd + Arrow Right. It will be displayed as:

in the command line, and:

for Cmd + Arrow Left

Expected behavior Show at least NONE Left or CTRL Left if pressed Cmd + Left, the same applies for right

OS

  • macOS

Terminal/Console

  • IntelliJ IDEA Terminal

Issue does not appear to work in iterm2. If I disable tab changing on Cmd + Arrow, and try to execute the thing, it will return me NONE + Left for Cmd + Left. Btw, I would be pleased to see an entry for Cmd key in KeyModifiers :D

sh7dm

sh7dm

Comment Icon2

Describe the bug Crash when scrolling happens on the left of the terminal window. See video

Screencast from 08-08-2021 09 36 05 AM

To Reproduce Steps to reproduce the behavior:

  1. Start code from event-read example
  2. Move mouse to the left of the screen (terminal is maximized)
  3. Scroll either up or down
  4. Panic with the following backtrace:

Expected behavior No panic when cursor is leftmost

OS

  • Fedora 34

Terminal/Console

  • GNOME Terminal 3.40.2
Versions

Find the latest versions by id

0.23 - Feb 06, 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.

0.22 - Feb 06, 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.

0.21 - Feb 06, 2022

  • Expose is_raw function.
  • Add 'purge' option on unix system, this clears the entire screen buffer.
  • Improve serialisation for color enum values.

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

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.

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.

0.17.7 - Jul 20, 2020

  • Fix cursor position retrieval bug linux.

0.17.6 - Jul 06, 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

0.17.5 - May 23, 2020

  • Improved support of keymodifier for linux, arrow keys, function keys, home keys etc.
  • Add SetTitle command to change the terminal title.

0.17.4 - May 18, 2020

  • Add macros for Colorize and Styler impls, add an impl for String
  • Add shift modifier to uppercase char events on unix

0.17.3 - May 18, 2020

  • Fix get terminal size mac os, this did not report the correct size.

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.

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

0.14.2 - Jan 11, 2020

  • Fix TIOCGWINSZ for FreeBSD

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.

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

0.13.2 - Nov 04, 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

0.13.1 - Nov 04, 2019

  • Fix Async Reader, join background thread and avoid looping forever on windows.

0.13 - Nov 02, 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

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)

0.11.1 - Sep 25, 2019

Version 0.11.1

  • Maintenance release
  • All sub-crates were moved to their own repositories in the crossterm-rs organization

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

0.9.6 - Jun 15, 2019

  • Copy for KeyEvent
  • CTRL + Left, Down, Up, Right key support
  • SHIFT + Left, Down, Up, Right key support
  • Fixed UNIX cursor position bug issue, PR

0.9.5 - May 20, 2019

  • Prefetching buffer size for more efficient windows input reads. PR

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

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

0.8.0 - May 15, 2019

More advancer input handling

  • Introduced KeyEvents
  • Introduced MouseEvents
  • Upgraded crossterm_winapi 0.2

0.7.0 - May 15, 2019

Improved easier styling of text.

  • Introduced more Attributes
  • Introduced easier ways to style text issue 87.
  • Removed ColorType since it was unnecessary.

0.6.0 - May 15, 2019

  • Introduced feature flags; input, cursor, style, terminal, screen.
  • All modules are moved to their own crate.
  • Introduced crossterm workspace
  • Fewer dependencies.
  • Improved namespaces.

Information - Updated Apr 28, 2022

Stars: 1.6K
Forks: 152
Issues: 82

Cross-platform library for system information fetching

Examples can be found Async-first

Cross-platform library for system information fetching

Cross-platform filesystem notification library for Rust

Add file-system notifications via this library for Rust

Cross-platform filesystem notification library for Rust

Cross-platform, realtime MIDI processing in Rust

You can find some examples in the examples directory

Cross-platform, realtime MIDI processing in Rust

Cross-platform network scan library

This library requires the ability to create raw sockets

Cross-platform network scan library

Cross-platform music tagger written in Rust, Vue

You might need to install additional dependencies to make One Tagger work:

Cross-platform music tagger written in Rust, Vue

Cross-platform command-line application used to analyze specific metrics from the CKJM Extended Tool

ckjm_analyzer --jar &lt;JAR_PATH&gt; --path &lt;PROJECTS_PATH&gt;

Cross-platform command-line application used to analyze specific metrics from the CKJM Extended Tool

Cross platform FFI bindings for FFmpeg inner libraries

Linking FFmpeg libraries for you

Cross platform FFI bindings for FFmpeg inner libraries
Facebook Instagram Twitter GitHub Dribbble
Privacy