From 6cbae83f174fa6d114ea66b1f8dd6185950ca835 Mon Sep 17 00:00:00 2001 From: Felippe da Motta Raposo Date: Fri, 8 Jun 2018 16:32:21 -0700 Subject: 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. --- 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 4ae25860..f592da5c 100644 --- a/src/event.rs +++ b/src/event.rs @@ -106,7 +106,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); } -- cgit From caf4580daa31c4c7249331b32826124d2b2b4143 Mon Sep 17 00:00:00 2001 From: Felippe da Motta Raposo Date: Sat, 23 Jun 2018 03:13:19 -0700 Subject: Ignore mouse input if window is unfocused --- src/event.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index f592da5c..cff013e3 100644 --- a/src/event.rs +++ b/src/event.rs @@ -301,9 +301,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 = x as i32; -- cgit From 12afbd007db8a8995617b3e7ebda3840860bbadc Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 1 Jul 2018 16:31:46 +0000 Subject: Fix clippy issues --- 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 cff013e3..c10f8a72 100644 --- a/src/event.rs +++ b/src/event.rs @@ -291,7 +291,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; -- cgit From dbcb5885adb1f0b23c29838ef8dd837212322409 Mon Sep 17 00:00:00 2001 From: Josh Leeb-du Toit Date: Sun, 22 Jul 2018 10:38:53 +1000 Subject: Add binding action for hiding the window --- 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 c10f8a72..7e8a955c 100644 --- a/src/event.rs +++ b/src/event.rs @@ -40,6 +40,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> { @@ -133,6 +134,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 { @@ -199,6 +227,7 @@ pub struct Processor { suppress_chars: bool, last_modifiers: ModifiersState, pending_events: Vec, + window_changes: WindowChanges, } /// Notify that the terminal was resized @@ -242,6 +271,7 @@ impl Processor { suppress_chars: false, last_modifiers: Default::default(), pending_events: Vec::with_capacity(4), + window_changes: Default::default(), } } @@ -401,6 +431,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 { @@ -448,6 +479,11 @@ impl Processor { } } + if self.window_changes.hide { + window.hide(); + } + + self.window_changes.clear(); self.wait_for_event = !terminal.dirty; terminal -- cgit