Skip to content

Commit 6b05cd8

Browse files
committed
update docs, fix align issue and readme
1 parent d4289eb commit 6b05cd8

File tree

5 files changed

+45
-53
lines changed

5 files changed

+45
-53
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Box CLI Maker is a Highly Customized Terminal Box Creator.
88

99
<div align="center">
1010

11-
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/Delta456/box-cli-maker)
11+
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/Delta456/box-cli-maker/v2)
1212
[![CI](https://github.com/Delta456/box-cli-maker/workflows/Box%20CLI%20Maker/badge.svg)](https://github.com/Delta456/box-cli-maker/actions?query=workflow%3A"Box+CLI+Maker")
1313
[![Go Report Card](https://goreportcard.com/badge/github.com/Delta456/box-cli-maker)](https://goreportcard.com/report/github.com/Delta456/box-cli-maker)
1414
[![GolangCI](https://golangci.com/badges/github.com/moul/golang-repo-template.svg)](https://golangci.com/r/github.com/Delta456/box-cli-maker)
@@ -188,7 +188,7 @@ var fgHiColors = map[string]color.Attribute{
188188

189189
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.
190190

191-
It can even have custom color which can be provided in `[3]uint` and `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]`.
191+
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]`.
192192

193193
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.
194194

@@ -204,7 +204,7 @@ As different terminals have different font by default so the right vertical alig
204204

205205
It uses [mattn/go-runewidth](https://github.com/mattn/go-runewidth) for Unicode and Emoji support though there are some limitations:
206206

207-
- `Windows Terminal` and `Windows System Linux` are the only know terminals which can render Unicode and Emojis properly on Windows.
207+
- `Windows Terminal` and `Windows SubSystem Linux` are the only know terminals which can render Unicode and Emojis properly on Windows.
208208
- Marathi Text only works on very few Terminals as less support it.
209209
- It is recommended not to use Online Playgrounds like [`Go Playground`](https://play.golang.org/) and [`Repl.it`](https://repl.it) because they use a font that only has ASCII support and other Character Set is used which becomes problematic for finding the length as the font changes during runtime.
210210
- Change your font which supports Unicode and Emojis else the right vertical alignment will break.

box.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ inside:
173173
spacing := space + sideMargin
174174
var format string
175175

176-
if i < titleLen && title != "" {
176+
if i < titleLen && title != "" && b.TitlePos == "Inside" {
177177
format = centerAlign
178178
} else {
179179
format = b.findAlign()
@@ -235,7 +235,7 @@ func (b Box) Print(title, lines string) {
235235
// then use Default Position which is Inside
236236
if b.TitlePos == "" {
237237
b.TitlePos = "Inside"
238-
} else if b.TitlePos != "Bottom" && b.TitlePos != "Top" {
238+
} else if b.TitlePos != "Inside" && b.TitlePos != "Bottom" && b.TitlePos != "Top" {
239239
errorMsg("[warning]: invalid value provided for TitlePos, using default")
240240
b.TitlePos = "Inside"
241241
}
@@ -267,7 +267,7 @@ func (b Box) Println(title, lines string) {
267267
// then use Default Position which is Inside
268268
if b.TitlePos == "" {
269269
b.TitlePos = "Inside"
270-
} else if b.TitlePos != "Bottom" && b.TitlePos != "Top" {
270+
} else if b.TitlePos != "Inside" && b.TitlePos != "Bottom" && b.TitlePos != "Top" {
271271
errorMsg("[warning]: invalid value provided for TitlePos, using default")
272272
b.TitlePos = "Inside"
273273
}

doc.go

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,82 @@
11
/*
22
Package Box CLI Maker is a Highly Customized Terminal Box Creator written in Go.
33
4-
It provides many styles and options to make Boxes. There are 8 inbuilt styles and Color support via RGB uint, RGB Array of [3]uint and string (given).
4+
It provides many styles and options to make Boxes. There are 8 inbuilt styles and has Color support via RGB uint, RGB Array of [3]uint and string (given).
55
66
Inbuilt Box Styles:
7-
Single
8-
Double
9-
Bold
10-
Single Double
11-
Double Single
12-
Round
13-
Hidden
7+
Single,
8+
Double,
9+
Bold,
10+
Single Double,
11+
Double Single,
12+
Round,
13+
Hidden and
1414
Classic
1515
1616
Inbuilt Colors:
17-
Black
18-
Blue
19-
Red
20-
Yellow
21-
Green
22-
Cyan
23-
Magenta
24-
HiBlack
25-
HiBlue
26-
HiRed
27-
HiYellow
28-
HiGreen
29-
HiCyan
17+
Black,
18+
Blue,
19+
Red,
20+
Yellow,
21+
Green,
22+
Cyan,
23+
Magenta,
24+
HiBlack,
25+
HiBlue,
26+
HiRed,
27+
HiYellow,
28+
HiGreen,
29+
HiCyan and
3030
HiMagenta
3131
3232
It also has Unicode and Emoji support which works across all terminals though there might be some terminals which do not support
33-
Unicode and Emoji like Windows CMD and Powershell. Unlike other terminals makers Box CLI Mkaer supports tab and multi line string.
33+
Unicode and Emoji like Windows CMD and Powershell. Unlike other CLI Makers, Box CLI Maker supports tab and multi line string.
34+
35+
Note: As different terminals have different font by default so the right vertical alignment may not be aligned well.
36+
You will have to change your font accordingly to make it work.
3437
3538
Basic Example:
3639
3740
Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: "Cyan"})
3841
Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker")
3942
4043
You can specify and change the options by changing the above Config struct.
41-
If "Style" isn't provided in box.Config struct then by default it will be "Single".
42-
43-
You can customize and change the TitlePos to Inside, Top, Bottom and ContentAlign to Left, Right and Center.
44-
By default TitlePos is Inside and ContentAlign is Left.
4544
4645
Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", TitlePos: "Top", ContentAlign: "Left"})
4746
48-
If you want the string representation of the Box then you can just use String() method of the Box:
47+
You can also customize and change the TitlePos to Inside, Top, Bottom and ContentAlign to Left, Right and Center.
48+
By default TitlePos is Inside, ContentAlign is Left and Style is Single.
4949
50-
If you want the Box to be printed correctly irrespective of it will form the correct color or not on Windows then you will have to add Box.Output
51-
as the passing stream to Fprintf(), Fprintln() and etc to the passing stream functions:
50+
You can also use the String() method for the string representation of the Box.
5251
53-
if runtime.GOOS == "windows" {
54-
fmt.Fprintf(box.Output, box_str)
55-
}
52+
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
53+
as the passing stream to stream based functions:
5654
57-
Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: "Cyan"})
58-
b := Box.String("Box CLI Maker", "Highly Customized Terminal Box Maker")
59-
... // use it afterwards
55+
fmt.Fprintf(box.Output, boxStr)
6056
61-
If you do not want the title and lines to be there then you can just leave i.e. put an empty in the both places.const
57+
Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: "Cyan"})
58+
boxStr := Box.String("Box CLI Maker", "Highly Customized Terminal Box Maker")
6259
63-
The following two will not be applicable for terminals which don't have 24 bit support i.e. True Color ANSI Code.
64-
If used then the color effect will not be there.
60+
The Custom Color option will not be applicable for terminals which don't have 24 bit support i.e. True Color ANSI Code.
61+
If it is used then the Color effect will not be there.
6562
66-
RBG Uint Example:
63+
RGB Uint Example:
6764
6865
Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: uint(0x34562f)})
6966
Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker")
7067
7168
Note: Uint must be in a range of [0x000000, 0xFFFFFF] else it will panic.
7269
73-
74-
RBG [3]uint Example:
70+
RGB [3]uint Example:
7571
7672
Box := box.New(box.Config{Px: 2, Py: 5, Type: "Single", Color: [3]uint{23, 56, 78}})
7773
Box.Print("Box CLI Maker", "Highly Customized Terminal Box Maker")
7874
7975
Note: [3]uint array elements must be in a range of [0x0, 0xFF] else it will panic.
8076
81-
82-
You can even make your custom Box Style by using box.Box struct:
77+
You can even make your custom Box Style by using struct box.Box:
8378
8479
config := box.Config{Px: 2, Py: 3, Type: "", TitlePos: "Inside"}
8580
boxNew := box.Box{TopRight: "*", TopLeft: "*", BottomRight: "*", BottomLeft: "*", Horizontal: "-", Vertical: "|", Config: config}
86-
... // use it afterwards
8781
*/
88-
8982
package box

types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ var (
9292
}
9393
// Output is an io.Writer and instance of
9494
// color.Output which is needed
95-
// for outputting in windows console
95+
// for outputting on Windows Console
9696
Output = color.Output
9797
)

util.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func longestLine(lines []string) (int, []expandedLine) {
6767
}
6868

6969
lineLen = runewidth.StringWidth(tmpLine.String())
70-
7170
expandedLines = append(expandedLines, expandedLine{tmpLine.String(), lineLen})
7271

7372
if lineLen > longest {

0 commit comments

Comments
 (0)