summaryrefslogtreecommitdiffstats
path: root/src/cell.rs
diff options
context:
space:
mode:
authorpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2015-11-19 09:54:38 +0100
committerpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2015-11-19 09:54:38 +0100
commit92c144e657ede392d0ae116bab85f197e64a65cd (patch)
tree3dd26f3d48ffbbca745c2cb19a85dc753aa7fcc4 /src/cell.rs
parent6add8e7b8adfb4f685224c56dae443ea522c3526 (diff)
Updated Cargo.toml and README.md.
Using style string don't panic anymore if some specifier are unknown. Tables and Rows are now Indexable. Empty rows are now correctly printed. New lines use "\n" for all platforms except windows (which uses "\r\n").
Diffstat (limited to 'src/cell.rs')
-rw-r--r--src/cell.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/cell.rs b/src/cell.rs
index 2fd50d2..31006ff 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -102,9 +102,6 @@ impl Cell {
/// * **R** : Bright Red
/// * **B** : Bright Blue
/// * ... and so on ...
- ///
- /// # Panic
- /// If the spec string is wrong
pub fn style_spec(mut self, spec: &str) -> Cell {
let mut foreground = false;
let mut background = false;
@@ -127,7 +124,11 @@ impl Cell {
'W' => color::BRIGHT_WHITE,
'd' => color::BLACK,
'D' => color::BRIGHT_BLACK,
- _ => panic!("Unsupported color specifier {}", c)
+ _ => { // Silently ignore unknown tags
+ foreground = false;
+ background = false;
+ continue;
+ }
};
if foreground { self.style(Attr::ForegroundColor(color)); }
else if background { self.style(Attr::BackgroundColor(color)); }
@@ -144,8 +145,8 @@ impl Cell {
'c' => self.align(Align::CENTER),
'l' => self.align(Align::LEFT),
'r' => self.align(Align::RIGHT),
- 'd' => {/*Default : do nothing*/}
- _ => panic!("Unsupported style specifier {}", c)
+ 'd' => {/* Default : do nothing */}
+ _ => {/* Silently ignore unknown tags */}
}
}
}