Rename id to name: phase 3

This commit is contained in:
Alexandre Bury 2020-01-06 15:41:51 -08:00
parent 6824cc4299
commit cd26e40fcb
6 changed files with 13 additions and 13 deletions

View File

@ -23,7 +23,7 @@ includes greek and japanese characters to show non-ascii support.
## [`edit`](edit.rs) ## [`edit`](edit.rs)
Here we have an `EditView` to get input from the user, and use that input in 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. later.
## [`mutation`](mutation.rs) ## [`mutation`](mutation.rs)
@ -83,7 +83,7 @@ This example draws a colorful square to show off true color support.
## [`refcell_view`](refcell_view.rs) ## [`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) ## [`progress`](progress.rs)

View File

@ -26,7 +26,7 @@ fn main() {
) )
.button("Ok", |s| { .button("Ok", |s| {
// 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 name is found.
let name = s let name = s
.call_on_name("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 File

@ -13,7 +13,7 @@ fn main() {
siv.add_global_callback('q', |s| s.quit()); 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), // 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(

View File

@ -15,7 +15,7 @@ use crate::vec::Vec2;
use crate::view::{self, Finder, IntoBoxedView, Position, View}; use crate::view::{self, Finder, IntoBoxedView, Position, View};
use crate::views::{self, LayerPosition}; 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 // How long we wait between two empty input polls
const INPUT_POLL_DELAY_MS: u64 = 30; const INPUT_POLL_DELAY_MS: u64 = 30;
@ -287,7 +287,7 @@ impl Cursive {
self.add_layer( self.add_layer(
views::Dialog::around( views::Dialog::around(
views::ScrollView::new(views::NamedView::new( views::ScrollView::new(views::NamedView::new(
DEBUG_VIEW_ID, DEBUG_VIEW_NAME,
views::DebugView::new(), views::DebugView::new(),
)) ))
.scroll_x(true), .scroll_x(true),
@ -307,7 +307,7 @@ impl Cursive {
/// ``` /// ```
pub fn toggle_debug_console(&mut self) { pub fn toggle_debug_console(&mut self) {
if let Some(pos) = 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); self.screen_mut().remove_layer(pos);
} else { } else {
@ -592,7 +592,7 @@ impl Cursive {
/// Convenient method to find a view wrapped in [`NamedView`]. /// 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 /// a [`ViewRef`] to the wrapped view. The `ViewRef` implements
/// `DerefMut<Target=T>`, so you can treat it just like a `&mut T`. /// `DerefMut<Target=T>`, so you can treat it just like a `&mut T`.
/// ///

View File

@ -95,7 +95,7 @@ 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. /// Same as [`Selector::Name`].
#[deprecated( #[deprecated(
note = "`Selector::Id` is being renamed to `Selector::Name`" note = "`Selector::Id` is being renamed to `Selector::Name`"
)] )]

View File

@ -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, /// Returns `Some(pos)` if `self.get(pos)` has the given name,
/// or is a parent of a view with this ID. /// 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 /// Note that the returned position may be invalidated if some layers are
/// removed from the view. /// removed from the view.