Commit Graph

56 Commits

Author SHA1 Message Date
JerzySpendel
80a929ccc6
chore: fix typo (#513) 2021-08-08 11:10:21 +02:00
Florian Dehau
5ea54792c0 refactor(widgets/table): more flexible table
- control over the style of each cell and its content using the styling capabilities of Text.
- rows with multiple lines.
- fix panics on small areas.
- less generic type parameters.
2020-11-29 23:47:58 +01:00
Florian Dehau
5050f1ce1c feat(widgets/gauge): add LineGauge variant of Gauge 2020-09-28 00:40:19 +02:00
Florian Dehau
88c4b191fb feat(text): add new text primitives 2020-07-10 22:59:24 +02:00
Brooks Rady
112d2a65f6
feat(widgets/paragraph): add option to preserve indentation when the text is wrapped (#327) 2020-07-07 00:10:24 +02:00
Alexander Batischev
8c2ee0ed85
feat(terminal): Add after-draw() cursor control to Frame (#91) (#309) 2020-06-15 22:57:23 +02:00
Florian Dehau
5d99b4af00 docs: improve widgets documentation 2020-04-16 18:43:13 +02:00
Florian Dehau
bc2a512101 feat: add missing Clone and Copy on types 2020-04-14 19:25:49 +02:00
Florian Dehau
584e1b0500 refactor(widgets/canvas): allow canvas to render with a simple dot character instead of braille patterns
This change allows developers to gracefully degrade the output if the targeted
terminal does not support the full range of unicode symbols.
2020-04-14 02:17:22 +02:00
Stephan Dilly
7676d3c7df add clear widget and popup example utilizing it 2020-04-12 15:16:24 +02:00
Florian Dehau
ae677099d6 feat(widgets/table): allow one row to be selected 2020-03-13 00:36:19 +01: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
Caleb Bassi
262bf441ce Add linechart support
Closes #73

This commit only adds support for linecharts for the braille marker.
2020-01-19 21:25:17 +01:00
Matthew Stevenson
682349c03e update block example; add BorderType to exposed widgets API 2020-01-19 15:17:59 +01:00
Florian Dehau
2a7eec816a Add PartialEq to Text 2019-06-16 23:14:17 +02:00
Florian Dehau
8fbb764c9e Move Borders documentation 2019-06-16 23:02:52 +02:00
DarrienG
41cdd3e261 Provide clone and debug for Text type 2019-05-28 07:52:24 +02:00
Florian Dehau
b669cf9ce7 style: fix clippy warnings 2019-02-03 22:42:09 +01:00
Sven-Hendrik Haase
144bfb71cf Upgrade to 2018 edition 2019-01-13 14:35:51 +00:00
Karoline Pauls
10642d0e04 Paragraph: word wrapping 2018-12-22 15:38:51 +01:00
Antoine Büsch
f795173886 Unify Item and Text 2018-09-08 08:41:57 +02:00
Antoine Büsch
e42ab1fed8 Move Text to widgets/mod.rs 2018-09-08 08:41:57 +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
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
ca3308e945 [widgets] Fix Row export 2017-09-11 07:43:19 +02:00
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
2017-09-10 21:38:17 +02: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
feefa5d54f Convert backends to conditionnal features for compilation 2016-11-28 09:52:51 +01:00
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
2016-11-07 11:56:08 +01:00
Florian Dehau
224eb2d8e0 Add support for text styling 2016-11-06 18:49:57 +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
652ff12380 More documentation 2016-11-04 19:27:19 +01:00
Florian Dehau
93cc237007 Documentation 2016-11-03 23:59:04 +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
cd919e69f5 Fix some display errors 2016-11-01 15:59:33 +01:00
Florian Dehau
654be037be Redefine canvas widget and add shapes
* Give the canvas widget a proper modules and define a standard way to
draw to it (Shape trait)
* Add Points, Line, Rectangle and Map shapes
2016-11-01 12:09:14 +01:00
Florian Dehau
f0979dfeee Improve canvas functionalities and fix clippy warnings 2016-10-28 19:30:30 +02:00
Florian Dehau
c862fa9ce3 Add Map widget 2016-10-27 22:55:24 +02:00
Florian Dehau
7bdb11c681 Add Canvas widget
* Add a canvas widget to draw shapes using braille dots
* Use this widget in the chart widget when the braille mode is selected
2016-10-27 19:36:55 +02:00
Florian Dehau
95a160cf50 Add braille mode for the chart widget 2016-10-27 12:35:56 +02:00
Florian Dehau
c91436baee Change rendering method and adapt widget trait accordingly 2016-10-26 14:32:45 +02:00
Florian Dehau
063bde8764 Add bar chart prototype 2016-10-22 12:51:41 +02:00
Florian Dehau
15c3471f0b Fix clippy warnings 2016-10-20 17:17:35 +02:00
Florian Dehau
07ff2b08eb Improve Chart Widget, safer buffer and unicode width 2016-10-20 12:01:09 +02:00