summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2016-01-20 12:01:42 +0100
committerpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2016-01-20 12:01:42 +0100
commit73298cc53cbd88b0eed87be132787e33d965c883 (patch)
treeed4874ba234477f3f82f26653d1ad4286f49f9d2 /README.md
parent6c925d457249b369b7a1968df38875e545c0915b (diff)
parentb770f25eb61404c79e260ac951708369692b271c (diff)
Merge branch 'master' into ascription_fix
Conflicts: .travis.yml src/row.rs
Diffstat (limited to 'README.md')
-rw-r--r--README.md60
1 files changed, 59 insertions, 1 deletions
diff --git a/README.md b/README.md
index 7253b3b..9cb9030 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ More often, you will include the library as a dependency to your project. In ord
```toml
[dependencies]
-prettytable-rs = "^0.5"
+prettytable-rs = "^0.6"
```
## Basic usage
@@ -215,4 +215,62 @@ table.slice(2..); // Returns a table with rows starting at index 2
table.slice(..3); // Returns a table with rows until the one at index 3
```
+## Customize your table look and feel
+
+You can customize the look and feel of a table by providing it a `prettytable::format::TableFormat`.
+For example you can change the characters used for borders, junctions, column separations or line separations.
+To proceed, you can create a new `TableFormat` object and call the setter methods to configure it,
+or you can use the more convenient `prettytable::format::FormatBuilder` structure.
+
+For example :
+```rust
+let mut table = /* Initialize table */;
+let format = format::FormatBuilder::new()
+ .column_separator('|')
+ .borders('|')
+ .separators(
+ &[format::LinePosition::Top, format::LinePosition::Bottom],
+ format::LineSeparator::new('-', '+', '+', '+')
+ )
+ .padding(1, 1)
+ .build();
+table.set_format(format);
+```
+Would give a table like the following
+```
++-------------+------------+
+| Title 1 | Title 2 |
+| Value 1 | Value 2 |
+| Value three | Value four |
++-------------+------------+
+```
+
+For convenience, some predefined formats are provided in the module `prettytable::format::consts`.
+For example :
+```rust
+table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
+```
+Would give a table like the following
+```
++-------------+------------+
+| Title 1 | Title 2 |
++-------------+------------+
+| Value 1 | Value 2 |
+| Value three | Value four |
++-------------+------------+
+```
+or
+```rust
+table.set_format(*format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR);
+```
+Would give
+```
+Title 1 | Title 2
+------------+------------
+Value 1 | Value 2
+Value three | Value four
+```
+
+Check API documentation for the full list of available predefined formats
+
Additional examples are provided in documentation and in [examples](./examples/) directory