diff --git a/Cargo.lock b/Cargo.lock index 9684641..ee81486 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,6 +81,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "bstr" version = "0.2.17" @@ -125,7 +131,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.2.1", "strsim", "textwrap", "unicode-width", @@ -221,11 +227,11 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.20.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ebde6a9dd5e331cd6c6f48253254d117642c31653baa475e394657c59c1f7d" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags", + "bitflags 2.4.1", "crossterm_winapi", "libc", "mio", @@ -237,9 +243,9 @@ dependencies = [ [[package]] name = "crossterm_winapi" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6966607622438301997d3dac0d2f6e9a90c68bb6bc1785ea98456ab93c0507" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ "winapi", ] @@ -313,7 +319,7 @@ checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -331,15 +337,6 @@ dependencies = [ "libc", ] -[[package]] -name = "instant" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" -dependencies = [ - "cfg-if", -] - [[package]] name = "itertools" version = "0.10.3" @@ -372,16 +369,17 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.97" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "lock_api" -version = "0.4.4" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ + "autocfg", "scopeguard", ] @@ -411,33 +409,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.13" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "log", - "miow", - "ntapi", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", -] - -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", ] [[package]] @@ -473,27 +452,25 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.3" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", - "instant", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "smallvec", - "winapi", + "windows-targets", ] [[package]] @@ -552,7 +529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0d9cc07f18492d879586c92b485def06bc850da3118075cd45d50e9c95b0e5" dependencies = [ "bit-set", - "bitflags", + "bitflags 1.2.1", "byteorder", "lazy_static", "num-traits", @@ -665,7 +642,16 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" dependencies = [ - "bitflags", + "bitflags 1.2.1", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.2.1", ] [[package]] @@ -811,9 +797,9 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" [[package]] name = "signal-hook" -version = "0.3.9" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "470c5a6397076fae0094aaf06a08e6ba6f37acb77d3b1b91ea92b4d6c8650c39" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", "signal-hook-registry", @@ -821,9 +807,9 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fd5867f1c4f2c5be079aee7a2adf1152ebb04a4bc4d341f504b7dece607ed4" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", "mio", @@ -935,7 +921,7 @@ dependencies = [ "cfg-if", "libc", "rand", - "redox_syscall", + "redox_syscall 0.2.9", "remove_dir_all", "winapi", ] @@ -1079,6 +1065,12 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.82" @@ -1173,3 +1165,69 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/Cargo.toml b/Cargo.toml index deec4f1..cd02fcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ unicode-segmentation = "1.7" unicode-width = "0.1" clap = "2" smallvec = "1" -crossterm = "0.20" +crossterm = "0.27" gag = "1" time = "0.2" diff --git a/src/term_ui/mod.rs b/src/term_ui/mod.rs index 92bfcd1..df3217e 100644 --- a/src/term_ui/mod.rs +++ b/src/term_ui/mod.rs @@ -135,6 +135,8 @@ macro_rules! ui_loop { should_redraw = true; break; } + + _ => {} } // If too much time has passed since the last redraw, @@ -231,6 +233,7 @@ impl TermUI { KeyEvent { code: KeyCode::Char('q'), modifiers: KeyModifiers::CONTROL, + .. } => { self.quit = true; return (LoopStatus::Done, true); @@ -239,6 +242,7 @@ impl TermUI { KeyEvent { code: KeyCode::Char('s'), modifiers: KeyModifiers::CONTROL, + .. } => { self.editor.save_if_dirty().expect("For some reason the file couldn't be saved. Also, TODO: this code path shouldn't panic."); } @@ -246,6 +250,7 @@ impl TermUI { KeyEvent { code: KeyCode::Char('z'), modifiers: KeyModifiers::CONTROL, + .. } => { self.editor.undo(); } @@ -253,6 +258,7 @@ impl TermUI { KeyEvent { code: KeyCode::Char('y'), modifiers: KeyModifiers::CONTROL, + .. } => { self.editor.redo(); } @@ -260,6 +266,7 @@ impl TermUI { KeyEvent { code: KeyCode::Char('l'), modifiers: KeyModifiers::CONTROL, + .. } => { self.go_to_line_ui_loop(); } @@ -267,6 +274,7 @@ impl TermUI { KeyEvent { code: KeyCode::PageUp, modifiers: EMPTY_MOD, + .. } => { self.editor.page_up(); } @@ -274,6 +282,7 @@ impl TermUI { KeyEvent { code: KeyCode::PageDown, modifiers: EMPTY_MOD, + .. } => { self.editor.page_down(); } @@ -281,6 +290,7 @@ impl TermUI { KeyEvent { code: KeyCode::Up, modifiers: EMPTY_MOD, + .. } => { self.editor.cursor_up(1); } @@ -288,6 +298,7 @@ impl TermUI { KeyEvent { code: KeyCode::Up, modifiers: KeyModifiers::CONTROL, + .. } => { self.editor.cursor_up(8); } @@ -295,6 +306,7 @@ impl TermUI { KeyEvent { code: KeyCode::Down, modifiers: EMPTY_MOD, + .. } => { self.editor.cursor_down(1); } @@ -302,6 +314,7 @@ impl TermUI { KeyEvent { code: KeyCode::Down, modifiers: KeyModifiers::CONTROL, + .. } => { self.editor.cursor_down(8); } @@ -309,6 +322,7 @@ impl TermUI { KeyEvent { code: KeyCode::Left, modifiers: EMPTY_MOD, + .. } => { self.editor.cursor_left(1); } @@ -316,6 +330,7 @@ impl TermUI { KeyEvent { code: KeyCode::Right, modifiers: EMPTY_MOD, + .. } => { self.editor.cursor_right(1); } @@ -323,6 +338,7 @@ impl TermUI { KeyEvent { code: KeyCode::Enter, modifiers: EMPTY_MOD, + .. } => { let nl = line_ending_to_str(self.editor.line_ending_type); self.editor.insert_text_at_cursor(nl); @@ -331,6 +347,7 @@ impl TermUI { KeyEvent { code: KeyCode::Tab, modifiers: EMPTY_MOD, + .. } => { self.editor.insert_tab_at_cursor(); } @@ -338,6 +355,7 @@ impl TermUI { KeyEvent { code: KeyCode::Backspace, modifiers: EMPTY_MOD, + .. } => { self.editor.remove_text_behind_cursor(1); } @@ -345,6 +363,7 @@ impl TermUI { KeyEvent { code: KeyCode::Delete, modifiers: EMPTY_MOD, + .. } => { self.editor.remove_text_in_front_of_cursor(1); } @@ -353,6 +372,7 @@ impl TermUI { KeyEvent { code: KeyCode::Char(c), modifiers: EMPTY_MOD, + .. } => { self.editor.insert_text_at_cursor(&c.to_string()[..]); } @@ -399,6 +419,7 @@ impl TermUI { KeyEvent { code: KeyCode::Char('q'), modifiers: KeyModifiers::CONTROL, + .. } => { self.quit = true; return (LoopStatus::Done, true); @@ -407,6 +428,7 @@ impl TermUI { KeyEvent { code: KeyCode::Esc, modifiers: EMPTY_MOD, + .. } => { cancel = true; return (LoopStatus::Done, true); @@ -415,6 +437,7 @@ impl TermUI { KeyEvent { code: KeyCode::Enter, modifiers: EMPTY_MOD, + .. } => { return (LoopStatus::Done, true); } @@ -422,6 +445,7 @@ impl TermUI { KeyEvent { code: KeyCode::Backspace, modifiers: EMPTY_MOD, + .. } => { line.pop(); } @@ -430,6 +454,7 @@ impl TermUI { KeyEvent { code: KeyCode::Char(c), modifiers: EMPTY_MOD, + .. } => { if c.is_numeric() { line.push(c);