diff options
author | DLFW <daniel@llin.info> | 2022-01-04 00:05:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-03 18:05:15 -0500 |
commit | a420d6ae3dbc53da4e614b21c96d7b78b364dabb (patch) | |
tree | c07b5e7fb059181b376b7e4a4b2388f990ddee40 /src/context | |
parent | 7791f93d95d350bdbb8dbdde4a9ec6fcbd32df41 (diff) |
Continuous scrolling (#118)
* Continuous scrolling
The scrolling behavior is changed from “paging” to a continuous
scrolling. Joshuto keeps a buffer from the cursor to each end of the
list, which is configured by `[display] scroll_offset`. If the terminal
height is too small to keep the distance, the buffer is set to a value
that assures that the cursor is at least as close to the end the user is
scrolling towards as to the other end of the visible list.
If the window is resized and the cursor jumps out of scope, the viewport
is adjusted when changing the index next time.
Possible improvements:
* Issue a viewport update on terminal geometry change
* When scrolling down to the bottom, don't allow an empty section
beneath the last entry
* Update documentation for scroll_offset
* remove unused variable
* keep viewport index when replacing dirlist
* Don't keep copy of scroll_offset in JoshutoDirList
* sanity: remove obsolete parameter
Diffstat (limited to 'src/context')
-rw-r--r-- | src/context/app_context.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/context/app_context.rs b/src/context/app_context.rs index 30aafae..0bdcf28 100644 --- a/src/context/app_context.rs +++ b/src/context/app_context.rs @@ -1,5 +1,6 @@ use std::collections::HashSet; use std::sync::mpsc; +use tui::layout::Rect; use crate::config; use crate::context::{ @@ -20,6 +21,11 @@ pub enum QuitType { ChooseFiles, } +#[derive(Clone, Debug, PartialEq)] +pub struct UiContext { + pub layout: Vec<Rect>, +} + pub struct AppContext { pub quit: QuitType, // event loop querying @@ -42,6 +48,8 @@ pub struct AppContext { preview_context: PreviewContext, // context related to command line commandline_context: CommandLineContext, + // user interface context; data which is input to both, the UI rendering and the app state + ui_context: UiContext, // filesystem watcher to inform about changes in shown directories #[cfg(target_os = "linux")] watcher: notify::INotifyWatcher, @@ -81,6 +89,7 @@ impl AppContext { message_queue: MessageQueue::new(), worker_context: WorkerContext::new(event_tx), preview_context: PreviewContext::new(), + ui_context: UiContext { layout: vec![] }, commandline_context, config, watcher, @@ -172,6 +181,13 @@ impl AppContext { &mut self.preview_context } + pub fn ui_context_ref(&self) -> &UiContext { + &self.ui_context + } + pub fn ui_context_mut(&mut self) -> &mut UiContext { + &mut self.ui_context + } + pub fn worker_context_ref(&self) -> &WorkerContext { &self.worker_context } |