editorleaf

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 26 Imported by: 0

README

editorleaf - Text Editor Functionalities for ge

editorleaf is a package that provides text editor functionalities for the ge text editor.

Features

  • Default view in ge: Provides the default view for the ge text editor.
  • Includes functionalities for cursor movement, text editing, and more.

License

This package is licensed under the MIT License. See the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	INSERT syncType = iota
	DELETE
)

Variables

View Source
var (
	// Initialization has been moved to the newEditor function
	// BufferSets, _ = buffer.NewBufferSets(gecore.Files)
	BufferSets *buffer.BufferSets
	Marks      = mark.NewMarks()
)

Functions

func NewQuitGuard

func NewQuitGuard(bufferSets *buffer.BufferSets) gecore.QuitGuardResolver

Types

type BoundariesArray

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

BoundariesArray manages layout cache information per physical row.

It lazily computes wrapping information when needed and stores per-row layout metadata.

func NewBoundariesArray

func NewBoundariesArray(editor *Editorleaf) BoundariesArray

NewBoundariesArray creates a new BoundariesArray.

func (*BoundariesArray) BoundariesLen

func (b *BoundariesArray) BoundariesLen(rowIndex int) int

BoundariesLen returns the number of logical rows (wrapped segments) for the specified physical row.

func (*BoundariesArray) Boundary

func (b *BoundariesArray) Boundary(rowIndex, logicalRowIndex int) *Boundary

Boundary returns the Boundary for the specified row and logical row index.

func (*BoundariesArray) Clear

func (b *BoundariesArray) Clear(rowIndex int)

func (*BoundariesArray) ClearAll

func (b *BoundariesArray) ClearAll()

ClearAll clears all cached layout information.

func (*BoundariesArray) CursorPositionOnScreenLogicalRow added in v0.1.3

func (b *BoundariesArray) CursorPositionOnScreenLogicalRow(rowIndex, colIndex int) (lx, ly int)

Returns the screen position of the cursor corresponding from cached array to the specified column index in logical rows.

func (*BoundariesArray) Delete

func (b *BoundariesArray) Delete(rowIndex, count int) error

Delete removes count rows starting from rowIndex.

func (*BoundariesArray) GetHangingIndentWidth

func (b *BoundariesArray) GetHangingIndentWidth(rowIndex int) int

GetHangingIndentWidth returns the hanging indentation width for the specified row. It returns 0 if the row is out of range.

func (*BoundariesArray) GetIndexOfLogicalRow added in v0.1.3

func (b *BoundariesArray) GetIndexOfLogicalRow(rowIndex, colIndex int) int

func (*BoundariesArray) Insert

func (b *BoundariesArray) Insert(rowIndex, count int)

Insert inserts count empty rows at rowIndex.

func (*BoundariesArray) IsEndOfLogicalRow added in v0.1.3

func (b *BoundariesArray) IsEndOfLogicalRow(rowIndex, colIndex int) bool

func (*BoundariesArray) LastBoundary

func (b *BoundariesArray) LastBoundary(rowIndex int) *Boundary

LastBoundary returns the last logical row boundary for the specified physical row.

func (*BoundariesArray) Len

func (b *BoundariesArray) Len() int

Len returns the number of rows currently stored.

func (*BoundariesArray) NeedsReparse added in v0.1.3

func (b *BoundariesArray) NeedsReparse(rowIndex int) bool

NeedsReparse reports whether layout information for rowIndex needs to be recomputed.

func (*BoundariesArray) OnEndOfLogicalRow added in v0.1.3

func (b *BoundariesArray) OnEndOfLogicalRow(rowIndex, colIndex int) bool

Check if the column index is within the last boundary of the specified row Return false: out of index or not initialized.

func (*BoundariesArray) Set

func (b *BoundariesArray) Set(
	rowIndex int,
	boundaries []Boundary,
	hangingIndentWidth int,
	runeWidths []locale.Cell,
)

Set stores layout information for the specified row index.

It overwrites any existing layout data for the row.

type Boundary

type Boundary struct {
	// StartLogicalRowByteIndex is the inclusive start byte index
	// within the original row.
	StartLogicalRowByteIndex int

	// StopLogicalRowByteIndex is the exclusive end byte index
	// within the original row.
	StopLogicalRowByteIndex int

	// LogicalRowWidth is the rendered width (in cells)
	// of this logical row.
	LogicalRowWidth int

	// TotalCellWidth includes tab expansion width.
	TotalCellWidth int
}

