monitor.rs 925 B

1234567891011121314151617181920212223242526272829303132
  1. use crate::application::Application;
  2. use crate::errors::*;
  3. pub fn scroll_to_cursor(app: &mut Application) -> Result<()> {
  4. if let Some(ref buffer) = app.workspace.current_buffer {
  5. app.monitor.scroll_to_cursor(buffer)?;
  6. }
  7. Ok(())
  8. }
  9. pub fn scroll_to_center(app: &mut Application) -> Result<()> {
  10. if let Some(ref buffer) = app.workspace.current_buffer {
  11. app.monitor.scroll_to_center(buffer)?;
  12. }
  13. Ok(())
  14. }
  15. pub fn scroll_to_first_line(app: &mut Application) -> Result<()> {
  16. if let Some(ref mut buffer) = app.workspace.current_buffer {
  17. buffer.cursor.move_to_first_line();
  18. app.monitor.scroll_to_cursor(buffer)?;
  19. }
  20. Ok(())
  21. }
  22. pub fn scroll_to_last_line(app: &mut Application) -> Result<()> {
  23. if let Some(ref mut buffer) = app.workspace.current_buffer {
  24. buffer.cursor.move_to_last_line();
  25. app.monitor.scroll_to_cursor(buffer)?;
  26. }
  27. Ok(())
  28. }