terminal

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeDelete TaskType = iota
	TypeDownload
	TypePaste
	TypeRename
	TaskAddQuick

	StatusWating TaskStatus = iota
	StatusRunning
	StatusSuccess
	StatusFailed
)

Variables

View Source
var KeyDelete = key.NewBinding(
	key.WithKeys("D"),
	key.WithHelp("D", "删除"),
)
View Source
var KeyEnter = key.NewBinding(
	key.WithKeys("right", "l", "enter"),
	key.WithHelp("→/l/enter", "确认/打开"),
)

Functions

func GetBaseStyleHeight

func GetBaseStyleHeight() int

func GetBaseStyleWidth

func GetBaseStyleWidth() int

Types

type BDPan

type BDPan struct {
	Dir string

	// 需要离开 bubbles 执行的任务通知
	NextAction    string
	ActionPayload any

	Filter string // 过滤信息

	KeyMap KeyMap
	// contains filtered or unexported fields
}

func NewBDPan

func NewBDPan(dir string) (*BDPan, error)

func (*BDPan) AddFileTask

func (m *BDPan) AddFileTask(f *model.File, t TaskType) *Task

func (*BDPan) AddOrAppendFileTask

func (m *BDPan) AddOrAppendFileTask(f *model.File, tt TaskType) *Task

func (*BDPan) AddTask added in v0.0.3

func (m *BDPan) AddTask(b TaskBinding) *Task

func (*BDPan) CanPreviewFile added in v0.0.3

func (m *BDPan) CanPreviewFile(f *bdpan.FileInfo) (bool, tea.Cmd)

func (*BDPan) CanSelectFile

func (m *BDPan) CanSelectFile() bool

func (*BDPan) ClearCutSelectFileMap

func (m *BDPan) ClearCutSelectFileMap()

清空剪切选中文件集合

func (*BDPan) ClearLastKey

func (m *BDPan) ClearLastKey() *BDPan

func (*BDPan) ClearSelectFileMap

func (m *BDPan) ClearSelectFileMap()

清空选中文件集合

func (*BDPan) ConfirmFocused

func (m *BDPan) ConfirmFocused() bool

func (*BDPan) DisableLoadingFileList

func (m *BDPan) DisableLoadingFileList() *BDPan

func (*BDPan) DoneTask

func (m *BDPan) DoneTask(t *Task, err error) tea.Cmd

func (*BDPan) EnableLoadingFileList

func (m *BDPan) EnableLoadingFileList() *BDPan

func (*BDPan) FileContentFocused added in v0.0.3

func (m *BDPan) FileContentFocused() bool

func (*BDPan) FileListFocus

func (m *BDPan) FileListFocus() *BDPan

func (*BDPan) FileListModelIsNil

func (m *BDPan) FileListModelIsNil() bool

func (*BDPan) FileListModelIsNotNil

func (m *BDPan) FileListModelIsNotNil() bool

func (*BDPan) FilesIsNotNil

func (m *BDPan) FilesIsNotNil() bool

func (*BDPan) GetCenterView

func (m *BDPan) GetCenterView() string

func (*BDPan) GetConfirmTasks

func (m *BDPan) GetConfirmTasks() []*Task

func (*BDPan) GetConfirmView

func (m *BDPan) GetConfirmView() string

func (*BDPan) GetCurrFiles added in v0.0.3

func (m *BDPan) GetCurrFiles() []*model.File

func (*BDPan) GetCutSelectFilePaths

func (m *BDPan) GetCutSelectFilePaths() []string

获取剪切选中文件的地址列表

func (*BDPan) GetCutSelectFiles

func (m *BDPan) GetCutSelectFiles() []*model.File

func (*BDPan) GetDirView

func (m *BDPan) GetDirView() string

func (*BDPan) GetFileInfoView

func (m *BDPan) GetFileInfoView(f *model.File) string

func (*BDPan) GetFileListCursor

func (m *BDPan) GetFileListCursor() int

