ui

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ui implements the terminal text editor user interface.

Uses the tcell library for terminal event handling and rendering. The editor operates in three modes:

  • Insert mode (default): direct text input, arrow key navigation
  • Command mode: press : to enter, command bar at bottom
  • Search mode: press Ctrl+F to enter, search bar at bottom

Design: The Editor struct holds all state; the main loop in Run() handles events and rendering. Rendering is split into three sections: body (line numbers + text), status bar, command/search bar.

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 core editor struct holding all state.

func NewEditor

func NewEditor() *Editor

NewEditor creates a new Editor instance.

func (*Editor) OpenFile

func (e *Editor) OpenFile(path string) error

OpenFile opens a file.

func (*Editor) Quit

func (e *Editor) Quit(force bool) error

Quit requests the editor to quit.

func (*Editor) Run

func (e *Editor) Run() error

Run is the editor main loop.

func (*Editor) SaveFile

func (e *Editor) SaveFile(path string) error

SaveFile saves the file; if path is empty, uses the original path.

type Mode

type Mode int

Mode represents the editor mode.

const (
	ModeInsert  Mode = iota // Insert mode
	ModeCommand             // Command mode
	ModeSearch              // Search mode
	ModeReplace             // Replace mode
)

Jump to

Keyboard shortcuts

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