input

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

internal/input/action.go

internal/input/keymap.go

Index

Constants

View Source
const DefaultLeaderKey = ',' // Using comma as leader key

DefaultLeaderKey is the default key used to initiate sequences.

View Source
const LeaderTimeout = 500 * time.Millisecond

LeaderTimeout is the duration to wait for the second key in a sequence.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action represents a command or operation to be performed by the editor.

const (
	// --- Meta Actions ---
	ActionUnknown Action = iota // Default/invalid action
	ActionQuit
	ActionForceQuit // Quit without checking modified status
	ActionSave

	// --- Cursor Movement ---
	ActionMoveUp
	ActionMoveDown
	ActionMoveLeft
	ActionMoveRight
	ActionMovePageUp
	ActionMovePageDown
	ActionMoveHome // Beginning of line
	ActionMoveEnd  // End of line

	// --- Text Manipulation ---
	ActionInsertRune         // Requires Rune argument
	ActionInsertNewLine      // Specific action for Enter
	ActionInsertTab          // Specific action for Tab key
	ActionDeleteCharForward  // Delete key
	ActionDeleteCharBackward // Backspace key
	ActionYank               // Copy selection to clipboard
	ActionPaste              // Insert clipboard content
	ActionUndo               // Undo last edit
	ActionRedo               // Redo previously undone edit

	// --- Editor Mode ---
	ActionEnterCommandMode  // Special action for ':'
	ActionExecuteCommand    // Special action for Enter in Command Mode
	ActionCancelCommand     // Special action for Esc in Command Mode
	ActionAppendCommand     // Special action for runes in Command Mode
	ActionDeleteCommandChar // Special action for Backspace in Command Mode

	// --- find ---
	ActionEnterFindMode // Trigger find mode (e.g., '/')
	ActionFindNext      // Find next occurrence (e.g., 'n')
	ActionFindPrevious  // Find previous occurrence (e.g., 'N')

)

Define the set of possible editor actions.

type ActionEvent

type ActionEvent struct {
	Action Action
	Rune   rune // Used for ActionInsertRune

}

ActionEvent represents a decoded input event resulting in an action. It might carry payload data needed for the action (like the rune to insert).

type InputProcessor

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

InputProcessor translates tcell events into ActionEvents.

func NewInputProcessor

func NewInputProcessor() *InputProcessor

NewInputProcessor creates a processor with default keybindings.

func (*InputProcessor) GetLeaderKey

func (p *InputProcessor) GetLeaderKey() rune

GetLeaderKey returns the configured leader key rune.

func (*InputProcessor) IsLeaderSequenceKey

func (p *InputProcessor) IsLeaderSequenceKey(r rune) (Action, bool)

IsLeaderSequenceKey checks if a rune completes a known leader sequence.

func (*InputProcessor) ProcessEvent

func (p *InputProcessor) ProcessEvent(ev *tcell.EventKey) ActionEvent

ProcessEvent takes a tcell key event and returns the corresponding ActionEvent.

type Keymap

type Keymap map[tcell.Key]Action // For special keys (Enter, Arrows, etc.)

Keymap maps specific key events to editor actions. We use a simple map for now. Could evolve to handle sequences/modes later.

type LeaderSequenceMap

type LeaderSequenceMap map[rune]Action // For keys that follow the leader key

LeaderSequenceMap maps the key following the leader to an action

type ModKeymap

type ModKeymap map[tcell.ModMask]Keymap // For keys combined with modifiers (Ctrl, Alt, Shift)

type RuneKeymap

type RuneKeymap map[rune]Action // For simple rune bindings (rarely needed beyond insert)

Jump to

Keyboard shortcuts

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