From 34c982c307a639f519f5069f92c6ca68874c27c7 Mon Sep 17 00:00:00 2001 From: Delta456 Date: Wed, 11 Nov 2020 10:53:01 +0530 Subject: [PATCH] update docs --- README.md | 2 +- doc.go | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9dac8d1..0c75dac 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ var fgHiColors = map[string]color.Attribute{ If you want High Intensity Colors then the Color name should start with `Hi`. If Color option is empty or invalid then Box with default Color is formed. -It can even have custom color which has to be provided as `[3]uint` and `uint` but the elements of the array must be in a range of `[0x0, 0xFF]` and `uint` must be in a range of `[0x000000, 0xFFFFFF]`. +You can also have more 16 Colors but the terminals must be 24 bit and the `Color` field must be provided either as `[3]uint` or `uint` though the elements of the array must be in a range of `[0x0, 0xFF]` and `uint` must be in a range of `[0x000000, 0xFFFFFF]`. If you want to use the string representation of the `Box` and print them for [`Windows Console`](https://en.wikipedia.org/wiki/Windows_Console) then you would have to use `box.Output` as the passing stream to the respective functions. diff --git a/doc.go b/doc.go index 19aade7..9b99d3c 100644 --- a/doc.go +++ b/doc.go @@ -37,46 +37,48 @@ You will have to change your font accordingly to make it work. Basic Example: -Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: "Cyan"}) -Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker") + Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: "Cyan"}) + Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker") You can specify and change the options by changing the above Config struct. -Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", TitlePos: "Top", ContentAlign: "Left"}) + Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", TitlePos: "Top", ContentAlign: "Left"}) You can also customize and change the TitlePos to Inside, Top, Bottom and ContentAlign to Left, Right and Center. By default TitlePos is Inside, ContentAlign is Left and Style is Single. You can also use the String() method for the string representation of the Box. + Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: "Cyan"}) + boxStr := Box.String("Box CLI Maker", "Highly Customized Terminal Box Maker") + If you want the Box to be printed correctly irrespective of if it will form the correct Color or not on Windows (as Windows Console only supports 16 Colors) then you will have to add Box.Output as the passing stream to stream based functions: -fmt.Fprintf(box.Output, boxStr) - -Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: "Cyan"}) -boxStr := Box.String("Box CLI Maker", "Highly Customized Terminal Box Maker") + if runtime.GOOS == "windows" { + fmt.Fprintf(box.Output, boxStr) + } The Custom Color option will not be applicable for terminals which don't have 24 bit support i.e. True Color ANSI Code. If it is used then the Color effect will not be there. RGB Uint Example: -Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: uint(0x34562f)}) -Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker") + Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: uint(0x34562f)}) + Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker") Note: Uint must be in a range of [0x000000, 0xFFFFFF] else it will panic. RGB [3]uint Example: -Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: [3]uint{23, 56, 78}}) -Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker") + Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: [3]uint{23, 56, 78}}) + Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker") Note: [3]uint array elements must be in a range of [0x0, 0xFF] else it will panic. You can even make your custom Box Style by using struct box.Box: -config := box.Config{Px: 2, Py: 3, Type: "", TitlePos: "Inside"} -boxNew := box.Box{TopRight: "*", TopLeft: "*", BottomRight: "*", BottomLeft: "*", Horizontal: "-", Vertical: "|", Config: config} + config := box.Config{Px: 2, Py: 3, Type: "", TitlePos: "Inside"} + boxNew := box.Box{TopRight: "*", TopLeft: "*", BottomRight: "*", BottomLeft: "*", Horizontal: "-", Vertical: "|", Config: config} */ package box