Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
YS-L committed May 20, 2024
1 parent 7d54d6f commit 7a12486
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ impl InputHandler {

pub fn next(&mut self) -> Control {
if let CsvlensEvent::Input(mut key) = self.events.next().unwrap() {
/*
The shift key modifier is not consistent across platforms.
For upper case alphabets, e.g. 'A'
Unix: Char("A") + SHIFT
Windows: Char("A") + SHIFT
For non-alphabets, e.g. '>'
Unix: Char(">") + NULL
Windows: Char(">") + SHIFT
But the key event handling below assumes that the shift key modifier is only added for
alphabets. To satisfy the assumption, the following ensures that the presence or absence
of shift modifier is consistent across platforms.
Idea borrowed from: https://github.com/sxyazi/yazi/pull/174
*/
let platform_consistent_shift = match (key.code, key.modifiers) {
(KeyCode::Char(c), _) => c.is_ascii_uppercase(),
(_, m) => m.contains(KeyModifiers::SHIFT),
Expand Down

0 comments on commit 7a12486

Please sign in to comment.