Gim/internal/syntax/engine.go
Hayden Hargreaves 16d1318c22 feat: start TS impl
This is so vibe coded, but in the interest of time, its a bit
necessary. Plus this is a complex problem that I don't have the mental
bandwidth to invest right now.
2026-04-07 10:23:25 -07:00

28 lines
871 B
Go

package syntax
import (
"git.gophernest.net/azpect/TextEditor/internal/core"
"github.com/charmbracelet/lipgloss"
)
// Engine provides syntax highlight data for buffers.
//
// The renderer should consume this interface rather than doing parse/token work
// directly.
type Engine interface {
// Engine.PrepareBuffer: Ensure syntax state for a buffer is ready.
PrepareBuffer(buf *core.Buffer)
// Engine.ApplyEdit: Apply an incremental text edit to syntax state.
ApplyEdit(buf *core.Buffer, edit *core.BufferEdit)
// Engine.LineStyleMap: Returns per-rune styles for a line.
LineStyleMap(buf *core.Buffer, line int) []lipgloss.Style
// Engine.InvalidateBuffer: Marks all syntax state for a buffer as stale.
InvalidateBuffer(buf *core.Buffer)
// Engine.InvalidateLines: Marks a line range as stale.
InvalidateLines(buf *core.Buffer, startLine, endLine int)
}