diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-06-18 01:02:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 01:02:56 +0000 |
commit | 87e5b1aa25ea61937fa5f79668d2a46e88707c5e (patch) | |
tree | 59205d2e00072a5f8737dc104f57fc940db0c2ec /alacritty_terminal/src/util.rs | |
parent | d526649ee67237a1bedad8228f1f017035ddad3f (diff) | |
download | r-alacritty-87e5b1aa25ea61937fa5f79668d2a46e88707c5e.tar.gz r-alacritty-87e5b1aa25ea61937fa5f79668d2a46e88707c5e.tar.bz2 r-alacritty-87e5b1aa25ea61937fa5f79668d2a46e88707c5e.zip |
Add automatic scrolling during selection
This adds a new `Scheduler` which allows for staging events to be
processed at a later time.
If there is a selection active and the mouse is above or below the
window, the viewport will now scroll torwards the direction of the
mouse. The amount of lines scrolled depends on the distance of the mouse
to the boundaries used for selection scrolling.
To make it possible to scroll while in fullscreen, the selection
scrolling area includes the padding of the window and is at least 5
pixels high in case there is not enough padding present.
Diffstat (limited to 'alacritty_terminal/src/util.rs')
-rw-r--r-- | alacritty_terminal/src/util.rs | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/alacritty_terminal/src/util.rs b/alacritty_terminal/src/util.rs index fde06966..f996359a 100644 --- a/alacritty_terminal/src/util.rs +++ b/alacritty_terminal/src/util.rs @@ -1,6 +1,6 @@ use std::ffi::OsStr; +use std::io; use std::process::{Command, Stdio}; -use std::{cmp, io}; #[cfg(not(windows))] use std::os::unix::process::CommandExt; @@ -13,22 +13,18 @@ use winapi::um::winbase::{CREATE_NEW_PROCESS_GROUP, CREATE_NO_WINDOW}; /// Threading utilities. pub mod thread { /// Like `thread::spawn`, but with a `name` argument. - pub fn spawn_named<F, T, S>(name: S, f: F) -> ::std::thread::JoinHandle<T> + pub fn spawn_named<F, T, S>(name: S, f: F) -> std::thread::JoinHandle<T> where F: FnOnce() -> T + Send + 'static, T: Send + 'static, S: Into<String>, { - ::std::thread::Builder::new().name(name.into()).spawn(f).expect("thread spawn works") + std::thread::Builder::new().name(name.into()).spawn(f).expect("thread spawn works") } pub use std::thread::*; } -pub fn limit<T: Ord>(value: T, min: T, max: T) -> T { - cmp::min(cmp::max(value, min), max) -} - #[cfg(not(windows))] pub fn start_daemon<I, S>(program: &str, args: I) -> io::Result<()> where @@ -79,15 +75,3 @@ where .spawn() .map(|_| ()) } - -#[cfg(test)] -mod tests { - use super::limit; - - #[test] - fn limit_works() { - assert_eq!(10, limit(10, 0, 100)); - assert_eq!(10, limit(5, 10, 100)); - assert_eq!(100, limit(1000, 10, 100)); - } -} |