获取文件光标

func (*BDPan) GetFileListView

func (m *BDPan) GetFileListView() string

func (*BDPan) GetFiles added in v0.0.3

func (m *BDPan) GetFiles(dir string) []*model.File

func (*BDPan) GetHeight

func (m *BDPan) GetHeight() int

func (*BDPan) GetHelpView

func (m *BDPan) GetHelpView() string

func (*BDPan) GetInputView added in v0.0.3

func (m *BDPan) GetInputView() string

func (*BDPan) GetLeftWidth

func (m *BDPan) GetLeftWidth() int

func (*BDPan) GetMessageView

func (m *BDPan) GetMessageView() string

func (*BDPan) GetMidHeight

func (m *BDPan) GetMidHeight() int

func (*BDPan) GetMidView

func (m *BDPan) GetMidView() string

func (*BDPan) GetMidWidth

func (m *BDPan) GetMidWidth() int

func (*BDPan) GetQuickByKeyStr

func (m *BDPan) GetQuickByKeyStr(k string) *model.Quick

func (*BDPan) GetQuickByPath

func (m *BDPan) GetQuickByPath(p string) *model.Quick

func (*BDPan) GetQuickKeys

func (m *BDPan) GetQuickKeys() []key.Binding

func (*BDPan) GetRightExtModels added in v0.0.3

func (m *BDPan) GetRightExtModels() []wtea.Model

func (*BDPan) GetRightView

func (m *BDPan) GetRightView() string

func (*BDPan) GetRightWidth

func (m *BDPan) GetRightWidth() int

func (*BDPan) GetSelectFile

func (m *BDPan) GetSelectFile() (*model.File, error)

func (*BDPan) GetSelectFilePaths

func (m *BDPan) GetSelectFilePaths() []string

获取选中文件的地址列表

func (*BDPan) GetSelectFiles added in v0.0.3

func (m *BDPan) GetSelectFiles() []*model.File

func (*BDPan) GetStatusView

func (m *BDPan) GetStatusView() string

func (*BDPan) GetTaskByType

func (m *BDPan) GetTaskByType(tt TaskType) *Task

获取指定类型任务

func (*BDPan) GetWidth

func (m *BDPan) GetWidth() int

func (*BDPan) Goto

func (m *BDPan) Goto(dir string) tea.Cmd

改变显示的目录

func (*BDPan) HasSelectFile

func (m *BDPan) HasSelectFile() bool

是否有选中的文件

func (*BDPan) Init

func (m *BDPan) Init() tea.Cmd

func (*BDPan) InputBlur added in v0.0.3

func (m *BDPan) InputBlur()

func (*BDPan) InputFocused added in v0.0.3

func (m *BDPan) InputFocused() bool

func (*BDPan) IsLoadingFileList

func (m *BDPan) IsLoadingFileList() bool

func (*BDPan) ListenCombKeyMsg

func (m *BDPan) ListenCombKeyMsg(msg tea.Msg) (bool, tea.Cmd)

ListenCombKeyMsg 监听两个键位的组合

func (*BDPan) ListenFileListKeyMsg added in v0.0.3

func (m *BDPan) ListenFileListKeyMsg(msg tea.Msg) (bool, tea.Cmd)

func (*BDPan) ListenKeyMsg

func (m *BDPan) ListenKeyMsg(msg tea.Msg) (bool, tea.Cmd)

func (*BDPan) ListenOtherMsg

func (m *BDPan) ListenOtherMsg(msg tea.Msg) (bool, tea.Cmd)

func (*BDPan) ListenRunTaskMsg added in v0.0.3

func (m *BDPan) ListenRunTaskMsg(msg RunTaskMsg) (bool, tea.Cmd)

func (*BDPan) MatcheKeys

func (m *BDPan) MatcheKeys(msg tea.KeyMsg, b ...key.Binding) bool

func (*BDPan) MessageIsNotNil

func (m *BDPan) MessageIsNotNil() bool

func (*BDPan) NewFileList

