diff --git a/Cargo.lock b/Cargo.lock index fb47390..9eed12e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -281,9 +281,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "byteorder" @@ -1022,9 +1022,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b085a4f2cde5781fc4b1717f2e86c62f5cda49de7ba99a7c2eae02b61c9064c" +checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "lock_api" @@ -1293,9 +1293,9 @@ dependencies = [ [[package]] name = "ordered-float" -version = "3.6.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13a384337e997e6860ffbaa83708b2ef329fd8c54cb67a5f64d421e0f943254f" +checksum = "2fc2dbde8f8a79f2102cc474ceb0ad68e3b80b85289ea62389b60e66777e4213" dependencies = [ "num-traits", ] @@ -1589,9 +1589,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac6cf59af1067a3fb53fbe5c88c053764e930f932be1d71d3ffe032cbe147f59" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ "aho-corasick", "memchr", @@ -1600,9 +1600,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6868896879ba532248f33598de5181522d8b3d9d724dfd230911e1a7d4822f5" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "rmp" @@ -1643,9 +1643,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.13" +version = "0.37.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79bef90eb6d984c72722595b5b1348ab39275a5e5123faca6863bf07d75a4e0" +checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" dependencies = [ "bitflags", "errno", @@ -2006,7 +2006,7 @@ dependencies = [ "nix 0.24.3", "num-derive", "num-traits", - "ordered-float 3.6.0", + "ordered-float 3.7.0", "pest", "pest_derive", "phf 0.10.1", @@ -2377,7 +2377,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75e78c0cc60a76de5d93f9dad05651105351e151b6446ab305514945d7588aa" dependencies = [ "log", - "ordered-float 3.6.0", + "ordered-float 3.7.0", "strsim", "thiserror", "wezterm-dynamic-derive", @@ -2577,7 +2577,7 @@ dependencies = [ [[package]] name = "zellij-datetime" -version = "0.4.2" +version = "0.5.0" dependencies = [ "ansi_term", "chrono-wasi", diff --git a/Cargo.toml b/Cargo.toml index 7fcfb03..8dc411b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "zellij-datetime" -version = "0.4.2" +version = "0.5.0" authors = ["h1romas4 "] edition = "2021" [dependencies] -zellij-tile = "^0.36.0" -zellij-tile-utils = "0.36.0" -ansi_term = "0.12" -chrono-wasi = "0.4.11" +zellij-tile = "^0.36" +zellij-tile-utils = "^0.36" +ansi_term = "^0.12" +chrono-wasi = "^0.4" diff --git a/README.md b/README.md index 00b5b7f..c7673fe 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ zellij setup --dump-layout default > ~/.config/zellij/layouts/default.kdl # deploy plugin .wasm cd ~/.config/zellij/plugins/ # download datetime plugin -wget https://github.com/h1romas4/zellij-datetime/releases/download/v0.4.2/zellij-datetime.wasm +wget https://github.com/h1romas4/zellij-datetime/releases/download/v0.5.0/zellij-datetime.wasm ``` ## Usage diff --git a/src/main.rs b/src/main.rs index 63cc5cb..d4c1723 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use zellij_tile_utils::style; // FIXME: UTC+9 static TIMEZONE_OFFSET: i32 = 9; -// Dark gray +// FIXME: DateTime backgorund color static DATETIME_BG_COLOR: (u8, u8, u8) = (32, 32, 32); static ARROW_SEPARATOR_1: &str = ""; @@ -33,11 +33,7 @@ register_plugin!(State); impl ZellijPlugin for State { fn load(&mut self) { set_selectable(false); - subscribe(&[ - EventType::Timer, - EventType::Visible, - EventType::ModeUpdate, - ]); + subscribe(&[EventType::Timer, EventType::Visible, EventType::ModeUpdate]); self.before_now = u32::MAX; } @@ -55,8 +51,7 @@ impl ZellijPlugin for State { // TODO: suport timezone or add plugin setting // Timezone may not be obtained by WASI. // let now = Local::now(); - let now = Utc::now() - .with_timezone(&FixedOffset::east(TIMEZONE_OFFSET * 3600)); + let now = Utc::now().with_timezone(&FixedOffset::east(TIMEZONE_OFFSET * 3600)); // render at 1 minute intervals. let now_minute = now.minute(); if self.before_now != now_minute { @@ -70,7 +65,6 @@ impl ZellijPlugin for State { } Event::ModeUpdate(mode_info) => { if self.mode_info != mode_info { - render = true; self.mode_update = true; self.mode_info = mode_info; } @@ -88,24 +82,21 @@ impl ZellijPlugin for State { self.pallet_fg = self.mode_info.style.colors.fg; self.pallet_bg = self.mode_info.style.colors.bg; self.datetime_bg_color = PaletteColor::Rgb(DATETIME_BG_COLOR); - // create line string let bg1 = self.pallet_bg; let bg2 = self.datetime_bg_color; + // create charctor + let arrow = &style!(bg2, bg2).bold().paint(ARROW_SPACE).to_string(); + let sep_1 = &style!(bg2, bg1).bold().paint(ARROW_SEPARATOR_1).to_string(); + let sep_2 = &style!(bg1, bg2).bold().paint(ARROW_SEPARATOR_2).to_string(); self.lp_1 = String::new(); - self.lp_1 - .push_str(&style!(bg2, bg1).bold().paint(ARROW_SEPARATOR_1).to_string()); - self.lp_1 - .push_str(&style!(bg2, bg2).bold().paint(ARROW_SPACE).to_string()); + self.lp_1.push_str(sep_1); + self.lp_1.push_str(arrow); self.lp_2 = String::new(); - self.lp_2 - .push_str(&style!(bg2, bg2).bold().paint(ARROW_SPACE).to_string()); - self.lp_2 - .push_str(&style!(bg1, bg2).bold().paint(ARROW_SEPARATOR_2).to_string()); - self.lp_2 - .push_str(&style!(bg2, bg2).bold().paint(ARROW_SPACE).to_string()); + self.lp_2.push_str(arrow); + self.lp_2.push_str(sep_2); + self.lp_2.push_str(arrow); self.lp_3 = String::new(); - self.lp_3 - .push_str(&style!(bg2, bg2).bold().paint(ARROW_SPACE).to_string()); + self.lp_3.push_str(arrow); self.mode_update = false; } @@ -131,7 +122,9 @@ impl ZellijPlugin for State { if cols as isize - width as isize > 0 { // only half width char let padding = ARROW_SPACE.repeat(cols - width); - self.padding = style!(self.pallet_fg, self.pallet_bg).paint(padding).to_string(); + self.padding = style!(self.pallet_fg, self.pallet_bg) + .paint(padding) + .to_string(); } else { self.padding = String::new(); }