diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-07 09:37:36 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-07 12:51:31 +0530 |
commit | 28d84fc18f3efc7cfd4aa1728656998e652e934b (patch) | |
tree | b23ddb1f6ab5a72e6722de27c6560e2a5e73ad9d /src/common.rs | |
parent | 6bd6556449daae40fdabedf64866b641785787f5 (diff) |
First prettier version of mark pane
Diffstat (limited to 'src/common.rs')
-rw-r--r-- | src/common.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common.rs b/src/common.rs index 1440cc4..a9eabff 100644 --- a/src/common.rs +++ b/src/common.rs @@ -60,6 +60,18 @@ impl ByteFormat { _ => 10, } } + pub fn total_width(&self) -> usize { + use ByteFormat::*; + const THE_SPACE_BETWEEN_UNIT_AND_NUMBER: usize = 1; + + self.width() + + match self { + Binary | MiB | GiB => 3, + Metric | MB | GB => 2, + Bytes => 1, + } + + THE_SPACE_BETWEEN_UNIT_AND_NUMBER + } pub fn display(self, bytes: u64) -> ByteFormatDisplay { ByteFormatDisplay { format: self, |