Fix ansi colors

Also upgrade deps and do some cleanup.
pull/467/head
Arijit Basu 2 years ago committed by Arijit Basu
parent bbcd0be0c4
commit 171c93dbb1

@ -22,16 +22,19 @@ jobs:
artifact_prefix: macos artifact_prefix: macos
target: x86_64-apple-darwin target: x86_64-apple-darwin
binary_postfix: '' binary_postfix: ''
- os: ubuntu-latest - os: ubuntu-latest
artifact_prefix: linux artifact_prefix: linux
target: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu
binary_postfix: '' binary_postfix: ''
- os: ubuntu-20.04 - os: ubuntu-20.04
artifact_prefix: linux-musl artifact_prefix: linux-musl
target: x86_64-unknown-linux-musl target: x86_64-unknown-linux-musl
binary_postfix: '' binary_postfix: ''
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Installing Rust toolchain - name: Installing Rust toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -42,6 +45,7 @@ jobs:
- name: Installing needed macOS dependencies - name: Installing needed macOS dependencies
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
run: brew install openssl@1.1 run: brew install openssl@1.1
- name: Installing needed Ubuntu dependencies - name: Installing needed Ubuntu dependencies
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-20.04' if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-20.04'
run: | run: |
@ -50,6 +54,7 @@ jobs:
- name: Checking out sources - name: Checking out sources
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: Running cargo build - name: Running cargo build
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
@ -113,14 +118,19 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1 - uses: actions-rs/toolchain@v1
with: with:
toolchain: stable toolchain: stable
override: true override: true
- run: | - run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
command: publish command: publish
args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty args: --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_KEY }}

110
Cargo.lock generated

