From f31f96e0bc6373215977658fb3d7bb4d81bb55cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Vald=C3=A9s?= Date: Tue, 18 Feb 2020 23:02:36 +0100 Subject: [PATCH] Adding a setting to change the refresh rate --- src/settings.rs | 1 + src/window.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/settings.rs b/src/settings.rs index b5bebc8..f8a1d70 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -183,6 +183,7 @@ impl Settings { settings.insert("no_idle".to_string(), Setting::new_bool(no_idle)); settings.insert("extra_buffer_frames".to_string(), Setting::new_u16(buffer_frames)); + settings.insert("refresh_rate".to_string(), Setting::new_u16(60)); Settings { neovim_arguments, settings: Mutex::new(settings) } } diff --git a/src/window.rs b/src/window.rs index 5c45b62..b8a9beb 100644 --- a/src/window.rs +++ b/src/window.rs @@ -215,7 +215,8 @@ pub fn ui_loop() { } let elapsed = frame_start.elapsed(); - let frame_length = Duration::from_secs_f32(1.0 / 60.0); + let refresh_rate = SETTINGS.get("refresh_rate").read_u16() as f32; + let frame_length = Duration::from_secs_f32(1.0 / refresh_rate); if elapsed < frame_length { sleep(frame_length - elapsed); }