Commit Graph

866 Commits

Author SHA1 Message Date
Alexandre Bury
0a81454e7d Fix BoxView 2019-08-27 13:13:06 -07:00
Johannes Wünsche
e47dd87e0c BoxView Fixed, AtLeast, AtMost SizeConstraints (#368)
* Add wrap_draw implementation for BoxView

This implementation was required because the restriction of fixed &
at least sized BoxView was not fulfilled with the default. The new
implementation takes this into consideration.
2019-08-19 15:16:40 -07:00
Alexandre Bury
63302bf01b Cleanup text_view 2019-08-16 10:15:00 -07:00
Leonardo Lang
dc10fd8c44 Fix out-of-bounds access on TextView
Frequent updates to `TextContent` while the screen is being refreshed can
trigger an out-of-bounds access: an update with a smaller string being
performed between calls to `compute_rows()` and `draw()` on TextView will
cause an out-of-bounds access when slicing the string at `Segment::resolve`.

This change fixes the issue by caching the content value when performing
size calculations and using this cached content when drawing the view.

Some additional changes were also made to reuse `TextContent` invalidation
code on `TextView` and wrap content data with `RefCell<Arc<..>>` to enable
sharing the inner string between `content_value` and `content_cache`.
2019-08-01 20:29:50 -04:00
Alexandre Bury
c0004c54c0 SizeConstraint::Full now defer to requested size if larger than available 2019-07-31 21:44:21 -07:00
Alexandre Bury
349756e514 Fix clippy lints 2019-07-30 16:29:03 -07:00
Alexandre Bury
b7d71e8381 Rustfmt
Moves to "Tall" fn_args_layout
2019-07-30 16:08:40 -07:00
Andrzej J. Skalski
4a1fc3e49d Test backend (#310) 2019-07-30 11:57:01 -07:00
Timon
bddb1a9dde Crossterm Performance Update (#361) 2019-07-30 09:48:50 -07:00
cubetastic
ede8423e92 Update docs, fix minor typos, rephrase some parts of the tutorials (#364)
Also mention that strikethrough doesn't work with ncurses and blt.
2019-07-30 09:48:05 -07:00
cubetastic
9ca3f50bd6 Add strikethrough effect (#360) 2019-07-29 12:59:58 -07:00
Alexandre Bury
ef60cd0a76 Add ListView::remove_child 2019-07-26 15:36:19 -07:00
Gergely Nagy
74266edf29 replace CbFunc with Box<FnOnce()> (#351)
Since Rust 1.35, Box<FnOnce()> compiles, we can remove the workaround.
2019-07-05 00:16:26 -07:00
Alexandre Bury
babc038e36 Add some documentation to the view::scroll module 2019-07-02 16:50:21 -07:00
Danil Berestov
976cb99bdb Remove extra check (#357) 2019-06-27 16:19:07 -07:00
Alexandre Bury
ad23dfe59b Add ScrollView::{inner_size, is_at_{bottom, top, left, right}} 2019-06-23 21:53:11 -04:00
Alexandre Bury
0c8a7b2708 Rename repo name to use lowercase 2019-06-19 14:39:11 -04:00
Alexandre Bury
269f2ab521 Add dyn to trait objects 2019-06-18 11:44:47 -07:00
Mark LeMoine
39e14d8c93 Add getters for current and max value in SliderView (#353) 2019-06-07 09:47:48 -07:00
Alexandre Bury
23d65aa9dc Update examples and tutorials to Rust 2018 2019-05-20 15:53:22 -07:00
David Ross
b2184b3a36 Fix doc typo (abd -> and) (#350) 2019-05-20 10:19:49 -07:00
Alexandre Bury
8d6b256b1c More public fields in cursive::logger 2019-05-18 08:40:18 -07:00
Alexandre Bury
859c12320f Send Event::Refresh on fps timeout 2019-05-14 09:41:13 -07:00
Alexandre Bury
00f4b27794 Update dependencies 2019-05-09 09:35:39 -07:00
Shixin Zeng
df0391aef2 [PAN] Interprete 'carriage return' as 'enter' (#342)
Pancurses returns different key codes for "Enter" in the normal area
('\r'), and the one in the numpad ('\n'). Cursive only interpretes '\n'
as Enter, and leaves '\r' as CtrlChar('m'), which is different than
that with NCurses on Linux, and makes 'Enter' key not trigger a clicked
event on buttons.
2019-05-08 10:07:05 -07:00
Gergely Nagy
cf86f64334 Enable horizontal scrollbar for debug console (#341) 2019-05-06 13:23:41 -07:00
Alexandre Bury
fb0d26fb4a Add Cursive::take_user_data 2019-04-24 11:48:51 -07:00
Alexandre Bury
26ea559479 Fix clippy warnings 2019-04-17 11:47:01 -07:00
Timon
34ecb67f1b Added crossterm backend. (#335)
Add a backend using the crossterm library.
2019-04-17 11:36:32 -07:00
Alexandre Bury
ea9d215fa3 Fix markdown tests 2019-04-15 15:50:52 -07:00
Alexandre Bury
ac28309b3b Use cfg-if for to define Cursive::default()
And update other dependencies
2019-04-15 15:47:23 -07:00
Alexandre Bury
51c6450688 Rustfmt 2019-04-11 17:08:55 -07:00
Alexandre Bury
158bc65c33 Add direct downcast methods to AnyView 2019-04-08 17:44:42 -07:00
Arnav Singh
070508f0cf Cursive::step() now returns true if something interesting happened. (#332)
Also make `Cursive::refresh()` public so that callers can force a refresh.

Fixes #331
2019-03-30 11:24:47 -07:00
Chris Vest
88037717e6 Add a sort method to SelectView, to easily sort all contained items lexicographically by their label. (#329)
* Add a sort method to SelectView, to easily sort all contained items lexicographically by their label.

* Add more sort methods to SelectView, bringing the API up to parity with Vec (except SelectView does not expose _unstable_ sorting).

* Rename SelectView::sort to sort_by_label to make it clear that it does not sort by the ordering of the items.

* The Ord implementation for select_view::Item is not necessary.

* Implement a SelectView::sort method for when the item values are orderable.
2019-03-30 10:22:08 -07:00
Alexandre Bury
8ce3a667f7 Add Cursive::set_fps 2019-03-28 17:33:15 -07:00
Alexandre Bury
3099588f16 Fix spans tests 2019-03-20 17:08:03 -07:00
Alexandre Bury
038294339d Fix clippy warning 2019-03-20 17:05:18 -07:00
Alexandre Bury
aeb0d88987 Skip width computation in print_styled 2019-03-20 16:57:48 -07:00
Alexandre Bury
c9dc371223 Add width field to Span and IndexedSpan 2019-03-20 16:48:48 -07:00
Alexandre Bury
19ad7b6cc3 Use hashbrown::HashMap 2019-03-16 16:16:30 -07:00
Alexandre Bury
3a0b49088b Add manual scroll methods to scroll::Core 2019-03-12 15:42:36 -07:00
Chris Vest
ea7b5dbae2 Add Backend::print_at_rep and make Printer::print_hline use it. (#326)
* Add Backend::print_at_rep and make Printer::print_hline use it.

This avoids a string allocation in `print_hline` and makes it faster, presumably for all backends.
This speeds up the rendering of the background in StackView.

* Fix a bug in how Printer::print_hline computes the repetition count.
2019-03-12 15:03:00 -07:00
Alexandre Bury
4b5a7867e3 Refactor scroll::Core mechanism.
Moved most View-trait-performing-functions outside of `scroll::Core`
into `scroll::raw`.
Added a `Scroller` trait and convenience methods like `scroll::layout` to
weave the borrows appropriately.
2019-03-12 14:31:56 -07:00
Chris Vest
561b83dbc9 Avoid iterating graphemes unless we have to.
Iterating graphemes with `text.graphemes(true)` is somewhat expensive due to the complexity of unicode.
However, we were doing it _twice_ in the `Printer::print` method in order to truncate the input text to fit the content area.
This changes that method to track the width of the intput text, and only do the grapheme iteration when truncation is actually necessary.
2019-03-12 21:30:46 +01:00
Chris Vest
0dfa337ba4 Use a single hashmap lookup to determine if a color has been resolved, and to what, instead of two lookups. 2019-03-12 09:54:48 +01:00
Alexandre Bury
b2a0fa18ff Disable dead code lint for unstable module 2019-03-11 11:52:58 -07:00
Alexandre Bury
91a78f402b Hide view::scroll behind unstable_scroll feature 2019-03-11 00:03:54 -07:00
Alexandre Bury
12ad66badd Migrate MenuPopup to new scrollbase 2019-03-08 13:57:05 -08:00
Alexandre Bury
ae0e9216ce Add new ScrollBase 2019-03-07 22:33:43 -08:00