vim

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdQuit          = "q"
	CmdQuitAll       = "qa"
	CmdWrite         = "w"
	CmdWriteQuit     = "wq"
	CmdRefresh       = "r"
	CmdHelp          = "help"
	CmdClearFilter   = "cf"
	CmdSelectAll     = "sa"
	CmdDeselectAll   = "da"
	CmdToggleDetails = "d"
	CmdEC2           = "ec2"
	CmdS3            = "s3"
	CmdEKS           = "eks"
	CmdECS           = "ecs"
	CmdECR           = "ecr"
	CmdServices      = "services"
	CmdAccount       = "account"
	CmdRegion        = "region"
)

Common VIM commands for k9s-like interface

Variables

This section is empty.

Functions

func AllCommands

func AllCommands() []string

AllCommands returns a list of all available commands for completion

func CalculateNewIndex

func CalculateNewIndex(action NavigationAction, currentIndex, listLength, pageSize int) int

CalculateNewIndex calculates the new index based on navigation action

func CompleteCommand

func CompleteCommand(prefix string) (string, bool)

CompleteCommand returns the completed command if there's only one match

func GetCommandSuggestions

func GetCommandSuggestions(prefix string) []string

GetCommandSuggestions returns commands that match the given prefix

Types

type Command

type Command struct {
	Name string
	Args []string
}

Command represents a parsed VIM-style command

func ParseCommand

func ParseCommand(commandStr string) Command

ParseCommand parses a command string

type Mode

type Mode int

Mode represents the current VIM mode

const (
	NormalMode Mode = iota
	SearchMode
	CommandMode
)
type NavigationAction int

NavigationAction represents a VIM navigation action

const (
	NoAction NavigationAction = iota
	MoveUp
	MoveDown
	MoveTop
	MoveBottom
	MoveHalfPageUp
	MoveHalfPageDown
	MovePageUp
	MovePageDown
	EnterSearch
	NextSearchResult
	PrevSearchResult
	EnterCommand
)

func ParseNavigation

func ParseNavigation(msg tea.KeyMsg) NavigationAction

ParseNavigation parses a key press into a navigation action

type State

type State struct {
	Mode          Mode
	SearchQuery   string
	SearchResults []int // indices of matching items
	CurrentMatch  int   // current position in SearchResults
	CommandBuffer string
	LastSearch    string       // for n/N navigation
	MarkPosition  map[rune]int // VIM marks (m{a-z})
}

State holds the VIM-like state for navigation

func NewState

func NewState() *State

NewState creates a new VIM state

func (*State) EnterCommandMode

func (s *State) EnterCommandMode()

EnterCommandMode activates command mode

func (*State) EnterSearchMode

func (s *State) EnterSearchMode()

EnterSearchMode activates search mode

func (*State) GetCurrentMatch

func (s *State) GetCurrentMatch() int

GetCurrentMatch returns the current match index

func (*State) GetMark

func (s *State) GetMark(mark rune) (int, bool)

GetMark returns the position of a mark

func (*State) HandleKey

func (s *State) HandleKey(msg tea.KeyMsg) bool

HandleKey processes a key press and returns true if handled

func (*State) NextMatch

func (s *State) NextMatch() int

NextMatch moves to the next search result

func (*State) PrevMatch

func (s *State) PrevMatch() int

PrevMatch moves to the previous search result

func (*State) SearchItems

func (s *State) SearchItems(items []string)

SearchItems performs a search on a list of items and updates SearchResults

func (*State) SetMark

func (s *State) SetMark(mark rune, position int)

SetMark sets a mark at the given position

Jump to

Keyboard shortcuts

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