ui

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ui 提供终端交互:目录模糊选择与启动模式选择。

Package ui 提供终端交互:目录模糊选择与启动模式选择。

Package ui 提供终端交互:目录模糊选择与启动模式选择。

Index

Constants

This section is empty.

Variables

View Source
var (
	// TitleStyle 标题样式
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(colorPrimary).
				MarginBottom(1)

	// SubtitleStyle 副标题 / 描述
	SubtitleStyle = lipgloss.NewStyle().
					Foreground(colorDim)

	// ActiveItemStyle 选中项
	ActiveItemStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(colorSecondary).
					PaddingLeft(1).
					PaddingRight(2)

	// InactiveItemStyle 未选中项
	InactiveItemStyle = lipgloss.NewStyle().
						Foreground(colorFg).
						PaddingLeft(2).
						PaddingRight(2)

	// CursorBar 左侧指示条
	CursorBar = lipgloss.NewStyle().
				Foreground(colorCursorBar).
				SetString("▌")

	// SelectedStyle 已选中确认
	SelectedStyle = lipgloss.NewStyle().
					Foreground(colorAccent).
					Bold(true)

	// HelpStyle 底部帮助文字
	HelpStyle = lipgloss.NewStyle().
				Foreground(colorDim).
				MarginTop(1)

	// DocStyle 最外层的容器
	DocStyle = lipgloss.NewStyle().
				Margin(1, 2)

	// InputPromptStyle 输入框提示
	InputPromptStyle = lipgloss.NewStyle().
						Foreground(colorSecondary).
						Bold(true)

	// InputTextStyle 输入框文字
	InputTextStyle = lipgloss.NewStyle().
					Foreground(colorFg)

	// BannerStyle Banner 样式
	BannerStyle = lipgloss.NewStyle().
				Foreground(colorPrimary).
				Bold(true)

	// BannerInfoStyle Banner 信息行
	BannerInfoStyle = lipgloss.NewStyle().
					Foreground(colorDim).
					Italic(true)
)

── 通用样式 ──────────────────────────────────────────────────

View Source
var (
	// PanelStyle 选择面板容器:圆角边框 + 内边距
	PanelStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(colorDim).
				Padding(1, 2)

	// PanelTitleStyle 面板内标题
	PanelTitleStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(colorPrimary).
					PaddingBottom(1)

	// KeyBadgeStyle 快捷键 badge,例如 [Enter]
	KeyBadgeStyle = lipgloss.NewStyle().
					Foreground(colorCursorBar).
					Bold(true)

	// KeyDescStyle badge 旁的描述文字
	KeyDescStyle = lipgloss.NewStyle().
					Foreground(colorDim)

	// StepStyle 步骤指示器样式
	StepStyle = lipgloss.NewStyle().
				Foreground(colorDim).
				Bold(true)

	// DividerStyle 水平分割线
	DividerStyle = lipgloss.NewStyle().
					Foreground(colorDim)

	// ActiveRowStyle 选中行的背景条纹
	ActiveRowStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(colorSecondary)

	// CmdDescStyle 命令描述(等宽灰色)
	CmdDescStyle = lipgloss.NewStyle().
					Foreground(colorDim).
					Italic(true)
)

── 面板 & 增强样式 ─────────────────────────────────────────

Functions

func Divider added in v1.0.1

func Divider(width int) string

Divider 返回指定宽度的水平分割线

func FormatHelpLine added in v1.0.1

func FormatHelpLine(pairs ...string) string

FormatHelpLine 格式化一组快捷键帮助,用分隔符连接

func FormatKeyHelp added in v1.0.1

func FormatKeyHelp(key, desc string) string

FormatKeyHelp 格式化快捷键帮助,例如 FormatKeyHelp("↑↓", "选择") => "[↑↓] 选择"

func PrintBanner

func PrintBanner(w io.Writer, version string)

PrintBanner 在启动时输出带渐变色的 ASCII Art Logo。 version 为版本号,传空字符串则不显示。

func SelectCommand

func SelectCommand(commands []config.CommandConfig) (config.CommandConfig, bool, error)

SelectCommand 显示命令选择 TUI,返回用户选中的 CommandConfig。

func SelectDir

func SelectDir(dirs []scan.Dir) (scan.Dir, bool, error)

func SelectRoot

func SelectRoot(label string, options []RootOption, defaultInput string) (string, bool, error)

Types

type RootOption

type RootOption struct {
	Label    string
	Value    string
	IsManual bool
}

type WorkspaceChoice

type WorkspaceChoice int

WorkspaceChoice 表示用户选择的工作区来源。

const (
	WorkspaceCurrentDir WorkspaceChoice = iota // 使用当前目录
	WorkspaceProject                           // 使用项目书签
	WorkspaceBrowseRoot                        // 从已保存的根目录浏览子文件夹
	WorkspaceNewRoot                           // 选择新的根目录
)

type WorkspaceResult

type WorkspaceResult struct {
	Choice      WorkspaceChoice
	ProjectPath string // CurrentDir / Project 时填充目标路径
}

WorkspaceResult 封装选择结果。

func SelectWorkspace

func SelectWorkspace(savedRoot string, projects []config.ProjectConfig) (WorkspaceResult, bool, error)

SelectWorkspace 显示统一的工作区选择 TUI。 savedRoot: 已保存的根目录(空则不显示"从根目录浏览"选项)。 projects: 用户配置的项目书签列表。

Jump to

Keyboard shortcuts

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