edit

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: MIT Imports: 9 Imported by: 7

Documentation

Overview

Package edit provides an editable text field widget with support for password hiding.

Index

Constants

This section is empty.

Variables

View Source
var InvalidRuneIndex error = errors.New("Invalid rune index for string")

Functions

func CalculateTopMiddleBottom

func CalculateTopMiddleBottom(w IWidget, size gowid.IRenderSize) (int, int, int)

func DownLines

func DownLines(w IWidget, size gowid.IRenderSize, doPage bool, app gowid.IApp) bool

Return true if done

func MakeText

func MakeText(w IWidget) text.IWidget

func Render

func Render(w IWidget, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

func UpLines

func UpLines(w IWidget, size gowid.IRenderSize, doPage bool, app gowid.IApp) bool

Return true if done

func UserInput

func UserInput(w IWidget, ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

Types

type Caption

type Caption struct{}

type Cursor

type Cursor struct{}

type IEdit

type IEdit interface {
	text.ISimple
	IMask
	text.ICursor
	Caption() string
	MakeText() text.IWidget
}

IEdit is an interface to be implemented by a text editing widget. A suitable implementation will be able to defer to RenderEdit() in its Render() function.

type IMask

type IMask interface {
	UseMask() bool
	MaskChr() rune
}

type IPaste added in v1.4.0

type IPaste interface {
	PasteState(...bool) bool
	AddKey(*tcell.EventKey)
	GetKeys() []*tcell.EventKey
}

type IReadOnly added in v1.4.0

type IReadOnly interface {
	IsReadOnly() bool
}

type IWidget

type IWidget interface {
	IEdit
	text.IChrAt
	LinesFromTop() int
	SetLinesFromTop(int, gowid.IApp)
	UpLines(size gowid.IRenderSize, doPage bool, app gowid.IApp) bool
	DownLines(size gowid.IRenderSize, doPage bool, app gowid.IApp) bool
}

type Mask

type Mask struct {
	Chr    rune
	Enable bool
}

func DisabledMask

func DisabledMask() Mask

func MakeMask

func MakeMask(chr rune) Mask

func (Mask) MaskChr

func (m Mask) MaskChr() rune

func (Mask) UseMask

func (m Mask) UseMask() bool

type Options

type Options struct {
	Caption  string
	Text     string
	Mask     IMask
	ReadOnly bool
}

type Text

type Text struct{}

For callback registration

type Widget

type Widget struct {
	IMask

	Callbacks *gowid.Callbacks
	gowid.IsSelectable
	// contains filtered or unexported fields
}

func New

func New(args ...Options) *Widget

func (*Widget) AddKey added in v1.4.0

func (w *Widget) AddKey(ev *tcell.EventKey)

func (*Widget) CalculateTopMiddleBottom

func (w *Widget) CalculateTopMiddleBottom(size gowid.IRenderSize) (int, int, int)

func (*Widget) Caption

func (w *Widget) Caption() string

func (*Widget) ChrAt added in v1.1.0

func (w *Widget) ChrAt(i int) rune

TODO - this isn't ideal- if called in a loop, it would be quadratic.

func (*Widget) CursorEnabled

func (w *Widget) CursorEnabled() bool

func (*Widget) CursorPos

func (w *Widget) CursorPos() int

TODO - weird that you could call set to 0, then get and it would be > 0...

func (*Widget) DownLines

func (w *Widget) DownLines(size gowid.IRenderSize, doPage bool, app gowid.IApp) bool

func (*Widget) GetKeys added in v1.4.0

func (w *Widget) GetKeys() []*tcell.EventKey

func (*Widget) IsReadOnly added in v1.4.0

func (w *Widget) IsReadOnly() bool

func (*Widget) LinesFromTop

func (w *Widget) LinesFromTop() int

func (*Widget) MakeText

func (w *Widget) MakeText() text.IWidget

func (*Widget) OnCaptionSet

func (w *Widget) OnCaptionSet(cb gowid.IWidgetChangedCallback)

func (*Widget) OnCursorPosSet

func (w *Widget) OnCursorPosSet(cb gowid.IWidgetChangedCallback)

func (*Widget) OnTextSet

func (w *Widget) OnTextSet(cb gowid.IWidgetChangedCallback)

func (*Widget) PasteState added in v1.4.0

func (w *Widget) PasteState(b ...bool) bool

func (w *Widget) PasteState(b ...bool) []*tcell.EventKey {

func (*Widget) Read

func (w *Widget) Read(p []byte) (n int, err error)

Set array from widget content

func (*Widget) RemoveOnCaptionSet

func (w *Widget) RemoveOnCaptionSet(cb gowid.IIdentity)

func (*Widget) RemoveOnCursorPosSet

func (w *Widget) RemoveOnCursorPosSet(cb gowid.IIdentity)

func (*Widget) RemoveOnTextSet

func (w *Widget) RemoveOnTextSet(cb gowid.IIdentity)

func (*Widget) Render

func (w *Widget) Render(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

func (*Widget) RenderSize

func (w *Widget) RenderSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderBox

func (*Widget) SetCaption

func (w *Widget) SetCaption(text string, app gowid.IApp)

func (*Widget) SetCursorDisabled

func (w *Widget) SetCursorDisabled()

func (*Widget) SetCursorPos

func (w *Widget) SetCursorPos(pos int, app gowid.IApp)

func (*Widget) SetLinesFromTop

func (w *Widget) SetLinesFromTop(l int, app gowid.IApp)

func (*Widget) SetReadOnly added in v1.4.0

func (w *Widget) SetReadOnly(v bool, _ gowid.IApp)

func (*Widget) SetText

func (w *Widget) SetText(text string, app gowid.IApp)

func (*Widget) String

func (w *Widget) String() string

func (*Widget) Text

func (w *Widget) Text() string

func (*Widget) UpLines

func (w *Widget) UpLines(size gowid.IRenderSize, doPage bool, app gowid.IApp) bool

func (*Widget) UserInput

func (w *Widget) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

type Writer

type Writer struct {
	*Widget
	gowid.IApp
}

Writer embeds an EditWidget and provides the io.Writer interface. An gowid.IApp needs to be provided too because the widget's SetText() function requires it in order to issue callbacks when the text changes.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Set content from array

Jump to

Keyboard shortcuts

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