func (m *BDPan) NewFileList(files []*model.File) *FileList

func (*BDPan) PanIsNil

func (m *BDPan) PanIsNil() bool

func (*BDPan) PreviewFile added in v0.0.3

func (m *BDPan) PreviewFile(f *bdpan.FileInfo) (bool, tea.Cmd)

func (*BDPan) RefreshQuickSelect

func (m *BDPan) RefreshQuickSelect() *BDPan

func (*BDPan) RestoreState added in v0.0.3

func (m *BDPan) RestoreState(old *BDPan)

重新加载状态

func (*BDPan) SendClipboardMessage

func (m *BDPan) SendClipboardMessage(msg string) tea.Cmd

func (*BDPan) SendDeleteQuick

func (m *BDPan) SendDeleteQuick(q *model.Quick) tea.Cmd

func (*BDPan) SendGoto

func (m *BDPan) SendGoto(dir string) tea.Cmd

发送跳转目录的命令 实时获取最新结果

func (*BDPan) SendLoadingMessage

func (m *BDPan) SendLoadingMessage() tea.Cmd

func (*BDPan) SendMessage

func (m *BDPan) SendMessage(msg string, a ...any) tea.Cmd

func (*BDPan) SendMsg

func (m *BDPan) SendMsg(msg tea.Msg) tea.Cmd

func (*BDPan) SendRefreshPan

func (m *BDPan) SendRefreshPan() tea.Cmd

func (*BDPan) SendRefreshQuick

func (m *BDPan) SendRefreshQuick() tea.Cmd

func (*BDPan) SendRefreshUser

func (m *BDPan) SendRefreshUser() tea.Cmd

func (*BDPan) SendRunTask

func (m *BDPan) SendRunTask(t *Task) tea.Cmd

func (*BDPan) SendShowConfirm

func (m *BDPan) SendShowConfirm(
	title string,
	data wtea.ExtData,
	fromModel wtea.Model,
) tea.Cmd

发送显示确认框消息

参数:

  • title: 展示标题
  • data: 确认框携带的额外信息
  • fromModel: 从哪个模型跳转的,方便返回聚焦

func (*BDPan) SendShowInput added in v0.0.3

func (m *BDPan) SendShowInput(
	title, text string,
	task *Task,
	fromModel wtea.Model,
) tea.Cmd

发送显示输入框消息

参数:

  • title: 展示标题
  • text: 展示文本
  • task: 任务
  • fromModel: 从哪个模型跳转的,方便返回聚焦

func (*BDPan) SetFiles

func (m *BDPan) SetFiles(files []*model.File) *BDPan

func (*BDPan) SetFilesAndFocus added in v0.0.3

func (m *BDPan) SetFilesAndFocus(files []*model.File) *BDPan

func (*BDPan) SetLastKey

func (m *BDPan) SetLastKey(msg tea.KeyMsg) *BDPan

func (*BDPan) SetMessage

func (m *BDPan) SetMessage(msg string, args ...any)

设置消息

func (*BDPan) SetQuicks

func (m *BDPan) SetQuicks(q []*model.Quick)

func (*BDPan) SetSomeTaskMessage

func (m *BDPan) SetSomeTaskMessage()

func (*BDPan) Update

func (m *BDPan) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*BDPan) UserIsNil

func (m *BDPan) UserIsNil() bool

func (*BDPan) View

func (m *BDPan) View() string

type BlurMsg

type BlurMsg tea.Msg

type ChangeFilesMsg

type ChangeFilesMsg struct {
	Files []*model.File
}

type ChangePanMsg

type ChangePanMsg struct {
	Pan *model.Pan
}

type ChangeUserMsg

type ChangeUserMsg struct {
	User *model.User
}

type Confirm

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

func NewConfirm

func NewConfirm(
	title string,
) *Confirm

func (*Confirm) Blur

func (m *Confirm) Blur() *Confirm

func (*Confirm) Focus

func (m *Confirm) Focus() *Confirm

