Commit Graph

50 Commits (master)

Author SHA1 Message Date
Florian Dehau 9806217a6a feat!: use crossterm as default backend 3 years ago
Florian Dehau 853f3d9200 feat(terminal): add a read-only view of the terminal state after the draw call 3 years ago
Brooks Rady d00184a7c3
feat(text): extend `Text` to be stylable and extendable (#361)
* Extend `Text` to be extendable
* Add some documentation
4 years ago
Florian Dehau 90f3858eff feat(backend): keep the internal buffers in sync when the terminal is cleared. 4 years ago
Florian Dehau 641f391137 feat(terminal): add unstable api to use a fixed viewport
There was now way to avoid the autoresize behavior of `Terminal`. While it was fine for most users,
it made the testing experience painful as it was impossible to avoid the calls to `Backend::size()`.
Indeed they trigger the following error: "Inappropriate ioctl for device" since we are not running
the tests in a real terminal (at least in the CI).

This commit introduces a new api to create a `Terminal` with a fixed viewport.
4 years ago
Florian Dehau 88c4b191fb feat(text): add new text primitives 4 years ago
Alexander Batischev 8c2ee0ed85
feat(terminal): Add after-draw() cursor control to Frame (#91) (#309) 4 years ago
Florian Dehau 5d99b4af00 docs: improve widgets documentation 4 years ago
Florian Dehau 3f62ce9c19 chore: remove unecessary dependencies
* Remove log, stderrlog, structopt
* Add argh
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
scauligi bca920bea0 get/set cursor position 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 228816f5f8 Frame: provide consistent size for rendering 6 years ago
Karoline Pauls 8cdfc883b9 Feature: Autoresize
It basically never makes sense to render without syncing the size.

Without resizing, if shrinking, we get artefacts. If growing, we may get
panics (before this change the Rustbox sample (the only one which didn't
handle resizing on its own) panicked because the widget would get an
updated size, while the terminal would not).
6 years ago
Florian Dehau fdf3015ad0 feat(terminal): log error if failed to show cursor on drop 6 years ago
Florian Dehau 7b4d35d224 feat: restore the cursor state on terminal drop 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 36a5eb2110 Format code 6 years ago
Florian Dehau ef2054a45b [lib] Derive Debug on Terminal 6 years ago
Florian Dehau af16518650 [src] Run rustfmt 6 years ago
Florian Dehau 1f285fbac0 [src] Run cargo fmt 7 years ago
Florian Dehau 71545a0aa8 Run cargo fmt 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 116ee4439a Improve Paragraph widget
* Add the possibility to disable the markup rendering
* Fix parser error
8 years ago
Florian Dehau feefa5d54f Convert backends to conditionnal features for compilation 8 years ago
Florian Dehau 4f8a57d500 Fix clippy warnings 8 years ago
Florian Dehau b30fede80c Add the possibility to provide a RustBox instance at backend initialization 8 years ago
Florian Dehau b19c014889 Fix layout cache on nightly 8 years ago
Florian Dehau 224eb2d8e0 Add support for text styling 8 years ago
Florian Dehau 9bc61551e2 Refactor Terminal to be able to support multiple backends
* Add Rustbox as an other possible backend
8 years ago
Florian Dehau 93cc237007 Documentation 8 years ago
Florian Dehau a5b632aeb0 Cleanup API 8 years ago
Florian Dehau 107d7297af Fix some layout problems 8 years ago
Florian Dehau f0979dfeee Improve canvas functionalities and fix clippy warnings 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 15c3471f0b Fix clippy warnings 8 years ago
Florian Dehau d7131ead11 Cache layout and performance fixes 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 d11dedd864 Add sparkline widget and fix warnings 8 years ago
Florian Dehau 5b5d37ee69 Add gauge, fix rendering and cleanup code 8 years ago
Florian Dehau 93f3263e2b Fix redraw for disappearing widgets 8 years ago
Florian Dehau 13f6a5a98b Add list widget and improve rendering 8 years ago
Florian Dehau 459201bc65 First commit 8 years ago