aboutsummaryrefslogtreecommitdiff
path: root/core/text
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-26 12:53:34 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-26 12:53:34 -0400
commitba354e0524ee6625ce13087b097fe96e5e8c9403 (patch)
tree0a58cb2d5776942bfdfe7d74e447b4402663aa35 /core/text
parentf13d30ad2306caafaa667e6ba9f430d64c482812 (diff)
Add documentation for `write_decorated_table`
Diffstat (limited to 'core/text')
-rw-r--r--core/text/table/doc.odin51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/text/table/doc.odin b/core/text/table/doc.odin
index 30358f31e..955ab8d21 100644
--- a/core/text/table/doc.odin
+++ b/core/text/table/doc.odin
@@ -265,5 +265,56 @@ This will print out:
| Excessive Diacritics | H̷e̶l̵l̸o̴p̵e̷ ̸w̶o̸r̵l̶d̵!̴ |
+-----------------------------+----------------------------------------------------------------------------------------------+
+**Decorated Tables:**
+
+If you'd prefer to change the borders used by the plain-text table printing,
+there is the `write_decorated_table` procedure that allows you to change the
+corners and dividers.
+
+Here is a complete example:
+
+ package main
+
+ import "core:fmt"
+ import "core:io"
+ import "core:os"
+ import "core:text/table"
+
+ box_drawing :: proc(w: io.Writer) {
+ t: table.Table
+ table.init(&t)
+ table.caption(&t, "Box Drawing Example")
+ table.padding(&t, 2, 2)
+ table.header_of_aligned_values(&t, {{.Left, "Operating System"}, {.Center, "Year Introduced"}})
+
+ table.row(&t, "UNIX", "1973")
+ table.row(&t, "MS-DOS", "1981")
+ table.row(&t, "Commodore 64 KERNAL", "1982")
+ table.row(&t, "Mac OS", "1984")
+ table.row(&t, "Amiga", "1985")
+ table.row(&t, "Windows 1.0", "1985")
+ table.row(&t, "Linux", "1991")
+ table.row(&t, "Windows 3.1", "1992")
+
+ decorations := table.Decorations {
+ "┌", "┬", "┐",
+ "├", "┼", "┤",
+ "└", "┴", "┘",
+ "│", "─",
+ }
+
+ table.write_decorated_table(w, &t, decorations)
+ fmt.println()
+ }
+
+ main :: proc() {
+ stdout := os.stream_from_handle(os.stdout)
+
+ box_drawing(stdout)
+ }
+
+While the decorations support multi-codepoint Unicode graphemes, do note that
+each border character should not be larger than one monospace cell.
+
*/
package text_table