mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 19:00:46 +00:00
Rename id
to name
: phase 2
This commit is contained in:
parent
ddac91373c
commit
6824cc4299
28
CHANGELOG.md
28
CHANGELOG.md
@ -7,21 +7,38 @@
|
|||||||
- `cursive::event::AnyCb` changed from `Box<...>` to `&mut ...`, so users of
|
- `cursive::event::AnyCb` changed from `Box<...>` to `&mut ...`, so users of
|
||||||
`View::call_on_any` no longer need to box their closures.
|
`View::call_on_any` no longer need to box their closures.
|
||||||
- Remove `BoxView::squishable`.
|
- Remove `BoxView::squishable`.
|
||||||
- Update crossterm to 0.12.
|
- Update crossterm to 0.14.
|
||||||
|
- Renamed multiple types (old names are still re-exported, but deprecated):
|
||||||
|
- `BoxView` -> `ResizedView`
|
||||||
|
- `ViewBox` -> `BoxedView`
|
||||||
|
- `SizedView` -> `LastSizeView`
|
||||||
|
- `Identifiable` -> `Nameable`
|
||||||
|
- `Boxable` -> `Resizable`
|
||||||
|
- `IdView` -> `NamedView`
|
||||||
|
- `Selector::Id` -> `Selector::Name`
|
||||||
|
- `with_id` -> `with_name`
|
||||||
|
- `call_on_id` -> `call_on_name`
|
||||||
|
- `find_id` -> `find_name`
|
||||||
|
- `focus_id` -> `focus_name`
|
||||||
|
|
||||||
### API updates
|
### API updates
|
||||||
|
|
||||||
- `SelectView::{item, with_all}` now accept `S: Into<StyledString>` for colored labels.
|
- `SelectView::{item, with_all}` now accept `S: Into<StyledString>` for colored labels.
|
||||||
- Add `ScrollView::scroll_to_important_area`.
|
- Add `ScrollView::scroll_to_important_area`.
|
||||||
- Add `LinearLayout::set_focus_index`.
|
- Add `LinearLayout::set_focus_index`.
|
||||||
- Add `XY::{sum, product}`
|
- Add `XY::{sum, product}`.
|
||||||
- `view::scroll` is now a public module
|
- `view::scroll` is now a public module.
|
||||||
- Add `Cursive::process_events` and `Cursive::post_events`
|
- Add `Cursive::process_events` and `Cursive::post_events`.
|
||||||
- This gives users finer control than `Cursive::step`
|
- This gives users finer control than `Cursive::step`.
|
||||||
|
- `Layer` now has a `color` option.
|
||||||
|
- `LinearLayout` can now directly add boxed views without re-boxing.
|
||||||
|
- Add inner getters to `EnableableView`.
|
||||||
|
- Add `PaddedView::get_inner(_mut)`.
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
||||||
- Changed the default color for `TitleSecondary` from yellow to light blue.
|
- Changed the default color for `TitleSecondary` from yellow to light blue.
|
||||||
|
- Changed the default color for `Tertiary` from grey to white.
|
||||||
- Reduced dependencies (`toml` is now optional, removed `hashbrown`).
|
- Reduced dependencies (`toml` is now optional, removed `hashbrown`).
|
||||||
- `Cursive::default()` now fallbacks do dummy backend if no other is available.
|
- `Cursive::default()` now fallbacks do dummy backend if no other is available.
|
||||||
|
|
||||||
@ -30,6 +47,7 @@
|
|||||||
- Fixed `ScrollView::show_scrollbars()`
|
- Fixed `ScrollView::show_scrollbars()`
|
||||||
- Fixed layout for `BoxView` with some size constraints.
|
- Fixed layout for `BoxView` with some size constraints.
|
||||||
- On Windows, do not print unix-specific character during initialization.
|
- On Windows, do not print unix-specific character during initialization.
|
||||||
|
- Fix out-of-bounds access for some mouse events in `MenuPopup`
|
||||||
|
|
||||||
## 0.13.0
|
## 0.13.0
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ fn main() {
|
|||||||
|
|
||||||
let select = SelectView::<String>::new()
|
let select = SelectView::<String>::new()
|
||||||
.on_submit(on_submit)
|
.on_submit(on_submit)
|
||||||
.with_id("select")
|
.with_name("select")
|
||||||
.fixed_size((10, 5));
|
.fixed_size((10, 5));
|
||||||
let buttons = LinearLayout::vertical()
|
let buttons = LinearLayout::vertical()
|
||||||
.child(Button::new("Add new", add_name))
|
.child(Button::new("Add new", add_name))
|
||||||
@ -38,7 +38,7 @@ fn main() {
|
|||||||
|
|
||||||
fn add_name(s: &mut Cursive) {
|
fn add_name(s: &mut Cursive) {
|
||||||
fn ok(s: &mut Cursive, name: &str) {
|
fn ok(s: &mut Cursive, name: &str) {
|
||||||
s.call_on_id("select", |view: &mut SelectView<String>| {
|
s.call_on_name("select", |view: &mut SelectView<String>| {
|
||||||
view.add_item_str(name)
|
view.add_item_str(name)
|
||||||
});
|
});
|
||||||
s.pop_layer();
|
s.pop_layer();
|
||||||
@ -46,12 +46,12 @@ fn add_name(s: &mut Cursive) {
|
|||||||
|
|
||||||
s.add_layer(Dialog::around(EditView::new()
|
s.add_layer(Dialog::around(EditView::new()
|
||||||
.on_submit(ok)
|
.on_submit(ok)
|
||||||
.with_id("name")
|
.with_name("name")
|
||||||
.fixed_width(10))
|
.fixed_width(10))
|
||||||
.title("Enter a new name")
|
.title("Enter a new name")
|
||||||
.button("Ok", |s| {
|
.button("Ok", |s| {
|
||||||
let name =
|
let name =
|
||||||
s.call_on_id("name", |view: &mut EditView| {
|
s.call_on_name("name", |view: &mut EditView| {
|
||||||
view.get_content()
|
view.get_content()
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
ok(s, &name);
|
ok(s, &name);
|
||||||
@ -62,7 +62,7 @@ fn add_name(s: &mut Cursive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn delete_name(s: &mut Cursive) {
|
fn delete_name(s: &mut Cursive) {
|
||||||
let mut select = s.find_id::<SelectView<String>>("select").unwrap();
|
let mut select = s.find_name::<SelectView<String>>("select").unwrap();
|
||||||
match select.selected_id() {
|
match select.selected_id() {
|
||||||
None => s.add_layer(Dialog::info("No name to remove")),
|
None => s.add_layer(Dialog::info("No name to remove")),
|
||||||
Some(focus) => {
|
Some(focus) => {
|
||||||
@ -193,7 +193,7 @@ this list with names!
|
|||||||
[`LinearLayout`]: https://docs.rs/cursive/0/cursive/views/struct.LinearLayout.html
|
[`LinearLayout`]: https://docs.rs/cursive/0/cursive/views/struct.LinearLayout.html
|
||||||
[`DummyView`]: https://docs.rs/cursive/0/cursive/views/struct.DummyView.html
|
[`DummyView`]: https://docs.rs/cursive/0/cursive/views/struct.DummyView.html
|
||||||
|
|
||||||
## IDs
|
## Identifying views
|
||||||
|
|
||||||
When the user presses the `<Add new>` button, we want to show a popup where he
|
When the user presses the `<Add new>` button, we want to show a popup where he
|
||||||
can enter a new name:
|
can enter a new name:
|
||||||
@ -224,12 +224,12 @@ The closure has access to the `&mut Cursive`, which in turn has access to all
|
|||||||
the views, so _in theory_, we could ask it to borrow the view, if only we knew
|
the views, so _in theory_, we could ask it to borrow the view, if only we knew
|
||||||
how to point to the correct view.
|
how to point to the correct view.
|
||||||
|
|
||||||
[`IdView`] is meant exactly for this: it wraps a view and gives it an ID.
|
[`IdView`] is meant exactly for this: it wraps a view and gives it a name.
|
||||||
Later, you can ask the Cursive root for this ID and get access to the view.
|
Later, you can ask the Cursive root for this name and get access to the view.
|
||||||
Just what we need!
|
Just what we need!
|
||||||
|
|
||||||
Like `ResizedView`, `IdView` can be used directly with [`IdView::new`], or through
|
Like `ResizedView`, `IdView` can be used directly with [`IdView::new`], or through
|
||||||
the [`Identifiable`] trait. [`Cursive::call_on_id`] allows you to run a closure
|
the [`Identifiable`] trait. [`Cursive::call_on_name`] allows you to run a closure
|
||||||
on the view.
|
on the view.
|
||||||
|
|
||||||
Here's what it looks like in action:
|
Here's what it looks like in action:
|
||||||
@ -237,11 +237,11 @@ Here's what it looks like in action:
|
|||||||
```rust,ignore
|
```rust,ignore
|
||||||
fn add_name(s: &mut Cursive) {
|
fn add_name(s: &mut Cursive) {
|
||||||
s.add_layer(Dialog::around(EditView::new()
|
s.add_layer(Dialog::around(EditView::new()
|
||||||
.with_id("name")
|
.with_name("name")
|
||||||
.fixed_width(10))
|
.fixed_width(10))
|
||||||
.title("Enter a new name")
|
.title("Enter a new name")
|
||||||
.button("Ok", |s| {
|
.button("Ok", |s| {
|
||||||
let name = s.call_on_id("name", |view: &mut EditView| {
|
let name = s.call_on_name("name", |view: &mut EditView| {
|
||||||
view.get_content()
|
view.get_content()
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
})
|
})
|
||||||
@ -252,15 +252,15 @@ fn add_name(s: &mut Cursive) {
|
|||||||
```
|
```
|
||||||
|
|
||||||
We create the `EditView` with the id `"name"`, and we use `"name"` again when
|
We create the `EditView` with the id `"name"`, and we use `"name"` again when
|
||||||
calling `call_on_id`.
|
calling `call_on_name`.
|
||||||
|
|
||||||
Now we just need to do something with this name: add it to the list!
|
Now we just need to do something with this name: add it to the list!
|
||||||
Remember the `SelectView` we created? Let's give it an ID too:
|
Remember the `SelectView` we created? Let's give it a name too:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
let select = SelectView::<String>::new()
|
let select = SelectView::<String>::new()
|
||||||
.on_submit(on_submit)
|
.on_submit(on_submit)
|
||||||
.with_id("select")
|
.with_name("select")
|
||||||
.fixed_size((10, 5));
|
.fixed_size((10, 5));
|
||||||
```
|
```
|
||||||
(Here again, the order is important: we want to wrap the `SelectView`, not
|
(Here again, the order is important: we want to wrap the `SelectView`, not
|
||||||
@ -271,7 +271,7 @@ That way, we can update it with a new item:
|
|||||||
```rust,ignore
|
```rust,ignore
|
||||||
fn add_name(s: &mut Cursive) {
|
fn add_name(s: &mut Cursive) {
|
||||||
fn ok(s: &mut Cursive, name: &str) {
|
fn ok(s: &mut Cursive, name: &str) {
|
||||||
s.call_on_id("select", |view: &mut SelectView<String>| {
|
s.call_on_name("select", |view: &mut SelectView<String>| {
|
||||||
view.add_item_str(name);
|
view.add_item_str(name);
|
||||||
});
|
});
|
||||||
s.pop_layer();
|
s.pop_layer();
|
||||||
@ -279,11 +279,11 @@ fn add_name(s: &mut Cursive) {
|
|||||||
|
|
||||||
s.add_layer(Dialog::around(EditView::new()
|
s.add_layer(Dialog::around(EditView::new()
|
||||||
.on_submit(ok)
|
.on_submit(ok)
|
||||||
.with_id("name")
|
.with_name("name")
|
||||||
.fixed_width(10))
|
.fixed_width(10))
|
||||||
.title("Enter a new name")
|
.title("Enter a new name")
|
||||||
.button("Ok", |s| {
|
.button("Ok", |s| {
|
||||||
let name = s.call_on_id("name", |v: &mut EditView| {
|
let name = s.call_on_name("name", |v: &mut EditView| {
|
||||||
v.get_content()
|
v.get_content()
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
ok(s, &name);
|
ok(s, &name);
|
||||||
@ -299,7 +299,7 @@ complicated:
|
|||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
fn delete_name(s: &mut Cursive) {
|
fn delete_name(s: &mut Cursive) {
|
||||||
let mut select = s.find_id::<SelectView<String>>("select").unwrap();
|
let mut select = s.find_name::<SelectView<String>>("select").unwrap();
|
||||||
match select.selected_id() {
|
match select.selected_id() {
|
||||||
None => s.add_layer(Dialog::info("No name to remove")),
|
None => s.add_layer(Dialog::info("No name to remove")),
|
||||||
Some(focus) => {
|
Some(focus) => {
|
||||||
@ -312,7 +312,7 @@ fn delete_name(s: &mut Cursive) {
|
|||||||
We use [`SelectView::selected_id`] and [`SelectView::remove_item`] to remove
|
We use [`SelectView::selected_id`] and [`SelectView::remove_item`] to remove
|
||||||
the item currently selected, nothing too surprising.
|
the item currently selected, nothing too surprising.
|
||||||
|
|
||||||
But this time, instead of using `call_on_id`, we use [`Cursive::find_id`]:
|
But this time, instead of using `call_on_name`, we use [`Cursive::find_name`]:
|
||||||
this method returns a handle, through which we can mutate the view.
|
this method returns a handle, through which we can mutate the view.
|
||||||
It uses `Rc` and `RefCell` under the hood to provide mutable access to the
|
It uses `Rc` and `RefCell` under the hood to provide mutable access to the
|
||||||
view without borrowing the `Cursive` root, leaving us free to pop layers.
|
view without borrowing the `Cursive` root, leaving us free to pop layers.
|
||||||
@ -321,8 +321,8 @@ view without borrowing the `Cursive` root, leaving us free to pop layers.
|
|||||||
[`IdView`]: https://docs.rs/cursive/0/cursive/views/struct.IdView.html
|
[`IdView`]: https://docs.rs/cursive/0/cursive/views/struct.IdView.html
|
||||||
[`IdView::new`]: https://docs.rs/cursive/0/cursive/prelude/struct.IdView.html#method.around
|
[`IdView::new`]: https://docs.rs/cursive/0/cursive/prelude/struct.IdView.html#method.around
|
||||||
[`Identifiable`]: https://docs.rs/cursive/0/cursive/view/trait.Identifiable.html
|
[`Identifiable`]: https://docs.rs/cursive/0/cursive/view/trait.Identifiable.html
|
||||||
[`Cursive::find_id`]: https://docs.rs/cursive/0/cursive/struct.Cursive.html#method.find_id
|
[`Cursive::find_name`]: https://docs.rs/cursive/0/cursive/struct.Cursive.html#method.find_name
|
||||||
[`Cursive::call_on_id`]: https://docs.rs/cursive/0/cursive/struct.Cursive.html#method.call_on_id
|
[`Cursive::call_on_name`]: https://docs.rs/cursive/0/cursive/struct.Cursive.html#method.call_on_name
|
||||||
[`SelectView::selected_id`]: https://docs.rs/cursive/0/cursive/views/struct.SelectView.html#method.selected_id
|
[`SelectView::selected_id`]: https://docs.rs/cursive/0/cursive/views/struct.SelectView.html#method.selected_id
|
||||||
[`SelectView::remove_item`]: https://docs.rs/cursive/0/cursive/views/struct.SelectView.html#method.remove_item
|
[`SelectView::remove_item`]: https://docs.rs/cursive/0/cursive/views/struct.SelectView.html#method.remove_item
|
||||||
|
|
||||||
@ -334,5 +334,5 @@ don't hesitate to read the documentation.
|
|||||||
You've now seen:
|
You've now seen:
|
||||||
* How to wrap views to control their size
|
* How to wrap views to control their size
|
||||||
* How to assemble views together in a linear layout
|
* How to assemble views together in a linear layout
|
||||||
* How to give an ID to views and use them later
|
* How to give names to views and use them later
|
||||||
* How to use `SelectView`, `EditView`, `Button`s...
|
* How to use `SelectView`, `EditView`, `Button`s...
|
||||||
|
@ -18,9 +18,9 @@ fn main() {
|
|||||||
// Call `show_popup` when the user presses `Enter`
|
// Call `show_popup` when the user presses `Enter`
|
||||||
.on_submit(show_popup)
|
.on_submit(show_popup)
|
||||||
// Give the `EditView` a name so we can refer to it later.
|
// Give the `EditView` a name so we can refer to it later.
|
||||||
.with_id("name")
|
.with_name("name")
|
||||||
// Wrap this in a `ResizedView` with a fixed width.
|
// Wrap this in a `ResizedView` with a fixed width.
|
||||||
// Do this _after_ `with_id` or the name will point to the
|
// Do this _after_ `with_name` or the name will point to the
|
||||||
// `ResizedView` instead of `EditView`!
|
// `ResizedView` instead of `EditView`!
|
||||||
.fixed_width(20),
|
.fixed_width(20),
|
||||||
)
|
)
|
||||||
@ -28,7 +28,7 @@ fn main() {
|
|||||||
// This will run the given closure, *ONLY* if a view with the
|
// This will run the given closure, *ONLY* if a view with the
|
||||||
// correct type and the given ID is found.
|
// correct type and the given ID is found.
|
||||||
let name = s
|
let name = s
|
||||||
.call_on_id("name", |view: &mut EditView| {
|
.call_on_name("name", |view: &mut EditView| {
|
||||||
// We can return content from the closure!
|
// We can return content from the closure!
|
||||||
view.get_content()
|
view.get_content()
|
||||||
})
|
})
|
||||||
|
@ -24,11 +24,11 @@ fn main() {
|
|||||||
Checkbox::new().on_change(|s, checked| {
|
Checkbox::new().on_change(|s, checked| {
|
||||||
// Enable/Disable the next field depending on this checkbox
|
// Enable/Disable the next field depending on this checkbox
|
||||||
for name in &["email1", "email2"] {
|
for name in &["email1", "email2"] {
|
||||||
s.call_on_id(name, |view: &mut EditView| {
|
s.call_on_name(name, |view: &mut EditView| {
|
||||||
view.set_enabled(checked)
|
view.set_enabled(checked)
|
||||||
});
|
});
|
||||||
if checked {
|
if checked {
|
||||||
s.focus_id("email1").unwrap();
|
s.focus_name("email1").unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@ -41,14 +41,14 @@ fn main() {
|
|||||||
.child(
|
.child(
|
||||||
EditView::new()
|
EditView::new()
|
||||||
.disabled()
|
.disabled()
|
||||||
.with_id("email1")
|
.with_name("email1")
|
||||||
.fixed_width(15),
|
.fixed_width(15),
|
||||||
)
|
)
|
||||||
.child(TextView::new("@"))
|
.child(TextView::new("@"))
|
||||||
.child(
|
.child(
|
||||||
EditView::new()
|
EditView::new()
|
||||||
.disabled()
|
.disabled()
|
||||||
.with_id("email2")
|
.with_name("email2")
|
||||||
.fixed_width(10),
|
.fixed_width(10),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -17,7 +17,7 @@ fn main() {
|
|||||||
// We add the P callback on the textview only (and not globally),
|
// We add the P callback on the textview only (and not globally),
|
||||||
// so that we can't call it when the popup is already visible.
|
// so that we can't call it when the popup is already visible.
|
||||||
siv.add_layer(
|
siv.add_layer(
|
||||||
OnEventView::new(TextView::new(content).with_id("text"))
|
OnEventView::new(TextView::new(content).with_name("text"))
|
||||||
.on_event('p', |s| show_popup(s)),
|
.on_event('p', |s| show_popup(s)),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ fn show_popup(siv: &mut Cursive) {
|
|||||||
.button("Change", |s| {
|
.button("Change", |s| {
|
||||||
// Look for a view tagged "text".
|
// Look for a view tagged "text".
|
||||||
// We _know_ it's there, so unwrap it.
|
// We _know_ it's there, so unwrap it.
|
||||||
s.call_on_id("text", |view: &mut TextView| {
|
s.call_on_name("text", |view: &mut TextView| {
|
||||||
let content = reverse(view.get_content().source());
|
let content = reverse(view.get_content().source());
|
||||||
view.set_content(content);
|
view.set_content(content);
|
||||||
});
|
});
|
||||||
|
@ -12,9 +12,9 @@ fn main() {
|
|||||||
siv.add_layer(
|
siv.add_layer(
|
||||||
Dialog::around(
|
Dialog::around(
|
||||||
LinearLayout::vertical()
|
LinearLayout::vertical()
|
||||||
.child(EditView::new().on_edit(on_edit).with_id("1"))
|
.child(EditView::new().on_edit(on_edit).with_name("1"))
|
||||||
.child(EditView::new().on_edit(on_edit).with_id("2"))
|
.child(EditView::new().on_edit(on_edit).with_name("2"))
|
||||||
.child(TextView::new("match").with_id("match"))
|
.child(TextView::new("match").with_name("match"))
|
||||||
.fixed_width(10),
|
.fixed_width(10),
|
||||||
)
|
)
|
||||||
.button("Quit", Cursive::quit),
|
.button("Quit", Cursive::quit),
|
||||||
@ -30,13 +30,13 @@ fn main() {
|
|||||||
// and directly retrieve the content from the `Cursive` root.
|
// and directly retrieve the content from the `Cursive` root.
|
||||||
fn on_edit(siv: &mut Cursive, _content: &str, _cursor: usize) {
|
fn on_edit(siv: &mut Cursive, _content: &str, _cursor: usize) {
|
||||||
// Get handles for each view.
|
// Get handles for each view.
|
||||||
let edit_1 = siv.find_id::<EditView>("1").unwrap();
|
let edit_1 = siv.find_name::<EditView>("1").unwrap();
|
||||||
let edit_2 = siv.find_id::<EditView>("2").unwrap();
|
let edit_2 = siv.find_name::<EditView>("2").unwrap();
|
||||||
|
|
||||||
// Directly compare references to edit_1 and edit_2.
|
// Directly compare references to edit_1 and edit_2.
|
||||||
let matches = edit_1.get_content() == edit_2.get_content();
|
let matches = edit_1.get_content() == edit_2.get_content();
|
||||||
|
|
||||||
siv.call_on_id("match", |v: &mut TextView| {
|
siv.call_on_name("match", |v: &mut TextView| {
|
||||||
v.set_content(if matches { "match" } else { "no match" })
|
v.set_content(if matches { "match" } else { "no match" })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ fn main() {
|
|||||||
.value(7)
|
.value(7)
|
||||||
.on_change(|s, v| {
|
.on_change(|s, v| {
|
||||||
let title = format!("[ {} ]", v);
|
let title = format!("[ {} ]", v);
|
||||||
s.call_on_id("dialog", |view: &mut Dialog| {
|
s.call_on_name("dialog", |view: &mut Dialog| {
|
||||||
view.set_title(title)
|
view.set_title(title)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -31,7 +31,7 @@ fn main() {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.title("[ 7 ]")
|
.title("[ 7 ]")
|
||||||
.with_id("dialog"),
|
.with_name("dialog"),
|
||||||
);
|
);
|
||||||
|
|
||||||
siv.run();
|
siv.run();
|
||||||
|
@ -154,13 +154,13 @@ fn build_selector(model: Model) -> impl cursive::view::View {
|
|||||||
.child(
|
.child(
|
||||||
views::EditView::new()
|
views::EditView::new()
|
||||||
.content(format!("{}", offset))
|
.content(format!("{}", offset))
|
||||||
.with_id("edit")
|
.with_name("edit")
|
||||||
.min_width(5),
|
.min_width(5),
|
||||||
)
|
)
|
||||||
.child(views::DummyView.fixed_width(1))
|
.child(views::DummyView.fixed_width(1))
|
||||||
.child(views::Button::new("Update", move |s| {
|
.child(views::Button::new("Update", move |s| {
|
||||||
if let Some(n) = s
|
if let Some(n) = s
|
||||||
.call_on_id("edit", |edit: &mut views::EditView| {
|
.call_on_name("edit", |edit: &mut views::EditView| {
|
||||||
edit.get_content()
|
edit.get_content()
|
||||||
})
|
})
|
||||||
.and_then(|content| content.parse().ok())
|
.and_then(|content| content.parse().ok())
|
||||||
|
@ -12,7 +12,7 @@ fn main() {
|
|||||||
Dialog::new()
|
Dialog::new()
|
||||||
.title("Describe your issue")
|
.title("Describe your issue")
|
||||||
.padding((1, 1, 1, 0))
|
.padding((1, 1, 1, 0))
|
||||||
.content(TextArea::new().with_id("text"))
|
.content(TextArea::new().with_name("text"))
|
||||||
.button("Ok", Cursive::quit),
|
.button("Ok", Cursive::quit),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -29,12 +29,12 @@ fn main() {
|
|||||||
.content(
|
.content(
|
||||||
EditView::new()
|
EditView::new()
|
||||||
.on_submit(find)
|
.on_submit(find)
|
||||||
.with_id("edit")
|
.with_name("edit")
|
||||||
.min_width(10),
|
.min_width(10),
|
||||||
)
|
)
|
||||||
.button("Ok", |s| {
|
.button("Ok", |s| {
|
||||||
let text = s
|
let text = s
|
||||||
.call_on_id("edit", |view: &mut EditView| {
|
.call_on_name("edit", |view: &mut EditView| {
|
||||||
view.get_content()
|
view.get_content()
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -55,7 +55,7 @@ fn find(siv: &mut Cursive, text: &str) {
|
|||||||
// First, remove the find popup
|
// First, remove the find popup
|
||||||
siv.pop_layer();
|
siv.pop_layer();
|
||||||
|
|
||||||
let res = siv.call_on_id("text", |v: &mut TextArea| {
|
let res = siv.call_on_name("text", |v: &mut TextArea| {
|
||||||
// Find the given text from the text area content
|
// Find the given text from the text area content
|
||||||
// Possible improvement: search after the current cursor.
|
// Possible improvement: search after the current cursor.
|
||||||
if let Some(i) = v.get_content().find(text) {
|
if let Some(i) = v.get_content().find(text) {
|
||||||
|
@ -306,7 +306,8 @@ impl Cursive {
|
|||||||
/// siv.add_global_callback('~', Cursive::toggle_debug_console);
|
/// siv.add_global_callback('~', Cursive::toggle_debug_console);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn toggle_debug_console(&mut self) {
|
pub fn toggle_debug_console(&mut self) {
|
||||||
if let Some(pos) = self.screen_mut().find_layer_from_id(DEBUG_VIEW_ID)
|
if let Some(pos) =
|
||||||
|
self.screen_mut().find_layer_from_name(DEBUG_VIEW_ID)
|
||||||
{
|
{
|
||||||
self.screen_mut().remove_layer(pos);
|
self.screen_mut().remove_layer(pos);
|
||||||
} else {
|
} else {
|
||||||
@ -524,7 +525,7 @@ impl Cursive {
|
|||||||
/// # use cursive::traits::*;
|
/// # use cursive::traits::*;
|
||||||
/// let mut siv = Cursive::dummy();
|
/// let mut siv = Cursive::dummy();
|
||||||
///
|
///
|
||||||
/// siv.add_layer(views::TextView::new("Text #1").with_id("text"));
|
/// siv.add_layer(views::TextView::new("Text #1").with_name("text"));
|
||||||
///
|
///
|
||||||
/// siv.add_global_callback('p', |s| {
|
/// siv.add_global_callback('p', |s| {
|
||||||
/// s.call_on(
|
/// s.call_on(
|
||||||
@ -559,20 +560,34 @@ impl Cursive {
|
|||||||
/// let mut siv = Cursive::dummy();
|
/// let mut siv = Cursive::dummy();
|
||||||
///
|
///
|
||||||
/// siv.add_layer(views::TextView::new("Text #1")
|
/// siv.add_layer(views::TextView::new("Text #1")
|
||||||
/// .with_id("text"));
|
/// .with_name("text"));
|
||||||
///
|
///
|
||||||
/// siv.add_global_callback('p', |s| {
|
/// siv.add_global_callback('p', |s| {
|
||||||
/// s.call_on_id("text", |view: &mut views::TextView| {
|
/// s.call_on_name("text", |view: &mut views::TextView| {
|
||||||
/// view.set_content("Text #2");
|
/// view.set_content("Text #2");
|
||||||
/// });
|
/// });
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
|
pub fn call_on_name<V, F, R>(
|
||||||
|
&mut self,
|
||||||
|
name: &str,
|
||||||
|
callback: F,
|
||||||
|
) -> Option<R>
|
||||||
|
where
|
||||||
|
V: View + Any,
|
||||||
|
F: FnOnce(&mut V) -> R,
|
||||||
|
{
|
||||||
|
self.call_on(&view::Selector::Name(name), callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Same as [`call_on_name`](Cursive::call_on_name).
|
||||||
|
#[deprecated(note = "`call_on_id` is being renamed to `call_on_name`")]
|
||||||
pub fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R>
|
pub fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R>
|
||||||
where
|
where
|
||||||
V: View + Any,
|
V: View + Any,
|
||||||
F: FnOnce(&mut V) -> R,
|
F: FnOnce(&mut V) -> R,
|
||||||
{
|
{
|
||||||
self.call_on(&view::Selector::Name(id), callback)
|
self.call_on_name(id, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenient method to find a view wrapped in [`NamedView`].
|
/// Convenient method to find a view wrapped in [`NamedView`].
|
||||||
@ -589,10 +604,10 @@ impl Cursive {
|
|||||||
/// # let mut siv = Cursive::dummy();
|
/// # let mut siv = Cursive::dummy();
|
||||||
/// use cursive::traits::Identifiable;
|
/// use cursive::traits::Identifiable;
|
||||||
///
|
///
|
||||||
/// siv.add_layer(TextView::new("foo").with_id("id"));
|
/// siv.add_layer(TextView::new("foo").with_name("id"));
|
||||||
///
|
///
|
||||||
/// // Could be called in a callback
|
/// // Could be called in a callback
|
||||||
/// let mut view: ViewRef<TextView> = siv.find_id("id").unwrap();
|
/// let mut view: ViewRef<TextView> = siv.find_name("id").unwrap();
|
||||||
/// view.set_content("bar");
|
/// view.set_content("bar");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -606,30 +621,45 @@ impl Cursive {
|
|||||||
/// use cursive::traits::Identifiable;
|
/// use cursive::traits::Identifiable;
|
||||||
///
|
///
|
||||||
/// let select = SelectView::new().item("zero", 0u32).item("one", 1u32);
|
/// let select = SelectView::new().item("zero", 0u32).item("one", 1u32);
|
||||||
/// siv.add_layer(select.with_id("select"));
|
/// siv.add_layer(select.with_name("select"));
|
||||||
///
|
///
|
||||||
/// // Specifying a wrong type will not return anything.
|
/// // Specifying a wrong type will not return anything.
|
||||||
/// assert!(siv.find_id::<SelectView<String>>("select").is_none());
|
/// assert!(siv.find_name::<SelectView<String>>("select").is_none());
|
||||||
///
|
///
|
||||||
/// // Omitting the type will use the default type, in this case `String`.
|
/// // Omitting the type will use the default type, in this case `String`.
|
||||||
/// assert!(siv.find_id::<SelectView>("select").is_none());
|
/// assert!(siv.find_name::<SelectView>("select").is_none());
|
||||||
///
|
///
|
||||||
/// // But with the correct type, it works fine.
|
/// // But with the correct type, it works fine.
|
||||||
/// assert!(siv.find_id::<SelectView<u32>>("select").is_some());
|
/// assert!(siv.find_name::<SelectView<u32>>("select").is_some());
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`NamedView`]: views/struct.NamedView.html
|
/// [`NamedView`]: views::NamedView
|
||||||
/// [`ViewRef`]: views/type.ViewRef.html
|
/// [`ViewRef`]: views::ViewRef
|
||||||
|
pub fn find_name<V>(&mut self, id: &str) -> Option<views::ViewRef<V>>
|
||||||
|
where
|
||||||
|
V: View + Any,
|
||||||
|
{
|
||||||
|
self.call_on_name(id, views::NamedView::<V>::get_mut)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Same as [`find_name`](Cursive::find_name).
|
||||||
|
#[deprecated(note = "`find_id` is being renamed to `find_name`")]
|
||||||
pub fn find_id<V>(&mut self, id: &str) -> Option<views::ViewRef<V>>
|
pub fn find_id<V>(&mut self, id: &str) -> Option<views::ViewRef<V>>
|
||||||
where
|
where
|
||||||
V: View + Any,
|
V: View + Any,
|
||||||
{
|
{
|
||||||
self.call_on_id(id, views::NamedView::<V>::get_mut)
|
self.find_name(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Moves the focus to the view identified by `id`.
|
/// Moves the focus to the view identified by `name`.
|
||||||
///
|
///
|
||||||
/// Convenient method to call `focus` with a `view::Selector::Id`.
|
/// Convenient method to call `focus` with a [`view::Selector::Name`].
|
||||||
|
pub fn focus_name(&mut self, name: &str) -> Result<(), ()> {
|
||||||
|
self.focus(&view::Selector::Name(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Same as [`focus_name`](Cursive::focus_name).
|
||||||
|
#[deprecated(note = "`focus_id` is being renamed to `focus_name`")]
|
||||||
pub fn focus_id(&mut self, id: &str) -> Result<(), ()> {
|
pub fn focus_id(&mut self, id: &str) -> Result<(), ()> {
|
||||||
self.focus(&view::Selector::Name(id))
|
self.focus(&view::Selector::Name(id))
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
//!
|
//!
|
||||||
//! This module defines two main concepts: [`Orientation`] and [`Direction`].
|
//! This module defines two main concepts: [`Orientation`] and [`Direction`].
|
||||||
//!
|
//!
|
||||||
//! [`Orientation`]: direction::Orientation
|
|
||||||
//! [`Direction`]: direction::Direction
|
|
||||||
//!
|
|
||||||
//! ### Orientation
|
//! ### Orientation
|
||||||
//!
|
//!
|
||||||
//! `Orientation` is a simple enum that can take two values:
|
//! `Orientation` is a simple enum that can take two values:
|
||||||
|
13
src/event.rs
13
src/event.rs
@ -1,17 +1,16 @@
|
|||||||
//! User-input events and their effects.
|
//! User-input events and their effects.
|
||||||
//!
|
//!
|
||||||
//! * Every user input the application receives is converted to an
|
//! * Every user input the application receives is converted to an [`Event`].
|
||||||
//! [`Event`](./enum.Event.html).
|
|
||||||
//! * Each event is then given to the root, and descends the view tree down to
|
//! * Each event is then given to the root, and descends the view tree down to
|
||||||
//! the view currently in focus, through the
|
//! the view currently in focus, through the [`on_event`] method.
|
||||||
//! [`on_event`](../view/trait.View.html#method.on_event) method.
|
|
||||||
//! * If the view consumes the event, it may return a callback to be
|
//! * If the view consumes the event, it may return a callback to be
|
||||||
//! executed.
|
//! executed.
|
||||||
//! * Otherwise, it ignores the event, and the view parent can in turn
|
//! * Otherwise, it ignores the event, and the view parent can in turn
|
||||||
//! choose to consume it or not.
|
//! choose to consume it or not.
|
||||||
//! * If no view consumes the event, the
|
//! * If no view consumes the event, the [global callback] table is checked.
|
||||||
//! [global callback](../struct.Cursive.html#method.add_global_callback)
|
//!
|
||||||
//! table is checked.
|
//! [`on_event`]: crate::View::on_event
|
||||||
|
//! [global callback]: crate::Cursive::add_global_callback
|
||||||
|
|
||||||
use crate::vec::Vec2;
|
use crate::vec::Vec2;
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
|
12
src/lib.rs
12
src/lib.rs
@ -8,19 +8,18 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Getting started
|
//! ## Getting started
|
||||||
//!
|
//!
|
||||||
//! * Every application should start with a [`Cursive`](struct.Cursive.html)
|
//! * Every application should start with a [`Cursive`] object. It is the main
|
||||||
//! object. It is the main entry-point to the library.
|
//! entry-point to the library.
|
||||||
//! * A declarative phase then describes the structure of the UI by adding
|
//! * A declarative phase then describes the structure of the UI by adding
|
||||||
//! views and configuring their behaviours.
|
//! views and configuring their behaviours.
|
||||||
//! * Finally, the event loop is started by calling
|
//! * Finally, the event loop is started by calling [`Cursive::run`].
|
||||||
//! [`Cursive::run(&mut self)`](struct.Cursive.html#method.run).
|
|
||||||
//!
|
//!
|
||||||
//! ## Views
|
//! ## Views
|
||||||
//!
|
//!
|
||||||
//! Views are the main components of a cursive interface.
|
//! Views are the main components of a cursive interface.
|
||||||
//! The [`views`](./views/index.html) module contains many views to use in your
|
//! The [`views`] module contains many views to use in your
|
||||||
//! application; if you don't find what you need, you may also implement the
|
//! application; if you don't find what you need, you may also implement the
|
||||||
//! [`View`](view/trait.View.html) trait and build your own.
|
//! [`View`] trait and build your own.
|
||||||
//!
|
//!
|
||||||
//! ## Callbacks
|
//! ## Callbacks
|
||||||
//!
|
//!
|
||||||
@ -104,5 +103,6 @@ pub use self::cursive::{CbSink, Cursive, ScreenId};
|
|||||||
pub use self::printer::Printer;
|
pub use self::printer::Printer;
|
||||||
pub use self::rect::Rect;
|
pub use self::rect::Rect;
|
||||||
pub use self::vec::Vec2;
|
pub use self::vec::Vec2;
|
||||||
|
pub use self::view::View;
|
||||||
pub use self::with::With;
|
pub use self::with::With;
|
||||||
pub use self::xy::XY;
|
pub use self::xy::XY;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! Menus are a way to arrange many actions in groups of more manageable size.
|
//! Menus are a way to arrange many actions in groups of more manageable size.
|
||||||
//!
|
//!
|
||||||
//! A menu can be seen as a `MenuTree`. It has a list of children:
|
//! A menu can be seen as a [`MenuTree`]. It has a list of children:
|
||||||
//!
|
//!
|
||||||
//! * Leaf nodes are made of a label and a callback
|
//! * Leaf nodes are made of a label and a callback
|
||||||
//! * Sub-trees are made of a label, and another `MenuTree`.
|
//! * Sub-trees are made of a label, and another `MenuTree`.
|
||||||
@ -10,7 +10,7 @@
|
|||||||
//!
|
//!
|
||||||
//! The [menubar] is the main way to show menus.
|
//! The [menubar] is the main way to show menus.
|
||||||
//!
|
//!
|
||||||
//! [menubar]: ../struct.Cursive.html#method.menubar
|
//! [menubar]: crate::Cursive::menubar
|
||||||
|
|
||||||
use crate::event::Callback;
|
use crate::event::Callback;
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
//! Characters can be printed in the terminal with a specific color.
|
//! Characters can be printed in the terminal with a specific color.
|
||||||
//! The [`Color`] enum represents the ways this can be set.
|
//! The [`Color`] enum represents the ways this can be set.
|
||||||
//!
|
//!
|
||||||
//! [`Color`]: enum.Color.html
|
|
||||||
//!
|
|
||||||
//! # Palette
|
//! # Palette
|
||||||
//!
|
//!
|
||||||
//! To achieve a customizable, yet unified look, Cursive uses a configurable
|
//! To achieve a customizable, yet unified look, Cursive uses a configurable
|
||||||
@ -14,8 +12,6 @@
|
|||||||
//!
|
//!
|
||||||
//! The [`PaletteColor`] enum defines possible entries in this palette.
|
//! The [`PaletteColor`] enum defines possible entries in this palette.
|
||||||
//!
|
//!
|
||||||
//! [`PaletteColor`]: enum.PaletteColor.html
|
|
||||||
//!
|
|
||||||
//! These entries are:
|
//! These entries are:
|
||||||
//!
|
//!
|
||||||
//! * **`Background`**: used to color the application background
|
//! * **`Background`**: used to color the application background
|
||||||
@ -42,9 +38,6 @@
|
|||||||
//!
|
//!
|
||||||
//! A [`Palette`] then maps each of these to an actual [`Color`].
|
//! A [`Palette`] then maps each of these to an actual [`Color`].
|
||||||
//!
|
//!
|
||||||
//! [`Palette`]: type.Palette.html
|
|
||||||
//! [`Color`]: enum.Color.html
|
|
||||||
//!
|
|
||||||
//! # Color Types
|
//! # Color Types
|
||||||
//!
|
//!
|
||||||
//! When drawing views, color can be picked in two way:
|
//! When drawing views, color can be picked in two way:
|
||||||
@ -55,8 +48,6 @@
|
|||||||
//!
|
//!
|
||||||
//! The [`ColorType`] enum abstract over these two choices.
|
//! The [`ColorType`] enum abstract over these two choices.
|
||||||
//!
|
//!
|
||||||
//! [`ColorType`]: enum.ColorType.html
|
|
||||||
//!
|
|
||||||
//! # Color Styles
|
//! # Color Styles
|
||||||
//!
|
//!
|
||||||
//! To actually print anything, two colors must be picked: one for the
|
//! To actually print anything, two colors must be picked: one for the
|
||||||
@ -102,8 +93,6 @@
|
|||||||
//! Using one of these pairs when styling your application helps give it a
|
//! Using one of these pairs when styling your application helps give it a
|
||||||
//! coherent look.
|
//! coherent look.
|
||||||
//!
|
//!
|
||||||
//! [`ColorStyle`]: struct.ColorStyle.html
|
|
||||||
//!
|
|
||||||
//! # Effects
|
//! # Effects
|
||||||
//!
|
//!
|
||||||
//! On top of a color style, some effects can be applied on cells: `Reverse`,
|
//! On top of a color style, some effects can be applied on cells: `Reverse`,
|
||||||
@ -115,8 +104,6 @@
|
|||||||
//! Finally, a style combine a [`ColorType`] and a set of [`Effect`]s, to
|
//! Finally, a style combine a [`ColorType`] and a set of [`Effect`]s, to
|
||||||
//! represent any way text should be printed on screen.
|
//! represent any way text should be printed on screen.
|
||||||
//!
|
//!
|
||||||
//! [`Effect`]: enum.Effect.html
|
|
||||||
//!
|
|
||||||
//! # Themes
|
//! # Themes
|
||||||
//!
|
//!
|
||||||
//! A theme defines the color palette an application will use, as well as
|
//! A theme defines the color palette an application will use, as well as
|
||||||
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
/// Atomic counter used by [`ProgressBar`].
|
/// Atomic counter used by [`ProgressBar`].
|
||||||
///
|
///
|
||||||
/// [`ProgressBar`]: ../views/struct.ProgressBar.html
|
/// [`ProgressBar`]: crate::views::ProgressBar
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Counter(pub Arc<AtomicUsize>);
|
pub struct Counter(pub Arc<AtomicUsize>);
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@ use crate::utils::span::{IndexedSpan, Span, SpannedString};
|
|||||||
///
|
///
|
||||||
/// **Note**: due to limitations in rustdoc, you will need to read the
|
/// **Note**: due to limitations in rustdoc, you will need to read the
|
||||||
/// documentation from the [`SpannedString`] page.
|
/// documentation from the [`SpannedString`] page.
|
||||||
///
|
|
||||||
/// [`SpannedString`]: ../span/struct.SpannedString.html
|
|
||||||
pub type StyledString = SpannedString<Style>;
|
pub type StyledString = SpannedString<Style>;
|
||||||
|
|
||||||
/// Indexes a span into a source string.
|
/// Indexes a span into a source string.
|
||||||
|
@ -14,7 +14,7 @@ use crate::XY;
|
|||||||
/// currently shown on the [`XY`] page.
|
/// currently shown on the [`XY`] page.
|
||||||
///
|
///
|
||||||
/// [#32077]: https://github.com/rust-lang/rust/issues/32077
|
/// [#32077]: https://github.com/rust-lang/rust/issues/32077
|
||||||
/// [`XY`]: ../struct.XY.html
|
/// [`XY`]: crate::XY
|
||||||
pub type Vec2 = XY<usize>;
|
pub type Vec2 = XY<usize>;
|
||||||
|
|
||||||
impl<T: PartialOrd> PartialOrd for XY<T> {
|
impl<T: PartialOrd> PartialOrd for XY<T> {
|
||||||
|
@ -7,8 +7,6 @@ use std::any::Any;
|
|||||||
/// This trait is mostly a wrapper around [`View::call_on_any`].
|
/// This trait is mostly a wrapper around [`View::call_on_any`].
|
||||||
///
|
///
|
||||||
/// It provides a nicer interface to find a view when you know its type.
|
/// It provides a nicer interface to find a view when you know its type.
|
||||||
///
|
|
||||||
/// [`View::call_on_any`]: ./trait.View.html#method.call_on_any
|
|
||||||
pub trait Finder {
|
pub trait Finder {
|
||||||
/// Runs a callback on the view identified by `sel`.
|
/// Runs a callback on the view identified by `sel`.
|
||||||
///
|
///
|
||||||
@ -25,23 +23,40 @@ pub trait Finder {
|
|||||||
V: View + Any,
|
V: View + Any,
|
||||||
F: FnOnce(&mut V) -> R;
|
F: FnOnce(&mut V) -> R;
|
||||||
|
|
||||||
/// Convenient method to use `call_on` with a `view::Selector::Id`.
|
/// Convenient method to use `call_on` with a `view::Selector::Name`.
|
||||||
|
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
|
||||||
|
where
|
||||||
|
V: View + Any,
|
||||||
|
F: FnOnce(&mut V) -> R,
|
||||||
|
{
|
||||||
|
self.call_on(&Selector::Name(name), callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Same as [`call_on_name`](Finder::call_on_name).
|
||||||
|
#[deprecated(note = "`call_on_id` is being renamed to `call_on_name`")]
|
||||||
fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R>
|
fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R>
|
||||||
where
|
where
|
||||||
V: View + Any,
|
V: View + Any,
|
||||||
F: FnOnce(&mut V) -> R,
|
F: FnOnce(&mut V) -> R,
|
||||||
{
|
{
|
||||||
self.call_on(&Selector::Name(id), callback)
|
self.call_on_name(id, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenient method to find a view wrapped in an [`NamedView`].
|
/// Convenient method to find a view wrapped in an [`NamedView`].
|
||||||
///
|
fn find_name<V>(&mut self, name: &str) -> Option<ViewRef<V>>
|
||||||
/// [`NamedView`]: views/struct.NamedView.html
|
where
|
||||||
|
V: View + Any,
|
||||||
|
{
|
||||||
|
self.call_on_name(name, NamedView::<V>::get_mut)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Same as [`find_name`](Finder::find_name()).
|
||||||
|
#[deprecated(note = "`find_id` is being renamed to `find_name`")]
|
||||||
fn find_id<V>(&mut self, id: &str) -> Option<ViewRef<V>>
|
fn find_id<V>(&mut self, id: &str) -> Option<ViewRef<V>>
|
||||||
where
|
where
|
||||||
V: View + Any,
|
V: View + Any,
|
||||||
{
|
{
|
||||||
self.call_on_id(id, NamedView::<V>::get_mut)
|
self.find_name(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +96,9 @@ impl<T: View> Finder for T {
|
|||||||
/// Selects a single view (if any) in the tree.
|
/// Selects a single view (if any) in the tree.
|
||||||
pub enum Selector<'a> {
|
pub enum Selector<'a> {
|
||||||
/// Selects a view from its ID.
|
/// Selects a view from its ID.
|
||||||
#[deprecated(note = "Id is being renamed to Name")]
|
#[deprecated(
|
||||||
|
note = "`Selector::Id` is being renamed to `Selector::Name`"
|
||||||
|
)]
|
||||||
Id(&'a str),
|
Id(&'a str),
|
||||||
|
|
||||||
/// Selects a view from its name.
|
/// Selects a view from its name.
|
||||||
|
@ -119,8 +119,8 @@ pub use self::view_path::ViewPath;
|
|||||||
pub use self::view_trait::View;
|
pub use self::view_trait::View;
|
||||||
pub use self::view_wrapper::ViewWrapper;
|
pub use self::view_wrapper::ViewWrapper;
|
||||||
|
|
||||||
#[deprecated(note = "Boxable is being renamed to Resizable")]
|
#[deprecated(note = "`Boxable` is being renamed to `Resizable`")]
|
||||||
pub use self::resizable::Resizable as Boxable;
|
pub use self::resizable::Resizable as Boxable;
|
||||||
|
|
||||||
#[deprecated(note = "Identifiable is being renamed to Nameable")]
|
#[deprecated(note = "`Identifiable` is being renamed to `Nameable`")]
|
||||||
pub use self::nameable::Nameable as Identifiable;
|
pub use self::nameable::Nameable as Identifiable;
|
||||||
|
@ -2,8 +2,6 @@ use crate::view::View;
|
|||||||
use crate::views::NamedView;
|
use crate::views::NamedView;
|
||||||
|
|
||||||
/// Makes a view wrappable in an [`NamedView`].
|
/// Makes a view wrappable in an [`NamedView`].
|
||||||
///
|
|
||||||
/// [`NamedView`]: ../views/struct.NamedView.html
|
|
||||||
pub trait Nameable: View + Sized {
|
pub trait Nameable: View + Sized {
|
||||||
/// Wraps this view into an `NamedView` with the given id.
|
/// Wraps this view into an `NamedView` with the given id.
|
||||||
///
|
///
|
||||||
@ -22,12 +20,12 @@ pub trait Nameable: View + Sized {
|
|||||||
/// let mut siv = Cursive::dummy();
|
/// let mut siv = Cursive::dummy();
|
||||||
/// siv.add_layer(
|
/// siv.add_layer(
|
||||||
/// TextView::new("foo")
|
/// TextView::new("foo")
|
||||||
/// .with_id("text")
|
/// .with_name("text")
|
||||||
/// .fixed_width(10)
|
/// .fixed_width(10)
|
||||||
/// );
|
/// );
|
||||||
///
|
///
|
||||||
/// // You could call this from an event callback
|
/// // You could call this from an event callback
|
||||||
/// siv.call_on_id("text", |view: &mut TextView| {
|
/// siv.call_on_name("text", |view: &mut TextView| {
|
||||||
/// view.set_content("New content!");
|
/// view.set_content("New content!");
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
@ -38,15 +36,15 @@ pub trait Nameable: View + Sized {
|
|||||||
/// before other wrappers like [`fixed_width`]. Otherwise, you would be
|
/// before other wrappers like [`fixed_width`]. Otherwise, you would be
|
||||||
/// retrieving a [`ResizedView`]!
|
/// retrieving a [`ResizedView`]!
|
||||||
///
|
///
|
||||||
/// [`fixed_width`]: trait.Resizable.html#method.fixed_width
|
/// [`fixed_width`]: crate::view::Resizable::fixed_width
|
||||||
/// [`ResizedView`]: ../views/struct.ResizedView.html
|
/// [`ResizedView`]: crate::views::ResizedView
|
||||||
///
|
///
|
||||||
fn with_name<S: Into<String>>(self, name: S) -> NamedView<Self> {
|
fn with_name<S: Into<String>>(self, name: S) -> NamedView<Self> {
|
||||||
NamedView::new(name, self)
|
NamedView::new(name, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as [`with_name`](Self::with_name())
|
/// Same as [`with_name`](Nameable::with_name)
|
||||||
#[deprecated(note = "with_id is being renamed to with_name")]
|
#[deprecated(note = "`with_id` is being renamed to `with_name`")]
|
||||||
fn with_id<S: Into<String>>(self, id: S) -> NamedView<Self> {
|
fn with_id<S: Into<String>>(self, id: S) -> NamedView<Self> {
|
||||||
self.with_name(id)
|
self.with_name(id)
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,9 @@ use crate::view::{SizeConstraint, View};
|
|||||||
use crate::views::ResizedView;
|
use crate::views::ResizedView;
|
||||||
|
|
||||||
/// Makes a view wrappable in a [`ResizedView`].
|
/// Makes a view wrappable in a [`ResizedView`].
|
||||||
///
|
|
||||||
/// [`ResizedView`]: ../views/struct.ResizedView.html
|
|
||||||
pub trait Resizable: View + Sized {
|
pub trait Resizable: View + Sized {
|
||||||
/// Same as [`resized`](Self::resized())
|
/// Same as [`resized`](Resizable::resized)
|
||||||
#[deprecated(note = "Use resized() instead.")]
|
#[deprecated(note = "Use `Resizable::resized()` instead.")]
|
||||||
fn boxed(
|
fn boxed(
|
||||||
self,
|
self,
|
||||||
width: SizeConstraint,
|
width: SizeConstraint,
|
||||||
|
@ -4,7 +4,7 @@ use std::cmp::min;
|
|||||||
///
|
///
|
||||||
/// This describes a possible behaviour for a [`ResizedView`].
|
/// This describes a possible behaviour for a [`ResizedView`].
|
||||||
///
|
///
|
||||||
/// [`ResizedView`]: ../views/struct.ResizedView.html
|
/// [`ResizedView`]: crate::views::ResizedView
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum SizeConstraint {
|
pub enum SizeConstraint {
|
||||||
/// No constraint imposed, the child view's response is used.
|
/// No constraint imposed, the child view's response is used.
|
||||||
|
@ -76,7 +76,7 @@ pub trait View: Any + AnyView {
|
|||||||
/// See [`Finder::call_on`] for a nicer interface, implemented for all
|
/// See [`Finder::call_on`] for a nicer interface, implemented for all
|
||||||
/// views.
|
/// views.
|
||||||
///
|
///
|
||||||
/// [`Finder::call_on`]: trait.Finder.html#method.call_on
|
/// [`Finder::call_on`]: crate::view::Finder::call_on
|
||||||
///
|
///
|
||||||
/// If the selector doesn't find a match, the closure will not be run.
|
/// If the selector doesn't find a match, the closure will not be run.
|
||||||
///
|
///
|
||||||
|
@ -17,8 +17,6 @@ use crate::Printer;
|
|||||||
/// You can also override any of the `wrap_*` methods for more specific
|
/// You can also override any of the `wrap_*` methods for more specific
|
||||||
/// behaviors (the default implementations simply forwards the calls to the
|
/// behaviors (the default implementations simply forwards the calls to the
|
||||||
/// child view).
|
/// child view).
|
||||||
///
|
|
||||||
/// [`wrap_impl!`]: ../macro.wrap_impl.html
|
|
||||||
pub trait ViewWrapper: 'static {
|
pub trait ViewWrapper: 'static {
|
||||||
/// Type that this view wraps.
|
/// Type that this view wraps.
|
||||||
type V: View + ?Sized;
|
type V: View + ?Sized;
|
||||||
@ -151,7 +149,7 @@ impl<T: ViewWrapper> View for T {
|
|||||||
/// It defines the `with_view` and `with_view_mut` implementations,
|
/// It defines the `with_view` and `with_view_mut` implementations,
|
||||||
/// as well as the `type V` declaration.
|
/// as well as the `type V` declaration.
|
||||||
///
|
///
|
||||||
/// [`ViewWrapper`]: view/trait.ViewWrapper.html
|
/// [`ViewWrapper`]: crate::view::ViewWrapper
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
@ -194,8 +192,8 @@ macro_rules! wrap_impl {
|
|||||||
///
|
///
|
||||||
/// It defines the `get_inner` and `get_inner_mut` implementations.
|
/// It defines the `get_inner` and `get_inner_mut` implementations.
|
||||||
///
|
///
|
||||||
/// [`ViewWrapper`]: view/trait.ViewWrapper.html
|
/// [`ViewWrapper`]: crate::view::ViewWrapper
|
||||||
/// [`View`]: view/trait.View.html
|
/// [`View`]: crate::View
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -16,7 +16,7 @@ use std::rc::Rc;
|
|||||||
/// use cursive::views::Checkbox;
|
/// use cursive::views::Checkbox;
|
||||||
/// use cursive::traits::Identifiable;
|
/// use cursive::traits::Identifiable;
|
||||||
///
|
///
|
||||||
/// let checkbox = Checkbox::new().checked().with_id("check");
|
/// let checkbox = Checkbox::new().checked().with_name("check");
|
||||||
/// ```
|
/// ```
|
||||||
pub struct Checkbox {
|
pub struct Checkbox {
|
||||||
checked: bool,
|
checked: bool,
|
||||||
|
@ -14,8 +14,6 @@ use std::cmp::max;
|
|||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
/// Identifies currently focused element in [`Dialog`].
|
/// Identifies currently focused element in [`Dialog`].
|
||||||
///
|
|
||||||
/// [`Dialog`]: struct.Dialog.html
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum DialogFocus {
|
pub enum DialogFocus {
|
||||||
/// Content element focused
|
/// Content element focused
|
||||||
|
@ -46,11 +46,11 @@ pub type OnSubmit = dyn Fn(&mut Cursive, &str);
|
|||||||
/// .content(
|
/// .content(
|
||||||
/// EditView::new()
|
/// EditView::new()
|
||||||
/// .on_submit(show_popup)
|
/// .on_submit(show_popup)
|
||||||
/// .with_id("name")
|
/// .with_name("name")
|
||||||
/// .fixed_width(20),
|
/// .fixed_width(20),
|
||||||
/// )
|
/// )
|
||||||
/// .button("Ok", |s| {
|
/// .button("Ok", |s| {
|
||||||
/// let name = s.call_on_id(
|
/// let name = s.call_on_name(
|
||||||
/// "name",
|
/// "name",
|
||||||
/// |view: &mut EditView| view.get_content(),
|
/// |view: &mut EditView| view.get_content(),
|
||||||
/// ).unwrap();
|
/// ).unwrap();
|
||||||
|
@ -16,9 +16,9 @@ use crate::Printer;
|
|||||||
/// let mut siv = Cursive::dummy();
|
/// let mut siv = Cursive::dummy();
|
||||||
///
|
///
|
||||||
/// siv.add_layer(LinearLayout::vertical()
|
/// siv.add_layer(LinearLayout::vertical()
|
||||||
/// .child(EnableableView::new(Checkbox::new()).with_id("my_view"))
|
/// .child(EnableableView::new(Checkbox::new()).with_name("my_view"))
|
||||||
/// .child(Button::new("Toggle", |s| {
|
/// .child(Button::new("Toggle", |s| {
|
||||||
/// s.call_on_id("my_view", |v: &mut EnableableView<Checkbox>| {
|
/// s.call_on_name("my_view", |v: &mut EnableableView<Checkbox>| {
|
||||||
/// // This will disable (or re-enable) the checkbox, preventing the user from
|
/// // This will disable (or re-enable) the checkbox, preventing the user from
|
||||||
/// // interacting with it.
|
/// // interacting with it.
|
||||||
/// v.set_enabled(!v.is_enabled());
|
/// v.set_enabled(!v.is_enabled());
|
||||||
|
@ -6,7 +6,7 @@ use crate::Printer;
|
|||||||
///
|
///
|
||||||
/// This is mostly used as layer in the [`StackView`].
|
/// This is mostly used as layer in the [`StackView`].
|
||||||
///
|
///
|
||||||
/// [`StackView`]: struct.StackView.html
|
/// [`StackView`]: crate::views::StackView
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Layer<T: View> {
|
pub struct Layer<T: View> {
|
||||||
view: T,
|
view: T,
|
||||||
|
@ -11,8 +11,6 @@ use std::rc::Rc;
|
|||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
/// Represents a child from a [`ListView`].
|
/// Represents a child from a [`ListView`].
|
||||||
///
|
|
||||||
/// [`ListView`]: struct.ListView.html
|
|
||||||
pub enum ListChild {
|
pub enum ListChild {
|
||||||
/// A single row, with a label and a view.
|
/// A single row, with a label and a view.
|
||||||
Row(String, Box<dyn View>),
|
Row(String, Box<dyn View>),
|
||||||
|
@ -31,7 +31,7 @@ enum State {
|
|||||||
/// The [`Cursive`] root already includes a menubar
|
/// The [`Cursive`] root already includes a menubar
|
||||||
/// that you just need to configure.
|
/// that you just need to configure.
|
||||||
///
|
///
|
||||||
/// [`Cursive`]: ../struct.Cursive.html#method.menubar
|
/// [`Cursive`]: crate::Cursive::menubar
|
||||||
pub struct Menubar {
|
pub struct Menubar {
|
||||||
/// Menu items in this menubar.
|
/// Menu items in this menubar.
|
||||||
root: MenuTree,
|
root: MenuTree,
|
||||||
|
@ -119,17 +119,17 @@ pub use self::text_view::{TextContent, TextContentRef, TextView};
|
|||||||
pub use self::tracked_view::TrackedView;
|
pub use self::tracked_view::TrackedView;
|
||||||
|
|
||||||
/// Same as [`LastSizeView`](self::LastSizeView).
|
/// Same as [`LastSizeView`](self::LastSizeView).
|
||||||
#[deprecated(note = "SizedView is being renamed to LastSizeView")]
|
#[deprecated(note = "`SizedView` is being renamed to `LastSizeView`")]
|
||||||
pub type SizedView<T> = LastSizeView<T>;
|
pub type SizedView<T> = LastSizeView<T>;
|
||||||
|
|
||||||
/// Same as [`ResizedView`](self::ResizedView).
|
/// Same as [`ResizedView`](self::ResizedView).
|
||||||
#[deprecated(note = "BoxView is being renamed to ResizedView")]
|
#[deprecated(note = "`BoxView` is being renamed to `ResizedView`")]
|
||||||
pub type BoxView<T> = ResizedView<T>;
|
pub type BoxView<T> = ResizedView<T>;
|
||||||
|
|
||||||
/// Same as [`BoxedView`](self::BoxedView).
|
/// Same as [`BoxedView`](self::BoxedView).
|
||||||
#[deprecated(note = "ViewBox is being renamed to BoxedView")]
|
#[deprecated(note = "`ViewBox` is being renamed to `BoxedView`")]
|
||||||
pub type ViewBox = BoxedView;
|
pub type ViewBox = BoxedView;
|
||||||
|
|
||||||
/// Same as [`NamedView`](self::NamedView).
|
/// Same as [`NamedView`](self::NamedView).
|
||||||
#[deprecated(note = "IdView is being renamed to NamedView")]
|
#[deprecated(note = "`IdView` is being renamed to `NamedView`")]
|
||||||
pub type IdView<T> = NamedView<T>;
|
pub type IdView<T> = NamedView<T>;
|
||||||
|
@ -19,7 +19,7 @@ pub struct NamedView<V: View> {
|
|||||||
///
|
///
|
||||||
/// This behaves like a [`RefMut`], but without being tied to a lifetime.
|
/// This behaves like a [`RefMut`], but without being tied to a lifetime.
|
||||||
///
|
///
|
||||||
/// [`RefMut`]: https://doc.rust-lang.org/std/cell/struct.RefMut.html
|
/// [`RefMut`]: std::cell::RefMut
|
||||||
pub type ViewRef<V> = OwningHandle<RcRef<RefCell<V>>, RefMut<'static, V>>;
|
pub type ViewRef<V> = OwningHandle<RcRef<RefCell<V>>, RefMut<'static, V>>;
|
||||||
|
|
||||||
impl<V: View> NamedView<V> {
|
impl<V: View> NamedView<V> {
|
||||||
|
@ -24,10 +24,10 @@ use std::rc::Rc;
|
|||||||
/// "Simple" callbacks ([`on_event`] and [`on_pre_event`]) skip this first
|
/// "Simple" callbacks ([`on_event`] and [`on_pre_event`]) skip this first
|
||||||
/// phase and are only called with a `&mut Cursive`.
|
/// phase and are only called with a `&mut Cursive`.
|
||||||
///
|
///
|
||||||
/// [`on_event`]: struct.OnEventView.html#method.on_event
|
/// [`on_event`]: OnEventView::on_event
|
||||||
/// [`on_pre_event`]: struct.OnEventView.html#method.on_pre_event
|
/// [`on_pre_event`]: OnEventView::on_pre_event
|
||||||
/// [`on_event_inner`]: struct.OnEventView.html#method.on_event_inner
|
/// [`on_event_inner`]: OnEventView::on_event_inner
|
||||||
/// [`on_pre_event_inner`]: struct.OnEventView.html#method.on_pre_event_inner
|
/// [`on_pre_event_inner`]: OnEventView::on_pre_event_inner
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -26,8 +26,6 @@ impl<T> SharedState<T> {
|
|||||||
/// A `RadioGroup` is used to create and manage [`RadioButton`]s.
|
/// A `RadioGroup` is used to create and manage [`RadioButton`]s.
|
||||||
///
|
///
|
||||||
/// A `RadioGroup` can be cloned; it will keep pointing to the same group.
|
/// A `RadioGroup` can be cloned; it will keep pointing to the same group.
|
||||||
///
|
|
||||||
/// [`RadioButton`]: struct.RadioButton.html
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct RadioGroup<T> {
|
pub struct RadioGroup<T> {
|
||||||
// Given to every child button
|
// Given to every child button
|
||||||
@ -114,10 +112,8 @@ impl RadioGroup<String> {
|
|||||||
/// time.
|
/// time.
|
||||||
///
|
///
|
||||||
/// `RadioButton`s are not created directly, but through
|
/// `RadioButton`s are not created directly, but through
|
||||||
/// [`RadioGroup::button()`].
|
/// [`RadioGroup::button`].
|
||||||
///
|
///
|
||||||
/// [`RadioGroup`]: struct.RadioGroup.html
|
|
||||||
/// [`RadioGroup::button()`]: struct.RadioGroup.html#method.button
|
|
||||||
pub struct RadioButton<T> {
|
pub struct RadioButton<T> {
|
||||||
state: Rc<RefCell<SharedState<T>>>,
|
state: Rc<RefCell<SharedState<T>>>,
|
||||||
id: usize,
|
id: usize,
|
||||||
|
@ -178,7 +178,7 @@ impl<T: 'static> SelectView<T> {
|
|||||||
/// use cursive::traits::Identifiable;
|
/// use cursive::traits::Identifiable;
|
||||||
/// use cursive::views::{TextView, SelectView};
|
/// use cursive::views::{TextView, SelectView};
|
||||||
///
|
///
|
||||||
/// let text_view = TextView::new("").with_id("text");
|
/// let text_view = TextView::new("").with_name("text");
|
||||||
///
|
///
|
||||||
/// let select_view = SelectView::new()
|
/// let select_view = SelectView::new()
|
||||||
/// .item("One", 1)
|
/// .item("One", 1)
|
||||||
@ -191,7 +191,7 @@ impl<T: 'static> SelectView<T> {
|
|||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// // Update the textview with the currently selected item.
|
/// // Update the textview with the currently selected item.
|
||||||
/// s.call_on_id("text", |v: &mut TextView| {
|
/// s.call_on_name("text", |v: &mut TextView| {
|
||||||
/// v.set_content(content);
|
/// v.set_content(content);
|
||||||
/// }).unwrap();
|
/// }).unwrap();
|
||||||
/// });
|
/// });
|
||||||
|
@ -312,12 +312,12 @@ impl StackView {
|
|||||||
/// # use cursive::view::Identifiable;
|
/// # use cursive::view::Identifiable;
|
||||||
/// let mut stack = StackView::new();
|
/// let mut stack = StackView::new();
|
||||||
/// stack.add_layer(TextView::new("Back"));
|
/// stack.add_layer(TextView::new("Back"));
|
||||||
/// stack.add_layer(Dialog::around(TextView::new("Middle").with_id("text")));
|
/// stack.add_layer(Dialog::around(TextView::new("Middle").with_name("text")));
|
||||||
/// stack.add_layer(TextView::new("Front"));
|
/// stack.add_layer(TextView::new("Front"));
|
||||||
///
|
///
|
||||||
/// assert_eq!(stack.find_layer_from_id("text"), Some(LayerPosition::FromBack(1)));
|
/// assert_eq!(stack.find_layer_from_name("text"), Some(LayerPosition::FromBack(1)));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn find_layer_from_id(&mut self, id: &str) -> Option<LayerPosition> {
|
pub fn find_layer_from_name(&mut self, id: &str) -> Option<LayerPosition> {
|
||||||
let selector = Selector::Name(id);
|
let selector = Selector::Name(id);
|
||||||
|
|
||||||
for (i, child) in self.layers.iter_mut().enumerate() {
|
for (i, child) in self.layers.iter_mut().enumerate() {
|
||||||
@ -331,6 +331,14 @@ impl StackView {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Same as [`find_layer_from_name`](StackView::find_layer_from_name).
|
||||||
|
#[deprecated(
|
||||||
|
note = "`find_layer_from_id` is being renamed to `find_layer_from_name`"
|
||||||
|
)]
|
||||||
|
pub fn find_layer_from_id(&mut self, id: &str) -> Option<LayerPosition> {
|
||||||
|
self.find_layer_from_name(id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds a new full-screen layer on top of the stack.
|
/// Adds a new full-screen layer on top of the stack.
|
||||||
///
|
///
|
||||||
/// Chainable variant.
|
/// Chainable variant.
|
||||||
|
@ -25,7 +25,7 @@ use unicode_width::UnicodeWidthStr;
|
|||||||
///
|
///
|
||||||
/// let text_area = TextArea::new()
|
/// let text_area = TextArea::new()
|
||||||
/// .content("Write description here...")
|
/// .content("Write description here...")
|
||||||
/// .with_id("text_area")
|
/// .with_name("text_area")
|
||||||
/// .fixed_width(30)
|
/// .fixed_width(30)
|
||||||
/// .min_height(5);
|
/// .min_height(5);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -19,8 +19,6 @@ type InnerContentType = Arc<StyledString>;
|
|||||||
///
|
///
|
||||||
/// Cloning this object will still point to the same content.
|
/// Cloning this object will still point to the same content.
|
||||||
///
|
///
|
||||||
/// [`TextView`]: struct.TextView.html
|
|
||||||
///
|
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
@ -61,8 +59,6 @@ impl TextContent {
|
|||||||
///
|
///
|
||||||
/// This can be deref'ed into a [`StyledString`].
|
/// This can be deref'ed into a [`StyledString`].
|
||||||
///
|
///
|
||||||
/// [`StyledString`]: ../utils/markup/type.StyledString.html
|
|
||||||
///
|
|
||||||
/// This keeps the content locked. Do not store this!
|
/// This keeps the content locked. Do not store this!
|
||||||
pub struct TextContentRef {
|
pub struct TextContentRef {
|
||||||
_handle: OwningHandle<
|
_handle: OwningHandle<
|
||||||
|
@ -26,8 +26,8 @@ impl<T: View> TrackedView<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as [`with_name`](Self::with_name())
|
/// Same as [`with_name`](TrackedView::with_name)
|
||||||
#[deprecated(note = "with_id is being renamed to with_name")]
|
#[deprecated(note = "`with_id` is being renamed to `with_name`")]
|
||||||
pub fn with_id(self, id: &str) -> NamedView<Self> {
|
pub fn with_id(self, id: &str) -> NamedView<Self> {
|
||||||
self.with_name(id)
|
self.with_name(id)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user