event

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

internal/event/events.go

internal/event/manager.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppQuitData

type AppQuitData struct{}

AppQuitData could contain exit code or reason later.

type AppReadyData

type AppReadyData struct{}

AppReadyData could contain initial config or state later.

type BufferLoadedData

type BufferLoadedData struct {
	FilePath string
}

BufferLoadedData contains info about the loaded buffer.

type BufferModifiedData

type BufferModifiedData struct {
	Edit types.EditInfo // Information about the change for incremental parsing
}

BufferModifiedData contains info about buffer changes, including EditInfo.

type BufferSavedData

type BufferSavedData struct {
	FilePath string
}

BufferSavedData contains info about the saved buffer.

type CursorMovedData

type CursorMovedData struct {
	NewPosition types.Position
}

CursorMovedData contains the new cursor position.

type Event

type Event struct {
	Type Type        // The kind of event
	Data interface{} // Payload carrying event-specific data

}

Event is the structure passed through the event bus.

type Handler

type Handler func(e Event) bool

Handler defines the function signature for event subscribers. It returns true if the event was consumed (prevents further processing if needed). For now, we won't use the return value, but it's good practice for future flexibility.

type KeyPressedData

type KeyPressedData struct {
	KeyEvent *tcell.EventKey
}

KeyPressedData contains the raw tcell key event.

type Manager

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

Manager handles event subscriptions and dispatching.

func NewManager

func NewManager() *Manager

NewManager creates a new event manager.

func (*Manager) Dispatch

func (m *Manager) Dispatch(eventType Type, data interface{})

Dispatch sends an event to all registered handlers for its type. Runs handlers synchronously for simplicity. Could be made asynchronous.

func (*Manager) Subscribe

func (m *Manager) Subscribe(eventType Type, handler Handler)

Subscribe adds a handler function for a specific event type.

type ThemeChangedData

type ThemeChangedData struct {
	OldThemeName string
	NewThemeName string
}

ThemeChangedData holds theme change event data

type Type

type Type int

Type identifies the kind of event.

const (
	TypeUnknown Type = iota

	// Core Editor Events
	TypeBufferModified // Fired when buffer content changes (insert/delete)
	TypeBufferLoaded   // Fired after a buffer is successfully loaded
	TypeBufferSaved    // Fired after a buffer is successfully saved
	TypeCursorMoved    // Fired when the cursor position changes
	TypeModeChanged    // Fired when editor mode changes (e.g., Normal -> Insert) - Future

	// Input Events (potentially useful for plugins reacting to raw keys)
	TypeKeyPressed // Raw key press event forwarded

	// Application Lifecycle Events
	TypeAppReady // Fired when the application is fully initialized
	TypeAppQuit  // Fired just before application termination begins

	TypeThemeChanged // Fired when the theme is changed
)

Define specific event types.

Jump to

Keyboard shortcuts

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