Skip to content

Commit

Permalink
fix: Press arrow keys will dismiss current word
Browse files Browse the repository at this point in the history
  • Loading branch information
huytd committed Jan 12, 2024
1 parent 983837b commit 5ac0249
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Bộ gõ tiếng Việt mã nguồn mở đa hệ điều hành Gõ Key"
edition = "2021"
name = "goxkey"
version = "0.2.1"
version = "0.2.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down Expand Up @@ -33,4 +33,4 @@ copyright = "Copyright (c) Huy Tran 2023. All rights reserved."
icon = ["icons/icon.icns", "icons/icon.png"]
identifier = "com.goxkey.app"
name = "GoKey"
version = "0.2.0"
version = "0.2.2"
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use platform::{
};

use ui::{UIDataAdapter, UPDATE_UI};
use crate::platform::{RAW_ARROW_DOWN, RAW_ARROW_LEFT, RAW_ARROW_RIGHT, RAW_ARROW_UP};

static UI_EVENT_SINK: OnceCell<ExtEventSink> = OnceCell::new();
const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -109,6 +110,13 @@ fn event_handler(handle: Handle, pressed_key: Option<PressedKey>, modifiers: Key
toggle_vietnamese();
return true;
}
if raw_keycode == RAW_ARROW_UP || raw_keycode == RAW_ARROW_DOWN {
INPUT_STATE.new_word();
}
if raw_keycode == RAW_ARROW_LEFT || raw_keycode == RAW_ARROW_RIGHT {
// TODO: Implement a better cursor tracking on each word here
INPUT_STATE.new_word();
}
}
PressedKey::Char(keycode) => {
if INPUT_STATE.is_enabled() {
Expand Down
4 changes: 4 additions & 0 deletions src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ pub use os::SystemTray;
pub use os::SystemTrayMenuItemKey;

pub const RAW_KEY_GLOBE: u16 = 0xb3;
pub const RAW_ARROW_DOWN: u16 = 0x7d;
pub const RAW_ARROW_UP: u16 = 0x7e;
pub const RAW_ARROW_LEFT: u16 = 0x7b;
pub const RAW_ARROW_RIGHT: u16 = 0x7c;
pub const KEY_ENTER: char = '\x13';
pub const KEY_SPACE: char = '\u{0020}';
pub const KEY_TAB: char = '\x09';
Expand Down

0 comments on commit 5ac0249

Please sign in to comment.