mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
EditView: move cursor on content change
To the end of the content.
This commit is contained in:
parent
53178a2d6d
commit
d51772f714
@ -348,10 +348,7 @@ impl Cursive {
|
|||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn find<V: View + Any>(&mut self, sel: &view::Selector) -> Option<&mut V> {
|
pub fn find<V: View + Any>(&mut self, sel: &view::Selector) -> Option<&mut V> {
|
||||||
match self.find_any(sel) {
|
self.find_any(sel).and_then(|b| b.downcast_mut::<V>())
|
||||||
None => None,
|
|
||||||
Some(b) => b.downcast_mut::<V>(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenient method to use `find` with a `view::Selector::Id`.
|
/// Convenient method to use `find` with a `view::Selector::Id`.
|
||||||
|
@ -166,9 +166,9 @@ impl EditView {
|
|||||||
|
|
||||||
/// Replace the entire content of the view with the given one.
|
/// Replace the entire content of the view with the given one.
|
||||||
pub fn set_content(&mut self, content: &str) {
|
pub fn set_content(&mut self, content: &str) {
|
||||||
self.offset = 0;
|
|
||||||
self.cursor = 0;
|
|
||||||
self.content = Rc::new(content.to_string());
|
self.content = Rc::new(content.to_string());
|
||||||
|
self.offset = 0;
|
||||||
|
self.set_cursor(content.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current text.
|
/// Get the current text.
|
||||||
|
Loading…
Reference in New Issue
Block a user