title

package
v3.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OptionFunc

type OptionFunc func(t *Title)

OptionFunc definition

func WithAlignCenter

func WithAlignCenter() OptionFunc

WithAlignCenter setting the title align to center

func WithAlignRight

func WithAlignRight() OptionFunc

WithAlignRight setting the title align to right

func WithBorderBoth

func WithBorderBoth() OptionFunc

WithBorderBoth setting the title border to both top and bottom

func WithBorderBottom

func WithBorderBottom() OptionFunc

WithBorderBottom setting the title border to bottom

func WithBorderTop

func WithBorderTop() OptionFunc

WithBorderTop setting the title border to top

Example

ExampleBorderTop 演示顶部边框

package main

import (
	"github.com/gookit/gcli/v3/show/title"
)

func main() {
	title.New("Top Border Title", title.WithBorderTop()).Println()

	// 演示底部边框(默认)
	title.New("Bottom Border Title", title.WithBorderBottom()).Println()

	// 演示上下边框
	title.New("Top and Bottom Border Title", title.WithBorderBoth()).Println()

	// ExampleNoBorder 演示无边框
	title.New("No Border Title", title.WithoutBorder()).Println()
}

func WithoutBorder

func WithoutBorder() OptionFunc

WithoutBorder setting the title border to none

type Options

type Options struct {
	// Color 颜色Tag
	Color string
	// PaddingLR 是否左右填充 PaddingChar
	PaddingLR bool
	// PaddingChar 左右填充字符
	PaddingChar rune

	// 是否显示上下边框
	ShowBorder bool
	BorderChar rune
	// BorderPos 边框位置 0: 无, 1: 上, 2: 下, 4: 上下
	BorderPos gclicom.BorderPos

	// 总的显示宽度
	Width  int
	Indent int
	Align  comdef.Align
}

Options title options

type Title

type Title struct {
	showcom.Base
	Options
	Prefix string
	Title  string
}

Title 在终端中打印标题行

func New

func New(title string, fns ...OptionFunc) *Title

New Title instance

func (*Title) Format

func (t *Title) Format()

Format 格式化标题信息

func (*Title) Render

func (t *Title) Render() string

Render 渲染标题

func (*Title) SetTitle

func (t *Title) SetTitle(title string) *Title

SetTitle set title text

func (*Title) ShowNew

func (t *Title) ShowNew(title string)

ShowNew set new title and print

func (*Title) WithOptionFns

func (t *Title) WithOptionFns(fns []OptionFunc) *Title

WithOptionFns 设置选项

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL