Pty reads a command's output and feeds it to Screen using an unbounded
queue.
However, if the command produces output faster than what `Screen` can
render, `Pty` still pushes it on the queue, causing it to grow
indefinitely, resulting in high memory usage and latency.
This patch fixes this by using a bounded queue between Pty and Screen,
so if Screen can't keep up with Pty, the queue will fill up, exerting
back pressure on Pty, making it read the command's output only as fast
as Screen renders it.
The unbounded queue is kept between Screen and producers other than Pty
to avoid a deadlock such as this scenario:
* pty thread filling up screen queue as soon as screen thread pops
something from it
* wasm thread is processing a Render instruction, blocking on the screen
queue
* screen thread is trying to render a plugin pane. It attempts to send a
Render insturction to the blocked wasm thread running the plugin.
This patch also adds a generous amount of sleeps to the integration
tests as having backpressure changes the timing of how instructions are
processed.
Fixes#525.
Previously, a config file was loaded within `start()`, and if the config
file is invalid, Zellij was supposed to show a user what's wrong with
it. However, since `start()` starts setting up its terminal with an
alternative screen buffer, neither standard output nor standard error
could display such an error.
This change intends to address this issue by making Zellij load a config
file before `start()`.
In addition, the patch also includes some refactorings:
* Redefine `from_cli_config` with `TryFrom`, which was introduced in
Rust 1.34
* Remove conditional declaration `cfg(not(test))` because `start()` now
receive a `Config` as the third argument
* Introduce [`tempfile`](https://crates.io/crates/tempfile) in order to
run tests with actual files
* Typo?: "Deserialisation" -> "Deserialization"
* added some comments in the input module
* InputHandler now has InputState instead of separate InputMode and permanent bool
* keybinds are now associated with a Vec<Action> instead of a single Action
* removing "persistent" modes alltogether to reimplement the feature, help bar broken
* locked command mode by default, fixes#161, help bar still broken
* status bar fixed, still a few improvements/bugs to go
* better shortcut help bar contents
* fixed last bits and i think we are good
* modified tests according to new controls, not working
* Revert "modified tests according to new controls, not working"
This reverts commit f2d9421ff0169feb83dbd9b246e59b9244cafc16.
* basic.rs tests now pass, not the rest
* close_pane.rs tests pass, but very slowly?
* compatibility.rs tests pass, very slowly as well
* {layout, {move_focus_*}}.rs all working mildly slowly
* {resize_*}.rs should all work but very slowly and funky, see PR comments
* {tabs,toggle_fullscreen}.rs pass. Test performance issue yet to be fixed
* tests now work, with a hack :| ready for merge
* rustfmt + deleted references to InputState and mode persistency
* Initial definitions and thoughts for hotkeys
* Actually document InputKey properly
* Add a to string function for input keys
* Define keybinds and actions; restructure
* Implement hash and start on defining key bindings
* Derive Serialize for input keys
* Store the key strings as tuples for two-way mapping
* Some string to key functions
* Use termion's Key definition and implement action dispatch
* Fix some borrow-checker errors
* Missing keybind and command mode switching
* Fix incorrect handling of spawn terminal command
* fix(plugins): work with new input - tests not passing
* fix(infra): stabilize tests and properly close pty sessions
* style(fmt): rustfmt
Co-authored-by: Brooks J Rady <b.j.rady@gmail.com>
Co-authored-by: Aram Drevekenin <aram@poor.dev>
* Added clippy check.
* Changed step name.
* Used the suggested ci config.
* Some more clippy fixes.
* Some more clippy fixes.
* More clippy fixes.
* Removed allow annotations.
* Minor lint edit.
* More clippy fixes.
* Ran cargo fmt.
* More clippy fixes.
* More clippy fixes.
* More clippy fixes.
* More clippy fixes.
* More clippy fixes.
* More clippy fixes.
* Code review edits.
* Code review edits.
* Code review edits.
* CI update.
* CI update.
* CI update.
* Added clippy warn so wip won't fail ci.
* Cargo fmt.
* Move the input loop into a separate module
* Proof of concept implementation of command mode
* Update readme to reflect command mode
* Have Esc exit command mode
* Update tests to use command mode and make it transient by default
* Some merge fixes
* fix(tests): add missing COMMAND_TOGGLE and fix false positive test
* style(format): make rustfmt happy
* Update readme to describe command mode
Co-authored-by: Aram Drevekenin <aram@poor.dev>