Crosstermion is a utility crate to unify some types of both crates, allowing to easily build apps that use the leaner termion
crate on unix systems, but resort to crossterm on windows systems.
Currently provided facilities are:
- a
Keytype an aninput_stream(async) to receive key presses - an
AltenrativeRawTerminalwhich marries an alternative screen with raw mode - a way to create a
tuiortui-reactterminal with either the crossterm or the termion backend.
But how to do colors and styles?
- With
tui- When using the
tui, you will have native cross-backend support for colors and styles.
- When using the
- Without
tui- Use the
colorfeature for additional utilities for colors withansi_term. - Otherwise, using
ansi_term,coloredortermcolorwill work as expected.
- Use the
How to build with crossterm on Windows and termion on Unix?
There seems to be no easy way, as cargo will always build dependencies even though they are not supposed to be used on your platform.
This leads to both termion and crossterm to be built, which is fatal on Windows. Thus one will have to manually select feature toggles
when creating a release build, i.e. one would have to exclude all functionality that requires TUIs by default, and let the user enable
the features they require.
The compile_error!(…) macro can be useful to inform users if feature selection is required. Alternatively, assure that everything compiles
even without any selected backend.
Lastly, one can always give in and always compile against crossterm.
Features
All features work additively, but in case they are mutually exclusive, for instance
in case of tui-react and tui, or crossterm and termion, the more general one will be chosen.
- mutually exclusive
- crossterm
- provides
Keyconversion support fromcrossbeam::event::KeyEventand anAlternativeRawTerminal - provides a threaded key input channel
- additive
- input-async-crossterm
- adds native async capabilites to crossterm, which works without spawning an extra thread thanks to
mio. - note that threaded key input is always supported.
- adds native async capabilites to crossterm, which works without spawning an extra thread thanks to
- input-async-crossterm
- provides
- termion
- provides
Keyconversion support fromtermion::event::Keyand anAlternativeRawTerminal - provides a threaded key input channel
- additive
- input-async
- Spawn a thread and provide input events via a futures Stream
- note that threaded key input is always supported.
- input-async
- provides
- crossterm
- mutually exclusive
- _using
tui_(mutually exclusive)- tui-termion implies
termionfeature- combines
tuiwithtermionand provides atui::Terminalwithtermionbackend
- combines
- tui-crossterm implies
crosstermfeature- combines
tuiwithcrosstermand provides atui::Terminalwithcrosstermbackend
- combines
- tui-termion implies
- using
tui-react(mutually exclusive)- tui-react-termion implies
termionfeature- combines
tui-reactwithcrosstermand provides atui::Terminalwithcrosstermbackend
- combines
- tui-react-crossterm implies
crosstermfeature- combines
tui-reactwithcrosstermand provides atui::Terminalwithcrosstermbackend
- combines
- tui-react-termion implies
- _using
- color
- Add support for
ansi_termbased conditional coloring. The crate is small, to the point and allows zero-copy drawing of bytes and UTF-8 string, while supporting Windows 10 as well.
- Add support for
- cursor movement
- mutually exclusive
- crossterm
- Implements cursor movement with crossterm
- termion
- Implements cursor movement with termion
- crossterm
- mutually exclusive