diff --git a/Cargo.toml b/Cargo.toml index 193272b..3627418 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "omega" -version = "0.1.9" +version = "0.1.10" repository = "https://github.com/nwrenger/omega" documentation = "https://github.com/nwrenger/omega" readme = "README.md" diff --git a/src/events.rs b/src/events.rs index d63054f..e42d402 100644 --- a/src/events.rs +++ b/src/events.rs @@ -321,7 +321,7 @@ pub fn copy(text_area: &mut TextArea) -> Result<()> { } /// Pasts the current clipboard -pub fn paste(text_area: &mut TextArea) -> Result<()> { +pub fn paste(s: &mut Cursive, text_area: &mut TextArea) -> Result<()> { let content = text_area.get_content().to_string(); let cursor_pos = text_area.cursor(); @@ -333,6 +333,13 @@ pub fn paste(text_area: &mut TextArea) -> Result<()> { let inserted_line = split.0.to_string() + text.as_str() + split.1; lines[current_line] = inserted_line.as_str(); + s.call_on_all_named( + "editor_scroll", + |view: &mut ScrollView>| { + view.scroll_to_bottom(); + }, + ); + let new_content: String = lines.join("\n"); text_area.set_content(new_content); diff --git a/src/main.rs b/src/main.rs index 5fb476e..5c6e8c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,6 +86,7 @@ fn main() { .with_name("editor") .scrollable() .scroll_strategy(ScrollStrategy::StickToBottom) + .with_name("editor_scroll") .full_screen(); let events = OnEventView::new(text_area) @@ -96,7 +97,7 @@ fn main() { }) .on_pre_event(Event::CtrlChar('v'), move |s| { if let Some(mut text_area) = s.find_name::