

[](https://crates.io/crates/rat-salsa)
[](https://docs.rs/rat-salsa)
[](https://opensource.org/licenses/MIT)
[](https://www.apache.org/licenses/LICENSE-2.0)

# rat-salsa 2
Runs an application event-loop for ratatui and crossterm.
It can
- poll multiple event-sources fairly
- run [background tasks](SalsaContext::spawn) in one or more worker threads.
- run [background tasks](SalsaContext::spawn_async) as async tasks.
- define [timers](SalsaContext::add_timer).
- work as a message-queue for in-app messages.
- support focus-handling with [SalsaContext::focus](SalsaContext::focus)
- support for an autonomous dialog window stack.
All incoming events are converted to an application defined event-type,
and are distributed by calling an event-handler function. This function
returns a [control-flow](Control) which dictates further actions.
## Changes
[Changes](https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/changes.md)
## Book
[link](https://thscharler.github.io/rat-salsa/)
## Companion Crates
* [rat-widget](https://docs.rs/rat-widget)
widget library. Incorporates everything below, but each crate
can be used on its own too.
Foundational crates
* [rat-event](https://docs.rs/rat-event)
Defines the primitives for event-handling.
* [rat-cursor](https://docs.rs/rat-cursor)
Defines just one trait to propagate the required screen cursor position.
* [rat-focus](https://docs.rs/rat-focus)
Focus-handling for widgets.
* [rat-reloc](https://docs.rs/rat-reloc)
Relocate a widgets state after rendering.
This is needed to support view-like widgets.
* [rat-scrolled](https://docs.rs/rat-scrolled)
Utility widgets for scrolling.
* [rat-popup](https://docs.rs/rat-popup)
Utility widget to help with popups.
* [rat-dialog](https:://docs.rs/rat-dialog)
Stacks windows/dialogs above the main application.
Crates for specific widgets
* [rat-ftable](https://docs.rs/rat-ftable)
table. uses traits to render your data, and renders only the visible cells.
this makes rendering effectively O(1) in regard to the number of rows.
* [rat-menu](https://docs.rs/rat-menu)
Menu widgets.
* [rat-text](https://docs.rs/rat-text)
Text/Value input widgets.
* [rat-markdown](https://docs.rs/rat-markdown)
Extension for TextArea for markdown. *experimental*
And my 10ct on theming.
* [rat-theme2](https://docs.rs/rat-theme2)
Color-palettes and widget styles.
* [rat-theme4](https://docs.rs/rat-theme2)
Latest iteration. Move to a map of things.
+ better text-color support
+ support for deriving themes by modifying existing ones.
## Example
The examples directory contains some examples
- [async1.rs][refAsync1]: Async tasks.
- [files.rs][refFiles]: Minimal filesystem browser.
- [half_ui.rs][refHalfUI]: Inline/Fixed UI.
- [inline.rs][refInline]: Inline UI.
- [life.rs][refLife]: Game of Life.
- [links.rs][refLinks]: Terminal hyperlinks.
- [logscroll.rs][refLogscroll]: Logfile view and find.
- [textinput.rs][refTextInput]: Example for text input.
- [themes.rs][refThemeSamples]: Theme show-room.
- [todo.rs][refTodo]: Simple todo app.
- [turbo.rs][refTurbo]: Reboot Turbo Pascal.
- [ultra.rs][refUltra]: Rat-salsa in less than 100loc.
- [mdedit.rs][refMDEdit]: Minimal markdown editor.
There are some templates too
- [minimal.rs][refMinimal]: Minimal application with a menubar and statusbar.
- [nominal.rs][refNominal]: Minimal application, but using subcomponents.
- [dialog.rs][refDialog]: Minimal application, using dialog windows.
![image][refFilesGif]
[refFilesGif]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/files.gif?raw=true
[refMDEditGif]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/mdedit.gif?raw=true
[refLife]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/examples/life.rs
[refAsync1]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/examples/async1.rs
[refLogscroll]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/examples/logscroll.rs
[refThemeSamples]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/examples/theme_samples.rs
[refTurbo]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/examples/turbo.rs
[refMDEdit]: https://github.com/thscharler/mdedit
[refFiles]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/examples/files.rs
[refMinimal]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/minimal.rs
[refNominal]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/nominal.rs
[refDialog]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/dialog.rs
[refHalfUI]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/half_ui.rs
[refInline]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/inline.rs
[refLinks]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/links.rs
[refTextInput]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/textinput.rs
[refTodo]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/todo.rs
[refUltra]: https://github.com/thscharler/rat-salsa/blob/master/rat-salsa/templates/ultra.rs
[refRSBook]: https://thscharler.github.io/rat-salsa/