Update deps and add a build script

This commit is contained in:
Brooks J Rady 2021-01-07 11:10:39 +00:00
parent a57eadee8c
commit 75136a613d
4 changed files with 21 additions and 11 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
target/
Cargo.lock
Cargo.lock
*.yaml

View 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"
mosaic-tile = "0.2"
pretty-bytes = "0.2"
[profile.release]
lto = true

6
build-optimised.sh Executable file
View File

@ -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

View File

@ -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);
}