Default alignment (#2481)

* WIP - compiling but not working

* semi-working

* making progress

* working except for table lines

* fmt + clippy

* cleaned up some comments

* working line colors

* fmt, clippy, updated sample config.toml

* merges

* fixed bug where no config.toml or not set settings made weird defaults.

* clippy & fmt again

* Header default alignment is left.

Co-authored-by: Andrés N. Robalino <andres@androbtech.com>
This commit is contained in:
Darren Schroeder
2020-09-01 19:08:41 -05:00
committed by GitHub
parent f9acb7a7a5
commit 57a26bbd42
7 changed files with 63 additions and 51 deletions

View File

@ -7,7 +7,7 @@ fn main() {
let width = args[1].parse::<usize>().expect("Need a width in columns");
let msg = args[2..]
.iter()
.map(|x| StyledString::new(x.to_owned(), TextStyle::basic()))
.map(|x| StyledString::new(x.to_owned(), TextStyle::basic_left()))
.collect();
let t = Table::new(

View File

@ -217,9 +217,9 @@ impl TextStyle {
}
}
pub fn basic() -> TextStyle {
pub fn basic_center() -> TextStyle {
TextStyle::new()
.alignment(Alignment::Left)
.alignment(Alignment::Center)
.style(Style::default())
}
@ -229,6 +229,12 @@ impl TextStyle {
.style(Style::default())
}
pub fn basic_left() -> TextStyle {
TextStyle::new()
.alignment(Alignment::Left)
.style(Style::default())
}
pub fn default_header() -> TextStyle {
TextStyle::new()
.alignment(Alignment::Center)