diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 1b73af90..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,46 +0,0 @@ -on: - release: - types: [created] - push: - pull_request: - -name: ci - -jobs: - check: - name: Check - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Run cargo check - uses: actions-rs/cargo@v1 - with: - command: check - - test: - name: Test Suite - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Run cargo test - uses: actions-rs/cargo@v1 - with: - command: test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 31f20366..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Publish - -on: - workflow_dispatch: - push: - tags: - - '*' - -jobs: - publish: - name: ${{ matrix.target }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-20.04 - target: x86_64-unknown-linux-gnu - toolchain: stable - use-cross: false - - - os: ubuntu-20.04 - target: x86_64-unknown-linux-musl - toolchain: stable - use-cross: false - - - os: ubuntu-20.04 - target: aarch64-unknown-linux-gnu - toolchain: stable - use-cross: true - - - os: ubuntu-20.04 - target: aarch64-unknown-linux-musl - toolchain: stable - use-cross: true - - - os: macos-latest - target: x86_64-apple-darwin - toolchain: stable - use-cross: false - - - os: macos-latest - target: aarch64-apple-darwin - toolchain: stable - use-cross: false - - - os: windows-latest - target: x86_64-pc-windows-msvc - toolchain: nightly-2023-06-11 - use-cross: false - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.toolchain }} - profile: minimal - override: true - target: ${{ matrix.target }} - - - name: rust cache restore - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} - - - name: Build - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.use-cross }} - command: build - args: --target ${{ matrix.target }} --release --locked - - - name: Upload files (only for Mac/Linux) - if: matrix.target != 'x86_64-pc-windows-msvc' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - UPLOADTOOL_ISPRERELEASE: true - VERSION: ${{ github.ref_name }} - run: | - curl -L https://github.com/probonopd/uploadtool/raw/master/upload.sh --output upload.sh - mv target/${{ matrix.target }}/release/erd erd - tar -cavf erd-${VERSION}-${{ matrix.target }}.tar.gz erd CHANGELOG.md README.md LICENSE - bash upload.sh erd-${VERSION}-${{ matrix.target }}.tar.gz - - - name: Rename files (only for Windows) - if: matrix.target == 'x86_64-pc-windows-msvc' - env: - VERSION: ${{ github.ref_name }} - run: | - mkdir output/ - mv target/${{ matrix.target }}/release/erd.exe output/erd-$env:VERSION-${{ matrix.target }}.exe - - - name: Upload files (only for Windows) - uses: ncipollo/release-action@v1 - if: matrix.target == 'x86_64-pc-windows-msvc' - with: - allowUpdates: true - artifacts: "output/*" - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..afbc4151 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release + +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+-custom + - v[0-9]+.[0-9]+.[0-9]+-custom-r[0-9]+ + +permissions: + contents: write + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-22.04 + rust-target: x86_64-unknown-linux-gnu + - os: macos-12 + rust-target: x86_64-apple-darwin + - os: macos-12 + rust-target: aarch64-apple-darwin + env: + xcode_version: 14.2 + macosx_sdk: macosx13.1 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set RUST_TARGET + run: echo 'RUST_TARGET=${{ matrix.rust-target }}' >> $GITHUB_ENV + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + target: ${{ matrix.rust-target }} + + - name: Setup Xcode for macOS + if: matrix.os == 'macos-12' + run: sudo xcode-select -s '/Applications/Xcode_${{ env.xcode_version }}.app' + + - name: Set environment variables for Apple Silicon + if: matrix.rust-target == 'aarch64-apple-darwin' + run: | + export SDKROOT=$(xcrun -sdk ${{ env.macosx_sdk }} --show-sdk-path) + [[ -n $SDKROOT ]] && echo "SDKROOT=$SDKROOT" >> $GITHUB_ENV + export MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk ${{ env.macosx_sdk }} --show-sdk-platform-version) + [[ -n $MACOSX_DEPLOYMENT_TARGET ]] && echo "MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET" >> $GITHUB_ENV + + - name: Build + run: make + + - name: Release + uses: ncipollo/release-action@v1 + with: + artifacts: "*.tar.xz" + allowUpdates: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index f7bd7ac6..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,116 +0,0 @@ -name: Test App With Cache - -on: - workflow_dispatch: - inputs: - version: - description: "tag version" - required: true - default: "v0.0.1" - -jobs: - publish: - name: ${{ matrix.target }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-20.04 - target: x86_64-unknown-linux-gnu - use-cross: false - - - os: ubuntu-20.04 - target: x86_64-unknown-linux-musl - use-cross: false - - - os: ubuntu-20.04 - target: aarch64-unknown-linux-gnu - use-cross: true - - - os: ubuntu-20.04 - target: aarch64-unknown-linux-musl - use-cross: true - - - os: macos-latest - target: x86_64-apple-darwin - use-cross: false - - - os: macos-latest - target: aarch64-apple-darwin - use-cross: false - - - os: windows-latest - target: x86_64-pc-windows-msvc - use-cross: false - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - target: ${{ matrix.target }} - - - name: rust cache restore - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} - - - - name: Build - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.use-cross }} - command: build - args: --target ${{ matrix.target }} --release --locked - - - name: Rename files (only for Mac/Linux) - if: matrix.target != 'x86_64-pc-windows-msvc' - env: - VERSION: ${{ inputs.version }} - run: | - mkdir output/ - mv target/${{ matrix.target }}/release/et et - tar -cavf output/et-${VERSION}-${{ matrix.target }}.tar.gz et CHANGELOG.md README.md LICENSE - - - name: Rename files (only for Windows) - if: matrix.target == 'x86_64-pc-windows-msvc' - env: - VERSION: ${{ inputs.version }} - run: | - mkdir output/ - mv target/${{ matrix.target }}/release/et.exe output/et-$env:VERSION-${{ matrix.target }}.exe - - - name: Upload files - # arg info: https://github.com/ncipollo/release-action#release-action - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - prerelease: true - artifacts: "output/*" - tag: ${{ inputs.version }} - token: ${{ secrets.GITHUB_TOKEN }} - - - - name: rust cache store - uses: actions/cache/save@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} diff --git a/Cargo.lock b/Cargo.lock index 90778b58..3f2c7310 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,6 +300,7 @@ dependencies = [ "strip-ansi-escapes", "tempfile", "thiserror", + "unicode-width", "winapi", ] @@ -967,8 +968,7 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-width" version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +source = "git+https://github.com/waltarix/unicode-width?tag=v0.1.10-custom-r3#b80bfc311320645e2e715fc09fd174152a7e399a" [[package]] name = "utf8parse" diff --git a/Cargo.toml b/Cargo.toml index 31f2c53b..905c7634 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ lscolors = { version = "0.13.0", features = ["ansi_term"] } once_cell = "1.17.0" regex = "1.7.3" thiserror = "1.0.40" +unicode-width = "0.1.10" [target.'cfg(unix)'.dependencies] libc = "0.2.141" @@ -51,3 +52,12 @@ winapi = "0.3.9" indoc = "2.0.0" strip-ansi-escapes = "0.1.1" tempfile = "3.4.0" + +[profile.release] +codegen-units = 1 +lto = true +strip = true +opt-level = 3 + +[patch.crates-io] +unicode-width = { git = "https://github.com/waltarix/unicode-width", tag = "v0.1.10-custom-r3" } diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..2c2524fa --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +ifeq ($(RUST_TARGET),) + TARGET := + RELEASE_SUFFIX := +else + TARGET := $(RUST_TARGET) + RELEASE_SUFFIX := -$(TARGET) + export CARGO_BUILD_TARGET = $(RUST_TARGET) +endif + +PROJECT_NAME := erd + +_HASH := \# +VERSION := $(lastword $(subst @, ,$(subst $(_HASH), ,$(shell cargo pkgid)))) +RELEASE := $(PROJECT_NAME)-$(VERSION)$(RELEASE_SUFFIX) + +DIST_DIR := dist +RELEASE_DIR := $(DIST_DIR)/$(RELEASE) + +BINARY := target/$(TARGET)/release/$(PROJECT_NAME) + +RELEASE_BINARY := $(RELEASE_DIR)/$(PROJECT_NAME) + +ARTIFACT := $(RELEASE).tar.xz + +.PHONY: all +all: $(ARTIFACT) + +$(BINARY): + cargo build --locked --release + +$(DIST_DIR) $(RELEASE_DIR): + mkdir -p $@ + +$(RELEASE_BINARY): $(BINARY) $(RELEASE_DIR) + cp -f $< $@ + +$(ARTIFACT): $(RELEASE_BINARY) + tar -C $(DIST_DIR) -Jcvf $@ $(RELEASE) + +.PHONY: clean +clean: + $(RM) -rf $(ARTIFACT) $(DIST_DIR) diff --git a/src/ansi.rs b/src/ansi.rs index a5682e3c..afbaae10 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -1,3 +1,5 @@ +use unicode_width::UnicodeWidthChar; + /// Trait that provides functionality to ANSI escaped strings to be truncated in a manner that /// preserves the ANSI color/style escape sequences. Consider the following: /// @@ -35,9 +37,13 @@ pub trait Escaped: AsRef { } } } - char_count += 1; + char_count += ch.width().unwrap_or(0); + + if char_count > new_len { + resultant.pop(); + } - if char_count == new_len { + if char_count >= new_len { break; } } @@ -61,4 +67,14 @@ fn truncate() { let trunc = ::truncate(&base, 5); assert_eq!(control, trunc); + + let base = format!("{}{}", Red.bold().paint("こんにちは、世界"), "!!!"); + assert_eq!( + Red.bold().paint("こん").to_string(), + ::truncate(&base, 5) + ); + assert_eq!( + Red.bold().paint("こんにちは").to_string(), + ::truncate(&base, 10) + ); } diff --git a/src/context/config/mod.rs b/src/context/config/mod.rs index c28c3a7a..659ae4eb 100644 --- a/src/context/config/mod.rs +++ b/src/context/config/mod.rs @@ -2,6 +2,7 @@ const ERDTREE_CONFIG_TOML: &str = ".erdtree.toml"; const ERDTREE_TOML_PATH: &str = "ERDTREE_TOML_PATH"; const ERDTREE_CONFIG_NAME: &str = ".erdtreerc"; +const ERDTREE_CONFIG_NAME_XDG: &str = "config"; const ERDTREE_CONFIG_PATH: &str = "ERDTREE_CONFIG_PATH"; const ERDTREE_DIR: &str = "erdtree"; diff --git a/src/context/config/rc.rs b/src/context/config/rc.rs index 27192b75..f3d8b72f 100644 --- a/src/context/config/rc.rs +++ b/src/context/config/rc.rs @@ -91,7 +91,7 @@ fn config_from_xdg_path() -> Option { let config_path = xdg_config .join(super::ERDTREE_DIR) - .join(super::ERDTREE_CONFIG_NAME); + .join(super::ERDTREE_CONFIG_NAME_XDG); fs::read_to_string(config_path).ok().or_else(|| { let config_path = xdg_config.join(super::ERDTREE_CONFIG_NAME); diff --git a/src/context/mod.rs b/src/context/mod.rs index 948770b0..2855ab17 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -151,7 +151,7 @@ pub struct Context { pub sort: sort::Type, /// Sort directories before or after all other file types - #[arg(long, value_enum, default_value_t)] + #[arg(short = 'D', long, value_enum, default_value_t, default_missing_value = "last", num_args = 0..=1)] pub dir_order: dir::Order, /// Number of threads to use diff --git a/src/context/time.rs b/src/context/time.rs index 88f9657c..5216b0df 100644 --- a/src/context/time.rs +++ b/src/context/time.rs @@ -21,6 +21,7 @@ pub enum Stamp { #[derive(Copy, Clone, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord, Default)] pub enum Format { /// Timestamp formatted following the iso8601, with slight differences and the time-zone omitted + #[default] Iso, /// Timestamp formatted following the exact iso8601 specifications @@ -30,6 +31,5 @@ pub enum Format { Short, /// Timestamp is shown in DD MMM HH:MM format - #[default] Default, } diff --git a/src/fs/permissions/file_type.rs b/src/fs/permissions/file_type.rs index 08fe8ce9..6252b54f 100644 --- a/src/fs/permissions/file_type.rs +++ b/src/fs/permissions/file_type.rs @@ -17,7 +17,7 @@ impl FileType { pub const fn identifier(&self) -> char { match self { Self::Directory => 'd', - Self::File => '.', + Self::File => '-', Self::Symlink => 'l', Self::Fifo => 'p', Self::Socket => 's', @@ -31,6 +31,7 @@ impl FileType { impl TryFrom for FileType { type Error = Error; + #[allow(clippy::useless_conversion)] fn try_from(mode: u32) -> Result { let file_mask = mode & u32::from(libc::S_IFMT); diff --git a/src/fs/permissions/mod.rs b/src/fs/permissions/mod.rs index 4beea3ba..7eeee486 100644 --- a/src/fs/permissions/mod.rs +++ b/src/fs/permissions/mod.rs @@ -110,6 +110,7 @@ impl Display for FileModeXAttrs<'_> { /// For the octal representation of permissions impl Octal for FileMode { + #[allow(clippy::useless_conversion)] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let modes_mask = self.st_mode & !u32::from(libc::S_IFMT); fmt::Octal::fmt(&modes_mask, f) diff --git a/src/fs/permissions/test.rs b/src/fs/permissions/test.rs index 31a17f94..573a8004 100644 --- a/src/fs/permissions/test.rs +++ b/src/fs/permissions/test.rs @@ -24,7 +24,7 @@ fn test_symbolic_notation() -> Result<(), Box> { assert_eq!(&other.triad, &PermissionsTriad::Read); let rwx = format!("{file_mode}"); - assert_eq!(rwx, ".rw-r--r--"); + assert_eq!(rwx, "-rw-r--r--"); let octal = format!("{file_mode:o}"); assert_eq!(octal, "644"); @@ -47,7 +47,7 @@ fn test_symbolic_notation_special_attr() -> Result<(), Box> { let file_mode = permissions.try_mode_symbolic_notation()?; let rwx = format!("{file_mode}"); - assert_eq!(rwx, ".rw-r--r-T"); + assert_eq!(rwx, "-rw-r--r-T"); let octal = format!("{file_mode:o}"); assert_eq!(octal, "1644"); @@ -57,7 +57,7 @@ fn test_symbolic_notation_special_attr() -> Result<(), Box> { let file_mode = permissions.try_mode_symbolic_notation()?; let rwx = format!("{file_mode}"); - assert_eq!(rwx, ".rw-r-Sr--"); + assert_eq!(rwx, "-rw-r-Sr--"); let octal = format!("{file_mode:o}"); assert_eq!(octal, "2644"); @@ -67,7 +67,7 @@ fn test_symbolic_notation_special_attr() -> Result<(), Box> { let file_mode = permissions.try_mode_symbolic_notation()?; let rwx = format!("{file_mode}"); - assert_eq!(rwx, ".rwSr--r--"); + assert_eq!(rwx, "-rwSr--r--"); let octal = format!("{file_mode:o}"); assert_eq!(octal, "4644"); @@ -77,7 +77,7 @@ fn test_symbolic_notation_special_attr() -> Result<(), Box> { let file_mode = permissions.try_mode_symbolic_notation()?; let rwx = format!("{file_mode}"); - assert_eq!(rwx, ".rwSr-Sr-T"); + assert_eq!(rwx, "-rwSr-Sr-T"); let octal = format!("{file_mode:o}"); assert_eq!(octal, "7644"); @@ -87,7 +87,7 @@ fn test_symbolic_notation_special_attr() -> Result<(), Box> { let file_mode = permissions.try_mode_symbolic_notation()?; let rwx = format!("{file_mode}"); - assert_eq!(rwx, ".rwsrwsrwt"); + assert_eq!(rwx, "-rwsrwsrwt"); let octal = format!("{file_mode:o}"); assert_eq!(octal, "7777"); diff --git a/src/icons/fs.rs b/src/icons/fs.rs index aa56ac70..f5e04cf2 100644 --- a/src/icons/fs.rs +++ b/src/icons/fs.rs @@ -58,7 +58,7 @@ pub fn compute_with_color( foreground: Some(fg), .. }) => { - let ansi_string: ANSIGenericString = fg.bold().paint(icon); + let ansi_string: ANSIGenericString = fg.paint(icon); let styled_icon = ansi_string.to_string(); Cow::from(styled_icon) }, diff --git a/src/icons/mod.rs b/src/icons/mod.rs index 7ac580f8..fd1d6c62 100644 --- a/src/icons/mod.rs +++ b/src/icons/mod.rs @@ -52,8 +52,8 @@ static DEFAULT_ICON: Lazy<(u8, &str)> = Lazy::new(|| (66, "\u{f15b}")); /// Dev icons sourced from [`exa`](https://github.com/ogham/exa/blob/master/src/output/icons.rs) static FILE_TYPE_ICON_MAP: Lazy> = Lazy::new(|| { hash!( - "dir" => "\u{f413}", //  - "symlink" => "\u{f482}" //  + "dir" => "\u{f4d4}", //  + "symlink" => "\u{f481}" //  ) }); diff --git a/src/render/grid/cell.rs b/src/render/grid/cell.rs index c24172e1..0e6b17a6 100644 --- a/src/render/grid/cell.rs +++ b/src/render/grid/cell.rs @@ -237,7 +237,7 @@ impl<'a> Cell<'a> { out }; - write!(f, "{formatted_datetime}") + write!(f, "[{formatted_datetime}]") } /// Rules on how to format timestamp diff --git a/src/render/theme.rs b/src/render/theme.rs index 926688ae..ac3f304c 100644 --- a/src/render/theme.rs +++ b/src/render/theme.rs @@ -2,7 +2,7 @@ use crate::{ styles::{self, ThemesMap}, tree::node::Node, }; -use ansi_term::{Color, Style}; +use ansi_term::Style; use std::borrow::Cow; type Theme = Box &'static ThemesMap>; @@ -44,11 +44,12 @@ pub fn link_theme_getter() -> Theme { pub fn stylize_file_name(node: &Node) -> Cow<'_, str> { let name = node.file_name(); let style = node.style(); + let symlink_target_style = node.symlink_target_style(); let Some(target_name) = node.symlink_target_file_name() else { - if let Some(Style {foreground: Some(ref fg), .. }) = style { + if let Some(style) = style { let file_name = name.to_string_lossy(); - let styled_name = fg.bold().paint(file_name).to_string(); + let styled_name = style.paint(file_name).to_string(); return Cow::from(styled_name); } @@ -57,14 +58,17 @@ pub fn stylize_file_name(node: &Node) -> Cow<'_, str> { if let Some(color) = style { let styled_name = color.paint(name.to_string_lossy()); - let target_name = Color::Red.paint(format!("\u{2192} {}", target_name.to_string_lossy())); + let target_name = symlink_target_style.map_or_else( + || Style::default().paint(target_name.to_string_lossy()), + |style| style.paint(target_name.to_string_lossy()), + ); - return Cow::from(format!("{styled_name} {target_name}")); + return Cow::from(format!("{styled_name} -> {target_name}")); } let link = name.to_string_lossy(); let target = target_name.to_string_lossy(); - Cow::from(format!("{link} \u{2192} {target}")) + Cow::from(format!("{link} -> {target}")) } /// Styles the symbolic notation of file permissions. diff --git a/src/styles/mod.rs b/src/styles/mod.rs index 42cae258..cc2f0001 100644 --- a/src/styles/mod.rs +++ b/src/styles/mod.rs @@ -212,62 +212,63 @@ fn init_plain() { #[inline] fn init_themes_for_long_view() { let permissions_theme = hash! { - '-' | '.' => Color::Purple.normal(), - 'd' => Color::Blue.bold(), - 'l' => Color::Red.bold(), - 'r' => Color::Green.bold(), - 'w' => Color::Yellow.bold(), - 'x' | 's' | 'S' | 't' | 'T' => Color::Red.bold(), - '@' => Color::Cyan.bold(), + '-' => Color::RGB(0x80, 0x80, 0x80).normal(), + 'd' => Color::RGB(0x85, 0xd8, 0xff).normal(), + 'l' => Color::Cyan.normal(), + 'r' => Color::Yellow.normal(), + 'w' => Color::RGB(0xfa, 0x80, 0x72).normal(), + 'x' => Color::Green.normal(), + 's' | 'S' | 't' | 'T' => Color::Red.normal(), + '@' => Color::Cyan.normal(), ' ' => Color::White.normal() }; PERMISSIONS_THEME.set(permissions_theme).unwrap(); - let octal_permissions_style = Color::Purple.bold(); + let octal_permissions_style = Color::Yellow.normal(); OCTAL_PERMISSIONS_STYLE .set(octal_permissions_style) .unwrap(); - let ino_style = Color::Cyan.bold(); + let ino_style = Color::RGB(0xd3, 0xd3, 0xd3).normal(); INO_STYLE.set(ino_style).unwrap(); - let nlink_style = Color::Red.bold(); + let nlink_style = Color::RGB(0xdd, 0xa0, 0xdd).normal(); NLINK_STYLE.set(nlink_style).unwrap(); - let datetime_style = Color::Purple.bold(); + let datetime_style = Color::RGB(0xad, 0xff, 0x2f).normal(); DATETIME_STYLE.set(datetime_style).unwrap(); - let owner_style = Color::Cyan.bold(); + let owner_style = Color::Cyan.normal(); OWNER_STYLE.set(owner_style).unwrap(); - let group_style = Color::Green.bold(); + let group_style = Color::Green.normal(); GROUP_STYLE.set(group_style).unwrap(); } /// Initializes all color themes. fn init_themes() { let theme = hash! { - "vt" => format!("{}", Color::Purple.paint(VT)), - "uprt" => format!("{}", Color::Purple.paint(UPRT)), - "drt" => format!("{}", Color::Purple.paint(DRT)), - "vtrt" => format!("{}", Color::Purple.paint(VTRT)) + "vt" => format!("{}", Color::White.paint(VT)), + "uprt" => format!("{}", Color::White.paint(UPRT)), + "drt" => format!("{}", Color::White.paint(DRT)), + "vtrt" => format!("{}", Color::White.paint(VTRT)) }; TREE_THEME.set(theme).unwrap(); let link_theme = hash! { - "vt" => format!("{}", Color::Red.paint(VT)), - "uprt" => format!("{}", Color::Red.paint(UPRT)), - "drt" => format!("{}", Color::Red.paint(DRT)), - "vtrt" => format!("{}", Color::Red.paint(VTRT)) + "vt" => format!("{}", Color::White.paint(VT)), + "uprt" => format!("{}", Color::White.paint(UPRT)), + "drt" => format!("{}", Color::White.paint(DRT)), + "vtrt" => format!("{}", Color::White.paint(VTRT)) }; LINK_THEME.set(link_theme).unwrap(); let du_theme = hash! { - "B" => Color::Cyan.bold(), - "KB" | "KiB" => Color::Yellow.bold(), - "MB" | "MiB" => Color::Green.bold(), - "GB" | "GiB" => Color::Red.bold(), - "TB" | "TiB" => Color::Blue.bold() + "B" => Color::RGB(0xc0, 0xc0, 0xc0).normal(), + "KB" | "KiB" => Color::RGB(0x90, 0xee, 0x90).normal(), + "MB" | "MiB" => Color::RGB(0xf0, 0xe6, 0x8c).normal(), + "GB" | "GiB" => Color::RGB(0xff, 0x7f, 0x50).normal(), + "TB" | "TiB" => Color::Red.normal() }; DU_THEME.set(du_theme).unwrap(); diff --git a/src/tree/node/mod.rs b/src/tree/node/mod.rs index cca2e9e5..da254349 100644 --- a/src/tree/node/mod.rs +++ b/src/tree/node/mod.rs @@ -42,6 +42,7 @@ pub struct Node { file_size: Option, style: Option