editor

package
v0.0.0-...-77bfbca Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Custom multline text entry widget

Contains markdown editor toolbar component

Functions for altering the content of the text editor text

Markdown styling and editing actions for the editor toolbar

Index

Constants

This section is empty.

Variables

View Source
var MARKDOWN_PREFIXES_EXTENDED = append(MARKDOWN_ROW_PREFIXES, " > ", "```", "-----")

Markdown row prefixes extended set, including quote blocks, code blocks, and line breaks

View Source
var MARKDOWN_ROW_PREFIXES = []string{
	"# ", "## ", "### ", "#### ", "##### ",
	"- [ ] ", "- [x] ",
	"- ",
	"1. ", "2. ", "3. ", "4. ", "5. ", "6. ", "7. ", "8. ", "9.", "10. ",
}

These patterns will be assume as styling at the beginning of a row, and will be replaced during replaceRowPrefix operations. FIXME: replace this simplistic pattern check with regex

Functions

func New

New returns a new toolbar component for the markdown text editor, with attached functions and icons

Types

type MarkdownToolbar

type MarkdownToolbar struct {
	Toolbar fyne.Widget
}

MarkdownToolbar is a toolbar for the markdown text editor

type MultiLineWidget

type MultiLineWidget struct {
	widget.Entry
}

MultiLineWidget is a custom multiline entry widget, with improved cursor functions

func NewMultilineWidget

func NewMultilineWidget(content string) *MultiLineWidget

NewMultilineWidget returns a new custom multiline widget

func (*MultiLineWidget) Content

func (m *MultiLineWidget) Content() string

Content returns the editor's text content

func (*MultiLineWidget) ContentRows

func (m *MultiLineWidget) ContentRows() []string

ContentRows returns the content of the widget, broken into rows by newline

func (*MultiLineWidget) CursorPosition

func (m *MultiLineWidget) CursorPosition() shared.Position

CursorPosition returns the cursor position, in row/column format

func (*MultiLineWidget) DebugTextSelection

func (m *MultiLineWidget) DebugTextSelection()

Debug current text selection

func (*MultiLineWidget) GetSelection

func (m *MultiLineWidget) GetSelection() shared.TextSelection

GetSelection returns the current text selection and position. The Fyne entry widget counts position from 0,0. This function returns position from 1,1, to match standard editor conventions.

func (*MultiLineWidget) Redo

func (m *MultiLineWidget) Redo()

Redo the most recent changes to the text content

func (*MultiLineWidget) RowCount

func (m *MultiLineWidget) RowCount() int

RowCount returns the number of rows in the text content

func (*MultiLineWidget) SelectedRowRange

func (m *MultiLineWidget) SelectedRowRange() (int, int)

SelectedRowRange returns the row numbers of the current text selection. This returns start -> end, regardless if the selection is forwards or backwards. For example, if the current selection spans from rows 2 to 3, this would return 2,3 IF the selection is reversed, it will still return 2,3

func (*MultiLineWidget) SelectionStart

func (m *MultiLineWidget) SelectionStart() shared.Position

SelectionStart returns the selection cursor start position.

func (*MultiLineWidget) SetContent

func (m *MultiLineWidget) SetContent(t string)

SetContent replaces the editor's text content

func (*MultiLineWidget) Undo

func (m *MultiLineWidget) Undo()

Undo the most recent changes to the text content

type Position

type Position = shared.Position

type TextSelection

type TextSelection = shared.TextSelection

Jump to

Keyboard shortcuts

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