vi

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package vi implements a simple vi / vim like editor in Go. Reusable library part of the gvi editor (cli).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterSpecialChars added in v0.4.0

func FilterSpecialChars(str string) string

Types

type Buffer added in v0.2.0

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

Buffer represents a full buffer (file) in the editor. A view of it is shown in the terminal.

func (*Buffer) Close added in v0.2.0

func (b *Buffer) Close() error

func (*Buffer) GetLines added in v0.2.0

func (b *Buffer) GetLines(start, num int) []string

GetLines returns the lines in the buffer from start to end.

func (*Buffer) InsertChars added in v0.4.0

func (b *Buffer) InsertChars(v *Vi, lineNum, at int, text string) string

Returns the full line if insert is in the middle, empty if that was already at the end. It makes most common typing (at the end/append) faster.

func (*Buffer) InsertLine added in v0.4.0

func (b *Buffer) InsertLine(lineNum int, text string)

func (*Buffer) IsDirty added in v0.4.0

func (b *Buffer) IsDirty() bool

func (*Buffer) NumLines added in v0.2.0

func (b *Buffer) NumLines() int

func (*Buffer) Open added in v0.2.0

func (b *Buffer) Open(filename string) error

Open initializes the buffer with the contents of the file.

func (*Buffer) Save added in v0.5.0

func (b *Buffer) Save() error

type Mode

type Mode int
const (
	NavMode Mode = iota
	CommandMode
	InsertMode
)

func (Mode) String

func (m Mode) String() string

type Vi

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

func NewVi

func NewVi(ap *ansipixels.AnsiPixels) *Vi

func (*Vi) Beep added in v0.4.0

func (v *Vi) Beep()

func (*Vi) CmdResult added in v0.6.1

func (v *Vi) CmdResult(msg string, args ...any)

func (*Vi) CommandStatus

func (v *Vi) CommandStatus()

func (*Vi) HasEsc

func (v *Vi) HasEsc() int

func (*Vi) Insert added in v0.4.0

func (v *Vi) Insert(str string) (err error)

func (*Vi) NextTab added in v0.6.1

func (v *Vi) NextTab(x int) int

func (*Vi) Open added in v0.2.0

func (v *Vi) Open(filename string)

func (*Vi) Process

func (v *Vi) Process() bool

func (*Vi) ProcessOne added in v0.5.1

func (v *Vi) ProcessOne() bool

func (*Vi) ScreenAtToRune added in v0.6.1

func (v *Vi) ScreenAtToRune(x int, str string) int

Translate a screen position to the byte offset of the rune in the current line.

func (*Vi) ScreenWidth added in v0.6.1

func (v *Vi) ScreenWidth(str string) int

ScreenWidth calculates the screen width of a string, properly handling tabs, control characters, and multi-rune grapheme clusters.

func (*Vi) ShowError added in v0.2.0

func (v *Vi) ShowError(msg string, err error)

func (*Vi) Update

func (v *Vi) Update()

func (*Vi) UpdateRS added in v0.3.0

func (v *Vi) UpdateRS() error

func (*Vi) UpdateStatus

func (v *Vi) UpdateStatus()

func (*Vi) UpdateTabs added in v0.6.1

func (v *Vi) UpdateTabs()

func (*Vi) VScroll added in v0.3.0

func (v *Vi) VScroll(delta int)

func (*Vi) WriteBottom added in v0.6.1

func (v *Vi) WriteBottom(msg string, args ...any)

Jump to

Keyboard shortcuts

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