func (*Confirm) Focused

func (m *Confirm) Focused() bool

func (*Confirm) GetValue

func (m *Confirm) GetValue() bool

func (*Confirm) Init

func (m *Confirm) Init() tea.Cmd

func (*Confirm) SetTask

func (m *Confirm) SetTask(t *Task) *Confirm

func (*Confirm) Update

func (m *Confirm) Update(msg tea.Msg) (*Confirm, tea.Cmd)

func (*Confirm) View

func (m *Confirm) View() string

func (*Confirm) Width

func (m *Confirm) Width(w int) *Confirm

type ConfirmKeyMap

type ConfirmKeyMap struct {
	Enter   key.Binding
	Right   key.Binding
	Left    key.Binding
	Confirm key.Binding
	Cancel  key.Binding
}

func DefaultConfirmKeyMap

func DefaultConfirmKeyMap() ConfirmKeyMap

type DeleteQuickMsg

type DeleteQuickMsg struct {
	Quick *model.Quick
}

type Ext added in v0.0.3

type Ext any

type FileContent added in v0.0.3

type FileContent struct {
	Model viewport.Model

	KeyMap FileContentKeyMap
	// contains filtered or unexported fields
}

func NewFileContent added in v0.0.3

func NewFileContent(filePath string, opts ...any) (*FileContent, error)

func (FileContent) Init added in v0.0.3

func (m FileContent) Init() tea.Cmd

func (*FileContent) Update added in v0.0.3

func (m *FileContent) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (FileContent) View added in v0.0.3

func (m FileContent) View() string

type FileContentKeyMap added in v0.0.3

type FileContentKeyMap struct {
	viewport.KeyMap
	Esc key.Binding
}

func DefaultFileContentKeyMap added in v0.0.3

func DefaultFileContentKeyMap() FileContentKeyMap

func (FileContentKeyMap) FullHelp added in v0.0.3

func (km FileContentKeyMap) FullHelp() [][]key.Binding

FullHelp implements the KeyMap interface.

func (FileContentKeyMap) ShortHelp added in v0.0.3

func (km FileContentKeyMap) ShortHelp() []key.Binding

ShortHelp implements the KeyMap interface.

type FileInfo

type FileInfo struct {
	Model table.Model
}

func NewFileInfo

func NewFileInfo(f *model.File, height int) (*FileInfo, error)

func (FileInfo) Init

func (m FileInfo) Init() tea.Cmd

func (*FileInfo) Update

func (m *FileInfo) Update(msg tea.Msg) (*FileInfo, tea.Cmd)

func (FileInfo) View

func (m FileInfo) View() string

type FileList

type FileList struct {
	KeyMap  FileListKeyMap
	TaskMap FileListTaskMap
	// contains filtered or unexported fields
}

func NewFileList

func NewFileList(
	files []*model.File, width, height int, selectors []string,
	args ...FileListArg,
) *FileList

func (*FileList) Blur

func (m *FileList) Blur()

func (*FileList) Cursor

func (m *FileList) Cursor(i int) *FileList

设置光标

func (*FileList) Focus

func (m *FileList) Focus()

func (FileList) Focused

func (m FileList) Focused() bool

func (*FileList) GetCursor

func (m *FileList) GetCursor() int

func (FileList) GetKeyMap

func (m FileList) GetKeyMap() FileListKeyMap

func (*FileList) GetSelectFile

func (m *FileList) GetSelectFile() (*model.File, error)

func (*FileList) Init

func (m *FileList) Init() tea.Cmd

func (*FileList) Update

func (m *FileList) Update(msg tea.Msg) (*FileList, tea.Cmd)

func (FileList) View

func (m FileList) View() string

type FileListArg

type FileListArg struct {
	Type  FileListArgType
	Files []*model.File
}

type FileListArgType

type FileListArgType int
const (
	FLTypeSelect FileListArgType = iota
	FLTypeSelectCut
)

type FileListKeyMap

