Commit Graph

63 Commits (eee37011a543d2e1a9373f304819512ccf3e80d0)

Author SHA1 Message Date
Florian Dehau eee37011a5 chore: fix clippy warnings 2 years ago
Florian Dehau 6069d89dee chore: fix all clippy warnings 2 years ago
Florian Dehau 8c1f58079f chore: fix build 3 years ago
Antoine Büsch 4845c03eec
feat(widgets/list): repeat highlight symbol on multi-line items (#533)
When this option is true, the hightlight symbol is repeated for each
line of the selected item, instead of just the first line.
3 years ago
Florian Dehau a7c21a9729 fix(widgets): avoid offset panic in `Table` and `List` when input changes 3 years ago
Florian Dehau 8eb6336f5e refactor(widgets): remove iter::repeat for blank symbols 3 years ago
acheronfail 5a9b59866b feat(widgets/listitem): derive PartialEq 4 years ago
Florian Dehau 0ffea495b1 refactor: implement cascading styles
- merge `Style` and `StyleDiff` together. `Style` now is used to activate or deactivate certain
style rules not to overidden all of them.
- update all impacted widgets, examples and tests.
4 years ago
Florian Dehau 88c4b191fb feat(text): add new text primitives 4 years ago
Björn Steinbrink 8f9aa276e8 fix(widgets/list): fix line length calculation for selectable lists
The code that outputs the list elements uses the full inner width of its
block, without taking the width of the highlight symbol into
consideration. This allows the elements to overflow the box and draw
over the block's border. To fix that, we need to reduce the target width
for the list elements.
4 years ago
Florian Dehau bc2a512101 feat: add missing `Clone` and `Copy` on types 4 years ago
Florian Dehau 4f728d363f fix(widgets/list): stop highlighting blank placeholders 4 years ago
Florian Dehau 278c153d31 style: remove clippy warnings 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
Florian Dehau ea43413507 fix: remove clippy warnings 4 years ago
Florian Dehau a74d335cb4 Fix clippy warnings 5 years ago
David Flemström b7664a4108 Support several modifiers and indexed colors at once 5 years ago
Florian Dehau b669cf9ce7 style: fix clippy warnings 5 years ago
Sven-Hendrik Haase 144bfb71cf Upgrade to 2018 edition 5 years ago
Karoline Pauls 8522e028f1 Run `cargo fmt` with the new Rust stable toolchain (1.31.0) 6 years ago
Florian Dehau d8e5f57d53 style: fmt 6 years ago
Antoine Büsch f795173886 Unify Item and Text 6 years ago
Florian Dehau 6c69160d6b feat: remove unecessary borrows of Style 6 years ago
Florian Dehau cf169d1582 style: run rustfmt and clippy 6 years ago
Florian Dehau bcd1e30376 refactor: update List select behavior
* allow a selectable list to have no selected item
* show highlight_symbol only when something is selected
6 years ago
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
6 years ago
Florian Dehau d6016788ef refactor: clippy + rustfmt 6 years ago
Florian Dehau 7181970a32 feat: split layout from rendering
* remove layout logic from Terminal
* replace Group with Layout
* add Frame intermediate object
6 years ago
Florian Dehau 5de571fb03 feat(widgets): Add start_corner option to List 6 years ago
Florian Dehau 36a5eb2110 Format code 6 years ago
Florian Dehau fcd1b7b187 [widgets][list] Set the style of the underlying list 6 years ago
Florian Dehau 151d7e8a1c [src] Update dependencies
* Update all dependencies to their latest versions
* Change border to Borders to match v1.0 of bitflags
7 years ago
Florian Dehau af16518650 [src] Run rustfmt 7 years ago
Florian Dehau ba80889333 [clippy] Fix warnings 7 years ago
Florian Dehau 1f285fbac0 [src] Run cargo fmt 7 years ago
Florian Dehau 71545a0aa8 Run cargo fmt 7 years ago
Florian Dehau d6a91d1865 Fix List lifetime issues
Add a new lifetime for the items inside the list
7 years ago
Florian Dehau 41eac2aa4e Refactor demo example 7 years ago
Florian Dehau 89a173fe9b Refactor List Widget
* Add a generic item object for the list. The item can either be some data
alone or some data and its style
* The List widget now store an Iterator over those element. This should
avoid the need of allocating memory to store its elements
* The List consume the Iterator when it is drawn
7 years ago
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.
7 years ago
Florian Dehau b2bb24b9d2 Fix rustfmt and clippy errors 7 years ago
Florian Dehau e585bfeab5 Make List more user-friendly 8 years ago
Florian Dehau 4f8a57d500 Fix clippy warnings 8 years ago
Florian Dehau ad239ef23c Update list and table to be more flexible
* Move List to SelectableList
* Create a more generic List
* Change the way to pass items to the table widget
* Update demo
8 years ago
Florian Dehau 662e2dd102 Fix examples 8 years ago
Florian Dehau 224eb2d8e0 Add support for text styling 8 years ago
Florian Dehau 652ff12380 More documentation 8 years ago
Florian Dehau 93cc237007 Documentation 8 years ago
Florian Dehau a5b632aeb0 Cleanup API 8 years ago
Florian Dehau a36e20f217 Add background_color support for all existing wigets 8 years ago