Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
h1romas4 committed Oct 3, 2023
2 parents 639d37e + 60af23c commit b883caa
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
/target
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zellij-datetime"
version = "0.18.0"
version = "0.19.0"
authors = ["h1romas4 <[email protected]>"]
edition = "2021"

Expand Down
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ zellij 0.38.0
Preparation of Plug-in deployment destination:

```bash
# create configration directory
# create configuration directory
mkdir -p ~/.config/zellij/layouts/
mkdir -p ~/.config/zellij/plugins/
# If you have already created a layout file, you do not need to do the following.
# export default layaut (Be careful not to overwrite your settings)
# export default layout (Be careful not to overwrite your settings)
zellij setup --dump-layout default > ~/.config/zellij/layouts/default.kdl
```
[Download zellij-datetime.wasm](https://github.com/h1romas4/zellij-datetime/releases/latest/download/zellij-datetime.wasm):
Expand Down Expand Up @@ -103,7 +103,7 @@ layout {
| `arrow_separator1` | `"string"` | `""` | Delimiter string on line. Only the first character. |
| `arrow_separator2` | `"string"` | `""` | 📅 Only the first character. |
| `arrow_separator3` | `"string"` | `""` | ⌚ Only the first character. |
| `padding_adjust` | `i32` | `0` | It can be used to adjust left-justified padding. For example, adjusting the separator width if it is off by full-width. |
| `padding_adjust` | i32 | `0` | It can be used to adjust left-justified padding. For example, adjusting the separator width if it is off by full-width. |
| `text_align` | `"string"` | `"right"` | `right` or `left` or `center` |

## Build
Expand All @@ -129,7 +129,7 @@ Production
cargo install wasm-snip
# Build
cargo build --release
# Remove debug symbles and replaces unreachable.
# Remove debug symbols and replaces unreachable.
wasm-snip target/wasm32-wasi/release/zellij-datetime.wasm -o target/wasm32-wasi/release/zellij-datetime-snip.wasm
# Deploy plugin directory
cp -p target/wasm32-wasi/release/zellij-datetime-snip.wasm ~/.config/zellij/plugins/zellij-datetime.wasm
Expand All @@ -153,7 +153,15 @@ cargo xtask build --release
cd ../zellij-datetime
cargo build
# Run with container (podman or docker)
podman run --name zellij-datetime --env SHELL=/usr/bin/bash -v ../zellij/target/release/:/opt/zellij -v .:/opt/zellij-datetime -w /opt/zellij-datetime -it --rm ubuntu:22.04 /opt/zellij/zellij -l plugin.kb
podman run \
--name zellij-datetime \
--env SHELL=/usr/bin/bash \
-v ../zellij/target/release/:/opt/zellij \
-v .:/opt/zellij-datetime \
-w /opt/zellij-datetime \
-it --rm \
ubuntu:22.04 \
/opt/zellij/zellij -l plugin.kb
```

## License
Expand All @@ -176,7 +184,7 @@ MIT License

### Operation log in riscv64

At this time, RISC-V is not yet supported in Wasmer 2.3 used by Zellij. RISC-V has been supported since Wasmer 3.2.
At this time, RISC-V is not yet supported in Wasmer 3.1.1 used by Zellij. RISC-V has been supported since Wasmer 3.2.

```bash
$ uname -a
Expand Down
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static DEFAULT_TEXT_ALIGN: &str = "right";
pub struct Config {
timezone: LinkedHashMap<String, i32>,
default_timezone: String,
backgound_color: (u8, u8, u8),
background_color: (u8, u8, u8),
foreground_color: (u8, u8, u8),
pane_color: (u8, u8, u8),
enable_right_click: bool,
Expand All @@ -33,7 +33,7 @@ impl Default for Config {
Config {
timezone,
default_timezone: default_timezone.to_string(),
backgound_color: parse_color(DEFAULT_BACKGROUND_COLOR).unwrap(),
background_color: parse_color(DEFAULT_BACKGROUND_COLOR).unwrap(),
foreground_color: parse_color(DEFAULT_FOREGROUND_COLOR).unwrap(),
pane_color: parse_color(DEFAULT_PANE_COLOR).unwrap(),
enable_right_click: false,
Expand Down Expand Up @@ -91,8 +91,8 @@ impl Config {
}
}

pub fn get_backgound_color(&self) -> (u8, u8, u8) {
self.backgound_color
pub fn get_background_color(&self) -> (u8, u8, u8) {
self.background_color
}

pub fn get_foreground_color(&self) -> (u8, u8, u8) {
Expand Down Expand Up @@ -145,7 +145,7 @@ impl Config {
}
"background_color" => {
if let Ok(color) = parse_color(value) {
self.backgound_color = (color.0, color.1, color.2);
self.background_color = (color.0, color.1, color.2);
}
}
"foreground_color" => {
Expand Down
17 changes: 9 additions & 8 deletions src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use zellij_tile_utils::style;

#[derive(Default)]
pub struct Line {
backgound_color: PaletteColor,
background_color: PaletteColor,
foreground_color: PaletteColor,
pane_color: PaletteColor,
separator: (String, String, String),
Expand All @@ -27,15 +27,15 @@ impl Default for TextAlign {
impl Line {
pub fn update_style(
&mut self,
backgound_color: (u8, u8, u8),
background_color: (u8, u8, u8),
foreground_color: (u8, u8, u8),
pane_color: (u8, u8, u8),
separator: &(String, String, String),
padding_adjust: i32,
text_align: &str,
) {
// set color
self.backgound_color = PaletteColor::Rgb(backgound_color);
self.background_color = PaletteColor::Rgb(background_color);
self.foreground_color = PaletteColor::Rgb(foreground_color);
self.pane_color = PaletteColor::Rgb(pane_color);
// text align
Expand All @@ -45,9 +45,9 @@ impl Line {
"center" => TextAlign::Center,
_ => TextAlign::Right,
};
// create charctor
// create character
let bg_1 = self.pane_color;
let bg_2 = self.backgound_color;
let bg_2 = self.background_color;
let space = &style!(bg_2, bg_2).paint(" ").to_string();
let sep_1 = &style!(bg_2, bg_1).bold().paint(&separator.0).to_string();
let sep_2 = &style!(bg_1, bg_2).bold().paint(&separator.1).to_string();
Expand Down Expand Up @@ -93,6 +93,7 @@ impl Line {
let padding: String = if cols as isize - width as isize > 0 {
let size = match self.text_align {
TextAlign::Right | TextAlign::Left => cols - width,
// TODO: Incorrect calculation for odd-numbered characters.
TextAlign::Center => (cols - width) / 2,
};
let space = " ".repeat(size);
Expand All @@ -103,9 +104,9 @@ impl Line {
String::new()
};

let timezone = style!(self.foreground_color, self.backgound_color).paint(timezone);
let date = style!(self.foreground_color, self.backgound_color).paint(date);
let time = style!(self.foreground_color, self.backgound_color).paint(time);
let timezone = style!(self.foreground_color, self.background_color).paint(timezone);
let date = style!(self.foreground_color, self.background_color).paint(date);
let time = style!(self.foreground_color, self.background_color).paint(time);

match self.text_align {
TextAlign::Right => {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl ZellijPlugin for State {
self.config.configuration(&configuration);
self.reset_default_timezone();
self.line.update_style(
self.config.get_backgound_color(),
self.config.get_background_color(),
self.config.get_foreground_color(),
self.config.get_pane_color(),
self.config.get_separator(),
Expand Down

0 comments on commit b883caa

Please sign in to comment.