type FileListKeyMap struct {
	table.KeyMap
	Exit        key.Binding
	Enter       key.Binding
	Back        key.Binding
	Refresh     key.Binding
	Space       key.Binding // 空格,选中
	SelectAll   key.Binding // 选中全部
	Delete      key.Binding
	Cut         key.Binding // 剪切
	Paste       key.Binding // 黏贴
	AddQuick    key.Binding // 添加快速访问
	Rename      key.Binding // 重命名
	ShowContent key.Binding // 显示内容
	Filter      key.Binding // 过滤
}

func DefaultFileListKeyMap

func DefaultFileListKeyMap() FileListKeyMap

func (FileListKeyMap) FullHelp added in v0.0.3

func (km FileListKeyMap) FullHelp() [][]key.Binding

FullHelp implements the KeyMap interface.

func (FileListKeyMap) ShortHelp added in v0.0.3

func (km FileListKeyMap) ShortHelp() []key.Binding

ShortHelp implements the KeyMap interface.

type FileListTaskMap added in v0.0.3

type FileListTaskMap struct {
	AddQuick    TaskBinding
	ShowContent TaskBinding
	Filter      TaskBinding
}

func DefaultFileListTaskMap added in v0.0.3

func DefaultFileListTaskMap() FileListTaskMap

type FocusMsg

type FocusMsg tea.Msg

type GotoMsg

type GotoMsg struct {
	Dir string
}

type Input added in v0.0.3

type Input struct {
	KeyMap InputKeyMap
	// contains filtered or unexported fields
}

func NewInput added in v0.0.3

func NewInput(
	title, initText string,
	opts ...any,
) *Input

func (Input) Blur added in v0.0.3

func (m Input) Blur()

func (Input) Focus added in v0.0.3

func (m Input) Focus()

func (Input) Focused added in v0.0.3

func (m Input) Focused() bool

func (*Input) GetFromModel added in v0.0.3

func (m *Input) GetFromModel() wtea.Model

func (Input) Init added in v0.0.3

func (m Input) Init() tea.Cmd

func (*Input) SetFromModel added in v0.0.3

func (m *Input) SetFromModel(model wtea.Model)

func (Input) SetHeight added in v0.0.3

func (m Input) SetHeight(h int)

func (Input) SetWidth added in v0.0.3

func (m Input) SetWidth(w int)

func (*Input) Update added in v0.0.3

func (m *Input) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Input) Value added in v0.0.3

func (m Input) Value() string

func (Input) View added in v0.0.3

func (m Input) View() string

type InputKeyMap added in v0.0.3

type InputKeyMap struct {
	textarea.KeyMap
	Enter key.Binding
}

func DefaultInputKeyMap added in v0.0.3

func DefaultInputKeyMap() InputKeyMap

func (InputKeyMap) FullHelp added in v0.0.3

func (km InputKeyMap) FullHelp() [][]key.Binding

FullHelp implements the KeyMap interface.

func (InputKeyMap) ShortHelp added in v0.0.3

func (km InputKeyMap) ShortHelp() []key.Binding

ShortHelp implements the KeyMap interface.

type KeyMap

type KeyMap struct {
	Esc  key.Binding
	Exit key.Binding
	Back key.Binding
	// Right   key.Binding
	// Left    key.Binding
	Refresh key.Binding
	Restore key.Binding
	Help    key.Binding // 帮助

	// Pane
	MovePaneLeft  key.Binding
	MovePaneRight key.Binding

	// 复制组合键位
	CopyPath               key.Binding
	CopyDir                key.Binding
	CopyFilename           key.Binding
	CopyFilenameWithoutExt key.Binding
	CopyFSID               key.Binding

	// Goto 组合键位
	GotoRoot key.Binding
}

func DefaultKeyMap

func DefaultKeyMap() KeyMap

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view. It's part of the key.Map interface.

func (KeyMap) GetCombKeys

func (k KeyMap) GetCombKeys(keys []key.Binding) []key.Binding

