Commit Graph

33 Commits

Author SHA1 Message Date
Florian Dehau
88c4b191fb feat(text): add new text primitives 2020-07-10 22:59:24 +02:00
Florian Dehau
bc2a512101 feat: add missing Clone and Copy on types 2020-04-14 19:25:49 +02:00
Florian Dehau
cee65ed283 feat: allow BarChart and Sparkline to use a more portable set of symbols
Add `BarChart::bar_set` and `Sparkline::bar_set` methods to customize
the set of symbols used to display the data. The new set should give
a better looking output on terminal that do not support a wide range
of unicode symbols.
2020-04-14 02:17:22 +02:00
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
ea43413507 fix: remove clippy warnings 2020-01-19 23:11:12 +01:00
Joseph Knight
e5fdd442c3 typo in sparkline.rs 2019-08-11 14:03:58 +02:00
Florian Dehau
7a5ad3fbdb Fix sparkline panic when max is zero 2019-04-14 11:35:41 +02:00
Sven-Hendrik Haase
144bfb71cf Upgrade to 2018 edition 2019-01-13 14:35:51 +00: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
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
Florian Dehau
36a5eb2110 Format code 2018-05-06 15:54:47 +02: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
1f285fbac0 [src] Run cargo fmt 2017-10-30 23:14:57 +01:00
talha
3045ac4124 Minor codestyle fixes 2017-10-30 17:15:28 +01:00
Florian Dehau
b1737ce667 Update Widget Trait
The draw function now take a &mut reference to the widget, allowing the
widget to modify itself when drawn. This change the semantic of the draw
call since the widget should now be considered "consumed" after it.
2017-09-10 21:38:17 +02:00
Florian Dehau
662e2dd102 Fix examples 2016-11-06 21:41:32 +01:00
Florian Dehau
224eb2d8e0 Add support for text styling 2016-11-06 18:49:57 +01:00
Florian Dehau
652ff12380 More documentation 2016-11-04 19:27:19 +01:00
Florian Dehau
a5b632aeb0 Cleanup API 2016-11-02 19:16:53 +01:00
Florian Dehau
a36e20f217 Add background_color support for all existing wigets 2016-11-02 17:08:52 +01:00
Florian Dehau
bcb3d751bf Rename buffer methods 2016-10-27 12:35:26 +02:00
Florian Dehau
c91436baee Change rendering method and adapt widget trait accordingly 2016-10-26 14:32:45 +02:00
Florian Dehau
ea485b5439 Simpler layout and cleanup api 2016-10-23 14:14:43 +02:00
Florian Dehau
063bde8764 Add bar chart prototype 2016-10-22 12:51:41 +02:00
Florian Dehau
7a427c06d4 Update chart widget and fix colors in all widgets 2016-10-21 19:02:19 +02:00
Florian Dehau
15c3471f0b Fix clippy warnings 2016-10-20 17:17:35 +02:00
Florian Dehau
fde0ba95dd Remove cache system and add unicode segmentation 2016-10-16 00:38:20 +02:00
Florian Dehau
bd404f0238 Cleanup code and add chart widget 2016-10-14 19:44:52 +02:00
Florian Dehau
6ed19df342 Update color support for block, gauge, list and sparkline 2016-10-13 17:57:45 +02:00
Florian Dehau
ea1397319c Add support for multi line sparkline 2016-10-13 17:30:35 +02:00
Florian Dehau
9816ccd4e3 Change layout properties and improve gauge and sparkline 2016-10-13 16:27:33 +02:00
Florian Dehau
d11dedd864 Add sparkline widget and fix warnings 2016-10-12 19:43:39 +02:00