aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-01-11 19:00:31 +0000
committerBrooks J Rady <b.j.rady@gmail.com>2021-01-11 19:00:31 +0000
commiteb7a3fdf6034aa7119dea4e803136c44cfe7609e (patch)
treed091c5e701257102d5ea6f360b35177efddaae87
downloadsl0ppij-eb7a3fdf6034aa7119dea4e803136c44cfe7609e.tar.gz
sl0ppij-eb7a3fdf6034aa7119dea4e803136c44cfe7609e.tar.xz
sl0ppij-eb7a3fdf6034aa7119dea4e803136c44cfe7609e.zip
Keypress Debug Version
-rw-r--r--.cargo/config.toml2
-rw-r--r--.gitignore3
-rw-r--r--Cargo.toml13
-rw-r--r--LICENSE.md21
-rwxr-xr-xbuild-optimised.sh6
-rw-r--r--src/main.rs23
6 files changed, 68 insertions, 0 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 00000000..bc255e30
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,2 @@
+[build]
+target = "wasm32-wasi" \ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..b7a9cefc
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+target/
+Cargo.lock
+*.yaml \ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 00000000..5e37b20f
--- /dev/null
+++ b/Cargo.toml
@@ -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 \ No newline at end of file
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 00000000..0b264c31
--- /dev/null
+++ b/LICENSE.md
@@ -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.
diff --git a/build-optimised.sh b/build-optimised.sh
new file mode 100755
index 00000000..4e6cf764
--- /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/status-bar.wasm -o target/status-bar.wasm \ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 00000000..b820a18d
--- /dev/null
+++ b/src/main.rs
@@ -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);
+ }
+}