func (KeyMap) GetCopyKeys

func (k KeyMap) GetCopyKeys() []key.Binding

func (KeyMap) GetGotoKeys

func (k KeyMap) GetGotoKeys(keys []key.Binding) []key.Binding

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

type MessageTimeoutMsg

type MessageTimeoutMsg struct{}

type Quick

type Quick struct {
	KeyMap  QuickKeyMap
	TaskMap QuickTaskMap
	// contains filtered or unexported fields
}

func NewQuick

func NewQuick(title string, items []*model.Quick, opts ...any) *Quick

func (*Quick) Blur

func (m *Quick) Blur()

func (*Quick) Focus

func (m *Quick) Focus()

func (*Quick) Focused

func (m *Quick) Focused() bool

func (*Quick) GetKeyMap

func (m *Quick) GetKeyMap() QuickKeyMap

func (*Quick) GetSelect

func (m *Quick) GetSelect() *model.Quick

func (*Quick) Height

func (m *Quick) Height(h int) *Quick

func (Quick) Init

func (m Quick) Init() tea.Cmd

func (*Quick) Select

func (m *Quick) Select(i int) *Quick

func (*Quick) SetItems

func (m *Quick) SetItems(items []list.Item) *Quick

func (*Quick) Update

func (m *Quick) Update(msg tea.Msg) (*Quick, tea.Cmd)

func (Quick) View

func (m Quick) View() string

func (*Quick) Width

func (m *Quick) Width(w int) *Quick

type QuickKeyMap

type QuickKeyMap struct {
	list.KeyMap
	Enter  key.Binding
	Edit   key.Binding
	Delete key.Binding
}

func DefaultQuickKeyMap

func DefaultQuickKeyMap() QuickKeyMap

func (QuickKeyMap) FullHelp added in v0.0.3

func (km QuickKeyMap) FullHelp() [][]key.Binding

FullHelp implements the KeyMap interface.

func (QuickKeyMap) ShortHelp added in v0.0.3

func (km QuickKeyMap) ShortHelp() []key.Binding

ShortHelp implements the KeyMap interface.

type QuickTaskMap added in v0.0.3

type QuickTaskMap struct {
	Edit TaskBinding
}

func DefaultQuickTaskMap added in v0.0.3

func DefaultQuickTaskMap() QuickTaskMap

type RefreshPanMsg

type RefreshPanMsg struct{}

type RefreshQuickMsg

type RefreshQuickMsg struct{}

type RefreshUserMsg

type RefreshUserMsg struct{}

type RunTaskMsg

type RunTaskMsg struct {
	Task *Task
}

type ShowConfirmMsg

type ShowConfirmMsg struct {
	Title string
	Data  wtea.ExtData
	Model wtea.Model
}

type ShowInputMsg added in v0.0.3

type ShowInputMsg struct {
	Title string
	Text  string
	Model wtea.Model
}

type Task

type Task struct {
	ID        int
	File      *model.File
	Files     []*model.File
	Dir       string
	Type      TaskType
	Binding   TaskBinding
	Status    TaskStatus
	IsConfirm bool

	Data Ext
	Ext  Ext
	// contains filtered or unexported fields
}

func NewTask

func NewTask(type_ TaskType, f *model.File) *Task

func (Task) GetStatusString

func (t Task) GetStatusString() string

func (Task) GetTypeString

func (t Task) GetTypeString() string

func (Task) String

func (t Task) String() string

type TaskBinding added in v0.0.3

type TaskBinding struct {
	Title string
	Type  string
}

type TaskStatus

type TaskStatus int

type TaskType

type TaskType int

type Terminal

type Terminal struct {
	Path string
	// contains filtered or unexported fields
}

func NewTerminal

func NewTerminal(path string) *Terminal

func (*Terminal) Run

func (t *Terminal) Run() error

func (*Terminal) Send

func (t *Terminal) Send(second int, send func() any)

Jump to

Keyboard shortcuts

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