aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-08-22 06:28:45 +0000
committerBlaž Hrastnik2021-10-05 13:27:10 +0000
commitf99bea404f43ea0e373fd9fe54616d3282e8364b (patch)
treea716d6f0f00578e707bf49c0929227d863d14c24 /helix-view/src
parent8925fdd6f3afa3532c928a5c6e1357bc15201d8a (diff)
idle timer wip
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/editor.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index b08a2df2..5362acc8 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -9,10 +9,12 @@ use crate::{
use futures_util::future;
use std::{
path::{Path, PathBuf},
+ pin::Pin,
sync::Arc,
- time::Duration,
};
+use tokio::time::{sleep, Duration, Instant, Sleep};
+
use slotmap::SlotMap;
use anyhow::Error;
@@ -91,6 +93,8 @@ pub struct Editor {
pub status_msg: Option<(String, Severity)>,
pub config: Config,
+
+ pub idle_timer: Pin<Box<Sleep>>,
}
#[derive(Debug, Copy, Clone)]
@@ -125,10 +129,24 @@ impl Editor {
registers: Registers::default(),
clipboard_provider: get_clipboard_provider(),
status_msg: None,
+ idle_timer: Box::pin(sleep(Duration::from_millis(500))),
config,
}
}
+ pub fn clear_idle_timer(&mut self) {
+ // equivalent to internal Instant::far_future() (30 years)
+ self.idle_timer
+ .as_mut()
+ .reset(Instant::now() + Duration::from_secs(86400 * 365 * 30));
+ }
+
+ pub fn reset_idle_timer(&mut self) {
+ self.idle_timer
+ .as_mut()
+ .reset(Instant::now() + Duration::from_millis(500));
+ }
+
pub fn clear_status(&mut self) {
self.status_msg = None;
}