[#1223] lens/tui: Add metabase schema
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
b9043433a0
commit
1ae86f35a8
18 changed files with 1381 additions and 1 deletions
43
cmd/frostfs-lens/internal/schema/common/format.go
Normal file
43
cmd/frostfs-lens/internal/schema/common/format.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
|
||||
type FormatOptions struct {
|
||||
Color tcell.Color
|
||||
|
||||
Bold,
|
||||
Italic,
|
||||
Underline,
|
||||
StrikeThrough bool
|
||||
}
|
||||
|
||||
func Format(s string, opts FormatOptions) string {
|
||||
var boldTag, italicTag, underlineTag, strikeThroughTag string
|
||||
|
||||
switch {
|
||||
case opts.Bold:
|
||||
boldTag = "b"
|
||||
case opts.Italic:
|
||||
italicTag = "i"
|
||||
case opts.Underline:
|
||||
underlineTag = "u"
|
||||
case opts.StrikeThrough:
|
||||
strikeThroughTag = "s"
|
||||
}
|
||||
|
||||
attrs := fmt.Sprintf(
|
||||
"%s%s%s%s", boldTag, italicTag, underlineTag, strikeThroughTag,
|
||||
)
|
||||
color := strconv.FormatInt(int64(opts.Color.Hex()), 16)
|
||||
|
||||
return fmt.Sprintf("[#%06s::%s]%s[-::-]", color, attrs, s)
|
||||
}
|
||||
|
||||
func FormatSimple(s string, c tcell.Color) string {
|
||||
return Format(s, FormatOptions{Color: c})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue