smidgen

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

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 8 Imported by: 0

README

Smidgen, a text editor component for tview

This is the core text editor part of micro wrapped and hacked into a component for use with tview.

This is the same idea as femto except redone from scratch using the version of micro from 2025-10-27.

Note: This is still in early and rapid development. The primary purpose of Smidgen is to power my little text editor Dinky.

API

License

Smidgen is released under the MIT License. Note that the majority of code is originates from micro which also uses the MIT license.

Author

Created by Simon Edwards - @sedwards2009

Documentation

Index

Constants

View Source
const (
	ActionCursorUp                = "CursorUp"
	ActionCursorDown              = "CursorDown"
	ActionCursorPageUp            = "CursorPageUp"
	ActionCursorPageDown          = "CursorPageDown"
	ActionCursorLeft              = "CursorLeft"
	ActionCursorRight             = "CursorRight"
	ActionCursorStart             = "CursorStart"
	ActionCursorEnd               = "CursorEnd"
	ActionSelectToStart           = "SelectToStart"
	ActionSelectToEnd             = "SelectToEnd"
	ActionSelectUp                = "SelectUp"
	ActionSelectDown              = "SelectDown"
	ActionSelectLeft              = "SelectLeft"
	ActionSelectRight             = "SelectRight"
	ActionWordRight               = "WordRight"
	ActionWordLeft                = "WordLeft"
	ActionSelectWordRight         = "SelectWordRight"
	ActionSelectWordLeft          = "SelectWordLeft"
	ActionDeleteWordRight         = "DeleteWordRight"
	ActionDeleteWordLeft          = "DeleteWordLeft"
	ActionSelectLine              = "SelectLine"
	ActionSelectToStartOfLine     = "SelectToStartOfLine"
	ActionSelectToEndOfLine       = "SelectToEndOfLine"
	ActionParagraphPrevious       = "ParagraphPrevious"
	ActionParagraphNext           = "ParagraphNext"
	ActionInsertNewline           = "InsertNewline"
	ActionInsertSpace             = "InsertSpace"
	ActionBackspace               = "Backspace"
	ActionDelete                  = "Delete"
	ActionInsertTab               = "InsertTab"
	ActionCenter                  = "Center"
	ActionUndo                    = "Undo"
	ActionRedo                    = "Redo"
	ActionCopy                    = "Copy"
	ActionCut                     = "Cut"
	ActionCutLine                 = "CutLine"
	ActionDuplicateLine           = "DuplicateLine"
	ActionDeleteLine              = "DeleteLine"
	ActionMoveLinesUp             = "MoveLinesUp"
	ActionMoveLinesDown           = "MoveLinesDown"
	ActionIndentSelection         = "IndentSelection"
	ActionOutdentSelection        = "OutdentSelection"
	ActionOutdentLine             = "OutdentLine"
	ActionPaste                   = "Paste"
	ActionSelectAll               = "SelectAll"
	ActionStart                   = "Start"
	ActionEnd                     = "End"
	ActionPageUp                  = "PageUp"
	ActionPageDown                = "PageDown"
	ActionSelectPageUp            = "SelectPageUp"
	ActionSelectPageDown          = "SelectPageDown"
	ActionHalfPageUp              = "HalfPageUp"
	ActionHalfPageDown            = "HalfPageDown"
	ActionStartOfLine             = "StartOfLine"
	ActionEndOfLine               = "EndOfLine"
	ActionToggleRuler             = "ToggleRuler"
	ActionToggleOverwriteMode     = "ToggleOverwriteMode"
	ActionEscape                  = "Escape"
	ActionScrollUp                = "ScrollUp"
	ActionScrollDown              = "ScrollDown"
	ActionSpawnMultiCursor        = "SpawnMultiCursor"
	ActionSpawnMultiCursorSelect  = "SpawnMultiCursorSelect"
	ActionRemoveMultiCursor       = "RemoveMultiCursor"
	ActionRemoveAllMultiCursors   = "RemoveAllMultiCursors"
	ActionSkipMultiCursor         = "SkipMultiCursor"
	ActionJumpToMatchingBrace     = "JumpToMatchingBrace"
	ActionInsertEnter             = "InsertEnter"
	ActionUnbindKey               = "UnbindKey"
	ActionStartOfTextToggle       = "StartOfTextToggle"
	ActionMousePress              = "MousePress"
	ActionMouseDrag               = "MouseDrag"
	ActionMouseRelease            = "MouseRelease"
	ActionSetManualSelectionStart = "SetManualSelectionStart"
	ActionSetManualSelectionEnd   = "SetManualSelectionEnd"
	ActionToggleBookmark          = "ToggleBookmark"
)

Actions

Variables

This section is empty.

Functions

func ListColorschemes

func ListColorschemes() []string

func ListSyntaxes

func ListSyntaxes() []string

func NewBufferFromString

func NewBufferFromString(content string, path string) *buffer.Buffer

Types

type Action

type Action func() bool

type ActionController

type ActionController struct {
	*action.BufPane
}

type Colorscheme

type Colorscheme config.Colorscheme

func LoadInternalColorscheme

func LoadInternalColorscheme(name string) (Colorscheme, bool)

func ParseColorscheme

func ParseColorscheme(data string) Colorscheme

func (Colorscheme) GetColor

func (colorscheme Colorscheme) GetColor(color string) tcell.Style

type KeyDesc

type KeyDesc struct {
	KeyCode   tcell.Key
	Modifiers tcell.ModMask
	R         rune
}

func ParseKeySequence

func ParseKeySequence(k string) (KeyDesc, bool)

Utility function for parsing key sequences which have the same format as Smidgen keybindings

type Keybindings

type Keybindings struct {
	*action.KeyTree
}

func ParseKeybindings

func ParseKeybindings(config map[string]string) Keybindings

type View

type View struct {
	*tview.Box
	// contains filtered or unexported fields
}

func NewView

func NewView(app *tview.Application, buffer *buffer.Buffer) *View

func (*View) ActionController

func (v *View) ActionController() *ActionController

func (*View) Buffer

func (v *View) Buffer() *buffer.Buffer

func (*View) Cursor

func (v *View) Cursor() *buffer.Cursor

func (*View) Draw

func (v *View) Draw(screen tcell.Screen)

func (*View) GoToLoc

func (v *View) GoToLoc(loc buffer.Loc)

func (*View) InputHandler

func (v *View) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

func (*View) MapActionNameToAction

func (v *View) MapActionNameToAction(name string) Action

func (*View) MouseHandler

func (v *View) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*View) Relocate

func (v *View) Relocate()

func (*View) SetColorscheme

func (v *View) SetColorscheme(cs Colorscheme)

func (*View) SetKeybindings

func (v *View) SetKeybindings(keybindings Keybindings)

Directories

Path Synopsis
cmd
smidgen command
micro
pkg

Jump to

Keyboard shortcuts

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