Versions in this module Expand all Collapse all v0 v0.3.1 May 30, 2026 Changes in this version + func EncodeFromUTF8(text string, enc CommonEncoding) ([]byte, error) + func GBKToUTF8(data []byte) (string, error) + func StripBOM(data []byte) []byte + func UTF8ToGBK(text string) ([]byte, error) + type CommonEncoding int + const EncBig5 + const EncEUCJP + const EncEUCKR + const EncGBK + const EncLatin1 + const EncShiftJIS + const EncUTF16BE + const EncUTF16LE + const EncUTF8 + const EncUnknown + func DecodeToUTF8(data []byte) (string, CommonEncoding, error) + func DetectEncoding(data []byte) CommonEncoding + func (e CommonEncoding) BOM() []byte + func (e CommonEncoding) String() string + type Document struct + Buffer *GapBuffer + Encoding CommonEncoding + FilePath string + Modified bool + func NewDocument() *Document + func NewDocumentFromString(s string) *Document + func (d *Document) Content() string + func (d *Document) DeleteRange(pos, length int) []rune + func (d *Document) DeleteRuneAt(pos int) rune + func (d *Document) GetIndent(line int) string + func (d *Document) InsertRune(pos int, ch rune) + func (d *Document) InsertText(pos int, text string) + func (d *Document) Len() int + func (d *Document) Line(n int) string + func (d *Document) LineColToPos(line, col int) int + func (d *Document) LineCount() int + func (d *Document) LineLen(line int) int + func (d *Document) PosToLineCol(pos int) (int, int) + type GapBuffer struct + func NewGapBuffer(capacity int) *GapBuffer + func NewGapBufferFromRunes(runes []rune) *GapBuffer + func (gb *GapBuffer) BytePos(runePos int) int + func (gb *GapBuffer) Cap() int + func (gb *GapBuffer) Content() string + func (gb *GapBuffer) Delete(pos, length int) + func (gb *GapBuffer) Indentation(line int) string + func (gb *GapBuffer) Insert(pos int, text []rune) + func (gb *GapBuffer) Len() int + func (gb *GapBuffer) Line(line int) string + func (gb *GapBuffer) LineColToPos(line, col int) int + func (gb *GapBuffer) LineCount() int + func (gb *GapBuffer) LineEnd(line int) int + func (gb *GapBuffer) LineLen(line int) int + func (gb *GapBuffer) LineStart(line int) int + func (gb *GapBuffer) PosToLineCol(pos int) (int, int) + func (gb *GapBuffer) RuneAt(pos int) rune + func (gb *GapBuffer) Slice(start, end int) []rune + func (gb *GapBuffer) String() string + type Position struct + Col int + Line int + type UndoKind int + const UndoDelete + const UndoInsert + const UndoReplace + type UndoStack struct + func NewUndoStack(limit int) *UndoStack + func (us *UndoStack) CanRedo() bool + func (us *UndoStack) CanUndo() bool + func (us *UndoStack) Clear() + func (us *UndoStack) Push(kind UndoKind, pos int, text, deleted []rune) + func (us *UndoStack) Redo() (UndoStep, bool) + func (us *UndoStack) RedoCount() int + func (us *UndoStack) Undo() (UndoStep, bool) + func (us *UndoStack) UndoCount() int + type UndoStep struct + Deleted []rune + Kind UndoKind + Pos int + Text []rune