Documentation
¶
Index ¶
- Constants
- Variables
- type Banner
- type BorderStyle
- type OptionFunc
- func WithAlignment(alignment comdef.Align) OptionFunc
- func WithBannerCenter() OptionFunc
- func WithBannerRight() OptionFunc
- func WithHeight(height int) OptionFunc
- func WithMarginLeft(margin int) OptionFunc
- func WithMarginTopBottom(marginTop, marginBottom int) OptionFunc
- func WithMinWidth(minWidth int) OptionFunc
- func WithOverflowFlag(flag showcom.OverflowFlag) OptionFunc
- func WithPercentWidth(percent int) OptionFunc
- func WithWidth(width int) OptionFunc
- type Options
Constants ¶
View Source
const ( AtCenter = -1 AtRight = -2 )
特殊margin定义banner 居中,居右
Variables ¶
View Source
var ( /* SimpleBorderStyle example: +-----+ | hi | +-----+ */ SimpleBorderStyle = BorderStyle{TopLeft: '+', TopRight: '+', BottomLeft: '+', BottomRight: '+', Horizontal: '-', Vertical: '|'} /* RoundedBorderStyle example ╭─────╮ │ hi │ ╰─────╯ */ RoundedBorderStyle = BorderStyle{TopLeft: '╭', TopRight: '╮', BottomLeft: '╰', BottomRight: '╯', Horizontal: '─', Vertical: '│'} /* SharpBorderStyle example: ┌─────┐ │ hi │ └─────┘ */ SharpBorderStyle = BorderStyle{TopLeft: '┌', TopRight: '┐', BottomLeft: '└', BottomRight: '┘', Horizontal: '─', Vertical: '│'} /* DoubleBorderStyle example: ╔═════╗ ║ hi ║ ╚═════╝ */ DoubleBorderStyle = BorderStyle{TopLeft: '╔', TopRight: '╗', BottomLeft: '╚', BottomRight: '╝', Horizontal: '═', Vertical: '║'} )
预定义的边框样式
Functions ¶
This section is empty.
Types ¶
type Banner ¶
type Banner struct {
// use for internal
showcom.Base
// Options banner options
Options
// Prefix 横幅前缀
Prefix string
// Contents 横幅显示的内容
Contents []string
// contains filtered or unexported fields
}
Banner 在终端中绘制横幅样式的信息
func (*Banner) WithOptionFn ¶
func (b *Banner) WithOptionFn(fns ...OptionFunc) *Banner
WithOptionFn 设置 Banner 的选项
func (*Banner) WithOptionFns ¶
func (b *Banner) WithOptionFns(fns []OptionFunc) *Banner
WithOptionFns 设置 Banner 的选项
type BorderStyle ¶
type BorderStyle struct {
TopLeft rune
TopRight rune
BottomLeft rune
BottomRight rune
Horizontal rune // top, bottom
Vertical rune // left, right
// Color 边框颜色 tag
Color string
}
BorderStyle 边框样式
type OptionFunc ¶
type OptionFunc func(b *Options)
OptionFunc definition
func WithMarginTopBottom ¶
func WithMarginTopBottom(marginTop, marginBottom int) OptionFunc
WithMarginTopBottom 添加上下边距
func WithOverflowFlag ¶
func WithOverflowFlag(flag showcom.OverflowFlag) OptionFunc
WithOverflowFlag 设置内容溢出处理方式
type Options ¶
type Options struct {
// Padding 内边距 default: 1
Padding int
// MarginL 左外边距
// - >0 表示左外边距
// - 0 表示无外边距 居左显示banner(默认)
// - -1 表示居中显示banner
// - -2 表示居右显示banner
MarginL int
MarginR int // TODO
// MarginTB 上下外边距 TODO
MarginTB []int
// Width 横幅宽度
// - 0 表示自动计算内容宽度
Width int
// Height 内容高度行数,默认为内容行数
Height int
// MinWidth 最小宽度
// 0: 表示不限制最小宽度
MinWidth int
// PercentWidth 使用终端宽度的百分比宽度 (1-100)
// 0 表示不使用百分比宽度
PercentWidth int
// OverflowFlag 内容溢出处理 default: wrap
OverflowFlag showcom.OverflowFlag
// Alignment 内容对齐方式
Alignment comdef.Align
// TextColor 文本颜色 tag
TextColor string
// BorderStyle 边框样式
BorderStyle BorderStyle
}
Options banner options
宽度设置优先级: MinWidth > Width > PercentWidth > contentWidth
Click to show internal directories.
Click to hide internal directories.