Keypress Debug Version
This commit is contained in:
commit
eb7a3fdf60
6 changed files with 68 additions and 0 deletions
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[build]
|
||||||
|
target = "wasm32-wasi"
|
||||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
target/
|
||||||
|
Cargo.lock
|
||||||
|
*.yaml
|
||||||
13
Cargo.toml
Normal file
13
Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
[package]
|
||||||
|
name = "status-bar"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Brooks J Rady <b.j.rady@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
colored = "2"
|
||||||
|
mosaic-tile = { path = "/home/spinning/tll/Documents/Coding/Languages/Rust/mosaic-tile"}
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 Mosaic contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
6
build-optimised.sh
Executable file
6
build-optimised.sh
Executable 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/status-bar.wasm -o target/status-bar.wasm
|
||||||
23
src/main.rs
Normal file
23
src/main.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
use colored::*;
|
||||||
|
use mosaic_tile::*;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct State(usize, String);
|
||||||
|
|
||||||
|
register_tile!(State);
|
||||||
|
|
||||||
|
impl MosaicTile for State {
|
||||||
|
fn init(&mut self) {
|
||||||
|
set_selectable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw(&mut self, _rows: usize, cols: usize) {
|
||||||
|
let line = format!("{}: {}", self.0, self.1);
|
||||||
|
println!("{:cols$}", line.reversed(), cols = cols);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_global_key(&mut self, key: Key) {
|
||||||
|
self.0 += 1;
|
||||||
|
self.1 = format!("{:?}", key);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue