-
-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs: #3
- Loading branch information
Showing
7 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::*; | ||
|
||
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function> | ||
#[derive(Debug, Deserialize, Serialize, Clone)] | ||
pub enum EasingFunction { | ||
Linear, | ||
CubicBezier(f32, f32, f32, f32), | ||
Ease, | ||
EaseIn, | ||
EaseInOut, | ||
EaseOut, | ||
} | ||
impl_lua_conversion!(EasingFunction); | ||
|
||
impl EasingFunction { | ||
pub fn evaluate_at_position(&self, position: f32) -> f32 { | ||
fn cubic_bezier(p0: f32, p1: f32, p2: f32, p3: f32, x: f32) -> f32 { | ||
(1.0 - x).powi(3) * p0 | ||
+ 3.0 * (1.0 - x).powi(2) * x * p1 | ||
+ 3.0 * (1.0 - x) * x.powi(2) * p2 | ||
+ x.powi(3) * p3 | ||
} | ||
|
||
match self { | ||
Self::Linear => cubic_bezier(0., 0., 1.0, 1.0, position), | ||
Self::CubicBezier(a, b, c, d) => cubic_bezier(*a, *b, *c, *d, position), | ||
Self::Ease => cubic_bezier(0.25, 0.1, 0.25, 1.0, position), | ||
Self::EaseIn => cubic_bezier(0.42, 0.0, 1.0, 1.0, position), | ||
Self::EaseInOut => cubic_bezier(0.42, 0., 0.58, 1.0, position), | ||
Self::EaseOut => cubic_bezier(0., 0., 0.58, 1.0, position), | ||
} | ||
} | ||
} | ||
|
||
impl Default for EasingFunction { | ||
fn default() -> Self { | ||
Self::Ease | ||
} | ||
} | ||
|
||
#[derive(Default, Debug, Deserialize, Serialize, Clone)] | ||
pub struct VisualBell { | ||
#[serde(default)] | ||
pub fade_in_duration_ms: u64, | ||
#[serde(default)] | ||
pub fade_in_function: EasingFunction, | ||
#[serde(default)] | ||
pub fade_out_duration_ms: u64, | ||
#[serde(default)] | ||
pub fade_out_function: EasingFunction, | ||
} | ||
impl_lua_conversion!(VisualBell); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# visual_bell | ||
|
||
*Since: nightly builds only* | ||
|
||
When the BEL ascii sequence is sent to a pane, the bell is "rung" in that pane. | ||
|
||
You may choose to configure the `visual_bell` option so show a visible representation of the bell event, | ||
by having the background color of the pane briefly change color. | ||
|
||
There are four fields to the visual_bell config option: | ||
|
||
* `fade_in_duration_ms` - how long it should take for the bell color to fade in, in milliseconds. The default is 0. | ||
* `fade_out_duration_ms` - how long it should take for the bell color to fade out, in milliseconds. The default is 0. | ||
* `fade_in_function` - an easing function, similar to [CSS easing functions](https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function), that affects how the bell color is faded in. | ||
* `fade_out_function` - an easing function that affects how the bell color is faded out. | ||
|
||
If the total fade in and out durations are 0, then there will be no visual bell indication. | ||
|
||
The bell color is itself specified in your color settings; if not specified, the text foreground color will be used. | ||
|
||
The following easing functions are supported: | ||
|
||
* `Linear` - the fade happens at a constant rate. | ||
* `Ease` - The fade starts slowly, accelerates sharply, and then slows gradually towards the end. This is the default. | ||
* `EaseIn` - The fade starts slowly, and then progressively speeds up until the end, at which point it stops abruptly. | ||
* `EaseInOut` - The fade starts slowly, speeds up, and then slows down towards the end. | ||
* `EaseOut` - The fade starts abruptly, and then progressively slows down towards the end. | ||
* `{CubicBezier={0.0, 0.0, 0.58, 1.0}}` - an arbitrary cubic bezier with the specified parameters. | ||
|
||
The following configuration enables a low intensity visual bell that takes a total of 300ms to "flash" the screen: | ||
|
||
```lua | ||
return { | ||
visual_bell = { | ||
fade_in_function = "EaseIn", | ||
fade_in_duration_ms = 150, | ||
fade_out_function = "EaseOut", | ||
fade_out_duration_ms = 150, | ||
}, | ||
colors = { | ||
visual_bell = "#202020" | ||
}, | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters