Documentation ¶
Index ¶
- Constants
- Variables
- func BlendColors(blending BlendMode, switched bool, c1, c2 color.Color) color.Color
- func CmpPos(a, b CharPos) int
- func GetKeyboardShortcutKey(s fyne.KeyboardShortcut) string
- func GradientColor(c1, c2 color.Color, t float64) color.Color
- func IsLeftParen(c rune) bool
- func IsQuotationMark(c rune) bool
- func IsRightParen(c rune) bool
- func SafePositiveValue(value int, maximum int) int
- type BlendMode
- type CaretMovement
- type Cell
- type CharInterval
- func (c CharInterval) Contains(pos CharPos) bool
- func (c CharInterval) Lines() int
- func (c CharInterval) MaybeSwap() CharInterval
- func (c1 CharInterval) OutsideOf(c2 CharInterval) bool
- func (c1 CharInterval) Overlapping(c2 CharInterval) bool
- func (c CharInterval) Sanitize(lastPos CharPos) CharInterval
- type CharPos
- type Config
- type CustomLoadFunc
- type CustomSaveFunc
- type CustomTagUnmarshallerFunc
- type Editor
- func (z *Editor) AddEmacsShortcuts()
- func (z *Editor) AddKeyHandler(key fyne.KeyName, handler func(z *Editor))
- func (z *Editor) AddShortcutHandler(s fyne.KeyboardShortcut, handler func(z *Editor))
- func (z *Editor) Backspace()
- func (z *Editor) BlinkCaret(on bool)
- func (z *Editor) CaretOff() bool
- func (z *Editor) CaretOn(blinking bool)
- func (z *Editor) CenterLineOnCaret()
- func (z *Editor) CharAt(pos CharPos) (rune, bool)
- func (s *Editor) CreateRenderer() fyne.WidgetRenderer
- func (z *Editor) CurrentSelection() (CharInterval, bool)
- func (z *Editor) Cursor() desktop.Cursor
- func (z *Editor) Cut()
- func (z *Editor) Delete(fromTo CharInterval)
- func (z *Editor) Delete1()
- func (z *Editor) DoubleTapped(evt *fyne.PointEvent)
- func (z *Editor) DragEnd()
- func (z *Editor) Dragged(evt *fyne.DragEvent)
- func (grid *Editor) FindParagraphEnd(row int, lf rune) int
- func (z *Editor) FindParagraphStart(row int, lf rune) int
- func (z *Editor) FindRune(pos CharPos, backward bool, searchFunc func(c rune) bool) (CharPos, bool)
- func (z *Editor) Focus()
- func (z *Editor) FocusGained()
- func (z *Editor) FocusLost()
- func (z *Editor) GetCaret() CharPos
- func (z *Editor) GetLineText(row int) string
- func (z *Editor) GetText() string
- func (z *Editor) HasBlinkingCaret() bool
- func (z *Editor) Highlight(interval CharInterval)
- func (z *Editor) Insert(r []rune, pos CharPos)
- func (z *Editor) LastColumn(n int) int
- func (z *Editor) LastLine() int
- func (z *Editor) LastPos() CharPos
- func (z *Editor) LineText(i int) string
- func (z *Editor) LineToPara(row int) (int, bool)
- func (z *Editor) Load(in io.Reader) error
- func (z *Editor) LoadFromFile(filepath string) error
- func (z *Editor) LoadMiscDataFromFile(filepath string) error
- func (z *Editor) LoadText(in io.Reader) error
- func (z *Editor) LoadTextFromFile(filepath string) error
- func (z *Editor) MarkErrorParen(interval CharInterval)
- func (z *Editor) MinSize() fyne.Size
- func (z *Editor) MouseIn(evt *desktop.MouseEvent)
- func (z *Editor) MouseMoved(evt *desktop.MouseEvent)
- func (z *Editor) MouseOut()
- func (z *Editor) MoveCaret(dir CaretMovement)
- func (z *Editor) NextPos(pos CharPos) (CharPos, bool)
- func (z *Editor) ParaCount() int
- func (z *Editor) ParaToLine(paraNum int) (int, bool)
- func (z *Editor) PosToCharPos(pos fyne.Position) CharPos
- func (z *Editor) PrevPos(pos CharPos) (CharPos, bool)
- func (z *Editor) Print(s string, tags []Tag)
- func (z *Editor) Refresh()
- func (z *Editor) RemoveKeyHandler(key fyne.KeyName)
- func (z *Editor) RemoveSelection()
- func (z *Editor) RemoveShortcutHandler(s string)
- func (z *Editor) Return()
- func (z *Editor) Save(out io.Writer) error
- func (z *Editor) SaveMiscDataToFile(filepath string) error
- func (z *Editor) SaveTextToFile(filepath string) error
- func (z *Editor) SaveToFile(filepath string) error
- func (z *Editor) ScrollDown()
- func (z *Editor) ScrollLeft(n int)
- func (z *Editor) ScrollRight(n int)
- func (z *Editor) ScrollUp()
- func (z *Editor) Scrolled(evt *fyne.ScrollEvent)
- func (z *Editor) Select(fromTo CharInterval)
- func (z *Editor) SelectAll()
- func (z *Editor) SelectWord(pos CharPos)
- func (z *Editor) SetCaret(pos CharPos)
- func (z *Editor) SetLine(row int, content []rune)
- func (z *Editor) SetLineNumberStyle(style Style)
- func (z *Editor) SetMark(n int)
- func (z *Editor) SetRune(pos CharPos, r rune)
- func (z *Editor) SetText(s string)
- func (z *Editor) SetTopLine(x int)
- func (z *Editor) Tapped(evt *fyne.PointEvent)
- func (z *Editor) Text() string
- func (z *Editor) ToEnd(start CharPos) CharInterval
- func (z *Editor) TypedKey(evt *fyne.KeyEvent)
- func (z *Editor) TypedRune(r rune)
- func (z *Editor) TypedShortcut(s fyne.Shortcut)
- func (z *Editor) WordWrapRows(rows [][]rune, wrapCol int, softWrap bool, hardLF, softLF rune, ...) ([][]rune, int, int)
- type FixedSpacer
- type FixedSpacerRenderer
- type StandardTag
- func (s *StandardTag) Callback() TagFunc
- func (s *StandardTag) Clone(newIndex int) Tag
- func (s *StandardTag) Index() int
- func (s StandardTag) MarshalJSON() ([]byte, error)
- func (s *StandardTag) Name() string
- func (s *StandardTag) SetCallback(cb TagFunc)
- func (s *StandardTag) SetUserData(data any)
- func (s *StandardTag) UnmarshalJSON(data []byte) error
- func (s *StandardTag) UserData() any
- type Style
- type StyleContainer
- type Tag
- type TagContainer
- func (t *TagContainer) Add(interval CharInterval, tags ...Tag)
- func (c *TagContainer) AllTags() []TagWithInterval
- func (t *TagContainer) Clear()
- func (t *TagContainer) CloneTag(tag Tag) Tag
- func (t *TagContainer) Delete(tag Tag) bool
- func (t *TagContainer) DeleteByName(name string) bool
- func (t *TagContainer) Lookup(tag Tag) (CharInterval, bool)
- func (t *TagContainer) LookupRange(interval CharInterval) ([]Tag, bool)
- func (c *TagContainer) SetAllTags(tags []TagWithInterval)
- func (t *TagContainer) TagsByName(name string) (*orderedset.OrderedSet[Tag], bool)
- func (t *TagContainer) Upsert(tag Tag, interval CharInterval)
- type TagEvent
- type TagFunc
- type TagPostReadFunc
- type TagPreWriteFunc
- type TagStyleFunc
- type TagStyler
- type TagWithInterval
Constants ¶
const MAGIC = 86637303 // magic cookie
const MINVERSION = 100 // minimum required version
const VERSION = 100 // this version 100 == "v1.0.0"
Variables ¶
var EmptyStyle = Style{}
var ErrInvalidStream = fmt.Errorf("invalid input text format")
var ErrTooLongLine = fmt.Errorf("a line in the input text was too large")
var ErrTooManyLines = fmt.Errorf("too many lines, the input text could not be read because it is too large")
var ErrTooManyTags = fmt.Errorf("the input text has too many tags")
var ErrVersionTooLow = fmt.Errorf("this software's version for input text reading is outdated and cannot read the provided text")
Functions ¶
func BlendColors ¶
func CmpPos ¶
CmpPos lexicographically compares to char positions and returns -1 if a is before b, 0 if a and b are equal positions, and 1 if a is after b. This is used for interval operation.
func GetKeyboardShortcutKey ¶
func GetKeyboardShortcutKey(s fyne.KeyboardShortcut) string
GetKeyboardShortcutKey makes a lookup key for a fyne.KeyboardShortcut that is equal for any two shortcuts with the same key and modifier. (The shortcut name does not have this property.)
func IsQuotationMark ¶
IsQuotationMark returns true if the rune is a quotation mark, which behaves similar to a paren but is symmetric (i.e., opening and closing marks are identical).
func IsRightParen ¶
IsRightParen returns true if the rune is a right paren.
func SafePositiveValue ¶
SafePositiveValue returns a sanitized integer that is 0 or larger and no larger than the given maximum value (inclusive).
Types ¶
type BlendMode ¶
type BlendMode int
const ( BlendColor BlendMode = iota + 1 BlendColorBurn BlendColorDodge BlendDarken BlendDarkerColor BlendDifference BlendDivide BlendExclusion BlendHardLight BlendHardMix BlendHue BlendLighten BlendLighterColor BlendLinearBurn BlendLinearDodge BlendLinearLight BlendLuminosity BlendMultiply BlendOverlay BlendPhoenix BlendPinLight BlendReflex BlendSaturation BlendScreen BlendSoftLight BlendSubstract BlendVividLight )
type CaretMovement ¶
type CaretMovement int
const ( CaretDown CaretMovement = iota + 1 CaretUp CaretLeft CaretRight CaretHome CaretEnd CaretLineStart CaretLineEnd CaretHalfPageDown CaretHalfPageUp CaretPageDown CaretPageUp )
type Cell ¶
func NewCellFromTextGridCell ¶
func NewCellFromTextGridCell(cell widget.TextGridCell) Cell
func (Cell) ToTextGridCell ¶
func (c Cell) ToTextGridCell() widget.TextGridCell
type CharInterval ¶
func (CharInterval) Contains ¶
func (c CharInterval) Contains(pos CharPos) bool
Contains returns true if the char interval contains the given position, false otherwise.
func (CharInterval) Lines ¶
func (c CharInterval) Lines() int
Lines returns the number of lines this interval spans, including start and end line.
func (CharInterval) MaybeSwap ¶
func (c CharInterval) MaybeSwap() CharInterval
MaybeSwap compares the start and the end, and if the end is before the start returns the interval where the end is the start and the start is the end. The function returns the unchanged interval otherwise.
func (CharInterval) OutsideOf ¶
func (c1 CharInterval) OutsideOf(c2 CharInterval) bool
OutsideOf returns true if c1 is outside of c2.
func (CharInterval) Overlapping ¶
func (c1 CharInterval) Overlapping(c2 CharInterval) bool
Overlapping returns true if the char interval is overlapping in any way with the interval passed as argument, flase otherwise. c1.Overlapping(c2) and c2.Overlapping(c1) are equivalent.
func (CharInterval) Sanitize ¶
func (c CharInterval) Sanitize(lastPos CharPos) CharInterval
Sanitize computes a new interval that is strictly between [(0,0)...lastPos]. This can be used as a helper when intervals might have invalid values (e.g. due to user input). Sanitize calls MaybeSwap.
type CharPos ¶
CharPos represents a character position in the grid. If IsLineNumber is true, then the position is in the line number display, Line contains the line number, and Column is 0. Otherwise, Line and Column contain the line, column pair of the grid closest to the position.
type Config ¶
type Config struct { SelectionTag Tag // the tag used for marking selection ranges SelectionStyler TagStyler // style of the selection tag HighlightTag Tag // for transient highlighting (usually has a different style than selection) HighlightStyler TagStyler // style func for highlight MarkTag Tag // template for the mark tags MarkTags []Tag // a number of pre-configured tags used for marking text (default: 0..9 tags) MarkStyler TagStyler // mark style func, using the tag index to distinguish marks ErrorTag Tag // for errors ParenErrorTag Tag // for wrong right parenthesis ErrorStyler TagStyler // style of errors (default: theme error color) ShowLineNumbers bool // switches on or off the line number display, which is in a separate grid ShowWhitespace bool // show special glyphs for line endings (currently defunct) BlendFG BlendMode // how layers of color are blended/composited for text foreground BlendFGSwitched bool // whether to switch the colors while blending forground (sometimes makes a difference) BlendBG BlendMode // how layers of color are blended for background BlendBGSwitched bool // whether the colors are switched while blending background colors (sometimes makes a difference) HardLF rune // hard line feed character SoftLF rune // soft line feed character (subject to word-wrapping and deletion in text) ScrollFactor float32 // speed of scrolling TabWidth int // If set to 0 the fyne.DefaultTabWidth is used MinRefreshInterval time.Duration // minimum interval in ms to refresh display CharDrift float32 // default 0.4, added to calculation per char when finding char position from x-position LineWrap bool // automatically wrap lines (default: true) SoftWrap bool // soft wrap lines, if not true wrapping inserst hard line feeds (default: true) HighlightParens bool // highlight parentheses and quotation marks (default: true) HighlightParenRange bool // highlight the whole range between matching parens (default: false) DrawCaret bool // if true, the caret is drawn, if false, the caret is handled but not drawn CaretBlinkDelay time.Duration // period after last interaction before caret starts blinking CaretOnDuration time.Duration // how long the caret is shown when blinking CaretOffDuration time.Duration // how long a blinking caret is off ParagraphLineNumbers bool // line numbers are based on paragraphs to take into account soft wrap TagPreWrite TagPreWriteFunc // called before a tag is written TagPostRead TagPostReadFunc // called after a tag has been read, may be used to re-store callback CustomLoader CustomLoadFunc // called during Load after the editor has loaded everything else CustomSaver CustomSaveFunc // called after during Save everything else has been saved MaxLines int64 // maximum number of lines (if 0 or below, no limit) only used during Load MaxColumn int64 // maximum column length (if 0 or below, no limit) only used during Load MaxTags int64 // maximum number of tags (if 0 or below, no limit) only used during Load MaxPrintLines int // maximum number of lines for printing for console mode, preceding lines are cut off }
Config stores configuration information for an editor.
type CustomLoadFunc ¶
type CustomSaveFunc ¶
type CustomTagUnmarshallerFunc ¶
var CustomTagUnmarshaller CustomTagUnmarshallerFunc
CustomTagUnmarshaller should be set to a function that takes the type name and []byte, and returns the appropriate custom Tag based on how MarshalJSON is implemented for that tag. The unmarshaller for all tags will automatically dispatch to this function when unmarshalling a custom tag implemented by the user of this package. This is a bit safer and more flexible than trying to do this automatically using reflection.
type Editor ¶
type Editor struct { widget.BaseWidget Lines int // the number of lines displayed Columns int // the number of columns displayed Rows [][]rune // the text Tags *TagContainer // all tags Styles *StyleContainer // styles associated with tags Config *Config // editor configuration // contains filtered or unexported fields }
Editor is the main editor widget. Even though some of its properties are public, this is merely for convenience and it's best to only modify it using methods. If there is no method for some operation, chances are high that direct manipulation of internals such as editor.Rows might break in the future.
func NewEditor ¶
NewEditor returns a new editor widget with fixed columns and lines, which is displayed in the given canvas object. The editor has default configuration.
func NewEditorWithConfig ¶
NewEditorWithConfig returns a new editor with fixed columns and lines, which is displayed in the given canvas and uses the given configuration. The Config must be obtained by NewConfig() to ensure all defaults are initialized but may be changed before calling this function.
func (*Editor) AddEmacsShortcuts ¶
func (z *Editor) AddEmacsShortcuts()
AddEmacsShortcuts adds some (very basic) Emacs shortcuts but some with Super key as modifier instead of Ctrl in order not to interfere with standard platform keyboard shortcuts.
func (*Editor) AddKeyHandler ¶
AddKeyHandler adds a direct handler for the given key. Unlike AddShortcutHandler, a key handler is called whenever the key is pressed, even when no modifier is used.
func (*Editor) AddShortcutHandler ¶
AddhortcutHandler adds a keyboard shortcut to the grid.
func (*Editor) Backspace ¶
func (z *Editor) Backspace()
Backspace deletes the character left of the caret, if there is one.
func (*Editor) BlinkCaret ¶
BlinkCursor starts blinking the cursor or stops the cursor from blinking.
func (*Editor) CaretOff ¶
CaretOff switches the caret off temporarily. It returns true was blinking.
func (*Editor) CenterLineOnCaret ¶
func (z *Editor) CenterLineOnCaret()
CenterLineOnCaret adjusts the displayed lines such that the caret is in the center of the grid.
func (*Editor) CreateRenderer ¶
func (s *Editor) CreateRenderer() fyne.WidgetRenderer
func (*Editor) CurrentSelection ¶
func (z *Editor) CurrentSelection() (CharInterval, bool)
CurrentSelection returns the CharInterval if there is a non-empty selection marked, an empty CharInterval and false otherwise.
func (*Editor) Delete ¶
func (z *Editor) Delete(fromTo CharInterval)
Delete deletes a range of characters, optionally soft wrapping the paragraph with given hardLF and softLF runes as hard and soft line feed characters.
func (*Editor) Delete1 ¶
func (z *Editor) Delete1()
Delete1 deletes the character under the caret or the selection, if there is one.
func (*Editor) DoubleTapped ¶
func (z *Editor) DoubleTapped(evt *fyne.PointEvent)
func (*Editor) FindParagraphEnd ¶
FindParagraphEnd finds the end row of the paragraph in which row is located. If row is the last row, then it is returned. Otherwise, it checks for the next row that ends in lf (which may be the row with which this method was called).
func (*Editor) FindParagraphStart ¶
FindParagraphStart finds the start row of the paragraph in which row is located. If the row is 0, 0 is returned, otherwise this checks for the next line ending with lf and returns the row after it.
func (*Editor) FindRune ¶
FindRune searches one rune forward or backward, using searchFunc and returns the matching rune's position and true, or (0,0) and false. pos is included in the search.
func (*Editor) GetLineText ¶
GetLineText obtains the text of a single line. The empty string is returned if there is no valid line.
func (*Editor) HasBlinkingCaret ¶
HasBlinkingCaret returns true if the input cursor is blinking, false otherwise. use BlinkCursor to switch blinking on or off.
func (*Editor) Highlight ¶
func (z *Editor) Highlight(interval CharInterval)
Highlight highlights a char interval using the default highlight tag and style. This method does not remove any previous highlights.
func (*Editor) Insert ¶
Insert inserts an array of TextGridCells at row, col, optionally soft wrapping it and using hardLF and softLF as hard and soft line feed characters. The cursor position and tags are updated automatically by this method.
func (*Editor) LastColumn ¶
LastColumn returns the last column of the given line (both 0-indexed).
func (*Editor) LineText ¶
LineText returns the text of line i, the empty string if i is out of bounds.
func (*Editor) LineToPara ¶
LineToPara returns the real paragraph number for a given 0-indexed row if there is one, false otherwise. The paragraph number is measured according to the hard LFs from the start of the document. If z.WordWrap is false, this function always returns the line + 1. However, if it is true, this function computes the paragraph number (indexed from 1) at the given line. This function is O(n) in the number of lines.
func (*Editor) LoadFromFile ¶
LoadFromFile loads the editor contents from the given file.
func (*Editor) LoadMiscDataFromFile ¶
LoadMiscDataFromFile loads the miscellaneous data and tags from the file. It's important to first load the text and then call this function, since it sets cursor and tags to values that assume the text is present.
func (*Editor) LoadTextFromFile ¶
LoadTextFromFile loads unicode text from the given file.
func (*Editor) MarkErrorParen ¶
func (z *Editor) MarkErrorParen(interval CharInterval)
MarkError marks an error at a given range or removes it. Any existing error in the interval is removed. This is a quick and dirty solution. For full syntax coloring, it may be better to use a custom function instead of this one.
func (*Editor) MouseIn ¶
func (z *Editor) MouseIn(evt *desktop.MouseEvent)
func (*Editor) MouseMoved ¶
func (z *Editor) MouseMoved(evt *desktop.MouseEvent)
func (*Editor) MoveCaret ¶
func (z *Editor) MoveCaret(dir CaretMovement)
MoveCaret moves the caret according to the given movement direction, which may be one of CaretUp, CaretDown, CaretLeft, and CaretRight.
func (*Editor) NextPos ¶
NextPos returns the next char position in the grid and true, or the last position and false if there is no more.
func (*Editor) ParaCount ¶
ParaCount counts the number of paragraphs, which is equivalent to the number of lines ending in HardLF + 1.
func (*Editor) ParaToLine ¶
ParaToLine returns the 0-indexed line number at which the given 1-index n-th paragraph starts and true if there is a paragraph with that index, 0 and false otherwise. This function is O(n) in the number of lines.
func (*Editor) PosToCharPos ¶
PosToCharPos converts an internal position of the widget in Fyne's pixel unit to a line, row pair.
func (*Editor) PrevPos ¶
PrevPos returns the previous char position in the grid and true, or 0, 0 and false if at home position.
func (*Editor) Print ¶
Print prints a string at the current cursor position, advancing the cursor and applying the given tags to the string. The string may have multiple lines. This method is for console mode applications and should not be used for user editing. If config.MaxPrintLines is exceeded, lines are cut off at the beginning of the buffer.
func (*Editor) RemoveKeyHandler ¶
func (z *Editor) RemoveKeyHandler(key fyne.KeyName)
RemoveKeyHandler removes the handler for the given key.
func (*Editor) RemoveSelection ¶
func (z *Editor) RemoveSelection()
RemoveSelection removes the current selection, both the range returned by GetSelection and its graphical display.
func (*Editor) RemoveShortcutHandler ¶
RemoveShortcutHandler removes the keyboard shortcut handler with the given key.
func (*Editor) Return ¶
func (z *Editor) Return()
Return implements the return key behavior, which creates a new line and advances the caret accordingly.
func (*Editor) SaveMiscDataToFile ¶
SaveMiscDataToFile saves tags and miscellaneous data to the given file. This can be used instead of SaveToFile if plaintext unicode file and miscellaneous data are supposed to be stored separately.
func (*Editor) SaveTextToFile ¶
SaveTextToFile saves the text as unicode to a file. Nothing else beside the text is saved.
func (*Editor) SaveToFile ¶
SaveToFile saves the editor's content to a file.
func (*Editor) ScrollDown ¶
func (z *Editor) ScrollDown()
ScrollDown scrolls down the editor's line display by one line.
func (*Editor) ScrollLeft ¶
ScrollLeft scrolls to the left by n chars or until the first char if n is too large.
func (*Editor) ScrollRight ¶
ScrollRight scrolls to the right by n chars but keeps some chars in display if n higher than the line.
func (*Editor) ScrollUp ¶
func (z *Editor) ScrollUp()
ScrollUp scrolls up the editor's line display by one line.
func (*Editor) Select ¶
func (z *Editor) Select(fromTo CharInterval)
Select the given char interval. The interval is sanitized before setting the selection.
func (*Editor) SelectWord ¶
SelectWord selects the word under pos if there is one, removes the selection in any case.
func (*Editor) SetCaret ¶
SetCaret sets the current caret position, taking care of paren highlighting and caret events but without scrolling or refreshing the display.
func (*Editor) SetLine ¶
SetLine sets the line text. If row is beyond the current size, empty rows are added accordingly.
func (*Editor) SetLineNumberStyle ¶
SetLineNumberStyle sets the style of the line number display in terms of an EditorStyle.
func (*Editor) SetText ¶
SetText sets the text in the editor to the given string, removing all tags in the process.
func (*Editor) SetTopLine ¶
SetTopLine sets the editor to display starting with the given line number.
func (*Editor) Text ¶
Text returns the Editor's text as string. Both soft and hard linefeeds are replaced with rune '\n'.
func (*Editor) ToEnd ¶
func (z *Editor) ToEnd(start CharPos) CharInterval
ToEnd returns the char interval from the given position to the last char of the buffer.
func (*Editor) TypedShortcut ¶
func (z *Editor) TypedShortcut(s fyne.Shortcut)
func (*Editor) WordWrapRows ¶
func (z *Editor) WordWrapRows(rows [][]rune, wrapCol int, softWrap bool, hardLF, softLF rune, cursorRow, cursorCol, startRow int, tags []Tag, pos CharPos) ([][]rune, int, int)
WordWrapRows word wraps a number of rows, making sure soft line breaks are adjusted and removed accordingly. The number of rows returned may be larger than the number of rows provided as an argument. The position of the original cursor row and column is returned.
type FixedSpacer ¶
type FixedSpacer struct { widget.BaseWidget // contains filtered or unexported fields }
FixedSpacer is a fyne widget that can be used a fixed-size dummy element that is not displayed. This is used in a hack to make an invisible widget for the scrollbar of the size of the number of rows in the editor widget, which is fixed size internally and only changes the display of lines when they are scrolled in and out of the view.
func NewFixedSpacer ¶
func NewFixedSpacer(size fyne.Size) *FixedSpacer
NewFixedSpacer creates a spacer of the given fized size. It will not change its size except when ChangeSize is called.
func (*FixedSpacer) ChangeSize ¶
func (s *FixedSpacer) ChangeSize(size fyne.Size)
ChangeSize can be used to change the spacer's size, so it reports this size to widgets that embed it such as the scrollbar.
func (*FixedSpacer) CreateRenderer ¶
func (s *FixedSpacer) CreateRenderer() fyne.WidgetRenderer
CreateRenderer creates the fixed spacer renderer.
func (*FixedSpacer) MinSize ¶
func (s *FixedSpacer) MinSize() fyne.Size
MinSize returns the minimum size of the spacer, which is the same as its size.
func (*FixedSpacer) SetHeight ¶
func (s *FixedSpacer) SetHeight(height float32)
SetHeight sets the height of the spacer only. This is is used when the spacer is used as a dummy for a scrollbar.
func (*FixedSpacer) Size ¶
func (s *FixedSpacer) Size() fyne.Size
Size returns the size of the spacer.
type FixedSpacerRenderer ¶
type FixedSpacerRenderer struct {
// contains filtered or unexported fields
}
FixedSpacerRenderer is a renderer for fixed spacer.
func (*FixedSpacerRenderer) Destroy ¶
func (r *FixedSpacerRenderer) Destroy()
Destroy destroys the renderer.
func (*FixedSpacerRenderer) Layout ¶
func (r *FixedSpacerRenderer) Layout(size fyne.Size)
Layout is the renderer layout procedure, which does nothing (a spacer is invisible).
func (*FixedSpacerRenderer) MinSize ¶
func (r *FixedSpacerRenderer) MinSize() fyne.Size
MinSize returns the spacer's minimum size.
func (*FixedSpacerRenderer) Objects ¶
func (r *FixedSpacerRenderer) Objects() []fyne.CanvasObject
Objects is needed for a renderer, but returns an empty array of CanvasObject for a spacer.
func (*FixedSpacerRenderer) Refresh ¶
func (r *FixedSpacerRenderer) Refresh()
Refresh does nothing, since a fixed spacer is not displayed by itself.
type StandardTag ¶
type StandardTag struct {
// contains filtered or unexported fields
}
StandardTag is the default implementation of a Tag.
func NewTag ¶
func NewTag(name string) *StandardTag
func NewTagWithUserData ¶
func NewTagWithUserData(name string, index int, userData any) *StandardTag
func (*StandardTag) Callback ¶
func (s *StandardTag) Callback() TagFunc
func (*StandardTag) Clone ¶
func (s *StandardTag) Clone(newIndex int) Tag
func (*StandardTag) Index ¶
func (s *StandardTag) Index() int
func (StandardTag) MarshalJSON ¶
func (s StandardTag) MarshalJSON() ([]byte, error)
func (*StandardTag) Name ¶
func (s *StandardTag) Name() string
func (*StandardTag) SetCallback ¶
func (s *StandardTag) SetCallback(cb TagFunc)
func (*StandardTag) SetUserData ¶
func (s *StandardTag) SetUserData(data any)
func (*StandardTag) UnmarshalJSON ¶
func (s *StandardTag) UnmarshalJSON(data []byte) error
func (*StandardTag) UserData ¶
func (s *StandardTag) UserData() any
type Style ¶
func (Style) ToTextGridStyle ¶
func (s Style) ToTextGridStyle() widget.TextGridStyle
type StyleContainer ¶
type StyleContainer struct {
// contains filtered or unexported fields
}
StyleContainer holds a number of tag stylers. The data structure is threadsafe.
func NewStyleContainer ¶
func NewStyleContainer() *StyleContainer
func (*StyleContainer) AddStyler ¶
func (c *StyleContainer) AddStyler(styler TagStyler)
AddStyler adds a new tag styler to the style container.
func (*StyleContainer) RemoveStyler ¶
func (c *StyleContainer) RemoveStyler(tag Tag)
RemoveStyler removes a tag styler from the container.
func (*StyleContainer) Stylers ¶
func (c *StyleContainer) Stylers() []TagStyler
Stylers returns all tag stylers.
type Tag ¶
type Tag interface { Name() string // return the tag's name, which is used for stylers Index() int // return the tag's new index, a serial number for tags with the same name Clone(newIndex int) Tag // clone the tag, giving it a new index Callback() TagFunc // called when TagEvents happen SetCallback(cb TagFunc) // set the callback function UserData() any // optional payload SetUserData(data any) // set optional payload MarshalJSON() ([]byte, error) // for serialization UnmarshalJSON(data []byte) error // for deserialization }
Tags are used to store information about the editor text associated with intervals. A tag's position is adjusted automatically as the editor text changes. Stylers can be associated to multiple tags with the same name.
type TagContainer ¶
type TagContainer struct {
// contains filtered or unexported fields
}
TagContainer is a container for holding tags and associating them with char intervals. The data structure is generally threadsafe but some methods can have race conditions and are documented as such.
func NewTagContainer ¶
func NewTagContainer() *TagContainer
NewTagContainer returns a new empty tag container.
func (*TagContainer) Add ¶
func (t *TagContainer) Add(interval CharInterval, tags ...Tag)
Add adds a number of tags and associates them with the given interval.
func (*TagContainer) AllTags ¶
func (c *TagContainer) AllTags() []TagWithInterval
func (*TagContainer) Clear ¶
func (t *TagContainer) Clear()
Clear deletes all tags in the container but retains stylers.
func (*TagContainer) CloneTag ¶
func (t *TagContainer) CloneTag(tag Tag) Tag
CloneTag clones the given tag with a new index, and registers the tag in the container but without an associated interval. If there is no tag in the container, it registers the tag and returns it without cloning it.
func (*TagContainer) Delete ¶
func (t *TagContainer) Delete(tag Tag) bool
Delete deletes the given tag, returns true if the tag was deleted, false if there was no such tag.
func (*TagContainer) DeleteByName ¶
func (t *TagContainer) DeleteByName(name string) bool
DeleteByName deletes all tags with the given name. This method does not guarantee that tags that are added concurrently while it is executed are deleted. They may or may not be deleted. So, the method is not protected against race conditions. It is generally thread-safe, however.
func (*TagContainer) Lookup ¶
func (t *TagContainer) Lookup(tag Tag) (CharInterval, bool)
Lookup returns the char interval associated with the given tag.
func (*TagContainer) LookupRange ¶
func (t *TagContainer) LookupRange(interval CharInterval) ([]Tag, bool)
LookupRange returns the tags intersecting with the given char interval.
func (*TagContainer) SetAllTags ¶
func (c *TagContainer) SetAllTags(tags []TagWithInterval)
func (*TagContainer) TagsByName ¶
func (t *TagContainer) TagsByName(name string) (*orderedset.OrderedSet[Tag], bool)
TagsByName returns all tags with the given name. This is used when stylers are applied because these work on a by-name basis.
func (*TagContainer) Upsert ¶
func (t *TagContainer) Upsert(tag Tag, interval CharInterval)
Upsert changes the interval associated with the given tag.
type TagFunc ¶
type TagFunc func(evt TagEvent, tag Tag, interval CharInterval)
type TagPostReadFunc ¶
type TagPostReadFunc func(tag TagWithInterval) error // used after a tag has been read
type TagPreWriteFunc ¶
type TagPreWriteFunc func(tag TagWithInterval) error // used before a tag is written
type TagStyleFunc ¶
type TagStyler ¶
type TagStyler struct { TagName string StyleFunc TagStyleFunc DrawFullLine bool }
TagSyler styles tags with the given name.
type TagWithInterval ¶
type TagWithInterval struct { Tag Tag Interval CharInterval }
TagWithInterval stores a tag and its accompanying interval.
func (TagWithInterval) MarshalJSON ¶
func (t TagWithInterval) MarshalJSON() ([]byte, error)
func (*TagWithInterval) UnmarshalJSON ¶
func (t *TagWithInterval) UnmarshalJSON(in []byte) error