Boundary represents a single wrapped logical row segment within a physical line.

A physical line (row) may be split into multiple logical rows due to wrapping. Each Boundary describes one such segment.

func (*Boundary) Clear

func (b *Boundary) Clear()

Clear resets the Boundary to its zero state.

func (*Boundary) IsEmpty

func (b *Boundary) IsEmpty() bool

IsEmpty reports whether the Boundary is uninitialized.

type EditorKeymapBinder

type EditorKeymapBinder func(root *keychord.RootNode, editor *Editorleaf)

type Editorleaf

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

Editorleaf Struct implements the gecore.tree.Leaf interface

func NewMinibufferLeaf

func NewMinibufferLeaf() *Editorleaf

MinibufferLeaf は tree に属さない Editor が生成されたタイミングで keymap をバインドしない

func (*Editorleaf) Active

func (e *Editorleaf) Active(a bool)

func (*Editorleaf) Autoindent

func (e *Editorleaf) Autoindent()

func (Editorleaf) BackwardKillLine

func (e Editorleaf) BackwardKillLine()

unix-line-discard backward-kill-line

func (*Editorleaf) ChangeFilePath

func (e *Editorleaf) ChangeFilePath(path string)

If an existing file is specified, it will be overwritten Backup works so no data is lost, but...

func (*Editorleaf) CharInfo

func (e *Editorleaf) CharInfo()

func (*Editorleaf) CommandPalette

func (e *Editorleaf) CommandPalette(s string)

func (*Editorleaf) CopyRegion

func (e *Editorleaf) CopyRegion()

Copy cursor region to Kill Buffer and Clipboard

func (*Editorleaf) DeleteRune

func (e *Editorleaf) DeleteRune()

If at the EOL, move contents of the next line to the end of the current line, erasing the next line after that. Otherwise, delete one character under the cursor.

func (*Editorleaf) DeleteRuneBackward

func (e *Editorleaf) DeleteRuneBackward()

func (*Editorleaf) DispatchKey

func (*Editorleaf) Draw

func (e *Editorleaf) Draw()

func (*Editorleaf) FilterByCharacters

func (e *Editorleaf) FilterByCharacters(chars string) []*mark.Mark

func (*Editorleaf) GetBuffers

func (e *Editorleaf) GetBuffers() *buffer.BufferSets

func (*Editorleaf) GetBuffersFilterByCharacters

func (e *Editorleaf) GetBuffersFilterByCharacters(chars string) *buffer.BufferSets

func (*Editorleaf) GetBytes

func (e *Editorleaf) GetBytes() []byte

編集中のテキストの []byte を返す editorleaf.editbuffer.RowsStruct.Bytes() のラッパー

func (*Editorleaf) GetPath

func (e *Editorleaf) GetPath() string

func (*Editorleaf) GetString

func (e *Editorleaf) GetString() string

func (*Editorleaf) Init

func (e *Editorleaf) Init()

func (*Editorleaf) InsertRune

func (e *Editorleaf) InsertRune(ch rune)

Wrapper is insertBytes

func (*Editorleaf) InsertString

func (e *Editorleaf) InsertString(s string)

Wrapper is insertBytes

func (*Editorleaf) InsertTab

func (e *Editorleaf) InsertTab()

func (*Editorleaf) IsActive

func (e *Editorleaf) IsActive() bool

func (*Editorleaf) IsDirtyFlag

func (e *Editorleaf) IsDirtyFlag() bool

func (Editorleaf) IsEndOfLine

func (e Editorleaf) IsEndOfLine() bool

func (*Editorleaf) IsRedoEmpty

func (e *Editorleaf) IsRedoEmpty() bool

func (*Editorleaf) Kill

func (e *Editorleaf) Kill(leaf tree.Leaf, isActive bool) tree.Leaf

func (*Editorleaf) KillLine

func (e *Editorleaf) KillLine()

Kill line: If not at the EOL, remove contents of the current line from the cursor to the end. Otherwise behave like 'delete'. 行を削除します: EOL でない場合は、カーソルから末尾までの現在の行の内容を削除します。 それ以外の場合は、「delete」のように動作します。

func (*Editorleaf) KillRegion

func (e *Editorleaf) KillRegion()

Kill region between last mark to cursor and push undo and kill buffers

func (*Editorleaf) LeafType

func (e *Editorleaf) LeafType() tree.LeafType

func (*Editorleaf) MinibufferMode

func (e *Editorleaf) MinibufferMode(mode Mode)

