diff options
| author | Brooks J Rady <b.j.rady@gmail.com> | 2021-01-07 11:10:39 +0000 |
|---|---|---|
| committer | Brooks J Rady <b.j.rady@gmail.com> | 2021-01-07 11:10:39 +0000 |
| commit | 75136a613d8bdfc94e0c6f4e071cf050a7e2a231 (patch) | |
| tree | 2fad8fb26fb6b609cf7fdd9e672b794b1e1cb52c | |
| parent | Update description (diff) | |
| download | sl0ppij-75136a613d8bdfc94e0c6f4e071cf050a7e2a231.tar.gz sl0ppij-75136a613d8bdfc94e0c6f4e071cf050a7e2a231.tar.xz sl0ppij-75136a613d8bdfc94e0c6f4e071cf050a7e2a231.zip | |
Update deps and add a build script
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Cargo.toml | 9 | ||||
| -rwxr-xr-x | build-optimised.sh | 6 | ||||
| -rw-r--r-- | src/main.rs | 14 |
4 files changed, 21 insertions, 11 deletions
@@ -1,2 +1,3 @@ target/ -Cargo.lock
\ No newline at end of file +Cargo.lock +*.yaml
\ No newline at end of file @@ -1,6 +1,6 @@ [package] name = "module" -version = "0.1.0" +version = "0.2.0" authors = ["Brooks J Rady <b.j.rady@gmail.com>"] edition = "2018" description = "A simplified ranger clone written as a mosaic tile" @@ -9,5 +9,8 @@ license = "MIT" [dependencies] colored = "2" -mosaic-tile = "0.1" -pretty-bytes = "0.2"
\ No newline at end of file +mosaic-tile = "0.2" +pretty-bytes = "0.2" + +[profile.release] +lto = true
\ No newline at end of file diff --git a/build-optimised.sh b/build-optimised.sh new file mode 100755 index 00000000..e0654d89 --- /dev/null +++ b/build-optimised.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# Build a release WASM from Rust with lto on +cargo build --release +# Further optimise for speed (and size) +wasm-opt -O target/wasm32-wasi/release/module.wasm -o target/strider.wasm
\ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f48d07fc..beb57e39 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ impl MosaicTile for State { } fn draw(&mut self, rows: usize, cols: usize) { - for i in 0..rows - 1 { + for i in 0..rows { if self.selected() < self.scroll() { *self.scroll_mut() = self.selected(); } @@ -39,23 +39,23 @@ impl MosaicTile for State { } } - fn handle_key(&mut self, key: KeyEvent) { - match key.code { - KeyCode::Up => { + fn handle_key(&mut self, key: Key) { + match key { + Key::Up => { *self.selected_mut() = self.selected().saturating_sub(1); } - KeyCode::Down => { + Key::Down => { let next = self.selected().saturating_add(1); *self.selected_mut() = min(self.files.len() - 1, next); } - KeyCode::Right | KeyCode::Enter => match self.files[self.selected()].clone() { + Key::Right | Key::Char('\n') => match self.files[self.selected()].clone() { FsEntry::Dir(p, _) => { self.path = p; refresh_directory(self); } FsEntry::File(p, _) => open_file(&p), }, - KeyCode::Left => { + Key::Left => { self.path.pop(); refresh_directory(self); } |
