Documentation
¶
Overview ¶
Package scroll provides Vim-style scrolling functionality for the Neru application.
This package implements a comprehensive scrolling system that allows users to navigate content using familiar Vim-style keybindings. The scroll functionality can be used both as a standalone mode and within other navigation modes (hints/grid) for precise content navigation.
Index ¶
- Constants
- type Action
- type Context
- type KeyMap
- func (m *KeyMap) Action(name string) (Action, bool)
- func (m *KeyMap) CanCompleteSequence(first, second string) bool
- func (m *KeyMap) IsSequenceStart(key string) bool
- func (m *KeyMap) KeyToAction() map[string]string
- func (m *KeyMap) Lookup(key string) (string, bool)
- func (m *KeyMap) LookupSequence(seq string) (string, bool)
- func (m *KeyMap) Normalize(key string) string
- func (m *KeyMap) Sequences() map[string]string
- type SequenceState
Constants ¶
const ( ArrowUp = "Up" ArrowDown = "Down" ArrowLeft = "Left" ArrowRight = "Right" PageUp = "PageUp" PageDown = "PageDown" )
Arrow key names for normalized key mapping. These use the canonical display forms from the centralized validNamedKeys registry.
const ( ActionScrollUp = "scroll_up" ActionScrollDown = "scroll_down" ActionScrollLeft = "scroll_left" ActionScrollRight = "scroll_right" ActionGoTop = "go_top" ActionGoBottom = "go_bottom" ActionPageUp = "page_up" ActionPageDown = "page_down" )
Scroll action names used in configuration.
const SequenceTimeout = 500 * time.Millisecond
SequenceTimeout is the maximum time allowed between keys in a multi-key sequence.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶ added in v1.13.0
type Action struct {
Direction services.ScrollDirection
Amount services.ScrollAmount
}
Action represents a scroll action with direction and amount.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds the state and context for scroll mode operations.
func (*Context) LastKeyState ¶ added in v1.21.4
LastKeyState atomically returns both the last key and its timestamp. Use this instead of separate LastKey()/LastKeyTime() calls when both values are needed together to avoid TOCTOU races.
func (*Context) LastKeyTime ¶ added in v1.13.0
LastKeyTime returns the timestamp when the last key was pressed.
func (*Context) Reset ¶
func (c *Context) Reset()
Reset resets the scroll context to its initial state.
func (*Context) SetIsActive ¶
SetIsActive sets whether scroll mode is currently active.
func (*Context) SetLastKey ¶
SetLastKey sets the last key pressed during scroll operations. When key is non-empty, the timestamp is updated to now. When key is empty (clearing state), the timestamp is zeroed.
type KeyMap ¶ added in v1.13.0
type KeyMap struct {
// contains filtered or unexported fields
}
KeyMap maps key bindings to scroll actions and handles key sequence detection.
func NewKeyMap ¶ added in v1.13.0
NewKeyMap creates a new KeyMap from the given bindings. Bindings is a map from action names to lists of key strings.
func (*KeyMap) Action ¶ added in v1.13.0
Action returns the Action struct for a given action name and whether it was found.
func (*KeyMap) CanCompleteSequence ¶ added in v1.13.0
CanCompleteSequence returns true if the given two keys form a complete sequence.
func (*KeyMap) IsSequenceStart ¶ added in v1.13.0
IsSequenceStart returns true if the given key can start a multi-key sequence.
func (*KeyMap) KeyToAction ¶ added in v1.13.0
KeyToAction returns the map of single keys to action names.
func (*KeyMap) Lookup ¶ added in v1.13.0
Lookup returns the action name for a given key and whether it was found.
func (*KeyMap) LookupSequence ¶ added in v1.13.0
LookupSequence returns the action name for a complete key sequence and whether it was found.
type SequenceState ¶ added in v1.13.0
SequenceState tracks the state of an incomplete key sequence.
func NewSequenceState ¶ added in v1.13.0
func NewSequenceState(key string, receivedAt int64) *SequenceState
NewSequenceState creates a new SequenceState for the given first key and timestamp.
func (*SequenceState) Expired ¶ added in v1.13.0
func (s *SequenceState) Expired() bool
Expired returns true if the sequence has exceeded the timeout window.