diff --git a/.gitignore b/.gitignore index 44709884..b7a9cefc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ -Cargo.lock \ No newline at end of file +Cargo.lock +*.yaml \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 7eab6a9a..0a5d298d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "module" -version = "0.1.0" +version = "0.2.0" authors = ["Brooks J Rady "] 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); }