view

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyHelp   tcell.Key = 63
	KeySpace  tcell.Key = 32
	KeySlash  tcell.Key = 47
	KeyColon  tcell.Key = 58
	KeyColonQ tcell.Key = 59
)
View Source
const (
	Key0 tcell.Key = iota + 48
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
)
View Source
const (
	KeyA tcell.Key = iota + 97
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyG
	KeyH
	KeyI
	KeyJ
	KeyK
	KeyL
	KeyM
	KeyN
	KeyO
	KeyP
	KeyQ
	KeyR
	KeyS
	KeyT
	KeyU
	KeyV
	KeyW
	KeyX
	KeyY
	KeyZ
)
View Source
const (
	KeyShiftA tcell.Key = iota + 65
	KeyShiftB
	KeyShiftC
	KeyShiftD
	KeyShiftE
	KeyShiftF
	KeyShiftG
	KeyShiftH
	KeyShiftI
	KeyShiftJ
	KeyShiftK
	KeyShiftL
	KeyShiftM
	KeyShiftN
	KeyShiftO
	KeyShiftP
	KeyShiftQ
	KeyShiftR
	KeyShiftS
	KeyShiftT
	KeyShiftU
	KeyShiftV
	KeyShiftW
	KeyShiftX
	KeyShiftY
	KeyShiftZ
)

Variables

View Source
var ActionNil = func(evt *tcell.EventKey) *tcell.EventKey { return evt }
View Source
var Borders = struct {
	Horizontal  rune
	Vertical    rune
	TopLeft     rune
	TopRight    rune
	BottomLeft  rune
	BottomRight rune

	LeftT   rune
	RightT  rune
	TopT    rune
	BottomT rune
	Cross   rune

	HorizontalFocus  rune
	VerticalFocus    rune
	TopLeftFocus     rune
	TopRightFocus    rune
	BottomLeftFocus  rune
	BottomRightFocus rune
}{
	Horizontal:  tview.BoxDrawingsLightHorizontal,
	Vertical:    tview.BoxDrawingsLightVertical,
	TopLeft:     tview.BoxDrawingsLightDownAndRight,
	TopRight:    tview.BoxDrawingsLightDownAndLeft,
	BottomLeft:  tview.BoxDrawingsLightUpAndRight,
	BottomRight: tview.BoxDrawingsLightUpAndLeft,

	LeftT:   tview.BoxDrawingsLightVerticalAndRight,
	RightT:  tview.BoxDrawingsLightVerticalAndLeft,
	TopT:    tview.BoxDrawingsLightDownAndHorizontal,
	BottomT: tview.BoxDrawingsLightUpAndHorizontal,
	Cross:   tview.BoxDrawingsLightVerticalAndHorizontal,

	HorizontalFocus:  tview.BoxDrawingsLightHorizontal,
	VerticalFocus:    tview.BoxDrawingsLightVertical,
	TopLeftFocus:     tview.BoxDrawingsLightDownAndRight,
	TopRightFocus:    tview.BoxDrawingsLightDownAndLeft,
	BottomLeftFocus:  tview.BoxDrawingsLightUpAndRight,
	BottomRightFocus: tview.BoxDrawingsLightUpAndLeft,
}

Functions

func Capitalize

func Capitalize(s string) string

func FixedWidth

func FixedWidth(text string, width int) string

Types

type ActionHandler

type ActionHandler func(key *tcell.EventKey) *tcell.EventKey

type ActionOpts

type ActionOpts struct {
	DisplayName string
	Visible     bool
	Shared      bool
	Default     bool // 是否只显示快捷键而不注册方法[适用于tview默认快捷键展示]
}

type ActionOptsFn

type ActionOptsFn func(opts *ActionOpts)

func WithDefault

func WithDefault() ActionOptsFn

func WithDisplayName

func WithDisplayName(displayName string) ActionOptsFn

type Application

type Application struct {
	*tview.Application
	// contains filtered or unexported fields
}

func CreateApplication

func CreateApplication(ctx context.Context) *Application

func (*Application) Alert

func (a *Application) Alert(msg string, after tview.Primitive)

func (*Application) AsKey

func (a *Application) AsKey(evt *tcell.EventKey) tcell.Key

func (*Application) Confirm

func (a *Application) Confirm(msg string, onConfirm, onCancel func())

func (*Application) HasAction

func (a *Application) HasAction(key tcell.Key) (KeyAction, bool)

func (*Application) HideLoading

func (a *Application) HideLoading(name string)

HideLoading 隐藏Loading

func (*Application) Info

func (a *Application) Info(msg string, after tview.Primitive)

func (*Application) IsTopDialog

func (a *Application) IsTopDialog() bool

func (*Application) Run

func (a *Application) Run() error

func (*Application) ShowLoading

func (a *Application) ShowLoading(message string, name string)

ShowLoading Loading(带动画)

func (*Application) SwitchPage

func (a *Application) SwitchPage(page string)

type Installer

type Installer struct {
	*tview.Modal
	// contains filtered or unexported fields
}

func NewInstall

func NewInstall(
	app *Application,
	pages *tview.Pages,
	lang core.Language,
	version *core.RemoteVersion,
	callback func(err error),
) *Installer

func (*Installer) Install

func (i *Installer) Install()

type KeyAction

