Skip to content

Commit

Permalink
TUI fix double type on other platforms
Browse files Browse the repository at this point in the history
Apparently Kitty didnt need this.

I haven't set up a dev environment on my new windows machine yet so this
patch was written in like 30 seconds using Notepad's find.
Hopefully nothing is rogered up.
  • Loading branch information
Beinsezii committed Mar 7, 2023
1 parent b9cbb26 commit f4e86dd
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use copypasta::{ClipboardContext, ClipboardProvider};

use crossterm::{
cursor, event,
event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind},
event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers, MouseEvent, MouseEventKind},
queue, terminal,
};

Expand All @@ -38,6 +38,7 @@ macro_rules! km {
Event::Key(KeyEvent {
code: KeyCode::Char($ch),
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
})
};
Expand All @@ -49,6 +50,7 @@ macro_rules! km_c {
Event::Key(KeyEvent {
code: KeyCode::Char($ch),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
..
})
};
Expand All @@ -59,6 +61,7 @@ macro_rules! km_s {
Event::Key(KeyEvent {
code: KeyCode::Char($ch),
modifiers: KeyModifiers::SHIFT,
kind: KeyEventKind::Press,
..
})
};
Expand Down Expand Up @@ -554,7 +557,11 @@ impl<T: Backend> UI<T> {
break;
}
},
Event::Key(KeyEvent { code, .. }) => match code {
Event::Key(KeyEvent {
code,
kind: KeyEventKind::Press,
..
}) => match code {
KeyCode::Esc => break 'outer false,
KeyCode::Enter => break 'outer true,
KeyCode::Backspace => drop(result.pop()),
Expand Down Expand Up @@ -651,6 +658,7 @@ impl<T: Backend> UI<T> {
Event::Key(KeyEvent {
code: KeyCode::Tab,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}) => {
if library.filter_count() != 0 {
Expand All @@ -663,6 +671,7 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Left,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}) => {
if self.sortpanes.active() {
Expand All @@ -678,12 +687,14 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Left,
modifiers: KeyModifiers::SHIFT,
kind: KeyEventKind::Press,
..
}) => self.move_pane(true),
km!('l')
| Event::Key(KeyEvent {
code: KeyCode::Right,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}) => {
if self.sortpanes.active() {
Expand All @@ -700,12 +711,14 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Right,
modifiers: KeyModifiers::SHIFT,
kind: KeyEventKind::Press,
..
}) => self.move_pane(false),
km!('j')
| Event::Key(KeyEvent {
code: KeyCode::Down,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}) => {
if self.sortpanes.active() {
Expand All @@ -719,6 +732,7 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Down,
modifiers: KeyModifiers::SHIFT,
kind: KeyEventKind::Press,
..
}) => {
if self.sortpanes.active() {
Expand All @@ -734,6 +748,7 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Up,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}) => {
if self.sortpanes.active() {
Expand All @@ -747,6 +762,7 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Up,
modifiers: KeyModifiers::SHIFT,
kind: KeyEventKind::Press,
..
}) => {
if self.sortpanes.active() {
Expand Down Expand Up @@ -781,6 +797,7 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Enter,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}) => {
if self.sortpanes.active() {
Expand All @@ -795,6 +812,7 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Enter,
modifiers: KeyModifiers::SHIFT,
kind: KeyEventKind::Press,
..
}) => {
if !self.sortpanes.active() {
Expand Down Expand Up @@ -832,6 +850,7 @@ impl<T: Backend> UI<T> {
| Event::Key(KeyEvent {
code: KeyCode::Esc,
modifiers: KeyModifiers::NONE,
kind: KeyEventKind::Press,
..
}) => {
self.menubar.up();
Expand Down

0 comments on commit f4e86dd

Please sign in to comment.