Skip to content

Commit 736e8a0

Browse files
committed
release: v2.2.1
1 parent 02f7563 commit 736e8a0

File tree

6 files changed

+83
-29
lines changed

6 files changed

+83
-29
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A clear and concise description of what the bug is.
1212

1313
**To Reproduce**
1414
Steps to reproduce the behavior:
15+
1516
1. Go to '...'
1617
2. Type '....'
1718
3. See error
@@ -23,9 +24,11 @@ A clear and concise description of what you expected to happen.
2324
If applicable, add screenshots or logs to help explain your problem.
2425

2526
**Versions (please complete the following information, if relevant):**
27+
2628
- Software version: [e.g. v1.2.3, latest, building from sources]
2729
- OS: [e.g. Ubuntu, Mac, iOS, ...]
28-
- Golang version [e.g. 1.13]
30+
- Golang version: [e.g. v1.15]
31+
- Terminal using and Version: [e.g. Windows Terminal v1.4]
2932

3033
**Additional context**
3134
Add any other context about the problem here.

README.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Box CLI Maker is a Highly Customized Terminal Box Creator.
99
<div align="center">
1010

1111
[![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)
12+
[![godocs.io](http://godocs.io/github.com/Delta456/box-cli-maker?status.svg)](https://godocs.io/github.com/Delta456/box-cli-maker)
1213
[![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")
1314
[![Go Report Card](https://goreportcard.com/badge/github.com/Delta456/box-cli-maker)](https://goreportcard.com/report/github.com/Delta456/box-cli-maker)
1415
[![GolangCI](https://golangci.com/badges/github.com/moul/golang-repo-template.svg)](https://golangci.com/r/github.com/Delta456/box-cli-maker)
@@ -53,9 +54,9 @@ func main() {
5354
- `Px` : Horizontal Padding
5455
- `Py` : Vertical Padding
5556
- `ContentAlign` : Align the content inside the Box i.e. `Center`, `Left` and `Right`
56-
- `Type`: Type of Box (by default it's Single) [*click this for more info*](./README.md/#box-types)
57-
- `TitlePos` : Position of the Title i.e. `Inside`, `Top` and `Bottom` [*click this for more info*](./README.md/#title-positions)
58-
- `Color` : Color of the Box [*click this for more info*](./README.md/#color-types)
57+
- `Type`: Type of Box
58+
- `TitlePos` : Position of the Title i.e. `Inside`, `Top` and `Bottom`
59+
- `Color` : Color of the Box
5960

6061
### `Box struct` Methods
6162

@@ -131,13 +132,13 @@ You can make your custom Box by using the inbuilt Box struct provided by the mod
131132

132133
```go
133134
type Box struct {
134-
TopRight string // TopRight corner used for Symbols
135-
TopLeft string // TopLeft corner used for Symbols
135+
TopRight string // Symbols used for TopRight Corner
136+
TopLeft string // Symbols used for TopLeft Corner
136137
Vertical string // Symbols used for Vertical Bars
137-
BottomRight string // BottomRight corner used for Symbols
138-
BottomLeft string // BotromLeft corner used for Symbols
138+
BottomRight string // Symbols used for BottomRight Corner
139+
BottomLeft string // Symbols used for BottomRight Corner
139140
Horizontal string // Symbols used for Horizontal Bars
140-
Config // Configuration for the Box to be made
141+
Config // Config for the Box struct
141142
}
142143
```
143144

@@ -189,42 +190,46 @@ It has color support from [gookit/color](github.com/gookit/color) module from wh
189190

190191
If you want High Intensity Colors then the Color name must start with `Hi`. If Color option is empty or invalid then Box with default Color is formed.
191192

192-
True Color is possible though you need to provide it as `uint` or `[3]uint` and make sure that the terminals which will be targetted must have it supported.
193+
1. True Color is also possible though you need to provide it as `uint` or `[3]uint` and make sure that the terminals which will be targetted must have it supported.
193194

194-
`[3]uint`'s element all must be in a range of `[0, 0xFF]` and `uint` in range of `[0x000000, 0xFFFFFF]`.
195+
2. `[3]uint`'s element all must be in a range of `[0, 0xFF]` and `uint` in range of `[0x000000, 0xFFFFFF]`.
195196

196197
As convenience, if the terminal's doesn't support True Color then it will round off according to the terminal's max supported colors which makes it easier for the users not to worry about other terminal for most of the cases.
197198

198199
Here's a list of 24 bit [supported terminals](https://gist.github.com/XVilka/8346728) and 8 bit [supported terminals](https://fedoraproject.org/wiki/Features/256_Color_Terminals).
199200

200201
This module also enables **True Color** and **256 Colors** support on Windows Console through [Virtual Terminal Processing](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) but you need have at least [Windows 10 Version 1511](https://en.wikipedia.org/wiki/Windows_10_version_history_(version_1511)) for 256 colors or [Windows 10 Version 1607](https://en.wikipedia.org/wiki/Windows_10_version_history_(version_1607)) for True Color Support.
201202

202-
4 bit Color are now supported by every terminal now so there is no list for them unlike the above ones.
203+
4-bit Colors are now standardized so it is supported by all terminals now.
204+
205+
If `ConEmu` or `ANSICON` is installed for Windows systems then it will be also detected. It is highly recommended to use the latest versions of both of them to have the best experience!
203206

204207
### Note
205208

206-
#### Vertical Alignment
209+
#### 1. Vertical Alignment
207210

208211
As different terminals have different font by default so the right vertical alignment may not be aligned well. You will have to change your font accordingly to make it work.
209212

210-
#### Limitations of Unicode and Emoji
213+
#### 2. Limitations of Unicode and Emoji
211214

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

214-
- `Windows Terminal` and `Mintty` are the only know terminal emulators which can render Unicode and Emojis properly on Windows.
217+
- `Windows Terminal`, `ConEmu` and `Mintty` are the only know terminal emulators which can render Unicode and Emojis properly on Windows.
215218
- Indic Text only works on very few Terminals as less support it.
216219
- It is recommended not to use this for Online Playgrounds like [`Go Playground`](https://play.golang.org/) and [`Repl.it`](https://repl.it), `CI/CDs` etc. 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.
217220
- Change your font which supports Unicode and Emojis else the right vertical alignment will break.
218221

219-
#### Terminal Color Detection
222+
#### 3. Terminal Color Detection
220223

221224
It is possible to round off true color provided to 8 bit or 16 bit according to your terminal's maximum capacity.
222225

223-
There is no **standardized way** of detecting the terminal's maximum color capacity so the way of detecting your terminal might not work for you. If this can be fixed for you then you can always make a PR.
226+
There is no **standardized way** of detecting the terminal's maximum color capacity so the way of detecting your terminal might not work for you. If this can be fixed for your terminal then you can always make a PR.
227+
228+
The following two points are just applicable for **Unix** systems:
224229

225-
If you think that the module can't detect True Color of the terminal then you must set your environment variable `COLORTERM` to `truecolor` or `24bit` for True Color support.
230+
- If you think that the module can't detect True Color of the terminal then you must set your environment variable `COLORTERM` to `truecolor` or `24bit` for True Color support.
226231

227-
If you are targetting 8 bit color based terminals and if the module couln't detect it then set your environment variable `TERM` to name of the terminal emulator with `256color` as suffix like `xterm-256color`.
232+
- If you are targetting 8 bit color based terminals and the module couln't detect it then set your environment variable `TERM` to name of the terminal emulator with `256color` as suffix like `xterm-256color`.
228233

229234
There might be no color effect for very old terminals like [`Windows Console (Legacy Mode)`](https://docs.microsoft.com/en-us/windows/console/legacymode) or environment variable `TERM` give `DUMB` so it will output some garbage value or a warning if used.
230235

box.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ const (
1919

2020
// Box struct defines the Box to be made.
2121
type Box struct {
22-
TopRight string // TopRight corner used for Symbols
23-
TopLeft string // TopLeft corner used for Symbols
22+
TopRight string // Symbols used for TopRight Corner
23+
TopLeft string // Symbols used for TopLeft Corner
2424
Vertical string // Symbols used for Vertical Bars
25-
BottomRight string // BottomRight corner used for Symbols
26-
BottomLeft string // BotromLeft corner used for Symbols
25+
BottomRight string // Symbols used for BottomRight Corner
26+
BottomLeft string // Symbols used for BottomRight Corner
2727
Horizontal string // Symbols used for Horizontal Bars
2828
Config // Config for the Box struct
2929
}

detect_windows.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,26 @@ func errorMsg(msg string) {
2828

2929
// detectTerminalColor detects the Color Level Supported
3030
func detectTerminalColor() terminfo.ColorLevel {
31+
if os.Getenv("ConEmuANSI") == "ON" {
32+
// ConEmuANSI is "ON" for generic ANSI support
33+
// but True Color option is enabled by default
34+
// I am just assuming that people wouldn't have disabled it
35+
// Even if it is not enabled then ConEmu will auto round off
36+
// accordingly
37+
return terminfo.ColorLevelMillions
38+
}
3139
// Before Windows 10 Build Number 10586, console never supported ANSI Colors
3240
if buildNumber < 10586 || winVersion < 10 {
41+
// Detect if using ANSICON on older systems
42+
if os.Getenv("ANSICON") != "" {
43+
conVersion := os.Getenv("ANSICON_VER")
44+
// 8 bit Colors were only supported after v1.81 release
45+
if conVersion >= "181" {
46+
return terminfo.ColorLevelHundreds
47+
} else {
48+
return terminfo.ColorLevelBasic
49+
}
50+
}
3351
return terminfo.ColorLevelNone
3452
} else {
3553
// True Color is only possible after Windows 10 Build Number 14931

go.mod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ module github.com/Delta456/box-cli-maker/v2
33
go 1.15
44

55
require (
6-
github.com/gookit/color v1.3.3
6+
github.com/davecgh/go-spew v1.1.1 // indirect
7+
github.com/gookit/color v1.3.6
8+
github.com/kr/text v0.2.0 // indirect
79
github.com/mattn/go-runewidth v0.0.9
10+
github.com/stretchr/testify v1.6.1 // indirect
811
github.com/xo/terminfo v0.0.0-20200218205459-454e5b68f9e8
9-
golang.org/x/sys v0.0.0-20201202213521-69691e467435
12+
golang.org/x/sys v0.0.0-20201223074533-0d417f636930
13+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
14+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
1015
)

go.sum

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
13
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2-
github.com/gookit/color v1.3.2 h1:WO8+16ZZtx+HlOb6cueziUAF8VtALZKRr/jOvuDk0X0=
3-
github.com/gookit/color v1.3.2/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
4-
github.com/gookit/color v1.3.3 h1:6IAwxWCdABGNc4gI+YFBMYw0Hz8g5+lpYeKRAaALQoQ=
5-
github.com/gookit/color v1.3.3/go.mod h1:GqqLKF1le3EfrbHbYsYa5WdLqfc/PHMdMRbt6tMnqIc=
4+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/gookit/color v1.3.6 h1:Rgbazd4JO5AgSTVGS3o0nvaSdwdrS8bzvIXwtK6OiMk=
7+
github.com/gookit/color v1.3.6/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ=
8+
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
9+
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
10+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
11+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
12+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
13+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
614
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
715
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
816
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
17+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
918
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
19+
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
1020
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
21+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
1122
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
23+
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
24+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1225
github.com/xo/terminfo v0.0.0-20200218205459-454e5b68f9e8 h1:woqigIZtZUZxws1zZA99nAvuz2mQrxtWsuZSR9c8I/A=
1326
github.com/xo/terminfo v0.0.0-20200218205459-454e5b68f9e8/go.mod h1:6Yhx5ZJl5942QrNRWLwITArVT9okUXc5c3brgWJMoDc=
1427
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1528
golang.org/x/sys v0.0.0-20201202213521-69691e467435 h1:25AvDqqB9PrNqj1FLf2/70I4W0L19qqoaFq3gjNwbKk=
1629
golang.org/x/sys v0.0.0-20201202213521-69691e467435/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
30+
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
31+
golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
32+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
33+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
34+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
35+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
36+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
37+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
38+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
39+
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)