type KeyAction struct {
	Description string
	Action      ActionHandler
	Opts        ActionOpts
}

func NewKeyAction

func NewKeyAction(d string, a ActionHandler, visible bool, opts ...ActionOptsFn) KeyAction

func NewKeyActionWithOpts

func NewKeyActionWithOpts(d string, a ActionHandler, opts ActionOpts, optsFn ...ActionOptsFn) KeyAction

type KeyActions

type KeyActions struct {
	// contains filtered or unexported fields
}

func NewKeyActions

func NewKeyActions() *KeyActions

func NewKeyActionsFromMap

func NewKeyActionsFromMap(m KeyMap) *KeyActions

func (*KeyActions) Add

func (a *KeyActions) Add(key tcell.Key, action KeyAction)

func (*KeyActions) Clear

func (a *KeyActions) Clear()

func (*KeyActions) Delete

func (a *KeyActions) Delete(keys ...tcell.Key)

func (*KeyActions) Get

func (a *KeyActions) Get(key tcell.Key) (KeyAction, bool)

func (*KeyActions) Len

func (a *KeyActions) Len() int

func (*KeyActions) Merge

func (a *KeyActions) Merge(as *KeyActions)

func (*KeyActions) Range

func (a *KeyActions) Range(f RandFn)

type KeyMap

type KeyMap map[tcell.Key]KeyAction

type LanguageVersions

type LanguageVersions struct {
	// contains filtered or unexported fields
}

func NewLanguageVersions

func NewLanguageVersions() *LanguageVersions

func (*LanguageVersions) Filter

func (lv *LanguageVersions) Filter(k, v string)

func (*LanguageVersions) GetData

func (lv *LanguageVersions) GetData(ctx context.Context, lang core.Language) (*LanguageVersions, error)

func (*LanguageVersions) GetRow

func (lv *LanguageVersions) GetRow(i []string) interface{}

func (*LanguageVersions) GetRowColor

func (lv *LanguageVersions) GetRowColor(i []string) tcell.Color

func (*LanguageVersions) Headers

func (lv *LanguageVersions) Headers() []*TableHeader

func (*LanguageVersions) RowCount

func (lv *LanguageVersions) RowCount() int

func (*LanguageVersions) Rows

func (lv *LanguageVersions) Rows() [][]string

func (*LanguageVersions) Title

func (lv *LanguageVersions) Title() string

type Languages

type Languages struct {
	// contains filtered or unexported fields
}

func NewLanguages

func NewLanguages() *Languages

func (*Languages) Filter

func (l *Languages) Filter(k, v string)

func (*Languages) GetRow

func (l *Languages) GetRow(i []string) interface{}

func (*Languages) GetRowColor

func (l *Languages) GetRowColor(i []string) tcell.Color

func (*Languages) Headers

func (l *Languages) Headers() []*TableHeader

func (*Languages) RowCount

func (l *Languages) RowCount() int

func (*Languages) Rows

func (l *Languages) Rows() [][]string

func (*Languages) Title

func (l *Languages) Title() string

type Page

type Page interface {
	tview.Primitive
	Init(ctx context.Context)
	SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey) *tview.Box
	GetKeyActions() *KeyActions
}

type PageLanguageVersions

type PageLanguageVersions struct {
	*SearchTable
	// contains filtered or unexported fields
}

func NewPageLanguageVersions

func NewPageLanguageVersions(app *Application) *PageLanguageVersions

func (*PageLanguageVersions) GetKeyActions

func (p *PageLanguageVersions) GetKeyActions() *KeyActions

func (*PageLanguageVersions) Init

func (p *PageLanguageVersions) Init(ctx context.Context)

type PageLanguages

type PageLanguages struct {
	*SearchTable
	// contains filtered or unexported fields
}

func NewPageLanguages

func NewPageLanguages(app *Application) *PageLanguages

func (*PageLanguages) GetKeyActions

func (p *PageLanguages) GetKeyActions() *KeyActions

func (*PageLanguages) Init

func (p *PageLanguages) Init(ctx context.Context)

type RandFn

type RandFn func(tcell.Key, KeyAction)

type SearchTable

type SearchTable struct {
	*tview.Flex
	// contains filtered or unexported fields
}

func NewSearchTable

func NewSearchTable(model Tabular, app *Application) *SearchTable

func (*SearchTable) BindKeys

func (t *SearchTable) BindKeys(km KeyMap)

func (*SearchTable) GetModel

func (t *SearchTable) GetModel() Tabular

func (*SearchTable) GetRowCount

func (t *SearchTable) GetRowCount() int

func (*SearchTable) GetSelection

func (t *SearchTable) GetSelection() (interface{}, bool)

func (*SearchTable) Render

func (t *SearchTable) Render()

func (*SearchTable) Select

func (t *SearchTable) Select(row, column int)

func (*SearchTable) SetModel

func (t *SearchTable) SetModel(model Tabular)

type TableHeader

type TableHeader struct {
	Title      string // 名称
	FixedWidth int
	Expansion  int // 占的列宽比例
	Hide       bool
}

type Tabular

type Tabular interface {
	Title() string
	RowCount() int
	Headers() []*TableHeader
	Rows() [][]string
	GetRow([]string) interface{}
	GetRowColor([]string) tcell.Color
	Filter(string, string)
}

Jump to

Keyboard shortcuts

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