Commit Graph

18 Commits (state)

Author SHA1 Message Date
Simas Toleikis 8832281dcf Update crossterm to 0.19. 3 years ago
Florian Dehau 11df94d601
fix(examples): avoid panic when computing event poll timeout in crossterm demo (#380) 4 years ago
Florian Dehau 72ba4ff2d4 refactor(examples): remove unecessary `terminal.hide_cursor` calls 4 years ago
Alexander Batischev 8c2ee0ed85
feat(terminal): Add after-draw() cursor control to Frame (#91) (#309) 4 years ago
Florian Dehau b59e4bb808 feat(examples): enable mouse capture to make crossterm demo on par with termion 4 years ago
Florian Dehau e81af75427 fix(examples): improve input handling in crossterm demo
* avoid stacking events
* ensure tick events are sent at the given tick rate (and not everytime a key is pressed).
4 years ago
Florian Dehau c98002eb76 feat: add an option to run the examples without all unicode symbols 4 years ago
Florian Dehau 3f62ce9c19 chore: remove unecessary dependencies
* Remove log, stderrlog, structopt
* Add argh
4 years ago
Florian Dehau 6cb57f5d2a feat: add stateful widgets
Most widgets can be drawn directly based on the input parameters. However, some
features may require some kind of associated state to be implemented.

For example, the `List` widget can highlight the item currently selected. This
can be translated in an offset, which is the number of elements to skip in
order to have the selected item within the viewport currently allocated to this
widget. The widget can therefore only provide the following behavior: whenever
the selected item is out of the viewport scroll to a predefined position (make
the selected item the last viewable item or the one in the middle).
Nonetheless, if the widget has access to the last computed offset then it can
implement a natural scrolling experience where the last offset is reused until
the selected item is out of the viewport.

To allow such behavior within the widgets, this commit introduces the following
changes:
- Add a `StatefulWidget` trait with an associated `State` type. Widgets that
can take advantage of having a "memory" between two draw calls needs to
implement this trait.
- Add a `render_stateful_widget` method on `Frame` where the associated
state is given as a parameter.

The chosen approach is thus to let the developers manage their widgets' states
themselves as they are already responsible for the lifecycle of the wigets
(given that the crate exposes an immediate mode api).

The following changes were also introduced:

- `Widget::render` has been deleted. Developers should use `Frame::render_widget`
instead.
- `Widget::background` has been deleted. Developers should use `Buffer::set_background`
instead.
- `SelectableList` has been deleted. Developers can directly use `List` where
`SelectableList` features have been back-ported.
4 years ago
Timon 60b99cfc66 feat: bump crossterm to 0.14 5 years ago
Timon e4873e4da9 feat(backend): bump crossterm to 0.13
* removed flush calls because execute already calls flush under the hood.
* moved some static functions into From traits
* removed useless clone in demo
* upgrade to crossterm 0.13
* map all errors
5 years ago
Florian Dehau 3747ddbefb feat(backend): Refactor crossterm backend
* Remove compilation warnings
* Fix rendering artifacts in the crossterm demo. In particular, the bold modifier
was leaking on most of the terminal screen because the old logic was not
properly unsetting the bold modifier after use (took inspiration of the termion
backend implementation)
5 years ago
Timon_Post a0f6605f59 Implemented command api crossterm, for better perfomance. 5 years ago
Florian Dehau 9a73ead88d Improve crossterm demo
* Use AlternateScreen
* Handle input events
5 years ago
timonpost@hotmail.nl 567cf7b8e5 update 0.9.2 5 years ago
Florian Dehau 7f5af46300 style: fmt 5 years ago
defiori cadb41c9e3 fix: unified crossterm backend 5 years ago
Florian Dehau f20512b599 feat: add rustbox and crossterm demo 5 years ago