mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-25 17:51:10 +00:00
Use unicode_width crate
This commit is contained in:
parent
adbaa51cb9
commit
d7d11f77f3
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -12,6 +12,7 @@ dependencies = [
|
||||
"num_cpus 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"number_prefix 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pad 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"users 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -8,6 +8,7 @@ name = "exa"
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.5.0"
|
||||
bitflags = "0.1"
|
||||
datetime = "0.1.3"
|
||||
getopts = "0.2.1"
|
||||
locale = "0.1.2"
|
||||
@ -15,8 +16,8 @@ natord = "1.0.7"
|
||||
num_cpus = "*"
|
||||
number_prefix = "0.2.3"
|
||||
pad = "0.1.1"
|
||||
unicode-width = "*"
|
||||
users = "0.3.1"
|
||||
bitflags = "0.1"
|
||||
|
||||
[features]
|
||||
default = [ "git" ]
|
||||
|
@ -1,9 +1,12 @@
|
||||
use std::iter::repeat;
|
||||
|
||||
use ansi_term::Style;
|
||||
|
||||
use options::{SizeFormat, TimeType};
|
||||
|
||||
use ansi_term::Style;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
|
||||
|
||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||
pub enum Column {
|
||||
Permissions,
|
||||
@ -86,7 +89,7 @@ impl Cell {
|
||||
pub fn paint(style: Style, string: &str) -> Cell {
|
||||
Cell {
|
||||
text: style.paint(string).to_string(),
|
||||
length: string.width(false),
|
||||
length: UnicodeWidthStr::width(string),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ use ansi_term::Colour::{Red, Green, Yellow, Blue, Purple, Cyan, Fixed};
|
||||
use users::Users;
|
||||
|
||||
use locale;
|
||||
use output::details::UserLocale;
|
||||
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use number_prefix::{binary_prefix, decimal_prefix, Prefixed, Standalone, PrefixNames};
|
||||
|
||||
@ -30,6 +31,7 @@ use column::Column::*;
|
||||
use dir::Dir;
|
||||
use filetype::HasType;
|
||||
use options::{SizeFormat, TimeType};
|
||||
use output::details::UserLocale;
|
||||
use feature::Attribute;
|
||||
|
||||
/// This grey value is directly in between white and black, so it's guaranteed
|
||||
@ -216,7 +218,7 @@ impl<'a> File<'a> {
|
||||
/// characters are 1 columns wide, but in some contexts, certain
|
||||
/// characters are actually 2 columns wide.
|
||||
pub fn file_name_width(&self) -> usize {
|
||||
self.name.width(false)
|
||||
UnicodeWidthStr::width(&self.name[..])
|
||||
}
|
||||
|
||||
/// Assuming the current file is a symlink, follows the link and
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(convert, core, exit_status, fs_ext, fs_time, io, libc, os, scoped, std_misc, unicode)]
|
||||
#![feature(collections, convert, core, exit_status, fs_ext, fs_time, io, libc, os, scoped, std_misc)]
|
||||
#![allow(deprecated)]
|
||||
|
||||
// Other platforms than macos don't need std_misc but you can't
|
||||
@ -14,6 +14,8 @@ extern crate num_cpus;
|
||||
extern crate number_prefix;
|
||||
extern crate pad;
|
||||
extern crate users;
|
||||
extern crate unicode_width;
|
||||
|
||||
|
||||
#[cfg(feature="git")]
|
||||
extern crate git2;
|
||||
|
Loading…
Reference in New Issue
Block a user