Well, it turns out that I spent 4 hours on something impossible...

This commit is contained in:
Brooks J Rady 2021-02-09 22:19:34 +00:00
parent 678a6f877c
commit 9791970856
1398 changed files with 579 additions and 37870 deletions

87
Cargo.lock generated
View File

@ -311,15 +311,14 @@ dependencies = [
[[package]]
name = "console"
version = "0.11.3"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c0994e656bba7b922d8dd1245db90672ffb701e684e45be58f20719d69abc5a"
checksum = "7cc80946b3480f421c2f17ed1cb841753a371c7c5104f51d507e13f532c856aa"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"terminal_size",
"termios",
"winapi",
]
@ -494,12 +493,6 @@ dependencies = [
"syn",
]
[[package]]
name = "difference"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
[[package]]
name = "directories-next"
version = "2.0.0"
@ -826,16 +819,17 @@ dependencies = [
[[package]]
name = "insta"
version = "0.16.1"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "617e921abc813f96a3b00958c079e7bf1e2db998f8a04f1546dd967373a418ee"
checksum = "6b0d4f10636e7b40bf9eb71ecaf660498a120a86e9251bd4dea72a64ce9b8a93"
dependencies = [
"console",
"difference",
"lazy_static",
"serde",
"serde_json",
"serde_yaml",
"similar",
"uuid",
]
[[package]]
@ -1043,15 +1037,14 @@ dependencies = [
[[package]]
name = "nix"
version = "0.17.0"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2"
dependencies = [
"bitflags",
"cc",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"libc",
"void",
]
[[package]]
@ -1360,6 +1353,15 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
@ -1447,6 +1449,12 @@ dependencies = [
"libc",
]
[[package]]
name = "similar"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da916d7c5876bff6fbf5794bd1e64aba8f5f110b76b192d80bb264423c0736f6"
[[package]]
name = "slab"
version = "0.4.2"
@ -1667,6 +1675,15 @@ dependencies = [
"winapi",
]
[[package]]
name = "toml"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [
"serde",
]
[[package]]
name = "tracing"
version = "0.1.23"
@ -1732,9 +1749,9 @@ checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
[[package]]
name = "unicode-truncate"
version = "0.1.1"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ac822301b0f9f2c2e60509da419b2401a5dc480c784e951ac6bebeee16a7beb"
checksum = "a04be5ca5f7a4a7270ffea82bc41c59b87c611ed04f20e77c338e8d3c2348e42"
dependencies = [
"unicode-width",
]
@ -1763,6 +1780,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372"
[[package]]
name = "uuid"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
[[package]]
name = "value-bag"
version = "1.0.0-alpha.6"
@ -1790,12 +1813,6 @@ version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "vte"
version = "0.3.3"
@ -1832,6 +1849,17 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
[[package]]
name = "walkdir"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
dependencies = [
"same-file",
"winapi",
"winapi-util",
]
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
@ -2167,6 +2195,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@ -2213,9 +2250,11 @@ dependencies = [
"strum_macros",
"termion",
"termios",
"toml",
"unicode-truncate",
"unicode-width",
"vte 0.8.0",
"walkdir",
"wasmer",
"wasmer-wasi",
]

View File

@ -1,9 +1,72 @@
[package]
name = "zellij"
version = "0.1.0"
authors = ["Aram Drevekenin <aram@poor.dev>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
backtrace = "0.3.55"
bincode = "1.3.1"
directories-next = "2.0"
futures = "0.3.5"
libc = "0.2"
nix = "0.19.1"
nom = "6.0.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.8"
signal-hook = "0.1.10"
strip-ansi-escapes = "0.1.0"
structopt = "0.3"
termion = { git = "https://gitlab.com/TheLostLambda/termion.git", features = ["serde"] }
termios = "0.3"
unicode-truncate = "0.2.0"
unicode-width = "0.1.8"
vte = "0.8.0"
strum = "0.20.0"
strum_macros = "0.20.0"
lazy_static = "1.4.0"
wasmer = "1.0.0"
wasmer-wasi = "1.0.0"
interprocess = "1.0.1"
[dependencies.async-std]
version = "1.3.0"
features = ["unstable"]
[dev-dependencies]
insta = "1.6.0"
[build-dependencies]
directories-next = "2.0"
structopt = "0.3"
walkdir = "2"
toml = "0.5.8"
[workspace]
members = [
"zellij",
"zellij-tile",
"default-tiles/*",
"default-tiles/status-bar",
"default-tiles/strider",
]
[profile.release]
lto = true
[package.metadata.deb]
depends = "$auto"
license-file = ["LICENSE.md", "4"]
assets = [
# TODO?
# ["assets/man/mosaic.1", "usr/share/man/man1/mosaic.1", "644"],
["target/release/mosaic", "usr/bin/mosaic", "755"],
["GOVERNANCE.md", "usr/share/doc/mosaic/GOVERNANCE.md", "644"],
["README.md", "usr/share/doc/mosaic/README.md", "644"],
["assets/layouts/*", "usr/share/mosaic/layouts/", "644"],
["assets/plugins/*", "usr/share/mosaic/plugins/", "644"],
["assets/completions/mosaic.bash", "usr/share/bash-completion/completions/mosaic.bash", "644"],
["assets/completions/mosaic.fish", "usr/share/fish/vendor_completions.d/mosaic.fish", "644"],
["assets/completions/_mosaic", "usr/share/zsh/vendor-completions/_mosaic", "644"],
]

View File

@ -1,8 +1,8 @@
#compdef mosaic
#compdef zellij
autoload -U is-at-least
_mosaic() {
_zellij() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1
@ -34,12 +34,12 @@ _mosaic() {
}
(( $+functions[_mosaic_commands] )) ||
_mosaic_commands() {
(( $+functions[_zellij_commands] )) ||
_zellij_commands() {
local commands; commands=(
)
_describe -t commands 'mosaic commands' commands "$@"
_describe -t commands 'zellij commands' commands "$@"
}
_mosaic "$@"
_zellij "$@"

View File

@ -1,4 +1,4 @@
_mosaic() {
_zellij() {
local i cur prev opts cmds
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
@ -9,8 +9,8 @@ _mosaic() {
for i in ${COMP_WORDS[@]}
do
case "${i}" in
mosaic)
cmd="mosaic"
zellij)
cmd="zellij"
;;
*)
@ -19,7 +19,7 @@ _mosaic() {
done
case "${cmd}" in
mosaic)
zellij)
opts=" -m -d -h -V -s -o -l --move-focus --debug --help --version --split --open-file --max-panes --layout "
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
@ -66,4 +66,4 @@ _mosaic() {
esac
}
complete -F _mosaic -o bashdefault -o default mosaic
complete -F _zellij -o bashdefault -o default zellij

View File

@ -0,0 +1,8 @@
complete -c zellij -n "__fish_use_subcommand" -s s -l split -d 'Send "split (direction h == horizontal / v == vertical)" to active mosaic session'
complete -c zellij -n "__fish_use_subcommand" -s o -l open-file -d 'Send "open file in new pane" to active mosaic session'
complete -c zellij -n "__fish_use_subcommand" -l max-panes -d 'Maximum panes on screen, caution: opening more panes will close old ones'
complete -c zellij -n "__fish_use_subcommand" -s l -l layout -d 'Path to a layout yaml file'
complete -c zellij -n "__fish_use_subcommand" -s m -l move-focus -d 'Send "move focused pane" to active mosaic session'
complete -c zellij -n "__fish_use_subcommand" -s d -l debug
complete -c zellij -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
complete -c zellij -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'

View File

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 3.4 MiB

View File

Before

Width:  |  Height:  |  Size: 213 KiB

After

Width:  |  Height:  |  Size: 213 KiB

84
build.rs Normal file
View File

@ -0,0 +1,84 @@
use directories_next::ProjectDirs;
use std::{env::*, fs, path::Path, process::Command};
use structopt::clap::Shell;
use toml::Value;
use walkdir::WalkDir;
include!("src/cli.rs");
const BIN_NAME: &str = "zellij";
fn main() {
// Build Sub-Projects (Temporary?)
for entry in WalkDir::new(".") {
let entry = entry.unwrap();
let ext = entry.path().extension();
if ext.is_some() && ext.unwrap() == "rs" {
println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy());
}
}
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let manifest: Value =
toml::from_str(&fs::read_to_string(manifest_dir.join("Cargo.toml")).unwrap()).unwrap();
let members = manifest
.get("workspace")
.unwrap()
.get("members")
.unwrap()
.as_array()
.unwrap();
let release = if var("PROFILE").unwrap() == "release" {
"--release"
} else {
""
};
let starting_dir = current_dir().unwrap();
for project in members {
let path = manifest_dir.join(project.as_str().unwrap());
set_current_dir(&path);
if var("PROFILE").unwrap() == "release" {
panic!("no");
Command::new("cargo").arg("build").arg("--release").status();
} else {
Command::new("cargo").arg("build").status();
}
eprintln!("{:?}", &path);
}
set_current_dir(&starting_dir);
// Generate Shell Completions
let mut clap_app = CliArgs::clap();
println!("cargo:rerun-if-changed=src/cli.rs");
let mut out_dir = std::env::var_os("CARGO_MANIFEST_DIR").unwrap();
out_dir.push("/assets/completions");
println!(
"Completion files will to added to this location: {:?}",
out_dir
);
fs::create_dir_all(&out_dir).unwrap();
clap_app.gen_completions(BIN_NAME, Shell::Bash, &out_dir);
clap_app.gen_completions(BIN_NAME, Shell::Zsh, &out_dir);
clap_app.gen_completions(BIN_NAME, Shell::Fish, &out_dir);
// Install Default Plugins and Layouts
let assets = vec![
"plugins/status-bar.wasm",
"plugins/strider.wasm",
"layouts/default.yaml",
"layouts/strider.yaml",
];
let project_dirs = ProjectDirs::from("org", "Mosaic Contributors", "Mosaic").unwrap();
let data_dir = project_dirs.data_dir();
fs::create_dir_all(data_dir.join("plugins")).unwrap();
fs::create_dir_all(data_dir.join("layouts")).unwrap();
for asset in assets {
println!("cargo:rerun-if-changed=assets/{}", asset);
fs::copy(Path::new("assets/").join(asset), data_dir.join(asset))
.expect("Failed to copy asset files");
}
}

View File

@ -1,6 +1,6 @@
use colored::*;
use std::fmt::{Display, Error, Formatter};
use zellij_tile::*;
use std::fmt::{Display, Formatter, Error};
// for more of these, copy paste from: https://en.wikipedia.org/wiki/Box-drawing_character
static ARROW_SEPARATOR: &str = "";
@ -22,7 +22,6 @@ impl Display for LinePart {
}
}
fn prefix(help: &Help) -> LinePart {
let prefix_text = " Mosaic ";
let part = match (&help.mode, help.mode_is_persistent) {
@ -48,10 +47,7 @@ fn prefix(help: &Help) -> LinePart {
}
};
let len = prefix_text.chars().count() + ARROW_SEPARATOR.chars().count();
LinePart {
part,
len
}
LinePart { part, len }
}
fn key_path(help: &Help) -> LinePart {
@ -61,7 +57,9 @@ fn key_path(help: &Help) -> LinePart {
(InputMode::Command, false) => {
let key_path = superkey_text.bold().on_magenta();
let first_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count() + ARROW_SEPARATOR.chars().count() + ARROW_SEPARATOR.chars().count();
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count();
(format!("{}{}", key_path, first_separator), len)
}
(InputMode::Command, true) => {
@ -69,8 +67,16 @@ fn key_path(help: &Help) -> LinePart {
let locked_separator = ARROW_SEPARATOR.yellow().on_magenta();
let key_path = superkey_text.bold().on_magenta();
let superkey_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count() + ARROW_SEPARATOR.chars().count() + locked_text.chars().count();
(format!("{}{}{}{}", locked, locked_separator, key_path, superkey_separator), len)
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ locked_text.chars().count();
(
format!(
"{}{}{}{}",
locked, locked_separator, key_path, superkey_separator
),
len,
)
}
(InputMode::Resize, false) => {
let mode_shortcut_text = "r ";
@ -79,12 +85,22 @@ fn key_path(help: &Help) -> LinePart {
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
ARROW_SEPARATOR.chars().count() +
mode_shortcut_text.chars().count() +
ARROW_SEPARATOR.chars().count();
(format!("{}{}{}{}{}", superkey, first_superkey_separator, second_superkey_separator, mode_shortcut, mode_shortcut_separator), len)
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}",
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
(InputMode::Resize, true) => {
let mode_shortcut_text = "r ";
@ -95,14 +111,26 @@ fn key_path(help: &Help) -> LinePart {
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = locked_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
superkey_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
ARROW_SEPARATOR.chars().count() +
mode_shortcut_text.chars().count() +
ARROW_SEPARATOR.chars().count();
(format!("{}{}{}{}{}{}{}", locked, locked_separator, superkey, first_superkey_separator, second_superkey_separator, mode_shortcut, mode_shortcut_separator), len)
let len = locked_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}{}{}",
locked,
locked_separator,
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
(InputMode::Pane, false) => {
let mode_shortcut_text = "p ";
@ -111,12 +139,22 @@ fn key_path(help: &Help) -> LinePart {
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
ARROW_SEPARATOR.chars().count() +
mode_shortcut_text.chars().count() +
ARROW_SEPARATOR.chars().count();
(format!("{}{}{}{}{}", superkey, first_superkey_separator, second_superkey_separator, mode_shortcut, mode_shortcut_separator), len)
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}",
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
(InputMode::Pane, true) => {
let mode_shortcut_text = "p ";
@ -127,14 +165,26 @@ fn key_path(help: &Help) -> LinePart {
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = locked_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
superkey_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
ARROW_SEPARATOR.chars().count() +
mode_shortcut_text.chars().count() +
ARROW_SEPARATOR.chars().count();
(format!("{}{}{}{}{}{}{}", locked, locked_separator, superkey, first_superkey_separator, second_superkey_separator, mode_shortcut, mode_shortcut_separator), len)
let len = locked_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}{}{}",
locked,
locked_separator,
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
(InputMode::Tab, false) => {
let mode_shortcut_text = "t ";
@ -143,12 +193,22 @@ fn key_path(help: &Help) -> LinePart {
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
ARROW_SEPARATOR.chars().count() +
mode_shortcut_text.chars().count() +
ARROW_SEPARATOR.chars().count();
(format!("{}{}{}{}{}", superkey, first_superkey_separator, second_superkey_separator, mode_shortcut, mode_shortcut_separator), len)
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}",
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
(InputMode::Tab, true) => {
let mode_shortcut_text = "t ";
@ -159,14 +219,26 @@ fn key_path(help: &Help) -> LinePart {
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = locked_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
superkey_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
ARROW_SEPARATOR.chars().count() +
mode_shortcut_text.chars().count() +
ARROW_SEPARATOR.chars().count();
(format!("{}{}{}{}{}{}{}", locked, locked_separator, superkey, first_superkey_separator, second_superkey_separator, mode_shortcut, mode_shortcut_separator), len)
let len = locked_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}{}{}",
locked,
locked_separator,
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
(InputMode::Scroll, false) => {
let mode_shortcut_text = "s ";
@ -175,12 +247,22 @@ fn key_path(help: &Help) -> LinePart {
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = superkey_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
ARROW_SEPARATOR.chars().count() +
mode_shortcut_text.chars().count() +
ARROW_SEPARATOR.chars().count();
(format!("{}{}{}{}{}", superkey, first_superkey_separator, second_superkey_separator, mode_shortcut, mode_shortcut_separator), len)
let len = superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}",
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
(InputMode::Scroll, true) => {
let mode_shortcut_text = "s ";
@ -191,36 +273,52 @@ fn key_path(help: &Help) -> LinePart {
let second_superkey_separator = ARROW_SEPARATOR.black().on_magenta();
let mode_shortcut = mode_shortcut_text.white().bold().on_magenta();
let mode_shortcut_separator = ARROW_SEPARATOR.magenta().on_black();
let len = locked_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
superkey_text.chars().count() +
ARROW_SEPARATOR.chars().count() +
ARROW_SEPARATOR.chars().count() +
mode_shortcut_text.chars().count() +
ARROW_SEPARATOR.chars().count();
(format!("{}{}{}{}{}{}{}", locked, locked_separator, superkey, first_superkey_separator, second_superkey_separator, mode_shortcut, mode_shortcut_separator), len)
let len = locked_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ superkey_text.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ ARROW_SEPARATOR.chars().count()
+ mode_shortcut_text.chars().count()
+ ARROW_SEPARATOR.chars().count();
(
format!(
"{}{}{}{}{}{}{}",
locked,
locked_separator,
superkey,
first_superkey_separator,
second_superkey_separator,
mode_shortcut,
mode_shortcut_separator
),
len,
)
}
(InputMode::Normal, _) | _ => {
let key_path = superkey_text.on_green();
let separator = ARROW_SEPARATOR.green().on_black();
(format!("{}{}", key_path, separator), superkey_text.chars().count() + ARROW_SEPARATOR.chars().count())
(
format!("{}{}", key_path, separator),
superkey_text.chars().count() + ARROW_SEPARATOR.chars().count(),
)
}
};
LinePart {
part,
len
}
LinePart { part, len }
}
fn keybinds(help: &Help, max_width: usize) -> LinePart {
let mut keybinds = String::new();
let mut len = 0;
let full_keybinds_len = help.keybinds.iter().enumerate().fold(0, |acc, (i, (shortcut, description))| {
let shortcut_length = shortcut.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let description_length = description.chars().count() + 2;
let (_separator, separator_len) = if i > 0 { (" / ", 3) } else { ("", 0) };
acc + shortcut_length + description_length + separator_len
});
let full_keybinds_len =
help.keybinds
.iter()
.enumerate()
.fold(0, |acc, (i, (shortcut, description))| {
let shortcut_length = shortcut.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let description_length = description.chars().count() + 2;
let (_separator, separator_len) = if i > 0 { (" / ", 3) } else { ("", 0) };
acc + shortcut_length + description_length + separator_len
});
if full_keybinds_len < max_width {
for (i, (shortcut, description)) in help.keybinds.iter().enumerate() {
let separator = if i > 0 { " / " } else { "" };
@ -243,10 +341,21 @@ fn keybinds(help: &Help, max_width: usize) -> LinePart {
InputMode::Normal => shortcut.cyan(),
_ => shortcut.white().bold(),
};
if current_length + shortcut_length + description_first_word_length + separator_len + MORE_MSG.chars().count() < max_width {
keybinds = format!("{}{}<{}> {}", keybinds, separator, shortcut, description_first_word);
if current_length
+ shortcut_length
+ description_first_word_length
+ separator_len
+ MORE_MSG.chars().count()
< max_width
{
keybinds = format!(
"{}{}<{}> {}",
keybinds, separator, shortcut, description_first_word
);
len += shortcut_length + description_first_word_length + separator_len;
} else if current_length + shortcut_length + separator_len + MORE_MSG.chars().count() < max_width {
} else if current_length + shortcut_length + separator_len + MORE_MSG.chars().count()
< max_width
{
keybinds = format!("{}{}<{}>", keybinds, separator, shortcut);
len += shortcut_length + separator_len;
} else {

View File

@ -1,9 +1,9 @@
mod state;
use colored::*;
use zellij_tile::*;
use state::{FsEntry, State};
use std::{cmp::min, fs::read_dir};
use zellij_tile::*;
register_tile!(State);

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
line17-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line18-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
line17-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line11-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line12-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
line11-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line12-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
line11-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line12-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
line17-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line11-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line12-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
line11-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line12-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
a │line1-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
line14-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line2-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
line1-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line2-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/basic.rs
expression: snapshot_before_quit
---
line1-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
line2-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
line1-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line2-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
line1-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line2-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
line1-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line2-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
line1-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
line2-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
a │line1-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
line14-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line2-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
a │bbbbbbbbbbbbbbb│line1-bbbbbbbb│line13-bbbbbbbbbbbbbbbbbbbbbb
line18-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│bbbbbbbbbbbbbbb│line2-bbbbbbbb│line14-bbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
a │line1-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
line14-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│line2-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa│bbbbbbbbbbbbbbb│line1-bbbbbbbb│line9-bbbbbbbbbbbbbbbbbbbbbbb
a │bbbbbbbbbbbbbbb│line2-bbbbbbbb│line10-bbbbbbbbbbbbbbbbbbbbbb

View File

@ -1,6 +1,7 @@
---
source: src/tests/integration/close_pane.rs
expression: snapshot_before_quit
---
line11-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
line12-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Some files were not shown because too many files have changed in this diff Show More