mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 09:25:01 +00:00
Rename id
to name
: phase 3
This commit is contained in:
parent
6824cc4299
commit
cd26e40fcb
@ -23,7 +23,7 @@ includes greek and japanese characters to show non-ascii support.
|
||||
## [`edit`](edit.rs)
|
||||
|
||||
Here we have an `EditView` to get input from the user, and use that input in
|
||||
the next view. It shows how to identify a view with an ID and refer to it
|
||||
the next view. It shows how to identify a view with an name and refer to it
|
||||
later.
|
||||
|
||||
## [`mutation`](mutation.rs)
|
||||
@ -83,7 +83,7 @@ This example draws a colorful square to show off true color support.
|
||||
|
||||
## [`refcell_view`](refcell_view.rs)
|
||||
|
||||
Here we show how to access multiple views concurently through their IDs.
|
||||
Here we show how to access multiple views concurently through their name.
|
||||
|
||||
## [`progress`](progress.rs)
|
||||
|
||||
|
@ -26,7 +26,7 @@ fn main() {
|
||||
)
|
||||
.button("Ok", |s| {
|
||||
// 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 name is found.
|
||||
let name = s
|
||||
.call_on_name("name", |view: &mut EditView| {
|
||||
// We can return content from the closure!
|
||||
|
@ -13,7 +13,7 @@ fn main() {
|
||||
|
||||
siv.add_global_callback('q', |s| s.quit());
|
||||
|
||||
// Let's wrap the view to give it a recognizable ID, so we can look for it.
|
||||
// Let's wrap the view to give it a recognizable name, so we can look for it.
|
||||
// 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.
|
||||
siv.add_layer(
|
||||
|
@ -15,7 +15,7 @@ use crate::vec::Vec2;
|
||||
use crate::view::{self, Finder, IntoBoxedView, Position, View};
|
||||
use crate::views::{self, LayerPosition};
|
||||
|
||||
static DEBUG_VIEW_ID: &str = "_cursive_debug_view";
|
||||
static DEBUG_VIEW_NAME: &str = "_cursive_debug_view";
|
||||
|
||||
// How long we wait between two empty input polls
|
||||
const INPUT_POLL_DELAY_MS: u64 = 30;
|
||||
@ -287,7 +287,7 @@ impl Cursive {
|
||||
self.add_layer(
|
||||
views::Dialog::around(
|
||||
views::ScrollView::new(views::NamedView::new(
|
||||
DEBUG_VIEW_ID,
|
||||
DEBUG_VIEW_NAME,
|
||||
views::DebugView::new(),
|
||||
))
|
||||
.scroll_x(true),
|
||||
@ -307,7 +307,7 @@ impl Cursive {
|
||||
/// ```
|
||||
pub fn toggle_debug_console(&mut self) {
|
||||
if let Some(pos) =
|
||||
self.screen_mut().find_layer_from_name(DEBUG_VIEW_ID)
|
||||
self.screen_mut().find_layer_from_name(DEBUG_VIEW_NAME)
|
||||
{
|
||||
self.screen_mut().remove_layer(pos);
|
||||
} else {
|
||||
@ -592,7 +592,7 @@ impl Cursive {
|
||||
|
||||
/// Convenient method to find a view wrapped in [`NamedView`].
|
||||
///
|
||||
/// This looks for a `NamedView<V>` with the given ID, and return
|
||||
/// This looks for a `NamedView<V>` with the given name, and return
|
||||
/// a [`ViewRef`] to the wrapped view. The `ViewRef` implements
|
||||
/// `DerefMut<Target=T>`, so you can treat it just like a `&mut T`.
|
||||
///
|
||||
|
@ -95,7 +95,7 @@ impl<T: View> Finder for T {
|
||||
|
||||
/// Selects a single view (if any) in the tree.
|
||||
pub enum Selector<'a> {
|
||||
/// Selects a view from its ID.
|
||||
/// Same as [`Selector::Name`].
|
||||
#[deprecated(
|
||||
note = "`Selector::Id` is being renamed to `Selector::Name`"
|
||||
)]
|
||||
|
@ -295,12 +295,12 @@ impl StackView {
|
||||
})
|
||||
}
|
||||
|
||||
/// Looks for the layer containing a view with the given ID.
|
||||
/// Looks for the layer containing a view with the given name.
|
||||
///
|
||||
/// Returns `Some(pos)` if `self.get(pos)` has the given ID,
|
||||
/// or is a parent of a view with this ID.
|
||||
/// Returns `Some(pos)` if `self.get(pos)` has the given name,
|
||||
/// or is a parent of a view with this name.
|
||||
///
|
||||
/// Returns `None` if the given ID is not found.
|
||||
/// Returns `None` if the given name is not found.
|
||||
///
|
||||
/// Note that the returned position may be invalidated if some layers are
|
||||
/// removed from the view.
|
||||
|
Loading…
Reference in New Issue
Block a user