Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Nov 11, 2020
1 parent 6b05cd8 commit 34c982c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
28 changes: 15 additions & 13 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 34c982c

Please sign in to comment.