func (*Editorleaf) MoveCursorBackward

func (e *Editorleaf) MoveCursorBackward()

Move cursor one character backward.

func (*Editorleaf) MoveCursorBeginningOfFile

func (e *Editorleaf) MoveCursorBeginningOfFile()

func (*Editorleaf) MoveCursorBeginningOfLine

func (e *Editorleaf) MoveCursorBeginningOfLine()

Move cursor to the beginning of the line. Consider indentation

func (*Editorleaf) MoveCursorBeginningOfLogicalLine

func (e *Editorleaf) MoveCursorBeginningOfLogicalLine()

Move cursor to the beginning of the logical row. Consider logical row Consider indentation....

func (*Editorleaf) MoveCursorEndOfFile

func (e *Editorleaf) MoveCursorEndOfFile()

func (*Editorleaf) MoveCursorEndOfLine

func (e *Editorleaf) MoveCursorEndOfLine()

Move cursor to the end of the line.

func (*Editorleaf) MoveCursorEndOfLogicalLine

func (e *Editorleaf) MoveCursorEndOfLogicalLine()

Move cursor to the end of logical the line. At the end of a logical line, the cursor should at the beginning of the next logical line. so I see...

func (*Editorleaf) MoveCursorForward

func (e *Editorleaf) MoveCursorForward()

Move cursor one character forward.

func (*Editorleaf) MoveCursorNextLine

func (e *Editorleaf) MoveCursorNextLine()

Move cursor to the next line.

func (*Editorleaf) MoveCursorNextWord

func (e *Editorleaf) MoveCursorNextWord()

Move cursor to next word.

func (*Editorleaf) MoveCursorPrevLine

func (e *Editorleaf) MoveCursorPrevLine()

Move cursor to the previous line.

func (*Editorleaf) MoveCursorPreviousWord

func (e *Editorleaf) MoveCursorPreviousWord()

func (*Editorleaf) MoveCursorToLine

func (e *Editorleaf) MoveCursorToLine(lineNumber int)

func (*Editorleaf) MoveNextFoundWord

func (e *Editorleaf) MoveNextFoundWord()

func (*Editorleaf) MovePrevFoundWord

func (e *Editorleaf) MovePrevFoundWord()

func (*Editorleaf) MoveViewHalfBackward

func (e *Editorleaf) MoveViewHalfBackward()

Move view 'n' lines forward or backward.

func (*Editorleaf) MoveViewHalfForward

func (e *Editorleaf) MoveViewHalfForward()

Move view 'n' lines forward or backward only if it's possible.

func (*Editorleaf) OpenFile

func (e *Editorleaf) OpenFile(path string) (editbuffer.Result, error)

If the file has already been read, use that buffer

func (*Editorleaf) Recenter

func (e *Editorleaf) Recenter()

func (*Editorleaf) Redo

func (e *Editorleaf) Redo()

func (*Editorleaf) ReplaceCurrentSearchString

func (e *Editorleaf) ReplaceCurrentSearchString(str string)

func (*Editorleaf) Resize

func (e *Editorleaf) Resize(viewArea utils.Rect)

func (*Editorleaf) Resume

func (e *Editorleaf) Resume()

func (*Editorleaf) RowsLength

func (e *Editorleaf) RowsLength() int

func (*Editorleaf) RuneStatus

func (e *Editorleaf) RuneStatus(ch rune) string

Convert rune to displaying string on mode line Conversion target:

  • control code: ^X
  • newline code

Line feed code is depending the editing buffer newline

func (*Editorleaf) SaveFile

func (e *Editorleaf) SaveFile()

If the file does not exist, a backup error will occur

func (*Editorleaf) SearchRegexp

func (e *Editorleaf) SearchRegexp(searchTerm string, caseSensitive bool, ctx context.Context)

func (*Editorleaf) SearchText

func (e *Editorleaf) SearchText(text string, caseSensitive, isRegexp bool, ctx context.Context)

When not using regular expressions

func (*Editorleaf) SetCurrentMark

func (e *Editorleaf) SetCurrentMark(m *mark.Mark)

func (*Editorleaf) SetCursor

func (e *Editorleaf) SetCursor(c editbuffer.Cursor)

func (*Editorleaf) SetKeyDispatcher

func (e *Editorleaf) SetKeyDispatcher(km *keychord.RootNode)

func (*Editorleaf) SetMarkAtCursor

func (e *Editorleaf) SetMarkAtCursor()

