From da09e5fa9464dd17b015dea10a06671adea84407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=99=9B=E7=99=BD?= <18016038327@189.cn> Date: Wed, 9 Oct 2024 02:32:48 +0800 Subject: [PATCH] undo rustfmt change to input_field --- src/views/input_field.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/views/input_field.rs b/src/views/input_field.rs index 5746e07..15a0b20 100644 --- a/src/views/input_field.rs +++ b/src/views/input_field.rs @@ -4,14 +4,24 @@ use { crossterm::{ cursor, event::{ - Event, KeyCode, KeyEvent, KeyModifiers, MouseButton, MouseEvent, MouseEventKind, + Event, + KeyCode, + KeyEvent, + KeyModifiers, + MouseButton, + MouseEvent, + MouseEventKind, }, queue, - style::{Attribute, Color, SetBackgroundColor}, + style::{ + Attribute, + Color, + SetBackgroundColor + }, }, *, }, - crokey::{key, KeyCombination, OneToThree}, + crokey::{OneToThree, KeyCombination, key}, std::io::Write, }; @@ -59,7 +69,7 @@ macro_rules! wrap_content_fun { impl InputField { pub const ENTER: KeyCombination = key!(enter); - pub const ALT_ENTER: KeyCombination = key!(alt - enter); + pub const ALT_ENTER: KeyCombination = key!(alt-enter); pub fn new(area: Area) -> Self { let focused_style = CompoundStyle::default(); @@ -272,7 +282,10 @@ impl InputField { /// of the input. If you want to totally handle events, you /// may call function like `put_char` and `del_char_left` /// directly. - pub fn apply_key_combination>(&mut self, key: K) -> bool { + pub fn apply_key_combination>( + &mut self, + key: K + ) -> bool { if !self.focused { return false; } @@ -418,9 +431,7 @@ impl InputField { pub fn apply_event(&mut self, event: &Event, is_double_click: bool) -> bool { match event { Event::Mouse(mouse_event) => self.apply_mouse_event(*mouse_event, is_double_click), - Event::Key(KeyEvent { - code, modifiers, .. - }) if self.focused => { + Event::Key(KeyEvent { code, modifiers, .. }) if self.focused => { if modifiers.is_empty() { self.apply_keycode_event(*code, false) } else if *modifiers == KeyModifiers::SHIFT {