Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 12.79.0 #390

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### 12.79.0

* `[panel]` Added indent customization

### 12.78.0

* `[barcode]` New package with methods to generate colored representation of unique data
Expand Down
2 changes: 1 addition & 1 deletion ek.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "12.78.0"
const VERSION = "12.79.0"

// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down
19 changes: 12 additions & 7 deletions fmtutil/panel/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ var (
// Width is panel width (≥ 40) if option WRAP is set
var Width = 88

// Indent is indent from the left side of terminal
var Indent = 0

// ////////////////////////////////////////////////////////////////////////////////// //

// minWidth is minimal panel width
Expand All @@ -83,24 +86,26 @@ func Info(title, message string, options ...Option) {
func Panel(label, colorTag, title, message string, options ...Option) {
var buf *bytes.Buffer

indent := strings.Repeat(" ", mathutil.Max(0, Indent))

if sliceutil.Contains(options, INDENT_OUTER) {
fmtc.NewLine()
}

if sliceutil.Contains(options, LABEL_POWERLINE) {
fmtc.Printf(colorTag+"{@*} %s {!}"+colorTag+"{!} "+colorTag+"%s{!}\n", label, title)
fmtc.Printf(colorTag+indent+"{@*} %s {!}"+colorTag+"{!} "+colorTag+"%s{!}\n", label, title)
} else {
fmtc.Printf(colorTag+"{@*} %s {!} "+colorTag+"%s{!}\n", label, title)
fmtc.Printf(colorTag+indent+"{@*} %s {!} "+colorTag+"%s{!}\n", label, title)
}

if sliceutil.Contains(options, INDENT_INNER) {
fmtc.Println(colorTag + "┃{!}")
fmtc.Println(colorTag + indent + "┃{!}")
}

switch {
case sliceutil.Contains(options, WRAP):
buf = bytes.NewBufferString(
fmtutil.Wrap(fmtc.Sprint(message), "", mathutil.Max(minWidth, Width-2)) + "\n",
fmtutil.Wrap(fmtc.Sprint(message), indent, mathutil.Max(minWidth, Width-2)) + "\n",
)
default:
buf = bytes.NewBufferString(message)
Expand All @@ -114,15 +119,15 @@ func Panel(label, colorTag, title, message string, options ...Option) {
break
}

fmtc.Print(colorTag + "┃{!} " + line)
fmtc.Print(colorTag + indent + "┃{!} " + line)
}

if sliceutil.Contains(options, INDENT_INNER) {
fmtc.Println(colorTag + "┃{!}")
fmtc.Println(colorTag + indent + "┃{!}")
}

if sliceutil.Contains(options, BOTTOM_LINE) {
fmtc.Println(colorTag + "┖" + strings.Repeat("─", mathutil.Max(minWidth, Width-1)))
fmtc.Println(colorTag + indent + "┖" + strings.Repeat("─", mathutil.Max(minWidth, Width-1)))
}

if sliceutil.Contains(options, INDENT_OUTER) {
Expand Down