diff options
| author | Jonah Caplan <jonahcaplan@gmail.com> | 2021-02-20 18:19:05 -0500 |
|---|---|---|
| committer | Jonah Caplan <jonahcaplan@gmail.com> | 2021-02-25 01:44:10 -0500 |
| commit | ce54127d7de314e683ed0fefd8be987bbc47e369 (patch) | |
| tree | 0fd91434af3477f9b7c16a61b822537a18abcca2 /default-tiles | |
| parent | Make fullscreen panes not override the status bar and strider (#209) (diff) | |
| download | sl0ppij-ce54127d7de314e683ed0fefd8be987bbc47e369.tar.gz sl0ppij-ce54127d7de314e683ed0fefd8be987bbc47e369.tar.xz sl0ppij-ce54127d7de314e683ed0fefd8be987bbc47e369.zip | |
add basic tab bar #166
Diffstat (limited to 'default-tiles')
| -rw-r--r-- | default-tiles/tab-bar/.cargo/config.toml | 2 | ||||
| -rw-r--r-- | default-tiles/tab-bar/Cargo.toml | 10 | ||||
| l--------- | default-tiles/tab-bar/LICENSE.md | 1 | ||||
| -rw-r--r-- | default-tiles/tab-bar/src/main.rs | 40 |
4 files changed, 53 insertions, 0 deletions
diff --git a/default-tiles/tab-bar/.cargo/config.toml b/default-tiles/tab-bar/.cargo/config.toml new file mode 100644 index 00000000..6b77899c --- /dev/null +++ b/default-tiles/tab-bar/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +target = "wasm32-wasi" diff --git a/default-tiles/tab-bar/Cargo.toml b/default-tiles/tab-bar/Cargo.toml new file mode 100644 index 00000000..1a0c5f78 --- /dev/null +++ b/default-tiles/tab-bar/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "tab-bar" +version = "0.1.0" +authors = ["Jonah Caplan <jonahcaplan@gmail.com>"] +edition = "2018" +license = "MIT" + +[dependencies] +colored = "2" +zellij-tile = { path = "../../zellij-tile" } diff --git a/default-tiles/tab-bar/LICENSE.md b/default-tiles/tab-bar/LICENSE.md new file mode 120000 index 00000000..f0608a63 --- /dev/null +++ b/default-tiles/tab-bar/LICENSE.md @@ -0,0 +1 @@ +../../LICENSE.md
\ No newline at end of file diff --git a/default-tiles/tab-bar/src/main.rs b/default-tiles/tab-bar/src/main.rs new file mode 100644 index 00000000..78a57aca --- /dev/null +++ b/default-tiles/tab-bar/src/main.rs @@ -0,0 +1,40 @@ +use colored::*; +use zellij_tile::*; + +#[derive(Default)] +struct State { + active_tab_index: usize, + num_tabs: usize, +} + +register_tile!(State); + +impl ZellijTile for State { + fn init(&mut self) { + set_selectable(false); + set_invisible_borders(true); + set_max_height(1); + self.active_tab_index = 0; + self.num_tabs = 0; + } + + fn draw(&mut self, _rows: usize, _cols: usize) { + let mut s = String::new(); + let active_tab = self.active_tab_index + 1; + for i in 1..=self.num_tabs { + let tab; + if i == active_tab { + tab = format!("*{} ", i).black().bold().on_magenta(); + } else { + tab = format!("-{} ", i).white(); + } + s = format!("{}{}", s, tab); + } + println!("Tabs: {}\u{1b}[40m\u{1b}[0K", s); + } + + fn update_tabs(&mut self, active_tab_index: usize, num_tabs: usize) { + self.active_tab_index = active_tab_index; + self.num_tabs = num_tabs; + } +} |
