From a7d95540384c0b37e75a4bedb0bff688fee7dcf1 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Thu, 1 Nov 2018 17:23:49 +0000 Subject: Rework cursor configuration There are a couple of cursor-related options in the Alacritty config file now, however they aren't grouped together in any way. To resolve this a new `cursor` field has been added where all cursor configuration options (besides colors) have been moved. The `custom_cursor_colors` option has also been removed, since it's not necessary anymore. Simply making the `colors.cursor.*` fields optional, allows overriding the cursor colors whenever one of them is present. Like that the user doesn't have to think about a relation between two separate configuration options. This PR initially put the `hide_cursor_when_typing` variable under `cursor.hide_when_typing`. However this field is completely unrelated to the cursor, but instead relates to the mouse cursor. Since the word `cursor` is already used for the active cell in the grid of a terminal emulator, all occurences of the word `cursor` when talking about the mouse have been replaced with the word `mouse`. The configuration option has also been moved to `mouse.hide_when_typing`, to make it clear what this option is changing. This fixes #1080. --- src/event.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 185a7d70..c6fd9168 100644 --- a/src/event.rs +++ b/src/event.rs @@ -243,8 +243,8 @@ pub struct Processor { resize_tx: mpsc::Sender<(u32, u32)>, ref_test: bool, size_info: SizeInfo, - hide_cursor_when_typing: bool, - hide_cursor: bool, + hide_mouse_when_typing: bool, + hide_mouse: bool, received_count: usize, suppress_chars: bool, last_modifiers: ModifiersState, @@ -287,8 +287,8 @@ impl Processor { ref_test, mouse: Default::default(), size_info, - hide_cursor_when_typing: config.hide_cursor_when_typing(), - hide_cursor: false, + hide_mouse_when_typing: config.hide_mouse_when_typing(), + hide_mouse: false, received_count: 0, suppress_chars: false, last_modifiers: Default::default(), @@ -306,7 +306,7 @@ impl Processor { event: Event, ref_test: bool, resize_tx: &mpsc::Sender<(u32, u32)>, - hide_cursor: &mut bool, + hide_mouse: &mut bool, window_is_focused: &mut bool, ) { match event { @@ -347,7 +347,7 @@ impl Processor { processor.process_key(input); if input.state == ElementState::Pressed { // Hide cursor while typing - *hide_cursor = true; + *hide_mouse = true; } }, ReceivedCharacter(c) => { @@ -355,7 +355,7 @@ impl Processor { }, MouseInput { state, button, modifiers, .. } => { if !cfg!(target_os = "macos") || *window_is_focused { - *hide_cursor = false; + *hide_mouse = false; processor.mouse_input(state, button, modifiers); processor.ctx.terminal.dirty = true; } @@ -364,11 +364,11 @@ impl Processor { 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; + *hide_mouse = false; processor.mouse_moved(x as usize, y as usize, modifiers); }, MouseWheel { delta, phase, modifiers, .. } => { - *hide_cursor = false; + *hide_mouse = false; processor.on_mouse_wheel(delta, phase, modifiers); }, Refresh => { @@ -382,7 +382,7 @@ impl Processor { processor.ctx.terminal.next_is_urgent = Some(false); } else { processor.ctx.terminal.dirty = true; - *hide_cursor = false; + *hide_mouse = false; } processor.on_focus_change(is_focused); @@ -460,10 +460,10 @@ impl Processor { let mut window_is_focused = window.is_focused; - // Scope needed to that hide_cursor isn't borrowed after the scope + // Scope needed to that hide_mouse isn't borrowed after the scope // ends. { - let hide_cursor = &mut self.hide_cursor; + let hide_mouse = &mut self.hide_mouse; let mut process = |event| { if print_events { println!("glutin event: {:?}", event); @@ -473,7 +473,7 @@ impl Processor { event, ref_test, resize_tx, - hide_cursor, + hide_mouse, &mut window_is_focused, ); }; @@ -485,8 +485,8 @@ impl Processor { window.poll_events(process); } - if self.hide_cursor_when_typing { - window.set_cursor_visible(!self.hide_cursor); + if self.hide_mouse_when_typing { + window.set_mouse_visible(!self.hide_mouse); } window.is_focused = window_is_focused; -- cgit v1.2.3-54-g00ecf