diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2022-07-01 11:40:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-01 11:40:27 +0300 |
commit | ebc6922eaae28173532235222f9790c8ab3fdaa7 (patch) | |
tree | 7f3e50f0dddb3fb74d3969d46b90e3dd8e207f54 /alacritty_terminal | |
parent | 28e3fc7c64a7f375ad843145a0a8f78e31bff05e (diff) | |
download | alacritty-ebc6922eaae28173532235222f9790c8ab3fdaa7.tar.gz alacritty-ebc6922eaae28173532235222f9790c8ab3fdaa7.zip |
Add `cursor.blink_timeout` config option
This option should prevent extensive power usage due to cursor blinking
when there's no user activity being performed.
Fixes #5992.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r-- | alacritty_terminal/src/config/mod.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/alacritty_terminal/src/config/mod.rs b/alacritty_terminal/src/config/mod.rs index 40c42d4f..5822d591 100644 --- a/alacritty_terminal/src/config/mod.rs +++ b/alacritty_terminal/src/config/mod.rs @@ -1,4 +1,4 @@ -use std::cmp::max; +use std::cmp; use std::collections::HashMap; use std::path::PathBuf; @@ -13,6 +13,7 @@ use crate::ansi::{CursorShape, CursorStyle}; pub use crate::config::scrolling::{Scrolling, MAX_SCROLLBACK_LINES}; pub const LOG_TARGET_CONFIG: &str = "alacritty_config_derive"; + const MIN_BLINK_INTERVAL: u64 = 10; /// Top-level config type. @@ -75,6 +76,7 @@ pub struct Cursor { thickness: Percentage, blink_interval: u64, + blink_timeout: u8, } impl Default for Cursor { @@ -83,6 +85,7 @@ impl Default for Cursor { thickness: Percentage(0.15), unfocused_hollow: true, blink_interval: 750, + blink_timeout: 5, style: Default::default(), vi_mode_style: Default::default(), } @@ -107,7 +110,18 @@ impl Cursor { #[inline] pub fn blink_interval(self) -> u64 { - max(self.blink_interval, MIN_BLINK_INTERVAL) + cmp::max(self.blink_interval, MIN_BLINK_INTERVAL) + } + + #[inline] + pub fn blink_timeout(self) -> u64 { + const MILLIS_IN_SECOND: u64 = 1000; + match self.blink_timeout { + 0 => 0, + blink_timeout => { + cmp::max(self.blink_interval * 5 / MILLIS_IN_SECOND, blink_timeout as u64) + }, + } } } |