Merge branch 'main' into display-session-name

This commit is contained in:
a-kenji 2021-07-22 16:12:35 +02:00 committed by GitHub
commit c9ccfb2919
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 847 additions and 203 deletions

View file

@ -5,8 +5,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased] ## [Unreleased]
* Plugins don't crash zellij anymore on receiving mouse events (https://github.com/zellij-org/zellij/pull/620)
* A universal logging system has been implemented (https://github.com/zellij-org/zellij/pull/592)
* Added [`log`](https://docs.rs/log/0.4.14/log/#macros) crate support for logging within Zellij
* Messages sent over the `stderr` of plugins are now logged as well, bringing back `dbg!` support!
## [0.15.0] - 2021-07-19
* Kill children properly (https://github.com/zellij-org/zellij/pull/601) * Kill children properly (https://github.com/zellij-org/zellij/pull/601)
* Change name of `Run` binding for actions (https://github.com/zellij-org/zellij/pull/602) * Change name of `Run` binding for actions (https://github.com/zellij-org/zellij/pull/602)
* Add running commands to `layouts` (https://github.com/zellij-org/zellij/pull/600)
POSSIBLE BREAKING CHANGE for custom layouts:
Plugins are under the run category now, that means:
```
plugin: status-bar
```
is now:
```
run:
plugin: status-bar
```
* Add `on_force_close` config option (https://github.com/zellij-org/zellij/pull/609)
## [0.14.0] - 2021-07-05 ## [0.14.0] - 2021-07-05
* Add improved error handling for layouts (https://github.com/zellij-org/zellij/pull/576) * Add improved error handling for layouts (https://github.com/zellij-org/zellij/pull/576)

378
Cargo.lock generated
View file

@ -17,6 +17,15 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.11.0" version = "0.11.0"
@ -35,6 +44,18 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "anyhow"
version = "1.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486"
[[package]]
name = "arc-swap"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dabe5a181f83789739c194cbe5a897dde195078fac08568d09221fd6137a7ba8"
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.5.2" version = "0.5.2"
@ -84,12 +105,11 @@ dependencies = [
[[package]] [[package]]
name = "async-io" name = "async-io"
version = "1.4.1" version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bbfd5cf2794b1e908ea8457e6c45f8f8f1f6ec5f74617bf4662623f47503c3b" checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b"
dependencies = [ dependencies = [
"concurrent-queue", "concurrent-queue",
"fastrand",
"futures-lite", "futures-lite",
"libc", "libc",
"log", "log",
@ -190,12 +210,12 @@ checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a"
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.11" version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [ dependencies = [
"hermit-abi",
"libc", "libc",
"termion",
"winapi", "winapi",
] ]
@ -216,7 +236,7 @@ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
"object 0.25.2", "object 0.25.3",
"rustc-demangle", "rustc-demangle",
] ]
@ -287,9 +307,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.68" version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -303,6 +323,19 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"time",
"winapi",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.33.3" version = "2.33.3"
@ -555,9 +588,9 @@ dependencies = [
[[package]] [[package]]
name = "darling" name = "darling"
version = "0.12.4" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c" checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"darling_macro", "darling_macro",
@ -565,9 +598,9 @@ dependencies = [
[[package]] [[package]]
name = "darling_core" name = "darling_core"
version = "0.12.4" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36" checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3"
dependencies = [ dependencies = [
"fnv", "fnv",
"ident_case", "ident_case",
@ -579,15 +612,26 @@ dependencies = [
[[package]] [[package]]
name = "darling_macro" name = "darling_macro"
version = "0.12.4" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"quote", "quote",
"syn", "syn",
] ]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "directories-next" name = "directories-next"
version = "2.0.0" version = "2.0.0"
@ -629,18 +673,18 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]] [[package]]
name = "enumset" name = "enumset"
version = "1.0.6" version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbd795df6708a599abf1ee10eacc72efd052b7a5f70fdf0715e4d5151a6db9c3" checksum = "7e76129da36102af021b8e5000dab2c1c30dbef85c1e482beeff8da5dde0e0b0"
dependencies = [ dependencies = [
"enumset_derive", "enumset_derive",
] ]
[[package]] [[package]]
name = "enumset_derive" name = "enumset_derive"
version = "0.5.4" version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e19c52f9ec503c8a68dc04daf71a04b07e690c32ab1a8b68e33897f255269d47" checksum = "6451128aa6655d880755345d085494cf7561a6bee7c8dc821e5d77e6d267ecd4"
dependencies = [ dependencies = [
"darling", "darling",
"proc-macro2", "proc-macro2",
@ -650,9 +694,9 @@ dependencies = [
[[package]] [[package]]
name = "erased-serde" name = "erased-serde"
version = "0.3.15" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5b36e6f2295f393f44894c6031f67df4d185b984cd54d08f768ce678007efcd" checksum = "3de9ad4541d99dc22b59134e7ff8dc3d6c988c89ecd7324bf10a8362b07a2afa"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -872,9 +916,9 @@ dependencies = [
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.9.1" version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
[[package]] [[package]]
name = "heck" name = "heck"
@ -887,13 +931,19 @@ dependencies = [
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.18" version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"
@ -902,9 +952,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.6.2" version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown",
@ -929,9 +979,9 @@ dependencies = [
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.9" version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
] ]
@ -1019,9 +1069,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.95" version = "0.2.98"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -1090,9 +1140,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"serde",
"value-bag", "value-bag",
] ]
[[package]]
name = "log-mdc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7"
[[package]]
name = "log4rs"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1572a880d1115ff867396eee7ae2bc924554225e67a0d3c85c745b3e60ca211"
dependencies = [
"anyhow",
"arc-swap",
"chrono",
"derivative",
"fnv",
"humantime",
"libc",
"log",
"log-mdc",
"parking_lot 0.11.1",
"regex",
"serde",
"serde-value",
"serde_json",
"serde_yaml",
"thiserror",
"thread-id",
"typemap",
"winapi",
]
[[package]] [[package]]
name = "mach" name = "mach"
version = "0.3.2" version = "0.3.2"
@ -1138,9 +1222,9 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.7.11" version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
@ -1194,6 +1278,25 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "num_cpus" name = "num_cpus"
version = "1.13.0" version = "1.13.0"
@ -1222,24 +1325,24 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.25.2" version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8bc1d42047cf336f0f939c99e97183cf31551bf0f2865a2ec9c8d91fd4ffb5e" checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.7.2" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.63" version = "0.9.65"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b0d6fb7d80f877617dfcb014e605e2b5ab2fb0afdf27935219bb6bd984cb98" checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@ -1248,6 +1351,15 @@ dependencies = [
"vcpkg", "vcpkg",
] ]
[[package]]
name = "ordered-float"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "039f02eb0f69271f26abe3202189275d7aa2258b903cb0281b5de710a2570ff3"
dependencies = [
"num-traits",
]
[[package]] [[package]]
name = "parking" name = "parking"
version = "2.0.0" version = "2.0.0"
@ -1298,16 +1410,16 @@ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"instant", "instant",
"libc", "libc",
"redox_syscall 0.2.8", "redox_syscall 0.2.9",
"smallvec", "smallvec",
"winapi", "winapi",
] ]
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.6" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -1323,14 +1435,14 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]] [[package]]
name = "polling" name = "polling"
version = "2.0.3" version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fc12d774e799ee9ebae13f4076ca003b40d18a11ac0f3641e6f899618580b7b" checksum = "92341d779fa34ea8437ef4d82d440d5e1ce3f3ff7f824aa64424cd481f9a1f25"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
"log", "log",
"wepoll-sys", "wepoll-ffi",
"winapi", "winapi",
] ]
@ -1429,24 +1541,24 @@ dependencies = [
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.3" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [ dependencies = [
"libc", "libc",
"rand_chacha", "rand_chacha",
"rand_core 0.6.2", "rand_core 0.6.3",
"rand_hc", "rand_hc",
] ]
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [ dependencies = [
"ppv-lite86", "ppv-lite86",
"rand_core 0.6.2", "rand_core 0.6.3",
] ]
[[package]] [[package]]
@ -1466,20 +1578,20 @@ checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.6.2" version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [ dependencies = [
"getrandom", "getrandom",
] ]
[[package]] [[package]]
name = "rand_hc" name = "rand_hc"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [ dependencies = [
"rand_core 0.6.2", "rand_core 0.6.3",
] ]
[[package]] [[package]]
@ -1524,9 +1636,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.2.8" version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee"
dependencies = [ dependencies = [
"bitflags", "bitflags",
] ]
@ -1537,7 +1649,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f" checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f"
dependencies = [ dependencies = [
"redox_syscall 0.2.8", "redox_syscall 0.2.9",
] ]
[[package]] [[package]]
@ -1547,7 +1659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
dependencies = [ dependencies = [
"getrandom", "getrandom",
"redox_syscall 0.2.8", "redox_syscall 0.2.9",
] ]
[[package]] [[package]]
@ -1561,6 +1673,23 @@ dependencies = [
"smallvec", "smallvec",
] ]
[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]] [[package]]
name = "region" name = "region"
version = "2.2.0" version = "2.2.0"
@ -1584,9 +1713,9 @@ dependencies = [
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.19" version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49"
[[package]] [[package]]
name = "rustc-hash" name = "rustc-hash"
@ -1615,6 +1744,16 @@ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]]
name = "serde-value"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
dependencies = [
"ordered-float",
"serde",
]
[[package]] [[package]]
name = "serde_bytes" name = "serde_bytes"
version = "0.11.5" version = "0.11.5"
@ -1785,9 +1924,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "structopt" name = "structopt"
version = "0.3.21" version = "0.3.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" checksum = "69b041cdcb67226aca307e6e7be44c8806423d83e018bd662360a93dabce4d71"
dependencies = [ dependencies = [
"clap", "clap",
"lazy_static", "lazy_static",
@ -1796,9 +1935,9 @@ dependencies = [
[[package]] [[package]]
name = "structopt-derive" name = "structopt-derive"
version = "0.4.14" version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" checksum = "7813934aecf5f51a54775e00068c237de98489463968231a51746bbbc03f9c10"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -1827,9 +1966,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.72" version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1860,8 +1999,8 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"libc", "libc",
"rand 0.8.3", "rand 0.8.4",
"redox_syscall 0.2.8", "redox_syscall 0.2.9",
"remove_dir_all", "remove_dir_all",
"winapi", "winapi",
] ]
@ -1895,7 +2034,7 @@ checksum = "077185e2eac69c3f8379a4298e1e07cd36beb962290d4a51199acf0fdc10607e"
dependencies = [ dependencies = [
"libc", "libc",
"numtoa", "numtoa",
"redox_syscall 0.2.8", "redox_syscall 0.2.9",
"redox_termios", "redox_termios",
] ]
@ -1910,18 +2049,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.25" version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.25" version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1929,12 +2068,24 @@ dependencies = [
] ]
[[package]] [[package]]
name = "time" name = "thread-id"
version = "0.1.43" version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1"
dependencies = [ dependencies = [
"libc", "libc",
"redox_syscall 0.1.57",
"winapi",
]
[[package]]
name = "time"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi",
"winapi", "winapi",
] ]
@ -1971,6 +2122,21 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "traitobject"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
[[package]]
name = "typemap"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6"
dependencies = [
"unsafe-any",
]
[[package]] [[package]]
name = "typetag" name = "typetag"
version = "0.1.7" version = "0.1.7"
@ -1997,9 +2163,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-segmentation" name = "unicode-segmentation"
version = "1.7.1" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
@ -2013,6 +2179,15 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "unsafe-any"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f"
dependencies = [
"traitobject",
]
[[package]] [[package]]
name = "utf8parse" name = "utf8parse"
version = "0.1.1" version = "0.1.1"
@ -2043,9 +2218,9 @@ dependencies = [
[[package]] [[package]]
name = "vcpkg" name = "vcpkg"
version = "0.2.13" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "025ce40a007e1907e58d5bc1a594def78e5573bb0b1160bc389634e8f12e4faa" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "vec_map" name = "vec_map"
@ -2097,9 +2272,9 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.10.2+wasi-snapshot-preview1" version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
@ -2369,18 +2544,18 @@ checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf"
[[package]] [[package]]
name = "wast" name = "wast"
version = "35.0.2" version = "36.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" checksum = "8b5d7ba374a364571da1cb0a379a3dc302582a2d9937a183bfe35b68ad5bb9c4"
dependencies = [ dependencies = [
"leb128", "leb128",
] ]
[[package]] [[package]]
name = "wat" name = "wat"
version = "1.0.37" version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02" checksum = "16383df7f0e3901484c2dda6294ed6895caa3627ce4f6584141dcf30a33a23e6"
dependencies = [ dependencies = [
"wast", "wast",
] ]
@ -2396,10 +2571,10 @@ dependencies = [
] ]
[[package]] [[package]]
name = "wepoll-sys" name = "wepoll-ffi"
version = "3.0.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fcb14dea929042224824779fbc82d9fab8d2e6d3cbc0ac404de8edf489e77ff" checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb"
dependencies = [ dependencies = [
"cc", "cc",
] ]
@ -2447,11 +2622,12 @@ dependencies = [
[[package]] [[package]]
name = "zellij" name = "zellij"
version = "0.15.0" version = "0.16.0"
dependencies = [ dependencies = [
"insta", "insta",
"log",
"names", "names",
"rand 0.8.3", "rand 0.8.4",
"ssh2", "ssh2",
"zellij-client", "zellij-client",
"zellij-server", "zellij-server",
@ -2460,9 +2636,10 @@ dependencies = [
[[package]] [[package]]
name = "zellij-client" name = "zellij-client"
version = "0.15.0" version = "0.16.0"
dependencies = [ dependencies = [
"insta", "insta",
"log",
"mio", "mio",
"termbg", "termbg",
"zellij-utils", "zellij-utils",
@ -2470,15 +2647,18 @@ dependencies = [
[[package]] [[package]]
name = "zellij-server" name = "zellij-server"
version = "0.15.0" version = "0.16.0"
dependencies = [ dependencies = [
"ansi_term 0.12.1", "ansi_term 0.12.1",
"async-trait", "async-trait",
"base64", "base64",
"cassowary", "cassowary",
"chrono",
"daemonize", "daemonize",
"insta", "insta",
"log",
"serde_json", "serde_json",
"typetag",
"unicode-width", "unicode-width",
"wasmer", "wasmer",
"wasmer-wasi", "wasmer-wasi",
@ -2487,7 +2667,7 @@ dependencies = [
[[package]] [[package]]
name = "zellij-tile" name = "zellij-tile"
version = "0.15.0" version = "0.16.0"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
@ -2497,14 +2677,14 @@ dependencies = [
[[package]] [[package]]
name = "zellij-tile-utils" name = "zellij-tile-utils"
version = "0.15.0" version = "0.16.0"
dependencies = [ dependencies = [
"ansi_term 0.12.1", "ansi_term 0.12.1",
] ]
[[package]] [[package]]
name = "zellij-utils" name = "zellij-utils"
version = "0.15.0" version = "0.16.0"
dependencies = [ dependencies = [
"async-std", "async-std",
"backtrace", "backtrace",
@ -2515,6 +2695,8 @@ dependencies = [
"interprocess", "interprocess",
"lazy_static", "lazy_static",
"libc", "libc",
"log",
"log4rs",
"nix", "nix",
"once_cell", "once_cell",
"serde", "serde",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "zellij" name = "zellij"
version = "0.15.0" version = "0.16.0"
authors = ["Aram Drevekenin <aram@poor.dev>"] authors = ["Aram Drevekenin <aram@poor.dev>"]
edition = "2018" edition = "2018"
description = "A terminal workspace with batteries included" description = "A terminal workspace with batteries included"
@ -14,9 +14,10 @@ resolver = "2"
[dependencies] [dependencies]
names = "0.11.0" names = "0.11.0"
zellij-client = { path = "zellij-client/", version = "0.15.0" } zellij-client = { path = "zellij-client/", version = "0.16.0" }
zellij-server = { path = "zellij-server/", version = "0.15.0" } zellij-server = { path = "zellij-server/", version = "0.16.0" }
zellij-utils = { path = "zellij-utils/", version = "0.15.0" } zellij-utils = { path = "zellij-utils/", version = "0.16.0" }
log = "0.4.14"
[dev-dependencies] [dev-dependencies]
insta = { version = "1.6.0", features = ["backtrace"] } insta = { version = "1.6.0", features = ["backtrace"] }

View file

@ -151,7 +151,7 @@ run_task = "publish-zellij"
[tasks.release-commit] [tasks.release-commit]
dependencies = ["commit-all", "tag-release"] dependencies = ["commit-all", "tag-release"]
command = "git" command = "git"
args = ["push", "--atomic", "upstream", "main", "v${CARGO_MAKE_CRATE_VERSION}"] args = ["push", "--atomic", "origin", "main", "v${CARGO_MAKE_CRATE_VERSION}"]
[tasks.commit-all] [tasks.commit-all]
ignore_errors = true ignore_errors = true

View file

@ -0,0 +1,20 @@
---
direction: Vertical
parts:
- direction: Horizontal
split_size:
Percent: 50
parts:
- direction: Vertical
split_size:
Percent: 50
- direction: Vertical
split_size:
Percent: 50
run:
command: {cmd: htop}
- direction: Horizontal
split_size:
Percent: 50
run:
command: {cmd: htop}

View file

@ -0,0 +1,30 @@
---
direction: Horizontal
parts:
- direction: Vertical
split_size:
Fixed: 1
run:
plugin: tab-bar
- direction: Vertical
parts:
- direction: Vertical
parts:
- direction: Vertical
split_size:
Percent: 50
run:
command: {cmd: htop}
- direction: Vertical
split_size:
Percent: 50
run:
command: {cmd: htop, args: ["-C"]}
- direction: Vertical
split_size:
Fixed: 5
- direction: Vertical
split_size:
Fixed: 2
run:
plugin: status-bar

View file

@ -19,6 +19,7 @@ use zellij_utils::{
}; };
pub fn main() { pub fn main() {
configure_logger();
let opts = CliArgs::from_args(); let opts = CliArgs::from_args();
if let Some(Command::Sessions(Sessions::ListSessions)) = opts.command { if let Some(Command::Sessions(Sessions::ListSessions)) = opts.command {

View file

@ -1,6 +1,6 @@
[package] [package]
name = "zellij-client" name = "zellij-client"
version = "0.15.0" version = "0.16.0"
authors = ["Kunal Mohan <kunalmohan99@gmail.com>"] authors = ["Kunal Mohan <kunalmohan99@gmail.com>"]
edition = "2018" edition = "2018"
description = "The client-side library for Zellij" description = "The client-side library for Zellij"
@ -11,7 +11,8 @@ license = "MIT"
[dependencies] [dependencies]
mio = "0.7.11" mio = "0.7.11"
termbg = "0.2.3" termbg = "0.2.3"
zellij-utils = { path = "../zellij-utils/", version = "0.15.0" } zellij-utils = { path = "../zellij-utils/", version = "0.16.0" }
log = "0.4.14"
[dev-dependencies] [dev-dependencies]
insta = "1.6.0" insta = "1.6.0"

View file

@ -3,6 +3,7 @@ pub mod os_input_output;
mod command_is_executing; mod command_is_executing;
mod input_handler; mod input_handler;
use log::info;
use std::env::current_exe; use std::env::current_exe;
use std::io::{self, Write}; use std::io::{self, Write};
use std::path::Path; use std::path::Path;
@ -88,6 +89,7 @@ pub fn start_client(
info: ClientInfo, info: ClientInfo,
layout: Option<Layout>, layout: Option<Layout>,
) { ) {
info!("Starting Zellij client!");
let clear_client_terminal_attributes = "\u{1b}[?1l\u{1b}=\u{1b}[r\u{1b}12l\u{1b}[?1000l\u{1b}[?1002l\u{1b}[?1003l\u{1b}[?1005l\u{1b}[?1006l\u{1b}[?12l"; let clear_client_terminal_attributes = "\u{1b}[?1l\u{1b}=\u{1b}[r\u{1b}12l\u{1b}[?1000l\u{1b}[?1002l\u{1b}[?1003l\u{1b}[?1005l\u{1b}[?1006l\u{1b}[?12l";
let take_snapshot = "\u{1b}[?1049h"; let take_snapshot = "\u{1b}[?1049h";
let bracketed_paste = "\u{1b}[?2004h"; let bracketed_paste = "\u{1b}[?2004h";
@ -164,6 +166,8 @@ pub fn start_client(
}) })
}); });
let on_force_close = config_options.on_force_close.unwrap_or_default();
let _stdin_thread = thread::Builder::new() let _stdin_thread = thread::Builder::new()
.name("stdin_handler".to_string()) .name("stdin_handler".to_string())
.spawn({ .spawn({
@ -200,7 +204,7 @@ pub fn start_client(
Box::new({ Box::new({
let os_api = os_input.clone(); let os_api = os_input.clone();
move || { move || {
os_api.send_to_server(ClientToServerMsg::Action(Action::Detach)); os_api.send_to_server(ClientToServerMsg::Action(on_force_close.into()));
} }
}), }),
); );
@ -291,6 +295,7 @@ pub fn start_client(
); );
os_input.disable_mouse(); os_input.disable_mouse();
info!("{}", exit_msg);
os_input.unset_raw_mode(0); os_input.unset_raw_mode(0);
let mut stdout = os_input.get_stdout_writer(); let mut stdout = os_input.get_stdout_writer();
let _ = stdout.write(goodbye_message.as_bytes()).unwrap(); let _ = stdout.write(goodbye_message.as_bytes()).unwrap();

View file

@ -1,6 +1,6 @@
[package] [package]
name = "zellij-server" name = "zellij-server"
version = "0.15.0" version = "0.16.0"
authors = ["Kunal Mohan <kunalmohan99@gmail.com>"] authors = ["Kunal Mohan <kunalmohan99@gmail.com>"]
edition = "2018" edition = "2018"
description = "The server-side library for Zellij" description = "The server-side library for Zellij"
@ -18,7 +18,10 @@ unicode-width = "0.1.8"
wasmer = "1.0.0" wasmer = "1.0.0"
wasmer-wasi = "1.0.0" wasmer-wasi = "1.0.0"
cassowary = "0.3.0" cassowary = "0.3.0"
zellij-utils = { path = "../zellij-utils/", version = "0.15.0" } zellij-utils = { path = "../zellij-utils/", version = "0.16.0" }
log = "0.4.14"
typetag = "0.1.7"
chrono = "0.4.19"
[dev-dependencies] [dev-dependencies]
insta = "1.6.0" insta = "1.6.0"

View file

@ -2,6 +2,7 @@ pub mod os_input_output;
pub mod panes; pub mod panes;
pub mod tab; pub mod tab;
mod logging_pipe;
mod pty; mod pty;
mod route; mod route;
mod screen; mod screen;
@ -9,6 +10,7 @@ mod thread_bus;
mod ui; mod ui;
mod wasm_vm; mod wasm_vm;
use log::info;
use zellij_utils::zellij_tile; use zellij_utils::zellij_tile;
use std::path::PathBuf; use std::path::PathBuf;
@ -114,6 +116,7 @@ pub(crate) enum SessionState {
} }
pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) { pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
info!("Starting Zellij server!");
daemonize::Daemonize::new() daemonize::Daemonize::new()
.working_directory(std::env::current_dir().unwrap()) .working_directory(std::env::current_dir().unwrap())
.umask(0o077) .umask(0o077)

View file

@ -0,0 +1,250 @@
use std::{
collections::VecDeque,
io::{Read, Seek, Write},
};
use log::{debug, error};
use wasmer_wasi::{WasiFile, WasiFsError};
use zellij_utils::serde;
use chrono::prelude::*;
use serde::{Deserialize, Serialize};
// 16kB log buffer
const ZELLIJ_MAX_PIPE_BUFFER_SIZE: usize = 16_384;
#[derive(Debug, Serialize, Deserialize)]
#[serde(crate = "self::serde")]
pub struct LoggingPipe {
buffer: VecDeque<u8>,
plugin_name: String,
plugin_id: u32,
}
impl LoggingPipe {
pub fn new(plugin_name: &str, plugin_id: u32) -> LoggingPipe {
LoggingPipe {
buffer: VecDeque::new(),
plugin_name: String::from(plugin_name),
plugin_id,
}
}
fn log_message(&self, message: &str) {
debug!(
"|{:<25.25}| {} [{:<10.15}] {}",
self.plugin_name,
Local::now().format("%Y-%m-%d %H:%M:%S.%3f"),
format!("id: {}", self.plugin_id),
message
);
}
}
impl Read for LoggingPipe {
fn read(&mut self, _: &mut [u8]) -> std::io::Result<usize> {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Can not reed from a LoggingPipe",
))
}
}
impl Write for LoggingPipe {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
if self.buffer.len() + buf.len() > ZELLIJ_MAX_PIPE_BUFFER_SIZE {
let error_msg =
"Exceeded log buffer size. Make sure that your plugin calls flush on stderr on \
valid UTF-8 symbol boundary. Aditionally, make sure that your log message contains \
endline \\n symbol.";
error!("{}: {}", self.plugin_name, error_msg);
self.buffer.clear();
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
error_msg,
));
}
self.buffer.extend(buf);
Ok(buf.len())
}
// When we flush, check if current buffer is valid utf8 string, split by '\n' and truncate buffer in the process.
// We assume that eventually, flush will be called on valid string boundary (i.e. std::str::from_utf8(..).is_ok() returns true at some point).
// Above assumption might not be true, in which case we'll have to think about it. Make it simple for now.
fn flush(&mut self) -> std::io::Result<()> {
self.buffer.make_contiguous();
if let Ok(converted_buffer) = std::str::from_utf8(self.buffer.as_slices().0) {
if converted_buffer.contains('\n') {
let mut consumed_bytes = 0;
let mut split_converted_buffer = converted_buffer.split('\n').peekable();
while let Some(msg) = split_converted_buffer.next() {
if split_converted_buffer.peek().is_none() {
// Log last chunk iff the last char is endline. Otherwise do not do it.
if converted_buffer.ends_with('\n') && !msg.is_empty() {
self.log_message(msg);
consumed_bytes += msg.len() + 1;
}
} else {
self.log_message(msg);
consumed_bytes += msg.len() + 1;
}
}
drop(self.buffer.drain(..consumed_bytes));
}
} else {
error!("Buffer conversion didn't work. This is unexpected");
}
Ok(())
}
}
impl Seek for LoggingPipe {
fn seek(&mut self, _pos: std::io::SeekFrom) -> std::io::Result<u64> {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"can not seek in a pipe",
))
}
}
#[typetag::serde]
impl WasiFile for LoggingPipe {
fn last_accessed(&self) -> u64 {
0
}
fn last_modified(&self) -> u64 {
0
}
fn created_time(&self) -> u64 {
0
}
fn size(&self) -> u64 {
self.buffer.len() as u64
}
fn set_len(&mut self, len: u64) -> Result<(), WasiFsError> {
self.buffer.resize(len as usize, 0);
Ok(())
}
fn unlink(&mut self) -> Result<(), WasiFsError> {
Ok(())
}
fn bytes_available(&self) -> Result<usize, WasiFsError> {
Ok(self.buffer.len())
}
}
// Unit tests
#[cfg(test)]
mod logging_pipe_test {
use super::*;
#[test]
fn write_without_endl_does_not_consume_buffer_after_flush() {
let mut pipe = LoggingPipe::new("TestPipe", 0);
let test_buffer = "Testing write".as_bytes();
pipe.write(test_buffer).expect("Err write");
pipe.flush().expect("Err flush");
assert_eq!(pipe.buffer.len(), test_buffer.len());
}
#[test]
fn write_with_single_endl_at_the_end_consumes_whole_buffer_after_flush() {
let mut pipe = LoggingPipe::new("TestPipe", 0);
let test_buffer = "Testing write \n".as_bytes();
pipe.write(test_buffer).expect("Err write");
pipe.flush().expect("Err flush");
assert_eq!(pipe.buffer.len(), 0);
}
#[test]
fn write_with_endl_in_the_middle_consumes_buffer_up_to_endl_after_flush() {
let mut pipe = LoggingPipe::new("TestPipe", 0);
let test_buffer = "Testing write \n".as_bytes();
let test_buffer2 = "And the rest".as_bytes();
pipe.write(
[
test_buffer,
test_buffer,
test_buffer,
test_buffer,
test_buffer2,
]
.concat()
.as_slice(),
)
.expect("Err write");
pipe.flush().expect("Err flush");
assert_eq!(pipe.buffer.len(), test_buffer2.len());
}
#[test]
fn write_with_many_endl_consumes_whole_buffer_after_flush() {
let mut pipe = LoggingPipe::new("TestPipe", 0);
let test_buffer = "Testing write \n".as_bytes();
pipe.write(
[
test_buffer,
test_buffer,
test_buffer,
test_buffer,
test_buffer,
]
.concat()
.as_slice(),
)
.expect("Err write");
pipe.flush().expect("Err flush");
assert_eq!(pipe.buffer.len(), 0);
}
#[test]
fn write_with_incorrect_byte_boundary_does_not_crash() {
let mut pipe = LoggingPipe::new("TestPipe", 0);
let test_buffer = "😱".as_bytes();
// make sure it's not valid utf-8 string if we drop last symbol
assert!(std::str::from_utf8(&test_buffer[..test_buffer.len() - 1]).is_err());
pipe.write(&test_buffer[..test_buffer.len() - 1])
.expect("Err write");
pipe.flush().expect("Err flush");
assert_eq!(pipe.buffer.len(), test_buffer.len() - 1);
println!("len: {}, buf: {:?}", test_buffer.len(), test_buffer);
}
#[test]
fn write_with_many_endls_consumes_everything_after_flush() {
let mut pipe = LoggingPipe::new("TestPipe", 0);
let test_buffer = "Testing write \n".as_bytes();
pipe.write(
[test_buffer, test_buffer, b"\n", b"\n", b"\n"]
.concat()
.as_slice(),
)
.expect("Err write");
pipe.flush().expect("Err flush");
assert_eq!(pipe.buffer.len(), 0);
}
}

View file

@ -196,13 +196,13 @@ impl Pane for PluginPane {
self.position_and_size.y -= count; self.position_and_size.y -= count;
} }
fn scroll_up(&mut self, _count: usize) { fn scroll_up(&mut self, _count: usize) {
unimplemented!() //unimplemented!()
} }
fn scroll_down(&mut self, _count: usize) { fn scroll_down(&mut self, _count: usize) {
unimplemented!() //unimplemented!()
} }
fn clear_scroll(&mut self) { fn clear_scroll(&mut self) {
unimplemented!() //unimplemented!()
} }
// FIXME: This need to be reevaluated and deleted if possible. // FIXME: This need to be reevaluated and deleted if possible.
// `max` doesn't make sense when things are fixed... // `max` doesn't make sense when things are fixed...

View file

@ -1,11 +1,3 @@
use zellij_utils::async_std;
use async_std::future::timeout as async_timeout;
use async_std::task::{self, JoinHandle};
use std::collections::HashMap;
use std::os::unix::io::RawFd;
use std::time::{Duration, Instant};
use crate::{ use crate::{
os_input_output::{AsyncReader, Pid, ServerOsApi}, os_input_output::{AsyncReader, Pid, ServerOsApi},
panes::PaneId, panes::PaneId,
@ -14,9 +6,22 @@ use crate::{
wasm_vm::PluginInstruction, wasm_vm::PluginInstruction,
ServerInstruction, ServerInstruction,
}; };
use async_std::{
future::timeout as async_timeout,
task::{self, JoinHandle},
};
use std::{
collections::HashMap,
os::unix::io::RawFd,
time::{Duration, Instant},
};
use zellij_utils::{ use zellij_utils::{
async_std,
errors::{get_current_ctx, ContextType, PtyContext}, errors::{get_current_ctx, ContextType, PtyContext},
input::{command::TerminalAction, layout::Layout}, input::{
command::TerminalAction,
layout::{Layout, Run},
},
logging::debug_to_file, logging::debug_to_file,
}; };
@ -236,19 +241,36 @@ impl Pty {
pub fn spawn_terminals_for_layout( pub fn spawn_terminals_for_layout(
&mut self, &mut self,
layout: Layout, layout: Layout,
terminal_action: Option<TerminalAction>, default_shell: Option<TerminalAction>,
) { ) {
let total_panes = layout.total_terminal_panes(); let extracted_run_instructions = layout.extract_run_instructions();
let mut new_pane_pids = vec![]; let mut new_pane_pids = vec![];
for _ in 0..total_panes { for run_instruction in extracted_run_instructions {
let (pid_primary, pid_secondary): (RawFd, Pid) = self match run_instruction {
.bus Some(Run::Command(command)) => {
.os_input let cmd = TerminalAction::RunCommand(command);
.as_mut() let (pid_primary, pid_secondary): (RawFd, Pid) = self
.unwrap() .bus
.spawn_terminal(terminal_action.clone()); .os_input
self.id_to_child_pid.insert(pid_primary, pid_secondary); .as_mut()
new_pane_pids.push(pid_primary); .unwrap()
.spawn_terminal(Some(cmd));
self.id_to_child_pid.insert(pid_primary, pid_secondary);
new_pane_pids.push(pid_primary);
}
None => {
let (pid_primary, pid_secondary): (RawFd, Pid) = self
.bus
.os_input
.as_mut()
.unwrap()
.spawn_terminal(default_shell.clone());
self.id_to_child_pid.insert(pid_primary, pid_secondary);
new_pane_pids.push(pid_primary);
}
// Investigate moving plugin loading to here.
Some(Run::Plugin(_)) => {}
}
} }
self.bus self.bus
.senders .senders

View file

@ -15,7 +15,7 @@ use crate::{
wasm_vm::PluginInstruction, wasm_vm::PluginInstruction,
ServerInstruction, SessionState, ServerInstruction, SessionState,
}; };
use zellij_tile::data::{Event, InputMode, ModeInfo, Palette, PluginCapabilities, TabInfo}; use zellij_tile::data::{Event, ModeInfo, Palette, PluginCapabilities, TabInfo};
use zellij_utils::{ use zellij_utils::{
errors::{ContextType, ScreenContext}, errors::{ContextType, ScreenContext},
input::{get_mode_info, options::Options}, input::{get_mode_info, options::Options},
@ -149,7 +149,6 @@ pub(crate) struct Screen {
/// The index of this [`Screen`]'s active [`Tab`]. /// The index of this [`Screen`]'s active [`Tab`].
active_tab_index: Option<usize>, active_tab_index: Option<usize>,
mode_info: ModeInfo, mode_info: ModeInfo,
input_mode: InputMode,
colors: Palette, colors: Palette,
session_state: Arc<RwLock<SessionState>>, session_state: Arc<RwLock<SessionState>>,
} }
@ -161,7 +160,6 @@ impl Screen {
client_attributes: &ClientAttributes, client_attributes: &ClientAttributes,
max_panes: Option<usize>, max_panes: Option<usize>,
mode_info: ModeInfo, mode_info: ModeInfo,
input_mode: InputMode,
session_state: Arc<RwLock<SessionState>>, session_state: Arc<RwLock<SessionState>>,
) -> Self { ) -> Self {
Screen { Screen {
@ -172,7 +170,6 @@ impl Screen {
active_tab_index: None, active_tab_index: None,
tabs: BTreeMap::new(), tabs: BTreeMap::new(),
mode_info, mode_info,
input_mode,
session_state, session_state,
} }
} }
@ -192,7 +189,6 @@ impl Screen {
self.max_panes, self.max_panes,
Some(PaneId::Terminal(pane_id)), Some(PaneId::Terminal(pane_id)),
self.mode_info.clone(), self.mode_info.clone(),
self.input_mode,
self.colors, self.colors,
self.session_state.clone(), self.session_state.clone(),
); );
@ -354,7 +350,6 @@ impl Screen {
self.max_panes, self.max_panes,
None, None,
self.mode_info.clone(), self.mode_info.clone(),
self.input_mode,
self.colors, self.colors,
self.session_state.clone(), self.session_state.clone(),
); );
@ -428,7 +423,6 @@ pub(crate) fn screen_thread_main(
session_state: Arc<RwLock<SessionState>>, session_state: Arc<RwLock<SessionState>>,
) { ) {
let capabilities = config_options.simplified_ui; let capabilities = config_options.simplified_ui;
let default_mode = config_options.default_mode.unwrap_or_default();
let mut screen = Screen::new( let mut screen = Screen::new(
bus, bus,
@ -441,7 +435,6 @@ pub(crate) fn screen_thread_main(
arrow_fonts: capabilities, arrow_fonts: capabilities,
}, },
), ),
default_mode,
session_state, session_state,
); );
loop { loop {

View file

@ -24,9 +24,12 @@ use std::{
cmp::Reverse, cmp::Reverse,
collections::{BTreeMap, HashSet}, collections::{BTreeMap, HashSet},
}; };
use zellij_tile::data::{Event, InputMode, ModeInfo, Palette}; use zellij_tile::data::{Event, ModeInfo, Palette};
use zellij_utils::{ use zellij_utils::{
input::{layout::Layout, parse_keys}, input::{
layout::{Layout, Run},
parse_keys,
},
pane_size::PositionAndSize, pane_size::PositionAndSize,
shared::adjust_to_size, shared::adjust_to_size,
}; };
@ -84,7 +87,6 @@ pub(crate) struct Tab {
should_clear_display_before_rendering: bool, should_clear_display_before_rendering: bool,
session_state: Arc<RwLock<SessionState>>, session_state: Arc<RwLock<SessionState>>,
pub mode_info: ModeInfo, pub mode_info: ModeInfo,
pub input_mode: InputMode,
pub colors: Palette, pub colors: Palette,
} }
@ -96,7 +98,6 @@ pub(crate) struct TabData {
pub name: String, pub name: String,
pub active: bool, pub active: bool,
pub mode_info: ModeInfo, pub mode_info: ModeInfo,
pub input_mode: InputMode,
pub colors: Palette, pub colors: Palette,
} }
@ -257,7 +258,6 @@ impl Tab {
max_panes: Option<usize>, max_panes: Option<usize>,
pane_id: Option<PaneId>, pane_id: Option<PaneId>,
mode_info: ModeInfo, mode_info: ModeInfo,
input_mode: InputMode,
colors: Palette, colors: Palette,
session_state: Arc<RwLock<SessionState>>, session_state: Arc<RwLock<SessionState>>,
) -> Self { ) -> Self {
@ -296,7 +296,6 @@ impl Tab {
senders, senders,
should_clear_display_before_rendering: false, should_clear_display_before_rendering: false,
mode_info, mode_info,
input_mode,
colors, colors,
session_state, session_state,
} }
@ -338,7 +337,7 @@ impl Tab {
let mut new_pids = new_pids.iter(); let mut new_pids = new_pids.iter();
for (layout, position_and_size) in positions_and_size { for (layout, position_and_size) in positions_and_size {
// A plugin pane // A plugin pane
if let Some(plugin) = &layout.plugin { if let Some(Run::Plugin(Some(plugin))) = &layout.run {
let (pid_tx, pid_rx) = channel(); let (pid_tx, pid_rx) = channel();
self.senders self.senders
.send_to_plugin(PluginInstruction::Load(pid_tx, plugin.clone())) .send_to_plugin(PluginInstruction::Load(pid_tx, plugin.clone()))

View file

@ -1,5 +1,5 @@
use super::{Screen, ScreenInstruction}; use super::{Screen, ScreenInstruction};
use crate::zellij_tile::data::{InputMode, ModeInfo, Palette}; use crate::zellij_tile::data::{ModeInfo, Palette};
use crate::{ use crate::{
os_input_output::{AsyncReader, Pid, ServerOsApi}, os_input_output::{AsyncReader, Pid, ServerOsApi},
thread_bus::Bus, thread_bus::Bus,
@ -81,16 +81,8 @@ fn create_new_screen(position_and_size: PositionAndSize) -> Screen {
client_attributes.position_and_size = position_and_size; client_attributes.position_and_size = position_and_size;
let max_panes = None; let max_panes = None;
let mode_info = ModeInfo::default(); let mode_info = ModeInfo::default();
let input_mode = InputMode::Normal;
let session_state = Arc::new(RwLock::new(SessionState::Attached)); let session_state = Arc::new(RwLock::new(SessionState::Attached));
Screen::new( Screen::new(bus, &client_attributes, max_panes, mode_info, session_state)
bus,
&client_attributes,
max_panes,
mode_info,
input_mode,
session_state,
)
} }
#[test] #[test]

View file

@ -1,5 +1,5 @@
use super::Tab; use super::Tab;
use crate::zellij_tile::data::{InputMode, ModeInfo, Palette}; use crate::zellij_tile::data::{ModeInfo, Palette};
use crate::{ use crate::{
os_input_output::{AsyncReader, Pid, ServerOsApi}, os_input_output::{AsyncReader, Pid, ServerOsApi},
panes::PaneId, panes::PaneId,
@ -82,7 +82,6 @@ fn create_new_tab(position_and_size: PositionAndSize) -> Tab {
let max_panes = None; let max_panes = None;
let first_pane_id = Some(PaneId::Terminal(1)); let first_pane_id = Some(PaneId::Terminal(1));
let mode_info = ModeInfo::default(); let mode_info = ModeInfo::default();
let input_mode = InputMode::Normal;
let colors = Palette::default(); let colors = Palette::default();
let session_state = Arc::new(RwLock::new(SessionState::Attached)); let session_state = Arc::new(RwLock::new(SessionState::Attached));
Tab::new( Tab::new(
@ -95,7 +94,6 @@ fn create_new_tab(position_and_size: PositionAndSize) -> Tab {
max_panes, max_panes,
first_pane_id, first_pane_id,
mode_info, mode_info,
input_mode,
colors, colors,
session_state, session_state,
) )

View file

@ -1,3 +1,4 @@
use log::info;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::fs; use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
@ -16,6 +17,7 @@ use wasmer_wasi::{Pipe, WasiEnv, WasiState};
use zellij_tile::data::{Event, EventType, PluginIds}; use zellij_tile::data::{Event, EventType, PluginIds};
use crate::{ use crate::{
logging_pipe::LoggingPipe,
panes::PaneId, panes::PaneId,
pty::PtyInstruction, pty::PtyInstruction,
screen::ScreenInstruction, screen::ScreenInstruction,
@ -55,6 +57,7 @@ pub(crate) struct PluginEnv {
// Thread main -------------------------------------------------------------------------------------------------------- // Thread main --------------------------------------------------------------------------------------------------------
pub(crate) fn wasm_thread_main(bus: Bus<PluginInstruction>, store: Store, data_dir: PathBuf) { pub(crate) fn wasm_thread_main(bus: Bus<PluginInstruction>, store: Store, data_dir: PathBuf) {
info!("Wasm main thread starts");
let mut plugin_id = 0; let mut plugin_id = 0;
let mut plugin_map = HashMap::new(); let mut plugin_map = HashMap::new();
loop { loop {
@ -73,6 +76,10 @@ pub(crate) fn wasm_thread_main(bus: Bus<PluginInstruction>, store: Store, data_d
let output = Pipe::new(); let output = Pipe::new();
let input = Pipe::new(); let input = Pipe::new();
let stderr = LoggingPipe::new(
path.as_path().file_name().unwrap().to_str().unwrap(),
plugin_id,
);
let mut wasi_env = WasiState::new("Zellij") let mut wasi_env = WasiState::new("Zellij")
.env("CLICOLOR_FORCE", "1") .env("CLICOLOR_FORCE", "1")
.preopen(|p| { .preopen(|p| {
@ -85,6 +92,7 @@ pub(crate) fn wasm_thread_main(bus: Bus<PluginInstruction>, store: Store, data_d
.unwrap() .unwrap()
.stdin(Box::new(input)) .stdin(Box::new(input))
.stdout(Box::new(output)) .stdout(Box::new(output))
.stderr(Box::new(stderr))
.finalize() .finalize()
.unwrap(); .unwrap();

View file

@ -1,6 +1,6 @@
[package] [package]
name = "zellij-tile-utils" name = "zellij-tile-utils"
version = "0.15.0" version = "0.16.0"
authors = ["denis <denismaximov98@gmail.com>"] authors = ["denis <denismaximov98@gmail.com>"]
edition = "2018" edition = "2018"
description = "A utility library for Zellij plugins" description = "A utility library for Zellij plugins"

View file

@ -1,6 +1,6 @@
[package] [package]
name = "zellij-tile" name = "zellij-tile"
version = "0.15.0" version = "0.16.0"
authors = ["Brooks J Rady <b.j.rady@gmail.com>"] authors = ["Brooks J Rady <b.j.rady@gmail.com>"]
edition = "2018" edition = "2018"
description = "A small client-side library for writing Zellij plugins" description = "A small client-side library for writing Zellij plugins"

View file

@ -1,6 +1,6 @@
[package] [package]
name = "zellij-utils" name = "zellij-utils"
version = "0.15.0" version = "0.16.0"
authors = ["Kunal Mohan <kunalmohan99@gmail.com>"] authors = ["Kunal Mohan <kunalmohan99@gmail.com>"]
edition = "2018" edition = "2018"
description = "A utility library for Zellij client and server" description = "A utility library for Zellij client and server"
@ -27,7 +27,9 @@ structopt = "0.3"
strum = "0.20.0" strum = "0.20.0"
termion = "1.5.0" termion = "1.5.0"
vte = "0.10.1" vte = "0.10.1"
zellij-tile = { path = "../zellij-tile/", version = "0.15.0" } zellij-tile = { path = "../zellij-tile/", version = "0.16.0" }
log = "0.4.14"
log4rs = "1.0.0"
[dependencies.async-std] [dependencies.async-std]
version = "1.3.0" version = "1.3.0"

View file

@ -240,3 +240,10 @@ keybinds:
key: [Ctrl: 'q',] key: [Ctrl: 'q',]
- action: [Detach,] - action: [Detach,]
key: [Char: 'd',] key: [Char: 'd',]
# Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP
# eg. when terminal window with an active zellij session is closed
# Options:
# - detach (Default)
# - quit
#on_force_close: quit

View file

@ -4,9 +4,11 @@ parts:
- direction: Vertical - direction: Vertical
split_size: split_size:
Fixed: 1 Fixed: 1
plugin: tab-bar run:
plugin: tab-bar
- direction: Vertical - direction: Vertical
- direction: Vertical - direction: Vertical
split_size: split_size:
Fixed: 2 Fixed: 2
plugin: status-bar run:
plugin: status-bar

View file

@ -4,5 +4,6 @@ parts:
- direction: Vertical - direction: Vertical
split_size: split_size:
Fixed: 1 Fixed: 1
plugin: tab-bar run:
plugin: tab-bar
- direction: Vertical - direction: Vertical

View file

@ -4,15 +4,18 @@ parts:
- direction: Vertical - direction: Vertical
split_size: split_size:
Fixed: 1 Fixed: 1
plugin: tab-bar run:
plugin: tab-bar
- direction: Vertical - direction: Vertical
parts: parts:
- direction: Horizontal - direction: Horizontal
split_size: split_size:
Percent: 20 Percent: 20
plugin: strider run:
plugin: strider
- direction: Horizontal - direction: Horizontal
- direction: Vertical - direction: Vertical
split_size: split_size:
Fixed: 2 Fixed: 2
plugin: status-bar run:
plugin: status-bar

View file

@ -1,6 +1,7 @@
//! Definition of the actions that can be bound to keys. //! Definition of the actions that can be bound to keys.
use super::command::RunCommandAction; use super::command::RunCommandAction;
use crate::input::options::OnForceClose;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zellij_tile::data::InputMode; use zellij_tile::data::InputMode;
@ -81,3 +82,12 @@ pub enum Action {
MouseHold(Position), MouseHold(Position),
Copy, Copy,
} }
impl From<OnForceClose> for Action {
fn from(ofc: OnForceClose) -> Action {
match ofc {
OnForceClose::Quit => Action::Quit,
OnForceClose::Detach => Action::Detach,
}
}
}

View file

@ -11,6 +11,7 @@ pub enum TerminalAction {
#[derive(Clone, Debug, Deserialize, Default, Serialize, PartialEq, Eq)] #[derive(Clone, Debug, Deserialize, Default, Serialize, PartialEq, Eq)]
pub struct RunCommand { pub struct RunCommand {
#[serde(alias = "cmd")]
pub command: PathBuf, pub command: PathBuf,
#[serde(default)] #[serde(default)]
pub args: Vec<String>, pub args: Vec<String>,

View file

@ -8,7 +8,11 @@
// place. // place.
// If plugins should be able to depend on the layout system // If plugins should be able to depend on the layout system
// then [`zellij-utils`] could be a proper place. // then [`zellij-utils`] could be a proper place.
use crate::{input::config::ConfigError, pane_size::PositionAndSize, setup}; use crate::{
input::{command::RunCommand, config::ConfigError},
pane_size::PositionAndSize,
setup,
};
use crate::{serde, serde_yaml}; use crate::{serde, serde_yaml};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -29,6 +33,15 @@ pub enum SplitSize {
Fixed(u16), // An absolute number of columns or rows Fixed(u16), // An absolute number of columns or rows
} }
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(crate = "self::serde")]
pub enum Run {
#[serde(rename = "plugin")]
Plugin(Option<PathBuf>),
#[serde(rename = "command")]
Command(RunCommand),
}
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(crate = "self::serde")] #[serde(crate = "self::serde")]
pub struct Layout { pub struct Layout {
@ -36,7 +49,7 @@ pub struct Layout {
#[serde(default)] #[serde(default)]
pub parts: Vec<Layout>, pub parts: Vec<Layout>,
pub split_size: Option<SplitSize>, pub split_size: Option<SplitSize>,
pub plugin: Option<PathBuf>, pub run: Option<Run>,
} }
type LayoutResult = Result<Layout, ConfigError>; type LayoutResult = Result<Layout, ConfigError>;
@ -127,13 +140,28 @@ impl Layout {
let mut total_panes = 0; let mut total_panes = 0;
total_panes += self.parts.len(); total_panes += self.parts.len();
for part in self.parts.iter() { for part in self.parts.iter() {
if part.plugin.is_none() { match part.run {
total_panes += part.total_terminal_panes(); Some(Run::Command(_)) | None => {
total_panes += part.total_terminal_panes();
}
Some(Run::Plugin(_)) => {}
} }
} }
total_panes total_panes
} }
pub fn extract_run_instructions(&self) -> Vec<Option<Run>> {
let mut run_instructions = vec![];
if self.parts.is_empty() {
run_instructions.push(self.run.clone());
}
for part in self.parts.iter() {
let mut current_runnables = part.extract_run_instructions();
run_instructions.append(&mut current_runnables);
}
run_instructions
}
pub fn position_panes_in_space( pub fn position_panes_in_space(
&self, &self,
space: &PositionAndSize, space: &PositionAndSize,

View file

@ -2,12 +2,39 @@
use crate::cli::Command; use crate::cli::Command;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr;
use structopt::StructOpt; use structopt::StructOpt;
use zellij_tile::data::InputMode; use zellij_tile::data::InputMode;
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize)]
pub enum OnForceClose {
#[serde(alias = "quit")]
Quit,
#[serde(alias = "detach")]
Detach,
}
impl Default for OnForceClose {
fn default() -> Self {
Self::Detach
}
}
impl FromStr for OnForceClose {
type Err = Box<dyn std::error::Error>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"quit" => Ok(Self::Quit),
"detach" => Ok(Self::Detach),
e => Err(e.to_string().into()),
}
}
}
#[derive(Clone, Default, Debug, PartialEq, Deserialize, Serialize, StructOpt)] #[derive(Clone, Default, Debug, PartialEq, Deserialize, Serialize, StructOpt)]
/// Options that can be set either through the config file, /// Options that can be set either through the config file,
/// or cli flags /// or cli flags - cli flags should take precedence over the config file
pub struct Options { pub struct Options {
/// Allow plugins to use a more simplified layout /// Allow plugins to use a more simplified layout
/// that is compatible with more fonts /// that is compatible with more fonts
@ -29,7 +56,11 @@ pub struct Options {
pub layout_dir: Option<PathBuf>, pub layout_dir: Option<PathBuf>,
#[structopt(long)] #[structopt(long)]
#[serde(default)] #[serde(default)]
/// Disable handling of mouse events
pub disable_mouse_mode: bool, pub disable_mouse_mode: bool,
/// Set behaviour on force close (quit or detach)
#[structopt(long)]
pub on_force_close: Option<OnForceClose>,
} }
impl Options { impl Options {
@ -45,37 +76,16 @@ impl Options {
/// will supercede a `Some` in `self` /// will supercede a `Some` in `self`
// TODO: Maybe a good candidate for a macro? // TODO: Maybe a good candidate for a macro?
pub fn merge(&self, other: Options) -> Options { pub fn merge(&self, other: Options) -> Options {
let simplified_ui = if other.simplified_ui { let merge_bool = |opt_other, opt_self| if opt_other { true } else { opt_self };
true
} else {
self.simplified_ui
};
let default_mode = match other.default_mode { let simplified_ui = merge_bool(other.simplified_ui, self.simplified_ui);
None => self.default_mode, let disable_mouse_mode = merge_bool(other.disable_mouse_mode, self.disable_mouse_mode);
other => other,
};
let default_shell = match other.default_shell { let default_mode = other.default_mode.or(self.default_mode);
None => self.default_shell.clone(), let default_shell = other.default_shell.or_else(|| self.default_shell.clone());
other => other, let layout_dir = other.layout_dir.or_else(|| self.layout_dir.clone());
}; let theme = other.theme.or_else(|| self.theme.clone());
let on_force_close = other.on_force_close.or(self.on_force_close);
let layout_dir = match other.layout_dir {
None => self.layout_dir.clone(),
other => other,
};
let theme = match other.theme {
None => self.theme.clone(),
other => other,
};
let disable_mouse_mode = if other.disable_mouse_mode {
true
} else {
self.disable_mouse_mode
};
Options { Options {
simplified_ui, simplified_ui,
@ -84,6 +94,7 @@ impl Options {
default_shell, default_shell,
layout_dir, layout_dir,
disable_mouse_mode, disable_mouse_mode,
on_force_close,
} }
} }

View file

@ -7,9 +7,60 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use log::LevelFilter;
use log4rs::append::file::FileAppender;
use log4rs::config::{Appender, Config, Logger, Root};
use log4rs::encode::pattern::PatternEncoder;
use crate::consts::{ZELLIJ_TMP_LOG_DIR, ZELLIJ_TMP_LOG_FILE}; use crate::consts::{ZELLIJ_TMP_LOG_DIR, ZELLIJ_TMP_LOG_FILE};
use crate::shared::set_permissions; use crate::shared::set_permissions;
pub fn configure_logger() {
// {n} means platform dependent newline
// module is padded to exactly 25 bytes and thread is padded to be between 10 and 15 bytes.
let file_pattern = "{highlight({level:<6})} |{module:<25.25}| {date(%Y-%m-%d %H:%M:%S.%3f)} [{thread:<10.15}] [{file}:{line}]: {message} {n}";
// default zellij appender, should be used across most of the codebase.
let log_file = FileAppender::builder()
.encoder(Box::new(PatternEncoder::new(file_pattern)))
.append(true)
.build(ZELLIJ_TMP_LOG_DIR.join("zellij.log"))
.unwrap();
// plugin appender. To be used in loggin_pipe to forward stderr output from plugins. We do some formatting
// in logging_pipe to print plugin name as 'module' and plugin_id instead of thread.
let log_plugin = FileAppender::builder()
.encoder(Box::new(PatternEncoder::new(
"{highlight({level:<6})} {message} {n}",
)))
.append(true)
.build(ZELLIJ_TMP_LOG_DIR.join("zellij.log"))
.unwrap();
// Set the default logging level to "info" and log it to zellij.log file
// Decrease verbosity for `wasmer_compiler_cranelift` module because it has a lot of useless info logs
// For `zellij_server::logging_pipe`, we use custom format as we use logging macros to forward stderr output from plugins
let config = Config::builder()
.appender(Appender::builder().build("logFile", Box::new(log_file)))
.appender(Appender::builder().build("logPlugin", Box::new(log_plugin)))
.logger(
Logger::builder()
.appender("logFile")
.build("wasmer_compiler_cranelift", LevelFilter::Warn),
)
.logger(
Logger::builder()
.appender("logPlugin")
.additive(false)
.build("zellij_server::logging_pipe", LevelFilter::Trace),
)
.build(Root::builder().appender("logFile").build(LevelFilter::Info))
.unwrap();
let _ = log4rs::init_config(config).unwrap();
}
pub fn atomic_create_file(file_name: &Path) -> io::Result<()> { pub fn atomic_create_file(file_name: &Path) -> io::Result<()> {
let _ = fs::OpenOptions::new() let _ = fs::OpenOptions::new()
.append(true) .append(true)