aboutsummaryrefslogtreecommitdiff
path: root/src/term/mod.rs
diff options
context:
space:
mode:
authorDan Aloni <alonid@gmail.com>2017-10-14 20:35:56 +0300
committerJoe Wilm <jwilm@users.noreply.github.com>2017-10-14 10:35:56 -0700
commit8a0b1d9c3f5a9ddb98469a340bbcd06374d4a24e (patch)
tree80768003f9a2f3c99b0238dc68f4c9b119cc77d6 /src/term/mod.rs
parentfd410f9ec8bc53e35d46cc213244c978ef7c5816 (diff)
downloadalacritty-8a0b1d9c3f5a9ddb98469a340bbcd06374d4a24e.tar.gz
alacritty-8a0b1d9c3f5a9ddb98469a340bbcd06374d4a24e.zip
Implement user actions for font resize (#625)
Adds support for font resizing at run-time. Three new actions are introduced: * IncreaseFontSize - Increases current font size by 1.0 * DecreaseFontSize - Decreases current font size by 1.0 * ResetFontSize - Resets font size to that specified in the configuration. The stock config files have example configuration for each which should match gnome-terminal. For convenience, the config entries are: - { key: Key0, mods: Control, action: ResetFontSize } - { key: Equals, mods: Control, action: IncreaseFontSize } - { key: Subtract, mods: Control, action: DecreaseFontSize }
Diffstat (limited to 'src/term/mod.rs')
-rw-r--r--src/term/mod.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index f9bd5541..a16971b5 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -655,6 +655,9 @@ pub struct Term {
/// Scroll region
scroll_region: Range<Line>,
+ /// Font size modifier
+ pub font_size_modifier: i8,
+
/// Size
size_info: SizeInfo,
@@ -767,6 +770,7 @@ impl Term {
grid: grid,
alt_grid: alt,
alt: false,
+ font_size_modifier: 0,
active_charset: Default::default(),
cursor: Default::default(),
cursor_save: Default::default(),
@@ -783,6 +787,18 @@ 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;
+ }
+ }
+
+ pub fn reset_font_size(&mut self) {
+ self.font_size_modifier = 0;
+ self.dirty = true;
+ }
+
pub fn update_config(&mut self, config: &Config) {
self.semantic_escape_chars = config.selection().semantic_escape_chars.clone();
self.original_colors.fill_named(config.colors());
@@ -965,30 +981,22 @@ impl Term {
}
/// Resize terminal to new dimensions
- pub fn resize(&mut self, width: f32, height: f32) {
+ pub fn resize(&mut self, size : &SizeInfo) {
debug!("Term::resize");
+
// Bounds check; lots of math assumes width and height are > 0
- if width as usize <= 2 * self.size_info.padding_x as usize ||
- height as usize <= 2 * self.size_info.padding_y as usize
+ if size.width as usize <= 2 * self.size_info.padding_x as usize ||
+ size.height as usize <= 2 * self.size_info.padding_y as usize
{
return;
}
- let size = SizeInfo {
- width: width,
- height: height,
- cell_width: self.size_info.cell_width,
- cell_height: self.size_info.cell_height,
- padding_x: self.size_info.padding_x,
- padding_y: self.size_info.padding_y,
- };
-
let old_cols = self.grid.num_cols();
let old_lines = self.grid.num_lines();
let mut num_cols = size.cols();
let mut num_lines = size.lines();
- self.size_info = size;
+ self.size_info = *size;
if old_cols == num_cols && old_lines == num_lines {
debug!("Term::resize dimensions unchanged");