Commit Graph

44 Commits (master)

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 41142732ec feat(buffer): add a method to build a `Style` out of an existing `Cell` 4 years ago
Brooks Rady 0abaa20de9
refactor: clean up some folds (#362) 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
Florian Dehau 96c6b4efcb refactor(tests): move test utilities to TestBackend
* Remove custom Debug implementation of Buffer
* Add `TestBackend::assert_buffer` to compare buffers in integration tests. When
the assertion fails, the output now show the list of differences in addition
of the views of the computed and expected buffers. This effectively replaces
the table of debug code for colors and modifiers as it is easier to read.
4 years ago
Florian Dehau a7761fe55d fix(buffer): ignore zero-width graphemes 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 816bc9b5c8 style: fix formatting and clippy issues 5 years ago
Florian Dehau 43e38ac483 Fix Buffer::merge
Coordinates returned by Buffer::pos_of were interpreted as local coordinates
while they were global. This was resulting in panics due to out of bounds
accesses. Interpreting the coordinates as global and using correct offsets
when computing the new index within the buffer for each cell fix the issue.
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 3fd9e23851 Buffer: correct diffing of buffers with multi-width characters
Resolves #104
5 years ago
Karoline Pauls 1802cf8dbc Improve wrapping of double-width characters 5 years ago
Karoline Pauls 89dac9d2a6 buffer: add quotes to fmt::Debug for better testing experience 6 years ago
Florian Dehau 22e8fade7e feat: add experimental test backend 6 years ago
Florian Dehau 6c69160d6b feat: remove unecessary borrows of Style 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
Magnus Bergmark d0d2f88346 BUG: Buffer::pos_of panics on inside-bounds index
- Add tests for this behavior.
- Extend documentation of Buffer::pos_of and Buffer::index_of
  - Clarify that the coordinates should be in global coordinate-space
  (rather than local).
  - Document panics.
  - Add examples.
6 years ago
Florian Dehau c3c5109c5a [src] Fix build and tests 6 years ago
Florian Dehau 1f285fbac0 [src] Run cargo fmt 7 years ago
Florian Dehau 71545a0aa8 Run cargo fmt 7 years ago
Florian Dehau 4f8a57d500 Fix clippy warnings 8 years ago
Florian Dehau 662e2dd102 Fix examples 8 years ago
Florian Dehau 224eb2d8e0 Add support for text styling 8 years ago
Florian Dehau 93cc237007 Documentation 8 years ago
Florian Dehau 107d7297af Fix some layout problems 8 years ago
Florian Dehau b0b1645010 Rename set_characters method in buffer interface 8 years ago
Florian Dehau bcb3d751bf Rename buffer methods 8 years ago
Florian Dehau 85bd76e17d Small improvements 8 years ago
Florian Dehau c91436baee Change rendering method and adapt widget trait accordingly 8 years ago
Florian Dehau 063bde8764 Add bar chart prototype 8 years ago
Florian Dehau 7a427c06d4 Update chart widget and fix colors in all widgets 8 years ago
Florian Dehau 07ff2b08eb Improve Chart Widget, safer buffer and unicode width 8 years ago
Florian Dehau fde0ba95dd Remove cache system and add unicode segmentation 8 years ago
Florian Dehau bd404f0238 Cleanup code and add chart widget 8 years ago
Florian Dehau 6ed19df342 Update color support for block, gauge, list and sparkline 8 years ago
Florian Dehau 9816ccd4e3 Change layout properties and improve gauge and sparkline 8 years ago
Florian Dehau 5b5d37ee69 Add gauge, fix rendering and cleanup code 8 years ago
Florian Dehau 459201bc65 First commit 8 years ago