editor

package
v0.0.0-...-2e0bb3c Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package editor ties the buffer, command registry, keymap and highlighter into a running tcell application. It owns the single UI goroutine: all state that is not itself thread-safe is mutated only here. Plugins (running in other processes) reach in via the actions queue — see Do and Prompt — so the hot path (typing, cursor motion) never blocks on RPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Editor

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

Editor is the top-level application state.

func New

func New(scr tcell.Screen, buf *buffer.Buffer) *Editor

New builds an editor for the given buffer and screen.

func (*Editor) AddBeforeSaveHook

func (e *Editor) AddBeforeSaveHook(fn func())

AddBeforeSaveHook registers fn to run before every buffer save.

func (*Editor) AddBuffer

func (e *Editor) AddBuffer(b *buffer.Buffer)

AddBuffer adds b to the buffer list if it is not already present.

func (*Editor) AddHook

func (e *Editor) AddHook(event string, fn func(any))

AddHook registers a plugin handler for a named event.

func (*Editor) AfterEdit

func (e *Editor) AfterEdit()

AfterEdit re-highlights and fires the change hook; call on the UI goroutine after a plugin mutates the buffer.

func (*Editor) BindKey

func (e *Editor) BindKey(seq, cmd string)

BindKey binds a key sequence to a command on the UI goroutine.

func (*Editor) Buffer

func (e *Editor) Buffer() *buffer.Buffer

Buffer exposes the current buffer (thread-safe on its own).

func (*Editor) Do

func (e *Editor) Do(fn func())

Do posts fn to run on the UI goroutine. Safe to call from any goroutine.

func (*Editor) Done

func (e *Editor) Done() <-chan struct{}

Done is closed once Run has returned.

func (*Editor) EnableLSP

func (e *Editor) EnableLSP()

EnableLSP turns on language-server integration (off by default so tests and headless use never spawn servers). Call once at startup.

func (*Editor) EnableSystemClipboard

func (e *Editor) EnableSystemClipboard()

EnableSystemClipboard wires kill/copy and yank to the OS clipboard when a platform clipboard utility is available. Off by default (like EnableLSP) so tests stay hermetic. Call once at startup.

func (*Editor) NoteOpened

func (e *Editor) NoteOpened(buf *buffer.Buffer)

NoteOpened records a freshly opened file as recent and restores its last cursor position. Exported for main to call for the startup buffer.

func (*Editor) OpenDir

func (e *Editor) OpenDir(dir string)

OpenDir opens dir in a *dired* buffer as the current buffer, without splitting the window. Used when moe is started with a directory argument.

func (*Editor) Prompt

func (e *Editor) Prompt(prompt string) string

Prompt reads a line from the minibuffer, blocking the caller until the user answers or cancels (empty string on cancel). Call from a non-UI goroutine.

func (*Editor) Quit

func (e *Editor) Quit()

Quit asks the editor to stop; safe to call from any goroutine.

func (*Editor) Registry

func (e *Editor) Registry() *command.Registry

Registry exposes the command registry (used by the plugin RPC layer).

func (*Editor) Run

func (e *Editor) Run()

Run enters the main loop and returns when the user quits.

func (*Editor) SetConfig

func (e *Editor) SetConfig(c *config.Config)

SetConfig replaces the editor configuration (tab width, indent style, ...).

func (*Editor) SetMessage

func (e *Editor) SetMessage(text string)

SetMessage shows text in the echo area (thread-safe).

func (*Editor) SetMessagesBuffer

func (e *Editor) SetMessagesBuffer(b *buffer.Buffer)

SetMessagesBuffer designates b as the *messages* log target.

func (*Editor) SetState

func (e *Editor) SetState(s *state.State)

SetState attaches the persisted cross-session state (recent files, last positions, command history) and seeds the in-memory command history from it.

Jump to

Keyboard shortcuts

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