From 45c2b3fbf72fa6dfd36bee590e64314c6da7c6c2 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Thu, 15 Feb 2018 18:35:49 -0800 Subject: checkpoint: very basic scrolling works Things that do not work - Limiting how far back in the buffer it's possible to scroll - Selections (need to transform to buffer offsets) --- src/event.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 4ae25860..9c3e8edc 100644 --- a/src/event.rs +++ b/src/event.rs @@ -55,6 +55,10 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { *self.size_info } + fn scroll(&mut self, count: isize) { + self.terminal.scroll_display(count); + } + fn copy_selection(&self, buffer: ::copypasta::Buffer) { if let Some(ref selection) = *self.selection { if let Some(ref span) = selection.to_span(self.terminal) { -- cgit From 7fe67743ebffd047532f6271bf28474f9d947f64 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Fri, 16 Feb 2018 17:33:32 -0800 Subject: Scroll to bottom on character received --- src/event.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 9c3e8edc..3b1df006 100644 --- a/src/event.rs +++ b/src/event.rs @@ -59,6 +59,10 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { self.terminal.scroll_display(count); } + fn reset_scroll(&mut self) { + self.terminal.reset_scroll(); + } + fn copy_selection(&self, buffer: ::copypasta::Buffer) { if let Some(ref selection) = *self.selection { if let Some(ref span) = selection.to_span(self.terminal) { -- cgit From 8ef062efd94975885776e61b6df936088b018da0 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Mon, 5 Mar 2018 09:57:34 -0800 Subject: Move selection into Grid Supporting selections with scrollback has two major components: 1. Grid needs access to Selection so that it may update the scroll position as the terminal text changes. 2. Selection needs to be implemented in terms of buffer offsets -- NOT lines -- and be updated when Storage is rotated. This commit implements the first part. --- src/event.rs | 56 +++++++++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 33 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 3b1df006..d6348ba0 100644 --- a/src/event.rs +++ b/src/event.rs @@ -33,10 +33,8 @@ pub trait Notify { pub struct ActionContext<'a, N: 'a> { pub notifier: &'a mut N, pub terminal: &'a mut Term, - pub selection: &'a mut Option, pub size_info: &'a SizeInfo, pub mouse: &'a mut Mouse, - pub selection_modified: bool, pub received_count: &'a mut usize, pub suppress_chars: &'a mut bool, pub last_modifiers: &'a mut ModifiersState, @@ -64,30 +62,35 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { } fn copy_selection(&self, buffer: ::copypasta::Buffer) { - if let Some(ref selection) = *self.selection { - if let Some(ref span) = selection.to_span(self.terminal) { - let buf = self.terminal.string_from_selection(&span); - if !buf.is_empty() { + self.terminal + .selection_to_string() + .map(|selected| { + if !selected.is_empty() { Clipboard::new() - .and_then(|mut clipboard| clipboard.store(buf, buffer)) + .and_then(|mut clipboard| clipboard.store(selected, buffer)) .unwrap_or_else(|err| { warn!("Error storing selection to clipboard. {}", Red(err)); }); } - } - } + }); } fn clear_selection(&mut self) { - *self.selection = None; - self.selection_modified = true; + *self.terminal.selection_mut() = None; + self.terminal.dirty = true; } fn update_selection(&mut self, point: Point, side: Side) { - self.selection_modified = true; + // Update selection if one exists - if let Some(ref mut selection) = *self.selection { + let mut had_selection = false; // borrowck + if let Some(ref mut selection) = *self.terminal.selection_mut() { selection.update(point, side); + had_selection = true; + } + + if had_selection { // borrowck + self.terminal.dirty = true; return; } @@ -96,18 +99,18 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { } fn simple_selection(&mut self, point: Point, side: Side) { - *self.selection = Some(Selection::simple(point, side)); - self.selection_modified = true; + *self.terminal.selection_mut() = Some(Selection::simple(point, side)); + self.terminal.dirty = true; } fn semantic_selection(&mut self, point: Point) { - *self.selection = Some(Selection::semantic(point, self.terminal)); - self.selection_modified = true; + *self.terminal.selection_mut() = Some(Selection::semantic(point, &*self.terminal)); + self.terminal.dirty = true; } fn line_selection(&mut self, point: Point) { - *self.selection = Some(Selection::lines(point)); - self.selection_modified = true; + *self.terminal.selection_mut() = Some(Selection::lines(point)); + self.terminal.dirty = true; } fn mouse_coords(&self) -> Option { @@ -200,7 +203,6 @@ pub struct Processor { resize_tx: mpsc::Sender<(u32, u32)>, ref_test: bool, size_info: SizeInfo, - pub selection: Option, hide_cursor_when_typing: bool, hide_cursor: bool, received_count: usize, @@ -215,7 +217,6 @@ pub struct Processor { impl OnResize for Processor { fn on_resize(&mut self, size: &SizeInfo) { self.size_info = size.to_owned(); - self.selection = None; } } @@ -242,8 +243,7 @@ impl Processor { resize_tx, ref_test, mouse: Default::default(), - selection: None, - size_info, + size_info: size_info, hide_cursor_when_typing: config.hide_cursor_when_typing(), hide_cursor: false, received_count: 0, @@ -321,10 +321,6 @@ impl Processor { *hide_cursor = false; processor.mouse_moved(x as u32, y as u32, modifiers); - - if !processor.ctx.selection.is_none() { - processor.ctx.terminal.dirty = true; - } }, MouseWheel { delta, phase, modifiers, .. } => { *hide_cursor = false; @@ -400,10 +396,8 @@ impl Processor { context = ActionContext { terminal: &mut terminal, notifier: &mut self.notifier, - selection: &mut self.selection, mouse: &mut self.mouse, size_info: &self.size_info, - selection_modified: false, received_count: &mut self.received_count, suppress_chars: &mut self.suppress_chars, last_modifiers: &mut self.last_modifiers, @@ -448,10 +442,6 @@ impl Processor { } window.is_focused = window_is_focused; - - if processor.ctx.selection_modified { - processor.ctx.terminal.dirty = true; - } } self.wait_for_event = !terminal.dirty; -- cgit From 8018dee1812ab88793c0f18e13335fa77c068000 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Tue, 6 Mar 2018 20:57:40 -0800 Subject: Support selections with scrolling buffer Selections now *mostly* work. They move as the buffer scrolls, copying works as it should, and it looks like the different selection modes behave properly as well. The new Selection implementation uses buffer coordinates instead of screen coordinates. This leads to doing a transform from mouse input to update the selection, and back to screen coordinates when displaying the selection. Scrolling the selection is fast because the grid is already operating in buffer coordinates. There are several bugs to address: * A _partially_ visible selection will lead to a crash since the drawing routine converts selection coordinates to screen coordinates. The solution will be to clip the coordinates at draw time. * A selection scrolling off the buffer in either direction leads to indexing out-of-bounds. The solution again is to clip, but this needs to be done within Selection::rotate by passing a max limit. It may also need a return type to indicate that the selection is no longer visible and should be discarded. * A selection scrolling out of a logical scrolling region is not clipped. A temporary and robust workaround is to simply discard the selection in the case of scrolling in a region. wip selections fix issue with line selection selection mostly working need to support selection not being on the screen at draw time Fix selection_to_string Uncomment tests --- src/event.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index d6348ba0..8d2d80e4 100644 --- a/src/event.rs +++ b/src/event.rs @@ -81,34 +81,33 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { } fn update_selection(&mut self, point: Point, side: Side) { + self.terminal.dirty = true; + let point = self.terminal.visible_to_buffer(point); // Update selection if one exists - let mut had_selection = false; // borrowck if let Some(ref mut selection) = *self.terminal.selection_mut() { selection.update(point, side); - had_selection = true; - } - - if had_selection { // borrowck - self.terminal.dirty = true; return; } // Otherwise, start a regular selection - self.simple_selection(point, side); + *self.terminal.selection_mut() = Some(Selection::simple(point, side)); } fn simple_selection(&mut self, point: Point, side: Side) { + let point = self.terminal.visible_to_buffer(point); *self.terminal.selection_mut() = Some(Selection::simple(point, side)); self.terminal.dirty = true; } fn semantic_selection(&mut self, point: Point) { + let point = self.terminal.visible_to_buffer(point); *self.terminal.selection_mut() = Some(Selection::semantic(point, &*self.terminal)); self.terminal.dirty = true; } fn line_selection(&mut self, point: Point) { + let point = self.terminal.visible_to_buffer(point); *self.terminal.selection_mut() = Some(Selection::lines(point)); self.terminal.dirty = true; } -- cgit From d3f64072f3fe4d31f7a60eb0cb17a98096617b4b Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Fri, 9 Mar 2018 19:45:40 +0100 Subject: Merge branch #1095 Because there was some overlap with branch #1095, these two PRs have been added together and the config has been restructured to make use of a `scrolling` section. The default faux scrolling amount has also been changed to `3` because this simplifies the code and falls in line with what most other terminal emulators do. There should be no additional test failures due to this. --- src/event.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 8d2d80e4..14ec0b0e 100644 --- a/src/event.rs +++ b/src/event.rs @@ -195,6 +195,7 @@ pub struct Processor { key_bindings: Vec, mouse_bindings: Vec, mouse_config: config::Mouse, + scrolling_config: config::Scrolling, print_events: bool, wait_for_event: bool, notifier: N, @@ -236,6 +237,7 @@ impl Processor { key_bindings: config.key_bindings().to_vec(), mouse_bindings: config.mouse_bindings().to_vec(), mouse_config: config.mouse().to_owned(), + scrolling_config: config.scrolling(), print_events: options.print_events, wait_for_event: true, notifier, @@ -404,6 +406,7 @@ impl Processor { processor = input::Processor { ctx: context, + scrolling_config: &self.scrolling_config, mouse_config: &self.mouse_config, key_bindings: &self.key_bindings[..], mouse_bindings: &self.mouse_bindings[..], -- cgit From 58c69cafad3b1dafa3631d911c6bfc21f5e5dec5 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 13 Mar 2018 19:00:14 +0100 Subject: Fix multi-line selection with single cell end When the user selected multiple lines, dragging the selection downwards, and then leaves the cursor to the left side of the first cell, the first cell was still incorrectly selected. This has been fixed. The selection also did not update if the mouse was outside of the window, now all movement events are accpeted even when the mouse is outside of the window. This allows updating the selection when the user is dragging the cursor too far. Mouse movement and click events outside of the window are not propagated, these are only used for updating the selection. --- src/event.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 14ec0b0e..b0987d58 100644 --- a/src/event.rs +++ b/src/event.rs @@ -154,8 +154,8 @@ pub enum ClickState { /// State of the mouse pub struct Mouse { - pub x: u32, - pub y: u32, + pub x: usize, + pub y: usize, pub left_button_state: ElementState, pub middle_button_state: ElementState, pub right_button_state: ElementState, @@ -315,13 +315,11 @@ impl Processor { processor.ctx.terminal.dirty = true; }, CursorMoved { position: (x, y), modifiers, .. } => { - let x = x as i32; - let y = y as i32; - let x = limit(x, 0, processor.ctx.size_info.width as i32); - let y = limit(y, 0, processor.ctx.size_info.height as i32); + let x = limit(x as i32, 0, processor.ctx.size_info.width as i32); + let y = limit(y as i32, 0, processor.ctx.size_info.height as i32); *hide_cursor = false; - processor.mouse_moved(x as u32, y as u32, modifiers); + processor.mouse_moved(x as usize, y as usize, modifiers); }, MouseWheel { delta, phase, modifiers, .. } => { *hide_cursor = false; -- cgit From 2c7bb9a4d3ce3ead6de4ca6485ca67c44c0bd1c1 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 10 Mar 2018 20:24:10 +0100 Subject: Add scrollback hotkeys This offers a few additional hotkeys that can be used in combination with scrollback. None of these are used by default yet. This implements the following bindings: - ScrollPageUp: Scroll exactly one screen height up - ScrollPageDown: Scroll exactly one screen height down - ScrollToTop: Scroll as far up as possible - ScrollToBottom: Scroll as far down as possible This fixes #1151. --- src/event.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index b0987d58..4823d824 100644 --- a/src/event.rs +++ b/src/event.rs @@ -61,6 +61,18 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { self.terminal.reset_scroll(); } + fn scroll_to_top(&mut self) { + self.terminal.scroll_to_top(); + } + + fn scroll_page_up(&mut self) { + self.terminal.scroll_page_up(); + } + + fn scroll_page_down(&mut self) { + self.terminal.scroll_page_down(); + } + fn copy_selection(&self, buffer: ::copypasta::Buffer) { self.terminal .selection_to_string() -- cgit From 0dcb9ca6a871fd6d28787142a134c9190001ac43 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 11 Mar 2018 13:01:06 +0100 Subject: Replace scrolling methods with enum The different scrolling methods added a bunch of boilerplate where the call was just forwarded to the next struct, this has been removed by making the scroll amount into a struct. Now everything is called through one method and the parameter decides how far the viewport should be scrolled. --- src/event.rs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 4823d824..cf7d1030 100644 --- a/src/event.rs +++ b/src/event.rs @@ -10,6 +10,7 @@ use parking_lot::MutexGuard; use glutin::{self, ModifiersState, Event, ElementState}; use copypasta::{Clipboard, Load, Store}; +use grid::Scroll; use config::{self, Config}; use cli::Options; use display::OnResize; @@ -53,24 +54,8 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { *self.size_info } - fn scroll(&mut self, count: isize) { - self.terminal.scroll_display(count); - } - - fn reset_scroll(&mut self) { - self.terminal.reset_scroll(); - } - - fn scroll_to_top(&mut self) { - self.terminal.scroll_to_top(); - } - - fn scroll_page_up(&mut self) { - self.terminal.scroll_page_up(); - } - - fn scroll_page_down(&mut self) { - self.terminal.scroll_page_down(); + fn scroll(&mut self, scroll: Scroll) { + self.terminal.scroll_display(scroll); } fn copy_selection(&self, buffer: ::copypasta::Buffer) { -- cgit From ac93f6d03198c1826dbed60fa8283aeb8d1a577d Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 15 May 2018 22:36:14 +0200 Subject: Truncate invisible lines before storing ref-tests Because there is no good way to store invisible lines in a backwards- and forwards-compatible way, they buffer now gets truncated before dumping the state of a grid when creating a ref-test. This involved a few workaround of which a few required adding additional methods which are only used in ref-tests, these should be minimal though. Since this required the creation of a truncation method anyways, some logic has been added which automatically truncates the invisible buffer when there are more than X (set to 100) invisible lines. This should not impact performance because it rarely occurs, but it could save a bit of memory when the history size is shrunk during runtime (see #1293). This also adds an optional `config.json` file to the ref-test output where it is possible to manually specify variables which should override config defaults, this has been used only for history_size so far. Creating a new ref-test does also still work, so there was no regression here, if history size is altered, the config.json just has to be created manually with the content `{"history_size":HIST_SIZE}`, where `HIST_SIZE` is the desired history size. --- src/event.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index cf7d1030..37e4eccf 100644 --- a/src/event.rs +++ b/src/event.rs @@ -271,7 +271,8 @@ impl Processor { CloseRequested => { if ref_test { // dump grid state - let grid = processor.ctx.terminal.grid(); + let mut grid = processor.ctx.terminal.grid().clone(); + grid.truncate(); let serialized_grid = json::to_string(&grid) .expect("serialize grid"); -- cgit From 24c50fa0a793cd8c6127b5cf8ba3ea59f47cc1ca Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Tue, 29 May 2018 21:45:28 -0700 Subject: Remove dead code --- src/event.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 37e4eccf..ff95c880 100644 --- a/src/event.rs +++ b/src/event.rs @@ -99,7 +99,7 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { fn semantic_selection(&mut self, point: Point) { let point = self.terminal.visible_to_buffer(point); - *self.terminal.selection_mut() = Some(Selection::semantic(point, &*self.terminal)); + *self.terminal.selection_mut() = Some(Selection::semantic(point)); self.terminal.dirty = true; } -- cgit From f50ca1a54c94fe324d22d985c1acae1ff7c16a80 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 21 Jul 2018 17:17:41 +0000 Subject: Scrollback cleanup There were some unneeded codeblocks and TODO/XXX comments in the code that have been removed. All issues marked with TODO/XXX have either been already resolved or tracking issues exist. --- src/event.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index ff95c880..3af417bd 100644 --- a/src/event.rs +++ b/src/event.rs @@ -59,17 +59,15 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { } fn copy_selection(&self, buffer: ::copypasta::Buffer) { - self.terminal - .selection_to_string() - .map(|selected| { - if !selected.is_empty() { - Clipboard::new() - .and_then(|mut clipboard| clipboard.store(selected, buffer)) - .unwrap_or_else(|err| { - warn!("Error storing selection to clipboard. {}", Red(err)); - }); - } - }); + if let Some(selected) = self.terminal.selection_to_string() { + if !selected.is_empty() { + Clipboard::new() + .and_then(|mut clipboard| clipboard.store(selected, buffer)) + .unwrap_or_else(|err| { + warn!("Error storing selection to clipboard. {}", Red(err)); + }); + } + } } fn clear_selection(&mut self) { @@ -113,7 +111,7 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { self.terminal.pixels_to_coords(self.mouse.x as usize, self.mouse.y as usize) } - fn change_font_size(&mut self, delta: i8) { + fn change_font_size(&mut self, delta: f32) { self.terminal.change_font_size(delta); } @@ -241,7 +239,7 @@ impl Processor { resize_tx, ref_test, mouse: Default::default(), - size_info: size_info, + size_info, hide_cursor_when_typing: config.hide_cursor_when_typing(), hide_cursor: false, received_count: 0, @@ -298,7 +296,7 @@ impl Processor { }, KeyboardInput { input, .. } => { let glutin::KeyboardInput { state, virtual_keycode, modifiers, .. } = input; - processor.process_key(state, virtual_keycode, &modifiers); + processor.process_key(state, virtual_keycode, modifiers); if state == ElementState::Pressed { // Hide cursor while typing *hide_cursor = true; @@ -308,9 +306,11 @@ impl Processor { processor.received_char(c); }, MouseInput { state, button, modifiers, .. } => { - *hide_cursor = false; - processor.mouse_input(state, button, modifiers); - processor.ctx.terminal.dirty = true; + if *window_is_focused { + *hide_cursor = false; + processor.mouse_input(state, button, modifiers); + processor.ctx.terminal.dirty = true; + } }, CursorMoved { position: (x, y), modifiers, .. } => { let x = limit(x as i32, 0, processor.ctx.size_info.width as i32); -- cgit From c4a0f9c4cb7e8d73914800c4ba64413970f98540 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 28 Jul 2018 23:10:13 +0000 Subject: Merge master into scrollback * Allow disabling DPI scaling This makes it possible to disable DPI scaling completely, instead the the display pixel ration will always be fixed to 1.0. By default nothing has changed and DPI is still enabled, this just seems like a better way than running `WINIT_HIDPI_FACTOR=1.0 alacritty` every time the user wants to start alacritty. It would be possible to allow specifying any DPR, however I've decided against this since I'd assume it's a very rare usecase. It's also still possible to make use of `WINIT_HIDPI_FACTOR` to do this on X11. Currently this is not updated at runtime using the live config update, there is not really much of a technical limitation why this woudn't be possible, however a solution for that issue should be first added in jwilm/alacritty#1346, once a system is established for changing DPI at runtime, porting that functionality to this PR should be simple. * Add working --class and --title CLI parameters * Reduce Increase-/DecreaseFontSize step to 0.5 Until now the Increase-/DecreaseFontSize keybinds hand a step size of 1.0. Since the font size however is multiplied by two to allow more granular font size control, this lead to the bindings skipping one font size (incrementing/decrementing by +-2). To fix this the step size of the Increase-/DecreaseFontSize bindings has been reduced to the minimum step size that exists with the current font configuration (0.5). This should allow users to increment and decrement the font size by a single point instead of two. This also adds a few tests to make sure the methods for increasing/decreasing/resetting font size work properly. * Add Copy/Cut/Paste keys This just adds support for the Copy/Cut/Paste keys and sets up Copy/Paste as alternative defaults for Ctrl+Shift+C/V. * Move to cargo clippy Using clippy as a library has been deprecated, instead the `cargo clippy` command should be used instead. To comply with this change clippy has been removed from the `Cargo.toml` and is now installed with cargo when building in CI. This has also lead to a few new clippy issues to show up, this includes everything in the `font` subdirectory. This has been fixed and `font` should now be covered by clippy CI too. This also upgrades all dependencies, as a result this fixes #1341 and this fixes #1344. * Override dynamic_title when --title is specified * Change green implementation to use the macro * Ignore mouse input if window is unfocused * Make compilation of binary a phony target * Add opensuse zypper install method to readme * Fix clippy issues * Update manpage to document all CLI options The introduction of `--class` has added a flag to the CLI without adding it to the manpage. This has been fixed by updating the manpage. This also adds the default values of `--class` and `--title` to the CLI options. * Remove unnecessary clippy lint annotations We moved to "cargo clippy" in 5ba34d4f9766a55a06ed5e3e44cc384af1b09f65 and removing the clippy lint annotations in `src/lib.rs` does not cause any additional warnings. This also changes `cargo clippy` to use the flags required for checking integration tests. * Enable clippy in font/copypasta crates Enabled clippy in the sub-crates font and copypasta. All issues that were discovered by this change have also been fixed. * Remove outdated comment about NixOS * Replace debug asserts with static_assertions To check that transmutes will work correctly without having to rely on error-prone runtime checking, the `static_assertions` crate has been introduced. This allows comparing the size of types at compile time, preventing potentially silent breakage. This fixes #1417. * Add `cargo deb` build instructions Updated the `Cargo.toml` file and added a `package.metadata.deb` subsection to define how to build a debian "deb" install file using `cargo deb`. This will allow debian/ubuntu users to install `alacritty` using their system's package manager. It also will make it easier to provide pre-built binaries for those systems. Also fixed a stray debug line in the bash autocomplete script that was writting to a tempfile. * Add config for unfocused window cursor change * Add support for cursor shape escape sequence * Add bright foreground color option It was requested in jwilm/alacritty#825 that it should be possible to add an optional bright foreground color. This is now added to the primary colors structure and allows the user to set a foreground color for bold normal text. This has no effect unless the draw_bold_text_with_bright_colors option is also enabled. If the color is not specified, the bright foreground color will fall back to the normal foreground color. This fixes #825. * Fix clone URL in deb install instructions * Fix 'cargo-deb' desktop file name * Remove redundant dependency from deb build * Switch from deprecated `std::env::home_dir` to `dirs::home_dir` * Allow specifying modifiers for mouse bindings * Send newline with NumpadEnter * Add support for LCD-V pixel mode * Add binding action for hiding the window * Switch to rustup clippy component * Add optional dim foreground color Add optional color for the dim foreground (`\e[2m;`) Defaults to 2/3 of the foreground color. (same as other colors). If a bright color is dimmed, it's displayed as the normal color. The exception for this is when the bright foreground is dimmed when no bright foreground color is set. In that case it's treated as a normal foreground color and dimmed to DimForeground. To minimize the surprise for the user, the bright and dim colors have been completely removed from the default configuration file. Some documentation has also been added to make it clear to users what these options can be used for. This fixes #1448. * Fix clippy lints and run font tests on travis This fixes some existing clippy issues and runs the `font` tests through travis. Testing of copypasta crate was omitted due to problens when running on headless travis-ci environment (x11 clipboard would fail). * Ignore errors when logger can't write to output The (e)print macro will panic when there is no output available to write to, however in our scenario where we only log user errors to stderr, the better choice would be to ignore when writing to stdout or stderr is not possible. This changes the (e)print macro to make use of `write` and ignore any potential errors. Since (e)println rely on (e)print, this also solves potential failuers when calling (e)println. With this change implemented, all of logging, (e)println and (e)print should never fail even if the stdout/stderr is not available. --- src/event.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 3af417bd..de0faf7f 100644 --- a/src/event.rs +++ b/src/event.rs @@ -39,6 +39,7 @@ pub struct ActionContext<'a, N: 'a> { pub received_count: &'a mut usize, pub suppress_chars: &'a mut bool, pub last_modifiers: &'a mut ModifiersState, + pub window_changes: &'a mut WindowChanges, } impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { @@ -138,6 +139,33 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { fn last_modifiers(&mut self) -> &mut ModifiersState { &mut self.last_modifiers } + + #[inline] + fn hide_window(&mut self) { + self.window_changes.hide = true; + } +} + +/// The ActionContext can't really have direct access to the Window +/// with the current design. Event handlers that want to change the +/// window must set these flags instead. The processor will trigger +/// the actual changes. +pub struct WindowChanges { + pub hide: bool, +} + +impl WindowChanges { + fn clear(&mut self) { + self.hide = false; + } +} + +impl Default for WindowChanges { + fn default() -> WindowChanges { + WindowChanges { + hide: false, + } + } } pub enum ClickState { @@ -204,6 +232,7 @@ pub struct Processor { suppress_chars: bool, last_modifiers: ModifiersState, pending_events: Vec, + window_changes: WindowChanges, } /// Notify that the terminal was resized @@ -246,6 +275,7 @@ impl Processor { suppress_chars: false, last_modifiers: Default::default(), pending_events: Vec::with_capacity(4), + window_changes: Default::default(), } } @@ -398,6 +428,7 @@ impl Processor { received_count: &mut self.received_count, suppress_chars: &mut self.suppress_chars, last_modifiers: &mut self.last_modifiers, + window_changes: &mut self.window_changes, }; processor = input::Processor { @@ -442,6 +473,11 @@ impl Processor { window.is_focused = window_is_focused; } + if self.window_changes.hide { + window.hide(); + } + + self.window_changes.clear(); self.wait_for_event = !terminal.dirty; terminal -- cgit From 72495172c25e00799f29eb2e79fe40ddfa189866 Mon Sep 17 00:00:00 2001 From: Nathan Lilienthal Date: Sat, 1 Sep 2018 20:30:03 -0400 Subject: Implement `ansi::ClearMode::Saved` The clearing the screen for the `ansi::ClearMode::Saved` enum value has been implemented. This is used to clear all lines which are currently outside of the visible region but still inside the scrollback buffer. The specifications of XTerm indicate that the clearing of saved lines should only clear the saved lines and not the saved lines plus the currently visible part of the grid. Applications like `clear` send both the escape for clearing history plus the escape for clearing history when requested, so all sources seem to agree here. To allow both clearing the screen and the saved lines when a key is pressed the `process_key_bindings` method has been altered so multiple bindings can be specified. So it is now possible to execute both `^L` and `ClearHistory` with just a single binding. The `process_mouse_bindings` method has also been changed for consistency. To make sure everything works properly a test has been added which clears the history and then attempts to scroll. Since scrolling is the only way for a user to check if scrollback is available, this seems like a nice abstraction to check if there is a scrollback. --- src/event.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index ea3d1d74..589f1a42 100644 --- a/src/event.rs +++ b/src/event.rs @@ -10,6 +10,7 @@ use parking_lot::MutexGuard; use glutin::{self, ModifiersState, Event, ElementState}; use copypasta::{Clipboard, Load, Store}; +use ansi::{Handler, ClearMode}; use grid::Scroll; use config::{self, Config}; use cli::Options; @@ -59,6 +60,10 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { self.terminal.scroll_display(scroll); } + fn clear_history(&mut self) { + self.terminal.clear_screen(ClearMode::Saved); + } + fn copy_selection(&self, buffer: ::copypasta::Buffer) { if let Some(selected) = self.terminal.selection_to_string() { if !selected.is_empty() { -- cgit