gecore

package module
v0.0.0-...-a1cdf6c Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 11 Imported by: 3

README

gecore - Core Functionalities for ge Text Editor

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

Features

  • Screen management: Handles screen rendering and updates.
  • Tree structure: Manages the hierarchical structure of text buffers.
  • Kill buffer: Provides functionality to delete or yank text.
  • Utility functions: Includes various utility functions used within the ge text editor.

Installation

To use gecore in your Go project, you can simply import it as follows:

import "github.com/ge-editor/gecore"

Then, you can use the functionalities provided by gecore in your project.

Contributing

Contributions to gecore are welcome! If you find any issues or have suggestions for improvement, please feel free to open an issue or create a pull request on the GitHub repository.

License

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

Documentation

Index

Constants

View Source
const (
	LabelCtrl  = "ctrl"
	LabelAlt   = "alt"
	LabelMeta  = "meta"
	LabelShift = "shift"
)

Modifier labels

Variables

View Source
var (
	WorkSpaces []string // directory
	Switches   []string // prefix -
	Files      []string
)

Arguments groups

View Source
var (
	ErrIsNotEventKeyError        = errors.New("Not event key error")
	ErrCodeKeyBound              = errors.New("Key bound")
	ErrCodeExtendedFunction      = errors.New("Extended function")
	ErrCodeFunc                  = errors.New("VCommand")
	ErrCodeAction                = errors.New("Action")
	ErrCodeKeyBindingNotFount    = errors.New("Key binding not found")
	ErrCodeUnknownKeyBindingType = errors.New("Unknown key binding type")
)
View Source
var ErrInvalidKeyEvent = errors.New("invalid key event")

ErrInvalidKeyEvent is the error returned when encoding or decoding a key event fails.

View Source
var UnifyEnterKeys = true

UnifyEnterKeys is a flag that determines whether or not KPEnter (keypad enter) key events are interpreted as Enter key events. When enabled, Ctrl+J key events are also interpreted as Enter key events.

Functions

func Decode

func Decode(s string) (mod tcell.ModMask, key tcell.Key, ch rune, err error)

Decode decodes a string as a key or combination of keys.

Types

type ExtendedFunctionInterface

type ExtendedFunctionInterface interface {
	Draw()
	Event(*tcell.EventKey) *tcell.EventKey
}

type Key

type Key int64

func MakeKey

func MakeKey(mod tcell.ModMask, key tcell.Key, ch rune) Key

mod int16, Key int16, rune int32

type KeyPointer

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

func KeyMapper

func KeyMapper() *KeyPointer

KeyMapper provides an entry point for managing key mapping and command execution.

func (*KeyPointer) Bind

func (kp *KeyPointer) Bind(keys []string, fn any)

Bind adds an action associated with the specified key.

func (*KeyPointer) Execute

func (kp *KeyPointer) Execute(tKey *tcell.EventKey, skipExtendedFunction bool) error

Execute executes the action associated with the specified key. SkipExtendedFunction should be set to true mainly in the following cases - Prioritize processing over ExtendedFunctions - when calling from inside ExtendedFunctions

func (*KeyPointer) GetExtendedFunctionInterface

func (kp *KeyPointer) GetExtendedFunctionInterface() *ExtendedFunctionInterface

func (*KeyPointer) IsExtendedFunctionValid

func (kp *KeyPointer) IsExtendedFunctionValid() bool

func (*KeyPointer) Release

func (kp *KeyPointer) Release()

func KeyMapper() Release the KeyPointer created with

func (*KeyPointer) Reset

func (kp *KeyPointer) Reset()

Reset resets the current keymap to the root keymap. Exit from ExtendedFunction

func (*KeyPointer) ResetKeyMap

func (kp *KeyPointer) ResetKeyMap()

Reset resets the current keymap to the root keymap.

func (*KeyPointer) ResetKeyMapInAllInstance

func (kp *KeyPointer) ResetKeyMapInAllInstance()

ResetKeyMapInAllInstance resets the current keymap of all KeyPointer instances created with func KeyMapper() to the root keymap.

func (*KeyPointer) SetExtendedFunction

func (kp *KeyPointer) SetExtendedFunction(e *ExtendedFunctionInterface)

type MiniBuffer

type MiniBuffer struct {
	*KeyPointer
	// contains filtered or unexported fields
}

bufferIndex is buffer[bufferIndex] Matches the edit cursor position In echo mode, buffer[bufferIndex] becomes the drawing start position drawStartIndex

func NewMiniBuffer

func NewMiniBuffer(message string, prefix string, echo bool) *MiniBuffer

Create and initialize a new MiniBuffer instance.

parameters:

  • message: Message to display in the minibuffer.
  • prefix: String displayed as prefix.
  • echo: echo flag. Specifies whether to echo the contents of the minibuffer.

Return value: initialized MiniBuffer instance.

func (*MiniBuffer) CursorBackward

func (mb *MiniBuffer) CursorBackward()

func (*MiniBuffer) CursorEnd

func (mb *MiniBuffer) CursorEnd()

func (*MiniBuffer) CursorForward

func (mb *MiniBuffer) CursorForward()

func (*MiniBuffer) CursorHome

func (mb *MiniBuffer) CursorHome()

func (*MiniBuffer) Cutoff

func (mb *MiniBuffer) Cutoff()

Cutoff: Remove characters after the cursor position.

func (*MiniBuffer) DeleteRune

func (mb *MiniBuffer) DeleteRune()

func (*MiniBuffer) DeleteRuneBackward

func (mb *MiniBuffer) DeleteRuneBackward()

func (*MiniBuffer) Draw

func (mb *MiniBuffer) Draw()

Draw MiniBuffer and update MiniBuffer.drawStartIndex, MiniBuffer.drawEndIndex

func (*MiniBuffer) Event

func (mb *MiniBuffer) Event(tev *tcell.EventKey) *tcell.EventKey

func (*MiniBuffer) Index

func (mb *MiniBuffer) Index() int

func (*MiniBuffer) InsertRune

func (mb *MiniBuffer) InsertRune(ch rune)

func (*MiniBuffer) Set

func (mb *MiniBuffer) Set(message string, index int)

func (*MiniBuffer) String

func (mb *MiniBuffer) String() string

Return editing data as string

func (*MiniBuffer) Truncate

func (mb *MiniBuffer) Truncate()

Truncate: Remove characters before the cursor position.

type Popupmenu

type Popupmenu struct {
	utils.Rect

	*KeyPointer
	// contains filtered or unexported fields
}

func NewPopupmenu

func NewPopupmenu(rect utils.Rect, items []string, itemIndex int) *Popupmenu

func (*Popupmenu) CursorBackward

func (pm *Popupmenu) CursorBackward()

func (*Popupmenu) CursorEnd

func (pm *Popupmenu) CursorEnd()

func (*Popupmenu) CursorForward

func (pm *Popupmenu) CursorForward()

func (*Popupmenu) CursorHome

func (pm *Popupmenu) CursorHome()

func (*Popupmenu) Draw

func (pm *Popupmenu) Draw()

func (*Popupmenu) Event

func (pm *Popupmenu) Event(tev *tcell.EventKey) *tcell.EventKey

func (m *Popupmenu) Event(tev *EventKey) *EventKey {

func (*Popupmenu) Index

func (pm *Popupmenu) Index() int

func (*Popupmenu) Item

func (pm *Popupmenu) Item() (int, string)

func (*Popupmenu) Set

func (pm *Popupmenu) Set(items []string, index int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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