Commit Graph

35 Commits

Author SHA1 Message Date
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.
2020-02-23 19:23:37 +01:00
Florian Dehau
8293cef703 Release v0.8.0 2019-12-15 23:12:55 +01:00
Florian Dehau
e0083fb8de chore: make the onboarding easier for Windows users. 2019-12-13 20:19:59 +01:00
Florian Dehau
3abafc307c Release v0.7.0 2019-11-29 10:05:06 +01:00
TheZoq2
bb28d02277 Update docs to point encourage installing 0.6 2019-10-31 09:18:51 +01:00
Florian Dehau
42731da546 Enable build failure on compilation warnings 2019-10-31 09:17:47 +01:00
Florian Dehau
4436110c44 Improve onboarding in documentation 2019-03-24 21:37:55 +01:00
Sven-Hendrik Haase
144bfb71cf Upgrade to 2018 edition 2019-01-13 14:35:51 +00:00
Karoline Pauls
090975481b Update tests and docs to take size from the Frame 2018-12-07 21:32:00 +01:00
Florian Dehau
4c46ef69e9 Release v0.3.0 2018-11-04 20:25:07 +01:00
Florian Dehau
5d52fd2486 refactor: remove custom termion backends 2018-09-23 20:55:50 +02:00
Florian Dehau
4ae9850e13 fix: replace links to assets 2018-09-09 08:55:51 +02:00
Florian Dehau
3d63f9607f doc: update main documentation 2018-09-04 22:23:44 +02:00
Florian Dehau
13e194cd26 refactor: update widgets
* all widgets use the consumable builder pattern
* `draw` on terminal expect a closure that take a frame as only arg
2018-09-04 22:23:44 +02:00
Florian Dehau
d6016788ef refactor: clippy + rustfmt 2018-09-04 22:23:44 +02:00
Florian Dehau
ad602a54bf refactor(widgets): replace text rendering in Paragraph
* remove custom markup language
* add Text container for both raw and styled strings
2018-09-04 22:23:44 +02:00
Florian Dehau
7181970a32 feat: split layout from rendering
* remove layout logic from Terminal
* replace Group with Layout
* add Frame intermediate object
2018-09-04 22:23:44 +02:00
Robin Nehls
3f8a9079ee [widgets] implement text alignment for paragraph widget 2018-05-25 21:09:27 +02:00
Florian Dehau
36a5eb2110 Format code 2018-05-06 15:54:47 +02:00
Florian Dehau
4b53acab14 [doc] Fix layout example in documentation 2018-04-01 18:28:17 +02:00
Florian Dehau
7d273b576d Bump version 2017-12-26 22:13:40 +01:00
Florian Dehau
c3c5109c5a [src] Fix build and tests 2017-12-26 21:45:46 +01:00
Florian Dehau
151d7e8a1c [src] Update dependencies
* Update all dependencies to their latest versions
* Change border to Borders to match v1.0 of bitflags
2017-12-26 21:45:46 +01:00
Florian Dehau
8907ab90a1 [doc] Move "Get started" from README to src/lib.rs 2017-12-26 21:45:46 +01:00
Florian Dehau
1f285fbac0 [src] Run cargo fmt 2017-10-30 23:14:57 +01:00
Florian Dehau
feefa5d54f Convert backends to conditionnal features for compilation 2016-11-28 09:52:51 +01:00
Florian Dehau
b19c014889 Fix layout cache on nightly 2016-11-06 21:41:54 +01:00
Florian Dehau
9bc61551e2 Refactor Terminal to be able to support multiple backends
* Add Rustbox as an other possible backend
2016-11-05 19:18:48 +01:00
Florian Dehau
a5b632aeb0 Cleanup API 2016-11-02 19:16:53 +01:00
Florian Dehau
cd919e69f5 Fix some display errors 2016-11-01 15:59:33 +01:00
Florian Dehau
07ff2b08eb Improve Chart Widget, safer buffer and unicode width 2016-10-20 12:01:09 +02:00
Florian Dehau
fde0ba95dd Remove cache system and add unicode segmentation 2016-10-16 00:38:20 +02:00
Florian Dehau
5b5d37ee69 Add gauge, fix rendering and cleanup code 2016-10-12 16:12:42 +02:00
Florian Dehau
13f6a5a98b Add list widget and improve rendering 2016-10-11 19:54:35 +02:00
Florian Dehau
459201bc65 First commit 2016-10-09 19:46:53 +02:00