cmdbar

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cmdbar is the command/status bar TUI component.

Index

Constants

This section is empty.

Variables

View Source
var (
	CmdBarStyle = lipgloss.NewStyle().
				Border(lipgloss.NormalBorder(), true, false, false, false).
				BorderForeground(lipgloss.Color("240")).
				Padding(0, 1)

	ModeViewStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color("252")).
					Background(lipgloss.Color("62"))

	ModeNormalStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color("252")).
					Background(lipgloss.Color("157"))

	ModeInsertStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color("252")).
					Background(lipgloss.Color("212"))

	ModeReplaceStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(lipgloss.Color("252")).
						Background(lipgloss.Color("203"))

	ModeVisualStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color("252")).
					Background(lipgloss.Color("214"))
)

Command bar lipgloss styles, updated by ApplyTheme.

Functions

func ApplyTheme

func ApplyTheme(t CmdBarTheme)

ApplyTheme updates the mode indicator styles from theme colors.

func ParseCommand

func ParseCommand(input string) (string, []string)

ParseCommand parses a command string into a command name and arguments. The special prefix "/" is treated as a vim-style in-buffer search: the entire string after the slash becomes a single argument (no quote stripping, no space splitting) so that patterns like "/hello world" work correctly.

Types

type ArgCompleter

type ArgCompleter func(cmd, argPrefix string) []string

ArgCompleter returns completion candidates for a command argument. cmd is the command name; argPrefix is the partial argument typed so far.

type CmdBarTheme

type CmdBarTheme struct {
	ModeView    lipgloss.Color
	ModeNormal  lipgloss.Color
	ModeInsert  lipgloss.Color
	ModeReplace lipgloss.Color
	ModeVisual  lipgloss.Color
	Accent      lipgloss.Color
	TabBg       lipgloss.Color
	Dim         lipgloss.Color
}

CmdBarTheme holds the colors needed to style the command bar.

type CommandMsg

type CommandMsg struct {
	Command string
	Args    []string
}

CommandMsg is dispatched when the user submits a command.

type Level

type Level int

Level represents the severity of a status message.

const (
	LevelInfo Level = iota
	LevelSuccess
	LevelWarn
	LevelError
)

Status bar severity levels.

type Model

type Model struct {
	Input       textinput.Model
	Status      string
	StatusLevel Level

	Active bool
	Width  int

	// Mode indicator (set by app from viewer)
	ModeLabel common.Mode
	ModeLine  int
	ModeCol   int

	ArgComplete ArgCompleter
	// contains filtered or unexported fields
}

Model is the command bar component.

func New

func New(custom *theme.CustomTheme, keys config.Keys) Model

New creates a new command bar model.

func (*Model) Activate

func (c *Model) Activate()

Activate focuses the command bar for input.

func (*Model) ClearStatus

func (c *Model) ClearStatus()

ClearStatus clears the status message and resets the level.

func (*Model) Reset

func (c *Model) Reset()

Reset clears the command bar and returns it to the default hint.

func (*Model) SetError

func (c *Model) SetError(s string)

SetError sets an error status message.

func (*Model) SetStatus

func (c *Model) SetStatus(s string)

SetStatus sets an informational status message.

func (*Model) SetSuccess

func (c *Model) SetSuccess(s string)

SetSuccess sets a success status message.

func (*Model) SetWarn

func (c *Model) SetWarn(s string)

SetWarn sets a warning status message.

func (Model) Update

func (c Model) Update(msg tea.Msg) (Model, tea.Cmd)

func (Model) View

func (c Model) View() string

Jump to

Keyboard shortcuts

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