Documentation
¶
Index ¶
- Constants
- func WithColors(score, content, meta, title string) func(*TerminalConfig)
- func WithContentMax(max int) func(*TerminalConfig)
- func WithShowDocID(show bool) func(*TerminalConfig)
- func WithShowIndex(show bool) func(*TerminalConfig)
- func WithShowScore(show bool) func(*TerminalConfig)
- type JSONFormatter
- type TerminalConfig
- type TerminalFormatter
Constants ¶
View Source
const ( Reset = "\033[0m" Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Magenta = "\033[35m" Cyan = "\033[36m" White = "\033[37m" Bold = "\033[1m" Dim = "\033[2m" )
ANSI 颜色码
Variables ¶
This section is empty.
Functions ¶
func WithColors ¶
func WithColors(score, content, meta, title string) func(*TerminalConfig)
WithColors 设置颜色方案
Types ¶
type TerminalConfig ¶
type TerminalConfig struct {
ShowScore bool // 是否显示分数
ShowDocID bool // 是否显示文档ID
ShowIndex bool // 是否显示序号
ContentMax int // 内容最大长度,0 表示不限制
ScoreColor string // 分数颜色
ContentColor string // 内容颜色
MetaColor string // 元数据颜色
TitleColor string // 标题颜色
}
TerminalConfig 终端格式化配置
func DefaultTerminalConfig ¶
func DefaultTerminalConfig() *TerminalConfig
DefaultTerminalConfig 默认终端配置
type TerminalFormatter ¶
type TerminalFormatter struct {
core.BaseFormatter
// contains filtered or unexported fields
}
TerminalFormatter 终端彩色输出格式化器
func NewTerminalFormatter ¶
func NewTerminalFormatter(opts ...func(*TerminalConfig)) *TerminalFormatter
NewTerminalFormatter 创建终端格式化器
func (*TerminalFormatter) Format ¶
func (f *TerminalFormatter) Format(hit *core.Hit) string
Format 格式化 Hit 容器为终端输出。 遍历 hit.Chunks 输出每个 Chunk。 hit 为 nil 或 Chunks 为空时返回空字符串。
func (*TerminalFormatter) FormatAll ¶
func (f *TerminalFormatter) FormatAll(hit *core.Hit) string
FormatAll 格式化 Hit 容器,含标题和全部 Chunks。 标题显示 Chunks 数量。
func (*TerminalFormatter) Print ¶
func (f *TerminalFormatter) Print(hit *core.Hit)
Print 便捷方法:直接打印到标准输出
func (*TerminalFormatter) Println ¶
func (f *TerminalFormatter) Println(hit *core.Hit)
Println 便捷方法:打印并换行
Click to show internal directories.
Click to hide internal directories.