Commit Graph

220 Commits (a6b35031aebd4308b5ac3dd5dd80d62c1cbaa6f5)

Author SHA1 Message Date
Vadim Chekan 1683e8d609
Clean redundant generics params in Table (#234)
* Clean redundant generics params in Table

It is possible to use associated types the same way as generics parameters. In fact associated types are nothing more than better organized generics params. For example, there is no need to introduce another param to constraint iterator item to be Display, you can just say `where I::Iterator, I::Item: Display`. This allows to drop type params for Table from 5 to 2.
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
Malte Tammena 808a5c9ffd Mark Style::* functions `const` 4 years ago
Florian Dehau d16db5ed90 style: fix clippy warnings 4 years ago
Florian Dehau 28017f97ea feat(widgets/chart): add more control on the visibility of the legend 4 years ago
Florian Dehau ea43413507 fix: remove clippy warnings 5 years ago
Caleb Bassi 829b7b6b70 Change linechart to draw the points also 5 years ago
Caleb Bassi 262bf441ce Add linechart support
Closes #73

This commit only adds support for linecharts for the braille marker.
5 years ago
Caleb Bassi 7aae9b380e Add header_gap field to Table 5 years ago
Florian Dehau 9085c81e76 refactor: clean up border type for blocks
* Merge line symbols in a single module.
* Replace set_border_type with border_type to match other builder methods.
* Remove unecessary branching.
5 years ago
Matthew Stevenson 682349c03e update block example; add BorderType to exposed widgets API 5 years ago
Matthew Stevenson a72389b28c revert to single Block struct; add set_border_type method and BorderType enum 5 years ago
Matthew Stevenson 06d159fb7b add RoundedBlock and DoubleBlock structs that impl From Block; add Block::rounded() and Block::double_border() 5 years ago
Matthew Stevenson 578560766d add round corners and double lines to symbols 5 years ago
Florian Dehau 8293cef703 Release v0.8.0 5 years ago
Timon 60b99cfc66 feat: bump crossterm to 0.14 5 years ago
Kyle Ruzic b8d0f947e8 Added a verticle 'cross' to the symbols as it was missing for no real reason 5 years ago
Sebastian Woetzel bbd4363fa9 Bugfix: title_style was not used to style the axis title 5 years ago
Florian Dehau e0083fb8de chore: make the onboarding easier for Windows users. 5 years ago
Florian Dehau 3abafc307c Release v0.7.0 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 2233cdc9cc chore: add CI based on github actions 5 years ago
Florian Dehau 816bc9b5c8 style: fix formatting and clippy issues 5 years ago
Florian Dehau a82c82fcd7 fix(widgets): remove compilation warning in table widget 5 years ago
TheZoq2 bb28d02277 Update docs to point encourage installing 0.6 5 years ago
Jeffas 94877f4e7e Use constraints for table column widths
This allows table column widths to be adapted more and scale with the
UI.

The constraints are solved using the Cassowary solver. An added
constraint for fitting them all in the width is added.
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
Florian Dehau 42731da546 Enable build failure on compilation warnings 5 years ago
Joseph Knight e183d63a5e typo in barcharg.rs 5 years ago
Joseph Knight e5fdd442c3 typo in sparkline.rs 5 years ago
Joseph Knight 97357c0e08 typo in curses.rs 5 years ago
Joseph Knight 8649ce4c78 fixed typo in symbols.rs 5 years ago
Timon_Post a0f6605f59 Implemented command api crossterm, for better perfomance. 5 years ago
Jeffas db9b1dd689 Make margins be vertical or horizontal
This adds support for margins to be either vertical or horizontal, or
both.
5 years ago
Joe Ardent 86f681a007 Silence check warnings about [lack of] use of 'dyn' for boxed trait objects. 5 years ago
Florian Dehau a3827aaeae Remove try call in termion backend 5 years ago
Jeremy Day 47c68e40a2 fix for canvas rendering edge cases causing overflow errors 5 years ago
Florian Dehau 2a7eec816a Add PartialEq to Text 5 years ago
Florian Dehau 8fbb764c9e Move Borders documentation 5 years ago
Florian Dehau 4756801fd9 Format 5 years ago
Russ f0e0b515ad avoid divide by zero 5 years ago
defiori 25a0825ae4 fix: curses backend cursor positions 5 years ago
scauligi b1ac297d71 fix crossterm terminal size and dark gray color 5 years ago
nytopop 8a9c76b003 Don't highlight Tabs separator behind selection 5 years ago
DarrienG 41cdd3e261 Provide clone and debug for Text type 5 years ago
Timon_Post f6a0a91a23 fmt 5 years ago
timonpost@hotmail.nl ffaaf5e39c review update 5 years ago
timonpost@hotmail.nl 567cf7b8e5 update 0.9.2 5 years ago
Florian Dehau a74d335cb4 Fix clippy warnings 5 years ago
Florian Dehau 7a5ad3fbdb Fix sparkline panic when max is zero 5 years ago