提交 d7d11f77 编写于 作者: B Ben S

Use unicode_width crate

上级 adbaa51c
......@@ -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" ]
......
use std::iter::repeat;
use options::{SizeFormat, TimeType};
use ansi_term::Style;
use unicode_width::UnicodeWidthStr;
use options::{SizeFormat, TimeType};
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum Column {
......@@ -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
......
#![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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册