@ -3,19 +3,19 @@
version = 3 version = 3
[[package]] [[package]]
name = "ansi-to-tui" name = "ansi-to-tui-forked"
version = "0.5.0" version = "0.5.2-fix.offset"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3768454e52b3f8b37b04d200dbf69af580600031af5007256cce7a0b56bd089d" checksum = "b6e5e99af6c1f7442a876dbf4b8ef6a643a05d96d99a4039803cb33b43f327ce"
dependencies = [ dependencies = [
"tui", "tui",
] ]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.56" version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
[[package]] [[package]]
name = "assert_cmd" name = "assert_cmd"
@ -411,9 +411,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.123" version = "0.2.125"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb691a747a7ab48abc15c5b42066eaafde10dc427e3b6ee2a1cf43db04c763bd" checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
@ -433,18 +433,18 @@ dependencies = [
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.16" version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]] [[package]]
name = "lua-src" name = "lua-src"
version = "544.0.0" version = "544.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7341ba039a781c4982ca20761c55f44e07bfefd496a45b1e929763d88f5fc68b" checksum = "708ba3c844d5e9d38def4a09dd871c17c370f519b3c4b7261fbabe4a613a814c"
dependencies = [ dependencies = [
"cc", "cc",
] ]
@ -460,9 +460,9 @@ dependencies = [
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.4.1" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]] [[package]]
name = "memoffset" name = "memoffset"
@ -560,9 +560,9 @@ dependencies = [
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.44" version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"num-traits", "num-traits",
@ -570,9 +570,9 @@ dependencies = [
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.14" 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 = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
@ -617,7 +617,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58"
dependencies = [ dependencies = [
"lock_api", "lock_api",
"parking_lot_core 0.9.2", "parking_lot_core 0.9.3",
] ]
[[package]] [[package]]
@ -636,9 +636,9 @@ dependencies = [
[[package]] [[package]]
name = "parking_lot_core" name = "parking_lot_core"
version = "0.9.2" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37" checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@ -829,15 +829,15 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "semver" name = "semver"
version = "1.0.7" version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.136" version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -854,9 +854,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.136" version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -865,9 +865,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.79" version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
dependencies = [ dependencies = [
"itoa 1.0.1", "itoa 1.0.1",
"ryu", "ryu",
@ -876,9 +876,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_yaml" name = "serde_yaml"
version = "0.8.23" version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0" checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"ryu", "ryu",
@ -925,9 +925,9 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.91" version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -951,18 +951,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -992,13 +992,13 @@ dependencies = [
[[package]] [[package]]
name = "tui" name = "tui"
version = "0.17.0" version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23ed0a32c88b039b73f1b6c5acbd0554bfa5b6be94467375fd947c4de3a02271" checksum = "96fe69244ec2af261bced1d9046a6fee6c8c2a6b0228e59e5ba39bc8ba4ed729"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cassowary", "cassowary",
"crossterm 0.22.1", "crossterm 0.23.2",
"serde", "serde",
"unicode-segmentation", "unicode-segmentation",
"unicode-width", "unicode-width",
@ -1037,9 +1037,9 @@ checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.2" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]] [[package]]
name = "version_check" name = "version_check"
@ -1176,9 +1176,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.34.0" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5acdd78cb4ba54c0045ac14f62d8f94a03d10047904ae2a40afa1e99d8f70825" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
dependencies = [ dependencies = [
"windows_aarch64_msvc", "windows_aarch64_msvc",
"windows_i686_gnu", "windows_i686_gnu",
@ -1189,39 +1189,39 @@ dependencies = [
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.34.0" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.34.0" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.34.0" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.34.0" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.34.0" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]] [[package]]
name = "xplr" name = "xplr"
version = "0.17.4" version = "0.17.5"
dependencies = [ dependencies = [
"ansi-to-tui", "ansi-to-tui-forked",
"anyhow", "anyhow",
"assert_cmd", "assert_cmd",
"chrono", "chrono",

@ -8,7 +8,7 @@ path = './benches/criterion.rs'
[package] [package]
name = 'xplr' name = 'xplr'
version = '0.17.4' version = '0.17.5'
authors = ['Arijit Basu <hi@arijitbasu.in>'] authors = ['Arijit Basu <hi@arijitbasu.in>']
edition = '2021' edition = '2021'
description = 'A hackable, minimal, fast TUI file explorer' description = 'A hackable, minimal, fast TUI file explorer'
@ -22,14 +22,14 @@ categories = ['command-line-interface', 'command-line-utilities']
include = ['src/**/*', 'docs/en/src/**/*', 'LICENSE', 'README.md'] include = ['src/**/*', 'docs/en/src/**/*', 'LICENSE', 'README.md']
[dependencies] [dependencies]
libc = "0.2.123" libc = "0.2.125"
humansize = "1.1.1" humansize = "1.1.1"
natord = "1.0.9" natord = "1.0.9"
anyhow = "1.0.56" anyhow = "1.0.57"
serde_yaml = "0.8.23" serde_yaml = "0.8.24"
crossterm = "0.23.2" crossterm = "0.23.2"
dirs = "4.0.0" dirs = "4.0.0"
ansi-to-tui = "0.5.0" ansi-to-tui-forked = "0.5.2-fix.offset"
[dependencies.lazy_static] [dependencies.lazy_static]
version = "1.4.0" version = "1.4.0"
@ -40,12 +40,12 @@ version = "2.0.4"
features = ["rev-mappings"] features = ["rev-mappings"]
[dependencies.tui] [dependencies.tui]
version = "0.17.0" version = "0.18.0"
default-features = false default-features = false
features = ['crossterm', 'serde'] features = ['crossterm', 'serde']
[dependencies.serde] [dependencies.serde]
version = "1.0.136" version = "1.0.137"
features = ['derive'] features = ['derive']
[dependencies.chrono] [dependencies.chrono]

@ -45,7 +45,7 @@ compatibility.
### Instructions ### Instructions
#### [v0.16.4][44] -> [v0.17.4][45] #### [v0.16.4][44] -> [v0.17.5][45]
- Deprecated `app.directory_buffer`, `app.history`, and `app.last_modes` in - Deprecated `app.directory_buffer`, `app.history`, and `app.last_modes` in
the custom dynamic layout renderer context. the custom dynamic layout renderer context.
@ -323,4 +323,4 @@ Else do the following:
[42]: https://github.com/sayanarijit/xplr/releases/tag/v0.14.4 [42]: https://github.com/sayanarijit/xplr/releases/tag/v0.14.4
[43]: https://github.com/sayanarijit/xplr/releases/tag/v0.15.2 [43]: https://github.com/sayanarijit/xplr/releases/tag/v0.15.2
[44]: https://github.com/sayanarijit/xplr/releases/tag/v0.16.4 [44]: https://github.com/sayanarijit/xplr/releases/tag/v0.16.4
[45]: https://github.com/sayanarijit/xplr/releases/tag/v0.17.4 [45]: https://github.com/sayanarijit/xplr/releases/tag/v0.17.5

@ -369,171 +369,128 @@ impl App {
if self.config.general.read_only && !msg.is_read_only() { if self.config.general.read_only && !msg.is_read_only() {
self.log_error("Cannot execute code in read-only mode.".into()) self.log_error("Cannot execute code in read-only mode.".into())
} else { } else {
use ExternalMsg::*;
match msg { match msg {
ExternalMsg::ExplorePwd => self.explore_pwd(), ExplorePwd => self.explore_pwd(),
ExternalMsg::ExploreParentsAsync => { ExploreParentsAsync => self.explore_parents_async(),
self.explore_parents_async() ExplorePwdAsync => self.explore_pwd_async(),
} Refresh => self.refresh(),
ExternalMsg::ExplorePwdAsync => self.explore_pwd_async(), ClearScreen => self.clear_screen(),
ExternalMsg::Refresh => self.refresh(), FocusFirst => self.focus_first(true),
ExternalMsg::ClearScreen => self.clear_screen(), FocusLast => self.focus_last(),
ExternalMsg::FocusFirst => self.focus_first(true), FocusPrevious => self.focus_previous(),
ExternalMsg::FocusLast => self.focus_last(), FocusPreviousByRelativeIndex(i) => {
ExternalMsg::FocusPrevious => self.focus_previous(),
ExternalMsg::FocusPreviousByRelativeIndex(i) => {
self.focus_previous_by_relative_index(i) self.focus_previous_by_relative_index(i)
} }
ExternalMsg::FocusPreviousByRelativeIndexFromInput => { FocusPreviousByRelativeIndexFromInput => {
self.focus_previous_by_relative_index_from_input() self.focus_previous_by_relative_index_from_input()
} }
ExternalMsg::FocusNext => self.focus_next(), FocusNext => self.focus_next(),
ExternalMsg::FocusNextByRelativeIndex(i) => { FocusNextByRelativeIndex(i) => {
self.focus_next_by_relative_index(i) self.focus_next_by_relative_index(i)
} }
ExternalMsg::FocusNextByRelativeIndexFromInput => { FocusNextByRelativeIndexFromInput => {
self.focus_next_by_relative_index_from_input() self.focus_next_by_relative_index_from_input()
} }
ExternalMsg::FocusPath(p) => self.focus_path(&p, true), FocusPath(p) => self.focus_path(&p, true),
ExternalMsg::FocusPathFromInput => self.focus_path_from_input(), FocusPathFromInput => self.focus_path_from_input(),
ExternalMsg::FocusByIndex(i) => self.focus_by_index(i), FocusByIndex(i) => self.focus_by_index(i),
ExternalMsg::FocusByIndexFromInput => { FocusByIndexFromInput => self.focus_by_index_from_input(),
self.focus_by_index_from_input() FocusByFileName(n) => self.focus_by_file_name(&n, true),
} ChangeDirectory(dir) => self.change_directory(&dir, true),
ExternalMsg::FocusByFileName(n) => { Enter => self.enter(),
self.focus_by_file_name(&n, true) Back => self.back(),
} LastVisitedPath => self.last_visited_path(),
ExternalMsg::ChangeDirectory(dir) => { NextVisitedPath => self.next_visited_path(),
self.change_directory(&dir, true) FollowSymlink => self.follow_symlink(),
} UpdateInputBuffer(op) => self.update_input_buffer(op),
ExternalMsg::Enter => self.enter(), UpdateInputBufferFromKey => {
ExternalMsg::Back => self.back(),
ExternalMsg::LastVisitedPath => self.last_visited_path(),
ExternalMsg::NextVisitedPath => self.next_visited_path(),
ExternalMsg::FollowSymlink => self.follow_symlink(),
ExternalMsg::UpdateInputBuffer(op) => {
self.update_input_buffer(op)
}
ExternalMsg::UpdateInputBufferFromKey => {
self.update_input_buffer_from_key(key) self.update_input_buffer_from_key(key)
} }
ExternalMsg::BufferInput(input) => self.buffer_input(&input), BufferInput(input) => self.buffer_input(&input),
ExternalMsg::BufferInputFromKey => { BufferInputFromKey => self.buffer_input_from_key(key),
self.buffer_input_from_key(key) SetInputBuffer(input) => self.set_input_buffer(input),
} RemoveInputBufferLastCharacter => {
ExternalMsg::SetInputBuffer(input) => {
self.set_input_buffer(input)
}
ExternalMsg::RemoveInputBufferLastCharacter => {
self.remove_input_buffer_last_character() self.remove_input_buffer_last_character()
} }
ExternalMsg::RemoveInputBufferLastWord => { RemoveInputBufferLastWord => {
self.remove_input_buffer_last_word() self.remove_input_buffer_last_word()
} }
ExternalMsg::ResetInputBuffer => self.reset_input_buffer(), ResetInputBuffer => self.reset_input_buffer(),
ExternalMsg::SwitchMode(mode) => self.switch_mode(&mode), SwitchMode(mode) => self.switch_mode(&mode),
ExternalMsg::SwitchModeKeepingInputBuffer(mode) => { SwitchModeKeepingInputBuffer(mode) => {
self.switch_mode_keeping_input_buffer(&mode) self.switch_mode_keeping_input_buffer(&mode)
} }
ExternalMsg::SwitchModeBuiltin(mode) => { SwitchModeBuiltin(mode) => self.switch_mode_builtin(&mode),
self.switch_mode_builtin(&mode) SwitchModeBuiltinKeepingInputBuffer(mode) => {
}
ExternalMsg::SwitchModeBuiltinKeepingInputBuffer(mode) => {
self.switch_mode_builtin_keeping_input_buffer(&mode) self.switch_mode_builtin_keeping_input_buffer(&mode)
} }
ExternalMsg::SwitchModeCustom(mode) => { SwitchModeCustom(mode) => self.switch_mode_custom(&mode),
self.switch_mode_custom(&mode) SwitchModeCustomKeepingInputBuffer(mode) => {
}
ExternalMsg::SwitchModeCustomKeepingInputBuffer(mode) => {
self.switch_mode_custom_keeping_input_buffer(&mode) self.switch_mode_custom_keeping_input_buffer(&mode)
} }
ExternalMsg::PopMode => self.pop_mode(), PopMode => self.pop_mode(),
ExternalMsg::PopModeKeepingInputBuffer => { PopModeKeepingInputBuffer => {
self.pop_mode_keeping_input_buffer() self.pop_mode_keeping_input_buffer()
} }
ExternalMsg::SwitchLayout(mode) => self.switch_layout(&mode), SwitchLayout(mode) => self.switch_layout(&mode),
ExternalMsg::SwitchLayoutBuiltin(mode) => { SwitchLayoutBuiltin(mode) => self.switch_layout_builtin(&mode),
self.switch_layout_builtin(&mode) SwitchLayoutCustom(mode) => self.switch_layout_custom(&mode),
} Call(cmd) => self.call(cmd),
ExternalMsg::SwitchLayoutCustom(mode) => { CallSilently(cmd) => self.call_silently(cmd),
self.switch_layout_custom(&mode) BashExec(cmd) => self.bash_exec(cmd),
} BashExecSilently(cmd) => self.bash_exec_silently(cmd),
ExternalMsg::Call(cmd) => self.call(cmd), CallLua(func) => self.call_lua(func),
ExternalMsg::CallSilently(cmd) => self.call_silently(cmd), CallLuaSilently(func) => self.call_lua_silently(func),
ExternalMsg::BashExec(cmd) => self.bash_exec(cmd), LuaEval(code) => self.lua_eval(code),
ExternalMsg::BashExecSilently(cmd) => { LuaEvalSilently(code) => self.lua_eval_silently(code),
self.bash_exec_silently(cmd) Select => self.select(),
} SelectAll => self.select_all(),
ExternalMsg::CallLua(func) => self.call_lua(func), SelectPath(p) => self.select_path(p),
ExternalMsg::CallLuaSilently(func) => { UnSelect => self.un_select(),
self.call_lua_silently(func) UnSelectAll => self.un_select_all(),
} UnSelectPath(p) => self.un_select_path(p),
ExternalMsg::LuaEval(code) => self.lua_eval(code), ToggleSelection => self.toggle_selection(),
ExternalMsg::LuaEvalSilently(code) => { ToggleSelectAll => self.toggle_select_all(),
self.lua_eval_silently(code) ToggleSelectionByPath(p) => self.toggle_selection_by_path(p),
} ClearSelection => self.clear_selection(),
ExternalMsg::Select => self.select(), AddNodeFilter(f) => self.add_node_filter(f),
ExternalMsg::SelectAll => self.select_all(), AddNodeFilterFromInput(f) => self.add_node_filter_from_input(f),
ExternalMsg::SelectPath(p) => self.select_path(p), RemoveNodeFilter(f) => self.remove_node_filter(f),
ExternalMsg::UnSelect => self.un_select(), RemoveNodeFilterFromInput(f) => {
ExternalMsg::UnSelectAll => self.un_select_all(),
ExternalMsg::UnSelectPath(p) => self.un_select_path(p),
ExternalMsg::ToggleSelection => self.toggle_selection(),
ExternalMsg::ToggleSelectAll => self.toggle_select_all(),
ExternalMsg::ToggleSelectionByPath(p) => {
self.toggle_selection_by_path(p)
}
ExternalMsg::ClearSelection => self.clear_selection(),
ExternalMsg::AddNodeFilter(f) => self.add_node_filter(f),
ExternalMsg::AddNodeFilterFromInput(f) => {
self.add_node_filter_from_input(f)
}
ExternalMsg::RemoveNodeFilter(f) => self.remove_node_filter(f),
ExternalMsg::RemoveNodeFilterFromInput(f) => {
self.remove_node_filter_from_input(f) self.remove_node_filter_from_input(f)
} }
ExternalMsg::ToggleNodeFilter(f) => self.toggle_node_filter(f), ToggleNodeFilter(f) => self.toggle_node_filter(f),
ExternalMsg::RemoveLastNodeFilter => { RemoveLastNodeFilter => self.remove_last_node_filter(),
self.remove_last_node_filter() ResetNodeFilters => self.reset_node_filters(),
} ClearNodeFilters => self.clear_node_filters(),
ExternalMsg::ResetNodeFilters => self.reset_node_filters(), AddNodeSorter(f) => self.add_node_sorter(f),
ExternalMsg::ClearNodeFilters => self.clear_node_filters(), RemoveNodeSorter(f) => self.remove_node_sorter(f),
ExternalMsg::AddNodeSorter(f) => self.add_node_sorter(f), ReverseNodeSorter(f) => self.reverse_node_sorter(f),
ExternalMsg::RemoveNodeSorter(f) => self.remove_node_sorter(f), ToggleNodeSorter(f) => self.toggle_node_sorter(f),
ExternalMsg::ReverseNodeSorter(f) => { RemoveLastNodeSorter => self.remove_last_node_sorter(),
self.reverse_node_sorter(f) ReverseNodeSorters => self.reverse_node_sorters(),
} ResetNodeSorters => self.reset_node_sorters(),
ExternalMsg::ToggleNodeSorter(f) => self.toggle_node_sorter(f), ClearNodeSorters => self.clear_node_sorters(),
ExternalMsg::RemoveLastNodeSorter => { EnableMouse => self.enable_mouse(),
self.remove_last_node_sorter() DisableMouse => self.disable_mouse(),
} ToggleMouse => self.toggle_mouse(),
ExternalMsg::ReverseNodeSorters => self.reverse_node_sorters(), StartFifo(f) => self.start_fifo(f),
ExternalMsg::ResetNodeSorters => self.reset_node_sorters(), StopFifo => self.stop_fifo(),
ExternalMsg::ClearNodeSorters => self.clear_node_sorters(), ToggleFifo(f) => self.toggle_fifo(f),
ExternalMsg::EnableMouse => self.enable_mouse(), LogInfo(l) => self.log_info(l),
ExternalMsg::DisableMouse => self.disable_mouse(), LogSuccess(l) => self.log_success(l),
ExternalMsg::ToggleMouse => self.toggle_mouse(), LogWarning(l) => self.log_warning(l),
ExternalMsg::StartFifo(f) => self.start_fifo(f), LogError(l) => self.log_error(l),
ExternalMsg::StopFifo => self.stop_fifo(), Quit => self.quit(),
ExternalMsg::ToggleFifo(f) => self.toggle_fifo(f), PrintPwdAndQuit => self.print_pwd_and_quit(),
ExternalMsg::LogInfo(l) => self.log_info(l), PrintFocusPathAndQuit => self.print_focus_path_and_quit(),
ExternalMsg::LogSuccess(l) => self.log_success(l), PrintSelectionAndQuit => self.print_selection_and_quit(),
ExternalMsg::LogWarning(l) => self.log_warning(l), PrintResultAndQuit => self.print_result_and_quit(),
ExternalMsg::LogError(l) => self.log_error(l), PrintAppStateAndQuit => self.print_app_state_and_quit(),
ExternalMsg::Quit => self.quit(), Debug(path) => self.debug(path),
ExternalMsg::PrintPwdAndQuit => self.print_pwd_and_quit(), Terminate => bail!(""),
ExternalMsg::PrintFocusPathAndQuit => {
self.print_focus_path_and_quit()
}
ExternalMsg::PrintSelectionAndQuit => {
self.print_selection_and_quit()
}
ExternalMsg::PrintResultAndQuit => self.print_result_and_quit(),
ExternalMsg::PrintAppStateAndQuit => {
self.print_app_state_and_quit()
}
ExternalMsg::Debug(path) => self.debug(path),
ExternalMsg::Terminate => bail!(""),
} }
}? }?
.refresh_selection() .refresh_selection()

@ -14,7 +14,6 @@ pub mod msg;
pub mod node; pub mod node;
pub mod permissions; pub mod permissions;
pub mod pipe; pub mod pipe;
pub mod pipe_reader;
pub mod pwd_watcher; pub mod pwd_watcher;
pub mod runner; pub mod runner;
pub mod ui; pub mod ui;

@ -154,24 +154,24 @@ mod tests {
assert!(check_version(VERSION, "foo path").is_ok()); assert!(check_version(VERSION, "foo path").is_ok());
// Current release if OK // Current release if OK
assert!(check_version("0.17.4", "foo path").is_ok()); assert!(check_version("0.17.5", "foo path").is_ok());
// Prev major release is ERR // Prev major release is ERR
// - Not yet // - Not yet
// Prev minor release is ERR (Change when we get to v1) // Prev minor release is ERR (Change when we get to v1)
assert!(check_version("0.16.4", "foo path").is_err()); assert!(check_version("0.16.5", "foo path").is_err());
// Prev bugfix release is OK // Prev bugfix release is OK
assert!(check_version("0.17.3", "foo path").is_ok()); assert!(check_version("0.17.4", "foo path").is_ok());
// Next major release is ERR // Next major release is ERR
assert!(check_version("1.17.4", "foo path").is_err()); assert!(check_version("1.17.5", "foo path").is_err());
// Next minor release is ERR // Next minor release is ERR
assert!(check_version("0.18.4", "foo path").is_err()); assert!(check_version("0.18.5", "foo path").is_err());
// Next bugfix release is ERR (Change when we get to v1) // Next bugfix release is ERR (Change when we get to v1)
assert!(check_version("0.17.5", "foo path").is_err()); assert!(check_version("0.17.6", "foo path").is_err());
} }
} }

@ -1,7 +1,9 @@
use std::path::PathBuf; use crate::app::ExternalMsg;
use anyhow::Result; use anyhow::Result;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fs;
use std::io::prelude::*;
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Pipe { pub struct Pipe {
@ -53,3 +55,25 @@ impl Pipe {
}) })
} }
} }
pub fn read_all(pipe: &str) -> Result<Vec<ExternalMsg>> {
let mut file = fs::OpenOptions::new()
.read(true)
.write(true)
.create(false)
.open(&pipe)?;
let mut in_str = String::new();
file.read_to_string(&mut in_str)?;
file.set_len(0)?;
if !in_str.is_empty() {
let mut msgs = vec![];
for msg in in_str.lines().map(|s| serde_yaml::from_str(s.trim())) {
msgs.push(msg?);
}
Ok(msgs)
} else {
Ok(vec![])
}
}

@ -1,26 +0,0 @@
use crate::app::ExternalMsg;
use anyhow::Result;
use std::fs;
use std::io::prelude::*;
pub fn read_all(pipe: &str) -> Result<Vec<ExternalMsg>> {
let mut file = fs::OpenOptions::new()
.read(true)
.write(true)
.create(false)
.open(&pipe)?;
let mut in_str = String::new();
file.read_to_string(&mut in_str)?;
file.set_len(0)?;
if !in_str.is_empty() {
let mut msgs = vec![];
for msg in in_str.lines().map(|s| serde_yaml::from_str(s.trim())) {
msgs.push(msg?);
}
Ok(msgs)
} else {
Ok(vec![])
}
}

@ -6,7 +6,7 @@ use crate::cli::Cli;
use crate::event_reader::EventReader; use crate::event_reader::EventReader;
use crate::explorer; use crate::explorer;
use crate::lua; use crate::lua;
use crate::pipe_reader; use crate::pipe;
use crate::pwd_watcher; use crate::pwd_watcher;
use crate::ui; use crate::ui;
use anyhow::{bail, Error, Result}; use anyhow::{bail, Error, Result};
@ -486,7 +486,7 @@ impl Runner {
}) })
.unwrap_or_else(|e| Err(e.to_string())); .unwrap_or_else(|e| Err(e.to_string()));
match pipe_reader::read_all(&app.pipe.msg_in) { match pipe::read_all(&app.pipe.msg_in) {
Ok(msgs) => { Ok(msgs) => {
app = app app = app
.handle_batch_external_msgs(msgs)?; .handle_batch_external_msgs(msgs)?;
@ -723,7 +723,7 @@ impl Runner {
.unwrap_or_else(|e| Err(e.to_string())); .unwrap_or_else(|e| Err(e.to_string()));
// TODO remove duplicate segment // TODO remove duplicate segment
match pipe_reader::read_all(&app.pipe.msg_in) { match pipe::read_all(&app.pipe.msg_in) {
Ok(msgs) => { Ok(msgs) => {
app = app app = app
.handle_batch_external_msgs(msgs)?; .handle_batch_external_msgs(msgs)?;

@ -4,7 +4,7 @@ use crate::app::{Node, ResolvedNode};
use crate::config::PanelUiConfig; use crate::config::PanelUiConfig;
use crate::lua; use crate::lua;
use crate::permissions::Permissions; use crate::permissions::Permissions;
use ansi_to_tui::ansi_to_text; use ansi_to_tui_forked::ansi_to_text;
use anyhow::Result; use anyhow::Result;
use indexmap::IndexSet; use indexmap::IndexSet;
use lazy_static::lazy_static; use lazy_static::lazy_static;

Loading…
Cancel
Save