func (Editorleaf) SetRows

func (e Editorleaf) SetRows(r [][]byte)

func (*Editorleaf) SwapCursorAndMark

func (e *Editorleaf) SwapCursorAndMark()

func (*Editorleaf) Undo

func (e *Editorleaf) Undo()

func (*Editorleaf) WillClose

func (e *Editorleaf) WillClose()

func (*Editorleaf) Yank

func (e *Editorleaf) Yank()

func (*Editorleaf) YankFromClipboard

func (e *Editorleaf) YankFromClipboard()

type LeafType

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

Implements LeafType interface

func NewLeafType

func NewLeafType(bind EditorKeymapBinder) *LeafType

func (*LeafType) Name

func (v *LeafType) Name() string

func (*LeafType) NewLeaf

func (v *LeafType) NewLeaf() tree.Leaf

Return *editorleaf.Editor as tree.Leaf *interface Editor が生成されたタイミングで keymap を作成してバインドする

func (*LeafType) NewSiblingLeaf

func (v *LeafType) NewSiblingLeaf(direction string, leaf tree.Leaf) tree.Leaf

Create a new tree.Leaf (Editor) from leaf *tree.Leaf information direction: "right", "bottom"

type MinibufferManagerStruct

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

Required implement Overlay interface

func MinibufferManager

func MinibufferManager() *MinibufferManagerStruct

func (*MinibufferManagerStruct) Active

func (m *MinibufferManagerStruct) Active(b bool)

func (*MinibufferManagerStruct) Cancel

func (m *MinibufferManagerStruct) Cancel()

func (*MinibufferManagerStruct) Close

func (m *MinibufferManagerStruct) Close()

func (*MinibufferManagerStruct) Dispatch

func (*MinibufferManagerStruct) Draw

func (*MinibufferManagerStruct) Editor

func (m *MinibufferManagerStruct) Editor() *Editorleaf

func (*MinibufferManagerStruct) GetBytes

func (m *MinibufferManagerStruct) GetBytes() []byte

Return input content

func (*MinibufferManagerStruct) GetString

func (m *MinibufferManagerStruct) GetString() string

Return input content

func (*MinibufferManagerStruct) IsActive

func (m *MinibufferManagerStruct) IsActive() bool

func (*MinibufferManagerStruct) MinibufferResize

func (m *MinibufferManagerStruct) MinibufferResize(overlayRect utils.Rect) int

return Remaining height overlayRect.Height: この値のみ画面の高さ

func (*MinibufferManagerStruct) Priority

func (m *MinibufferManagerStruct) Priority() int

func (*MinibufferManagerStruct) RequiredHeight

func (m *MinibufferManagerStruct) RequiredHeight() int

return minibuffer height

func (*MinibufferManagerStruct) Resize

func (m *MinibufferManagerStruct) Resize(overlayRect utils.Rect)

func (*MinibufferManagerStruct) SetBytes

func (m *MinibufferManagerStruct) SetBytes(content []byte)

func (*MinibufferManagerStruct) SetPrompt

func (m *MinibufferManagerStruct) SetPrompt(prompt string)

func (*MinibufferManagerStruct) SetString

func (m *MinibufferManagerStruct) SetString(content string)

func (*MinibufferManagerStruct) Start

func (m *MinibufferManagerStruct) Start(session *Session, onComplete func(result keychord.KeyDispatchTransition))

func (*MinibufferManagerStruct) UniversalCancel

func (m *MinibufferManagerStruct) UniversalCancel()

type Mode

type Mode int
const (
	ModeEditor Mode = iota
	ModeMinibuffer
)

type RowLayout

type RowLayout struct {
	// Boundaries contains all wrapped logical row segments.
	Boundaries []Boundary

	// HangingIndentWidth is the indentation width applied to
	// wrapped logical rows after the first one.
	HangingIndentWidth int

	RuneWidthCache []locale.Cell
}

RowLayout represents layout information for a single physical row.

It contains all computed wrapping boundaries and additional layout metadata such as hanging indentation width.

type Session

type Session struct {
	Editor      *Editorleaf
	Prompt      string
	PromptWidth int
	Mode        Mode
}

func NewSession

func NewSession(
	prompt string,
	bind func(*keychord.RootNode, *Editorleaf),
) *Session

func (*Session) SetPrompt

func (s *Session) SetPrompt(prompt string)

Directories

Path Synopsis
editorleaf/search/search.go
editorleaf/search/search.go

Jump to

Keyboard shortcuts

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