diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-01-05 03:22:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-05 03:22:58 +0000 |
commit | 228400a6c24bf651ecd74996d1fa68c3d92c9ff9 (patch) | |
tree | 5f7022854988b37592c8c47ef0215e62ce69c5b8 /src/term | |
parent | 7b4ba80bb195b862f50c16263405a9507f99bb82 (diff) | |
download | alacritty-228400a6c24bf651ecd74996d1fa68c3d92c9ff9.tar.gz alacritty-228400a6c24bf651ecd74996d1fa68c3d92c9ff9.zip |
Prevent font_size_modifier from sinking too low (#994)
This replaces the `font_size_modifier` stored on the `Term` struct with a `font_size` field.
With this change it is not necessary anymore to calculate the new font size from a delta but the current font size is always stored directly on the `Term` struct.
As a result of this it is now possible to increase the font size by more than 127 steps at runtime. It also limits the minimum font size to 1, so issues with the `font_size_modifier` dropping far below font size 1 are resolved with this change.
This fixes #955.
Diffstat (limited to 'src/term')
-rw-r--r-- | src/term/mod.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs index e43ea7b6..7e6ff1e0 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -22,7 +22,7 @@ use std::time::{Duration, Instant}; use arraydeque::ArrayDeque; use unicode_width::UnicodeWidthChar; -use font; +use font::{self, Size}; use ansi::{self, Color, NamedColor, Attr, Handler, CharsetIndex, StandardCharset, CursorStyle}; use grid::{BidirectionalIterator, Grid, ClearRegion, ToRange, Indexed}; use index::{self, Point, Column, Line, Linear, IndexRange, Contains, RangeInclusive}; @@ -685,8 +685,9 @@ pub struct Term { /// Scroll region scroll_region: Range<Line>, - /// Font size modifier - pub font_size_modifier: i8, + /// Font size + pub font_size: Size, + original_font_size: Size, /// Size size_info: SizeInfo, @@ -814,7 +815,8 @@ impl Term { grid: grid, alt_grid: alt, alt: false, - font_size_modifier: 0, + font_size: config.font().size(), + original_font_size: config.font().size(), active_charset: Default::default(), cursor: Default::default(), cursor_save: Default::default(), @@ -834,14 +836,14 @@ impl Term { } pub fn change_font_size(&mut self, delta: i8) { - if let Some(sum) = self.font_size_modifier.checked_add(delta) { - self.font_size_modifier = sum; - self.dirty = true; - } + // Saturating addition with minimum font size 1 + let new_size = self.font_size + Size::new(delta as f32); + self.font_size = max(new_size, Size::new(1.)); + self.dirty = true; } pub fn reset_font_size(&mut self) { - self.font_size_modifier = 0; + self.font_size = self.original_font_size; self.dirty = true; } |