Skip to content

Commit

Permalink
undo rustfmt change to input_field
Browse files Browse the repository at this point in the history
  • Loading branch information
xubaiwang committed Oct 8, 2024
1 parent 4615f84 commit da09e5f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/views/input_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<K: Into<KeyCombination>>(&mut self, key: K) -> bool {
pub fn apply_key_combination<K: Into<KeyCombination>>(
&mut self,
key: K
) -> bool {
if !self.focused {
return false;
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit da09e5f

Please sign in to comment.