editorleaf

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 33 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
)
View Source
var CaseTypes = [...]string{
	"snake_case",
	"SCREAMING_SNAKE_CASE",
	"kebab-case",
	"Train-Case",
	"lowerCamelCase",
	"UpperCamelCase",
	"lowercase",
	"UPPERCASE",
	"Word",
}

Functions

func NewFoundPosition added in v0.1.6

func NewFoundPosition(startRowIndex, startColIndex, stopRowIndex, stopColIndex int, color tcell.Style) *search.SearchResult

func NewQuitGuard

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

func SplitRows added in v0.1.6

func SplitRows(data []byte) (rows.Rows, error)

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) ClearAll

func (b *BoundariesArray) ClearAll()

ClearAll clears all cached layout information.

func (*BoundariesArray) ClearFrom added in v0.1.6

func (b *BoundariesArray) ClearFrom(rowIndex int)

ClearFrom clears all cached layout information from rowIndex onward.

func (*BoundariesArray) ClearRow added in v0.1.6

func (b *BoundariesArray) ClearRow(rowIndex int)

Clear clears the cached layout information for the specified row.

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) GetIndexOfLastLogicalRow added in v0.1.6

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

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) NeedsCompute added in v0.1.6

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

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 virtual row.
	// The virtual row includes LF for non-final rows and EOF for
	// the final row.
	StartLogicalRowByteIndex int

	// StopLogicalRowByteIndex is the exclusive end byte index
	// within the virtual 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 Case added in v0.1.6

type Case int
const (
	// CaseUnknown Case = iota
	CaseSnake Case = iota
	CaseScreamingSnake
	CaseKebab
	CaseTrain
	CaseLowerCamel
	CaseUpperCamel
	CaseLower
	CaseUpper
	CaseWord
)

type CaseChangeState added in v0.1.6

type CaseChangeState struct {
	Start int
	End   int
	Text  string
	Case  Case
}

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 (*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) CharInfoOnCursor added in v0.1.6

func (e *Editorleaf) CharInfoOnCursor() (rune, string)

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) DispatchMouse added in v0.1.6

func (e *Editorleaf) DispatchMouse(ev tcell.EventMouse)

func (*Editorleaf) Draw

func (e *Editorleaf) Draw() bool

func (*Editorleaf) FilterByCharacters

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

func (Editorleaf) FindHighlightSpan added in v0.1.6

func (e Editorleaf) FindHighlightSpan(
	pos rows.RowsPos,
	stat highlightPosStatus,
) (*highlight.Span, highlightPosStatus)

HighlightsLayer の情報から描画色を決定する highlightPosStatus 以降で pos と Traverse な関係にある highlights.Span を返す。

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, []int, error)

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

func (*Editorleaf) GetPath

func (e *Editorleaf) GetPath() 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) MoveCursorGoToLine added in v0.1.6

func (e *Editorleaf) MoveCursorGoToLine(lineNumber int)

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 row.

func (*Editorleaf) MoveCursorPreviousWord

func (e *Editorleaf) MoveCursorPreviousWord()

Move cursor to previous word.

func (*Editorleaf) MoveNextFoundWord

func (e *Editorleaf) MoveNextFoundWord()

func (*Editorleaf) MovePrevFoundWord

func (e *Editorleaf) MovePrevFoundWord()

func (*Editorleaf) MoveToMarkPosition added in v0.1.6

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

func (*Editorleaf) MoveViewHalfBackward

func (e *Editorleaf) MoveViewHalfBackward()

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

func (*Editorleaf) MoveViewHalfForward

func (e *Editorleaf) MoveViewHalfForward()

Move view 'n' lines forward 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 screen.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) SearchHistory added in v0.1.6

func (e *Editorleaf) SearchHistory() []string

func (*Editorleaf) SearchRegexp

func (e *Editorleaf) SearchRegexp(searchTerm string, caseSensitive bool)

func (*Editorleaf) SearchText

func (e *Editorleaf) SearchText(text string, caseSensitive, isRegexp bool)

When not using regular expressions

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 rows.Rows)

func (*Editorleaf) SetRowsPos added in v0.1.6

func (e *Editorleaf) SetRowsPos(c rows.RowsPos)

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) CancelManager added in v0.1.6

func (l *LeafType) CancelManager() *gecore.EventCancelManager

func (*LeafType) Name

func (l *LeafType) Name() string

func (*LeafType) NewLeaf

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

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

func (*LeafType) NewSiblingLeaf

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

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

func (*LeafType) RealName added in v0.1.6

func (l *LeafType) RealName() string

func (*LeafType) SetCtx added in v0.1.6

func (l *LeafType) SetCtx(ctx *tree.LeafContext)

func (*LeafType) SetRegisteredName added in v0.1.6

func (l *LeafType) SetRegisteredName(name string)

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 (m *MinibufferManagerStruct) Draw() bool

func (*MinibufferManagerStruct) Editor

func (m *MinibufferManagerStruct) Editor() *Editorleaf

func (*MinibufferManagerStruct) GetBytes

func (m *MinibufferManagerStruct) GetBytes() ([]byte, []int, error)

Return input content

func (*MinibufferManagerStruct) IsActive

func (m *MinibufferManagerStruct) IsActive() bool

func (*MinibufferManagerStruct) MinibufferResize

func (m *MinibufferManagerStruct) MinibufferResize(overlayRect screen.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 screen.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

Jump to

Keyboard shortcuts

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