widgets

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicEvent

type BasicEvent struct {
	At time.Time
	On views.Widget
}

BasicEvent is an embeddable type that implements the views.EventWidget interface.

func NewBasicEvent

func NewBasicEvent(widget views.Widget) BasicEvent

func (BasicEvent) When

func (e BasicEvent) When() time.Time

When returns the time at which the event took place.

func (BasicEvent) Widget

func (e BasicEvent) Widget() views.Widget

Widget returns the widget requesting the reply.

type Editor

type Editor struct {
	*views.TextArea
	// contains filtered or unexported fields
}

Editor implements a simple text editor as a widget. It emits EventSendRequest when an edited message is ready to be sent.

func NewEditor

func NewEditor() *Editor

NewEditor constructs an empty Editor()

func (*Editor) Clear

func (e *Editor) Clear()

Clear erases the content of the editor.

func (*Editor) HandleEvent

func (e *Editor) HandleEvent(ev tcell.Event) bool

HandleEvent handles keypresses.

func (*Editor) TypeRune

func (e *Editor) TypeRune(keypress rune)

Type rune adds the provided rune to the content of the editor.

func (*Editor) UntypeRune

func (e *Editor) UntypeRune()

Untype rune deletes the last rune in the editor.

func (*Editor) UpdateContent

func (e *Editor) UpdateContent()

UpdateContent synchronizes the internal editor state and the visible editor state.

type EphemeralEditor

type EphemeralEditor struct {
	PrimaryContent               views.Widget
	Separator, Editor, Requestor views.Widget
	// the ID field of the EventEditRequest currently being handled, if any
	RequestID     int
	EditorVisible bool
	*views.BoxLayout
	views.WidgetWatchers
}

EphemeralEditor is a layout that can summon and dismiss an Editor widget as needed. When it receives EventEditRequest, it will create an Editor widget that will accept all key events before its PrimaryContent. Once that Editor emits EventEditFinished, it will dismiss the editor.

func NewEphemeralEditor

func NewEphemeralEditor(primary views.Widget) *EphemeralEditor

NewEphemeralEditor creates a new layout with the given view as the primary content.

func (*EphemeralEditor) ClearRequestor

func (e *EphemeralEditor) ClearRequestor()

func (*EphemeralEditor) HandleEvent

func (e *EphemeralEditor) HandleEvent(ev tcell.Event) bool

HandleEvent processes events of interest to the EphemeralEditor. Notably, it handles EventEditRequest and EventEditFinished by summoning and dismissing the editor widget.

func (*EphemeralEditor) HideEditor

func (e *EphemeralEditor) HideEditor()

HideEditor makes the editor invisible and clears its content.

func (*EphemeralEditor) SetRequestor

func (e *EphemeralEditor) SetRequestor(event EventEditRequest)

func (*EphemeralEditor) ShowEditor

func (e *EphemeralEditor) ShowEditor()

ShowEditor makes the editor visible.

type EventEditFinished

type EventEditFinished struct {
	ID      int
	Content string
	BasicEvent
}

EventEditFinished indicates that an EventEditFinished has been processed by an editor and contains the final edited text that the user provided. It fulfills views.EventWidget.

func NewEventEditFinished

func NewEventEditFinished(id int, widget views.Widget, content string) EventEditFinished

NewEventEditFinished creates a new finished event. The id provided should be an ID from the EventEditRequest that was just finished.

type EventEditRequest

type EventEditRequest struct {
	ID      int
	Content string
	BasicEvent
}

EventEditRequest indicates that a widget has requested that an editor be presented to the user with the provided initial content. The ID field is provided by the creator of the request and should be included in any EventEditFinished event that is created as a result of this Request. This allows higher-level logic to correlate the Finished event with the Requst. It fulfills views.EventWidget.

func NewEventEditRequest

func NewEventEditRequest(id int, widget views.Widget, content string) EventEditRequest

NewEventEditRequest creates a new request.

type EventReplySelected

type EventReplySelected struct {
	Selected  *forest.Reply
	Author    *forest.Identity
	Community *forest.Community
	BasicEvent
}

EventReplySelected indicates that a particular node was selected in the TUI.

func NewEventReplySelected

func NewEventReplySelected(widget views.Widget, selected *forest.Reply, author *forest.Identity, community *forest.Community) EventReplySelected

NewEventReplySelected creates an event indicating which node was selected as well as providing a copy of its author and parent community nodes.

type StatusBar

type StatusBar struct {
	views.SimpleStyledTextBar
}

func NewStatusBar

func NewStatusBar() *StatusBar

func (*StatusBar) HandleEvent

func (s *StatusBar) HandleEvent(ev tcell.Event) bool

type Switcher

type Switcher struct {
	*wistTcell.Application
	LogWidget     views.Widget
	ContentWidget views.Widget

	Current views.Widget

	views.WidgetWatchers
}

Switcher allows toggling a single widget between multiple underlying widgets with only one widget visible at a time. Only the visible widget receives events.

func NewSwitcher

func NewSwitcher(app *wistTcell.Application, content, log views.Widget) *Switcher

NewSwitcher creates a Switcher with the given views as its Content and Log widgets.

func (*Switcher) Draw

func (s *Switcher) Draw()

func (*Switcher) HandleEvent

func (s *Switcher) HandleEvent(ev tcell.Event) bool

func (*Switcher) Resize

func (s *Switcher) Resize()

func (*Switcher) SetView

func (s *Switcher) SetView(view views.View)

func (*Switcher) Size

func (s *Switcher) Size() (int, int)

func (*Switcher) ToggleLogWidget

func (s *Switcher) ToggleLogWidget()

type Writer

type Writer struct {
	views.CellView
	// contains filtered or unexported fields
}

Writer is a TextArea modified to implement io.Writer

func NewWriterWidget

func NewWriterWidget() *Writer

func (*Writer) EnableCursor

func (ta *Writer) EnableCursor(on bool)

EnableCursor enables a soft cursor in the TextArea.

func (*Writer) HideCursor

func (ta *Writer) HideCursor(on bool)

HideCursor hides or shows the cursor in the TextArea. If on is true, the cursor is hidden. Note that a cursor is only shown if it is enabled.

func (*Writer) Init

func (ta *Writer) Init()

Init initializes the TextArea.

func (*Writer) SetLines

func (ta *Writer) SetLines(lines []string)

SetLines sets the content text to display.

func (*Writer) SetStyle

func (ta *Writer) SetStyle(style tcell.Style)

func (*Writer) Write

func (l *Writer) Write(b []byte) (int, error)

Write adds the given bytes to the end of the content in the TextArea

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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