From 6824cc429962dbfa824754212b48eea42cc3e7d7 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 6 Jan 2020 15:39:30 -0800 Subject: [PATCH] Rename `id` to `name`: phase 2 --- CHANGELOG.md | 28 +++++++++++++--- doc/tutorial_3.md | 44 ++++++++++++------------- examples/edit.rs | 6 ++-- examples/list_view.rs | 8 ++--- examples/mutation.rs | 4 +-- examples/refcell_view.rs | 12 +++---- examples/slider.rs | 4 +-- examples/tcp_server.rs | 4 +-- examples/text_area.rs | 8 ++--- src/cursive.rs | 62 ++++++++++++++++++++++++++---------- src/direction.rs | 3 -- src/event.rs | 13 ++++---- src/lib.rs | 12 +++---- src/menu.rs | 4 +-- src/theme/mod.rs | 13 -------- src/utils/counter.rs | 2 +- src/utils/markup/mod.rs | 2 -- src/vec.rs | 2 +- src/view/finder.rs | 33 ++++++++++++++----- src/view/mod.rs | 4 +-- src/view/nameable.rs | 14 ++++---- src/view/resizable.rs | 6 ++-- src/view/size_constraint.rs | 2 +- src/view/view_trait.rs | 2 +- src/view/view_wrapper.rs | 8 ++--- src/views/checkbox.rs | 2 +- src/views/dialog.rs | 2 -- src/views/edit_view.rs | 4 +-- src/views/enableable_view.rs | 4 +-- src/views/layer.rs | 2 +- src/views/list_view.rs | 2 -- src/views/menubar.rs | 2 +- src/views/mod.rs | 8 ++--- src/views/named_view.rs | 2 +- src/views/on_event_view.rs | 8 ++--- src/views/radio.rs | 6 +--- src/views/select_view.rs | 4 +-- src/views/stack_view.rs | 14 ++++++-- src/views/text_area.rs | 2 +- src/views/text_view.rs | 4 --- src/views/tracked_view.rs | 4 +-- 41 files changed, 203 insertions(+), 167 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0605433..9809fa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,21 +7,38 @@ - `cursive::event::AnyCb` changed from `Box<...>` to `&mut ...`, so users of `View::call_on_any` no longer need to box their closures. - 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 - `SelectView::{item, with_all}` now accept `S: Into` for colored labels. - Add `ScrollView::scroll_to_important_area`. - Add `LinearLayout::set_focus_index`. -- Add `XY::{sum, product}` -- `view::scroll` is now a public module -- Add `Cursive::process_events` and `Cursive::post_events` - - This gives users finer control than `Cursive::step` +- Add `XY::{sum, product}`. +- `view::scroll` is now a public module. +- Add `Cursive::process_events` and `Cursive::post_events`. + - 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 - 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`). - `Cursive::default()` now fallbacks do dummy backend if no other is available. @@ -30,6 +47,7 @@ - Fixed `ScrollView::show_scrollbars()` - Fixed layout for `BoxView` with some size constraints. - On Windows, do not print unix-specific character during initialization. +- Fix out-of-bounds access for some mouse events in `MenuPopup` ## 0.13.0 diff --git a/doc/tutorial_3.md b/doc/tutorial_3.md index 5ffb74e..bebb875 100644 --- a/doc/tutorial_3.md +++ b/doc/tutorial_3.md @@ -19,7 +19,7 @@ fn main() { let select = SelectView::::new() .on_submit(on_submit) - .with_id("select") + .with_name("select") .fixed_size((10, 5)); let buttons = LinearLayout::vertical() .child(Button::new("Add new", add_name)) @@ -38,7 +38,7 @@ fn main() { fn add_name(s: &mut Cursive) { fn ok(s: &mut Cursive, name: &str) { - s.call_on_id("select", |view: &mut SelectView| { + s.call_on_name("select", |view: &mut SelectView| { view.add_item_str(name) }); s.pop_layer(); @@ -46,12 +46,12 @@ fn add_name(s: &mut Cursive) { s.add_layer(Dialog::around(EditView::new() .on_submit(ok) - .with_id("name") + .with_name("name") .fixed_width(10)) .title("Enter a new name") .button("Ok", |s| { let name = - s.call_on_id("name", |view: &mut EditView| { + s.call_on_name("name", |view: &mut EditView| { view.get_content() }).unwrap(); ok(s, &name); @@ -62,7 +62,7 @@ fn add_name(s: &mut Cursive) { } fn delete_name(s: &mut Cursive) { - let mut select = s.find_id::>("select").unwrap(); + let mut select = s.find_name::>("select").unwrap(); match select.selected_id() { None => s.add_layer(Dialog::info("No name to remove")), Some(focus) => { @@ -193,7 +193,7 @@ this list with names! [`LinearLayout`]: https://docs.rs/cursive/0/cursive/views/struct.LinearLayout.html [`DummyView`]: https://docs.rs/cursive/0/cursive/views/struct.DummyView.html -## IDs +## Identifying views When the user presses the `` button, we want to show a popup where he 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 how to point to the correct view. -[`IdView`] is meant exactly for this: it wraps a view and gives it an ID. -Later, you can ask the Cursive root for this ID and get access to the view. +[`IdView`] is meant exactly for this: it wraps a view and gives it a name. +Later, you can ask the Cursive root for this name and get access to the view. Just what we need! 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. Here's what it looks like in action: @@ -237,11 +237,11 @@ Here's what it looks like in action: ```rust,ignore fn add_name(s: &mut Cursive) { s.add_layer(Dialog::around(EditView::new() - .with_id("name") + .with_name("name") .fixed_width(10)) .title("Enter a new name") .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() }).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 -calling `call_on_id`. +calling `call_on_name`. 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 let select = SelectView::::new() .on_submit(on_submit) - .with_id("select") + .with_name("select") .fixed_size((10, 5)); ``` (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 fn add_name(s: &mut Cursive) { fn ok(s: &mut Cursive, name: &str) { - s.call_on_id("select", |view: &mut SelectView| { + s.call_on_name("select", |view: &mut SelectView| { view.add_item_str(name); }); s.pop_layer(); @@ -279,11 +279,11 @@ fn add_name(s: &mut Cursive) { s.add_layer(Dialog::around(EditView::new() .on_submit(ok) - .with_id("name") + .with_name("name") .fixed_width(10)) .title("Enter a new name") .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() }).unwrap(); ok(s, &name); @@ -299,7 +299,7 @@ complicated: ```rust,ignore fn delete_name(s: &mut Cursive) { - let mut select = s.find_id::>("select").unwrap(); + let mut select = s.find_name::>("select").unwrap(); match select.selected_id() { None => s.add_layer(Dialog::info("No name to remove")), Some(focus) => { @@ -312,7 +312,7 @@ fn delete_name(s: &mut Cursive) { We use [`SelectView::selected_id`] and [`SelectView::remove_item`] to remove 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. 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. @@ -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::new`]: https://docs.rs/cursive/0/cursive/prelude/struct.IdView.html#method.around [`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::call_on_id`]: https://docs.rs/cursive/0/cursive/struct.Cursive.html#method.call_on_id +[`Cursive::find_name`]: https://docs.rs/cursive/0/cursive/struct.Cursive.html#method.find_name +[`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::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: * How to wrap views to control their size * 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... diff --git a/examples/edit.rs b/examples/edit.rs index 62c95e4..fc6432b 100644 --- a/examples/edit.rs +++ b/examples/edit.rs @@ -18,9 +18,9 @@ fn main() { // Call `show_popup` when the user presses `Enter` .on_submit(show_popup) // 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. - // 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`! .fixed_width(20), ) @@ -28,7 +28,7 @@ fn main() { // This will run the given closure, *ONLY* if a view with the // correct type and the given ID is found. let name = s - .call_on_id("name", |view: &mut EditView| { + .call_on_name("name", |view: &mut EditView| { // We can return content from the closure! view.get_content() }) diff --git a/examples/list_view.rs b/examples/list_view.rs index 2fc6fb4..ac0e78a 100644 --- a/examples/list_view.rs +++ b/examples/list_view.rs @@ -24,11 +24,11 @@ fn main() { Checkbox::new().on_change(|s, checked| { // Enable/Disable the next field depending on this checkbox 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) }); if checked { - s.focus_id("email1").unwrap(); + s.focus_name("email1").unwrap(); } } }), @@ -41,14 +41,14 @@ fn main() { .child( EditView::new() .disabled() - .with_id("email1") + .with_name("email1") .fixed_width(15), ) .child(TextView::new("@")) .child( EditView::new() .disabled() - .with_id("email2") + .with_name("email2") .fixed_width(10), ), ) diff --git a/examples/mutation.rs b/examples/mutation.rs index 2947cf9..07611f0 100644 --- a/examples/mutation.rs +++ b/examples/mutation.rs @@ -17,7 +17,7 @@ fn main() { // 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( - OnEventView::new(TextView::new(content).with_id("text")) + OnEventView::new(TextView::new(content).with_name("text")) .on_event('p', |s| show_popup(s)), ); @@ -33,7 +33,7 @@ fn show_popup(siv: &mut Cursive) { .button("Change", |s| { // Look for a view tagged "text". // 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()); view.set_content(content); }); diff --git a/examples/refcell_view.rs b/examples/refcell_view.rs index a2abf16..d6843fe 100644 --- a/examples/refcell_view.rs +++ b/examples/refcell_view.rs @@ -12,9 +12,9 @@ fn main() { siv.add_layer( Dialog::around( LinearLayout::vertical() - .child(EditView::new().on_edit(on_edit).with_id("1")) - .child(EditView::new().on_edit(on_edit).with_id("2")) - .child(TextView::new("match").with_id("match")) + .child(EditView::new().on_edit(on_edit).with_name("1")) + .child(EditView::new().on_edit(on_edit).with_name("2")) + .child(TextView::new("match").with_name("match")) .fixed_width(10), ) .button("Quit", Cursive::quit), @@ -30,13 +30,13 @@ fn main() { // and directly retrieve the content from the `Cursive` root. fn on_edit(siv: &mut Cursive, _content: &str, _cursor: usize) { // Get handles for each view. - let edit_1 = siv.find_id::("1").unwrap(); - let edit_2 = siv.find_id::("2").unwrap(); + let edit_1 = siv.find_name::("1").unwrap(); + let edit_2 = siv.find_name::("2").unwrap(); // Directly compare references to edit_1 and edit_2. 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" }) }); } diff --git a/examples/slider.rs b/examples/slider.rs index 70b5978..933bb27 100644 --- a/examples/slider.rs +++ b/examples/slider.rs @@ -18,7 +18,7 @@ fn main() { .value(7) .on_change(|s, 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) }); }) @@ -31,7 +31,7 @@ fn main() { }), ) .title("[ 7 ]") - .with_id("dialog"), + .with_name("dialog"), ); siv.run(); diff --git a/examples/tcp_server.rs b/examples/tcp_server.rs index 95a1258..8b454d9 100644 --- a/examples/tcp_server.rs +++ b/examples/tcp_server.rs @@ -154,13 +154,13 @@ fn build_selector(model: Model) -> impl cursive::view::View { .child( views::EditView::new() .content(format!("{}", offset)) - .with_id("edit") + .with_name("edit") .min_width(5), ) .child(views::DummyView.fixed_width(1)) .child(views::Button::new("Update", move |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() }) .and_then(|content| content.parse().ok()) diff --git a/examples/text_area.rs b/examples/text_area.rs index 34bf739..22272dd 100644 --- a/examples/text_area.rs +++ b/examples/text_area.rs @@ -12,7 +12,7 @@ fn main() { Dialog::new() .title("Describe your issue") .padding((1, 1, 1, 0)) - .content(TextArea::new().with_id("text")) + .content(TextArea::new().with_name("text")) .button("Ok", Cursive::quit), ); @@ -29,12 +29,12 @@ fn main() { .content( EditView::new() .on_submit(find) - .with_id("edit") + .with_name("edit") .min_width(10), ) .button("Ok", |s| { let text = s - .call_on_id("edit", |view: &mut EditView| { + .call_on_name("edit", |view: &mut EditView| { view.get_content() }) .unwrap(); @@ -55,7 +55,7 @@ fn find(siv: &mut Cursive, text: &str) { // First, remove the find popup 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 // Possible improvement: search after the current cursor. if let Some(i) = v.get_content().find(text) { diff --git a/src/cursive.rs b/src/cursive.rs index 3c6bbc8..6e170a8 100644 --- a/src/cursive.rs +++ b/src/cursive.rs @@ -306,7 +306,8 @@ impl Cursive { /// siv.add_global_callback('~', Cursive::toggle_debug_console); /// ``` 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); } else { @@ -524,7 +525,7 @@ impl Cursive { /// # use cursive::traits::*; /// 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| { /// s.call_on( @@ -559,20 +560,34 @@ impl Cursive { /// let mut siv = Cursive::dummy(); /// /// siv.add_layer(views::TextView::new("Text #1") - /// .with_id("text")); + /// .with_name("text")); /// /// 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"); /// }); /// }); /// ``` + pub fn call_on_name( + &mut self, + name: &str, + callback: F, + ) -> Option + 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(&mut self, id: &str, callback: F) -> Option where V: View + Any, 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`]. @@ -589,10 +604,10 @@ impl Cursive { /// # let mut siv = Cursive::dummy(); /// 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 - /// let mut view: ViewRef = siv.find_id("id").unwrap(); + /// let mut view: ViewRef = siv.find_name("id").unwrap(); /// view.set_content("bar"); /// ``` /// @@ -606,30 +621,45 @@ impl Cursive { /// use cursive::traits::Identifiable; /// /// 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. - /// assert!(siv.find_id::>("select").is_none()); + /// assert!(siv.find_name::>("select").is_none()); /// /// // Omitting the type will use the default type, in this case `String`. - /// assert!(siv.find_id::("select").is_none()); + /// assert!(siv.find_name::("select").is_none()); /// /// // But with the correct type, it works fine. - /// assert!(siv.find_id::>("select").is_some()); + /// assert!(siv.find_name::>("select").is_some()); /// ``` /// - /// [`NamedView`]: views/struct.NamedView.html - /// [`ViewRef`]: views/type.ViewRef.html + /// [`NamedView`]: views::NamedView + /// [`ViewRef`]: views::ViewRef + pub fn find_name(&mut self, id: &str) -> Option> + where + V: View + Any, + { + self.call_on_name(id, views::NamedView::::get_mut) + } + + /// Same as [`find_name`](Cursive::find_name). + #[deprecated(note = "`find_id` is being renamed to `find_name`")] pub fn find_id(&mut self, id: &str) -> Option> where V: View + Any, { - self.call_on_id(id, views::NamedView::::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<(), ()> { self.focus(&view::Selector::Name(id)) } diff --git a/src/direction.rs b/src/direction.rs index f1725d8..180b296 100644 --- a/src/direction.rs +++ b/src/direction.rs @@ -2,9 +2,6 @@ //! //! This module defines two main concepts: [`Orientation`] and [`Direction`]. //! -//! [`Orientation`]: direction::Orientation -//! [`Direction`]: direction::Direction -//! //! ### Orientation //! //! `Orientation` is a simple enum that can take two values: diff --git a/src/event.rs b/src/event.rs index c021a8b..8ad02e3 100644 --- a/src/event.rs +++ b/src/event.rs @@ -1,17 +1,16 @@ //! User-input events and their effects. //! -//! * Every user input the application receives is converted to an -//! [`Event`](./enum.Event.html). +//! * Every user input the application receives is converted to an [`Event`]. //! * Each event is then given to the root, and descends the view tree down to -//! the view currently in focus, through the -//! [`on_event`](../view/trait.View.html#method.on_event) method. +//! the view currently in focus, through the [`on_event`] method. //! * If the view consumes the event, it may return a callback to be //! executed. //! * Otherwise, it ignores the event, and the view parent can in turn //! choose to consume it or not. -//! * If no view consumes the event, the -//! [global callback](../struct.Cursive.html#method.add_global_callback) -//! table is checked. +//! * If no view consumes the event, the [global callback] table is checked. +//! +//! [`on_event`]: crate::View::on_event +//! [global callback]: crate::Cursive::add_global_callback use crate::vec::Vec2; use crate::Cursive; diff --git a/src/lib.rs b/src/lib.rs index cc1ce16..a834868 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,19 +8,18 @@ //! //! ## Getting started //! -//! * Every application should start with a [`Cursive`](struct.Cursive.html) -//! object. It is the main entry-point to the library. +//! * Every application should start with a [`Cursive`] object. It is the main +//! entry-point to the library. //! * A declarative phase then describes the structure of the UI by adding //! views and configuring their behaviours. -//! * Finally, the event loop is started by calling -//! [`Cursive::run(&mut self)`](struct.Cursive.html#method.run). +//! * Finally, the event loop is started by calling [`Cursive::run`]. //! //! ## Views //! //! 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 -//! [`View`](view/trait.View.html) trait and build your own. +//! [`View`] trait and build your own. //! //! ## Callbacks //! @@ -104,5 +103,6 @@ pub use self::cursive::{CbSink, Cursive, ScreenId}; pub use self::printer::Printer; pub use self::rect::Rect; pub use self::vec::Vec2; +pub use self::view::View; pub use self::with::With; pub use self::xy::XY; diff --git a/src/menu.rs b/src/menu.rs index 92f594c..8e838c0 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -2,7 +2,7 @@ //! //! 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 //! * Sub-trees are made of a label, and another `MenuTree`. @@ -10,7 +10,7 @@ //! //! 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::Cursive; diff --git a/src/theme/mod.rs b/src/theme/mod.rs index 24d17a2..f0cf4bb 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -5,8 +5,6 @@ //! Characters can be printed in the terminal with a specific color. //! The [`Color`] enum represents the ways this can be set. //! -//! [`Color`]: enum.Color.html -//! //! # Palette //! //! To achieve a customizable, yet unified look, Cursive uses a configurable @@ -14,8 +12,6 @@ //! //! The [`PaletteColor`] enum defines possible entries in this palette. //! -//! [`PaletteColor`]: enum.PaletteColor.html -//! //! These entries are: //! //! * **`Background`**: used to color the application background @@ -42,9 +38,6 @@ //! //! A [`Palette`] then maps each of these to an actual [`Color`]. //! -//! [`Palette`]: type.Palette.html -//! [`Color`]: enum.Color.html -//! //! # Color Types //! //! When drawing views, color can be picked in two way: @@ -55,8 +48,6 @@ //! //! The [`ColorType`] enum abstract over these two choices. //! -//! [`ColorType`]: enum.ColorType.html -//! //! # Color Styles //! //! 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 //! coherent look. //! -//! [`ColorStyle`]: struct.ColorStyle.html -//! //! # Effects //! //! 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 //! represent any way text should be printed on screen. //! -//! [`Effect`]: enum.Effect.html -//! //! # Themes //! //! A theme defines the color palette an application will use, as well as diff --git a/src/utils/counter.rs b/src/utils/counter.rs index f0c634d..3f07f89 100644 --- a/src/utils/counter.rs +++ b/src/utils/counter.rs @@ -3,7 +3,7 @@ use std::sync::Arc; /// Atomic counter used by [`ProgressBar`]. /// -/// [`ProgressBar`]: ../views/struct.ProgressBar.html +/// [`ProgressBar`]: crate::views::ProgressBar #[derive(Clone, Debug)] pub struct Counter(pub Arc); diff --git a/src/utils/markup/mod.rs b/src/utils/markup/mod.rs index 2f80884..b12e8f4 100644 --- a/src/utils/markup/mod.rs +++ b/src/utils/markup/mod.rs @@ -15,8 +15,6 @@ use crate::utils::span::{IndexedSpan, Span, SpannedString}; /// /// **Note**: due to limitations in rustdoc, you will need to read the /// documentation from the [`SpannedString`] page. -/// -/// [`SpannedString`]: ../span/struct.SpannedString.html pub type StyledString = SpannedString