Help us shape the future of Go! Take the 2026 Go Developer Survey

demo

command
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 7 Imported by: 0

README

editor demo

A single runnable example that hosts github.com/malivvan/editor on a tcell.Screen built by hand. There is no application framework involved: the demo opens the screen, paints its own frame and status bar with plain tcell calls, and forwards every event to one editor.View.

go run ./demo              # edit the built-in sample buffer
go run ./demo main.go      # edit a real file
Keys Action
Ctrl-S Save the buffer (no-op with a message for the sample).
Ctrl-Q Quit.
F1 Toggle line numbers.
F2 Cycle through the embedded colorschemes.

Typing a word opens the autocomplete popup; clicking moves the cursor, and dragging selects text.

The interesting part for host authors is how little is needed:

view := editor.NewView(buf)
view.SetRuntimeFiles(runtime.Files)      // syntax highlighting + colorschemes
view.SetRect(1, 1, width-2, height-3)    // the pane the host reserved
view.Draw(screen)                        // screen is a *tcell.Screen
view.HandleEvent(event)                  // keys and mouse, one entry point

Documentation

Overview

Package main is a showcase of github.com/malivvan/editor hosted by tcell directly: no widget toolkit, no application framework, no layout engine.

The program opens a tcell.Screen itself, paints its own frame and status bar with tcell calls, and hands every key and mouse event to a single editor.View. All the editor needs from its host is a rendering surface, and a tcell.Screen already satisfies it (see editor.Screen) — so the same View could just as well be drawn into an in-memory grid.

go run ./demo [file]

Keys:

Ctrl-S   save the buffer (built-in sample buffers have no file name)
Ctrl-Q   quit
F1       toggle line numbers
F2       cycle through the embedded colorschemes

Typing a word opens the autocomplete popup; the mouse selects text by dragging and moves the cursor on a click.

Jump to

Keyboard shortcuts

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