ui

package
v0.0.0-...-ed89ad4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup() error

Setup initializes the UI

Types

type Content

type Content interface {
	GetLabel() (string, error)
	GetLine(lineNumber int) (string, error)
	GetMaxLines() (int, error)
	HandleKey(ui *UI, key interface{}, mod gocui.Modifier, lineNumber int) error
}

Content defines the interface used to show contents in a Scroller

type EditorOnClose

type EditorOnClose func(ok bool, s string)

EditorOnClose defines a callback used in editors

type ListView

type ListView struct {
	// contains filtered or unexported fields
}

ListView displays a list of entries, which are read from 'query'

func NewListView

func NewListView(query string) (*ListView, error)

NewListView creates a new ListView with a specific query

func (*ListView) GetLabel

func (v *ListView) GetLabel() (string, error)

GetLabel returns the label of the ListView

func (*ListView) GetLine

func (v *ListView) GetLine(lineNumber int) (string, error)

GetLine returns the contents of a specific line from a query

func (*ListView) GetMaxLines

func (v *ListView) GetMaxLines() (int, error)

GetMaxLines returns the total number of lines in the ListView

func (*ListView) HandleKey

func (v *ListView) HandleKey(ui *UI, key interface{}, mod gocui.Modifier, lineNumber int) error

HandleKey updates the list view based on key input

type MailView

type MailView struct {
	// contains filtered or unexported fields
}

MailView displays an email message

func NewMailView

func NewMailView(filename string) (*MailView, error)

NewMailView creates a new MailView, with the contents from 'filename'

func (*MailView) GetLabel

func (v *MailView) GetLabel() (string, error)

GetLabel returns the label for the mailview

func (*MailView) GetLine

func (v *MailView) GetLine(lineNumber int) (string, error)

GetLine returns the contents of a specific line in the mailview

func (*MailView) GetMaxLines

func (v *MailView) GetMaxLines() (int, error)

GetMaxLines returns the number of lines in the message

func (*MailView) HandleKey

func (v *MailView) HandleKey(ui *UI, key interface{}, mod gocui.Modifier, lineNumber int) error

HandleKey updates the mailview based on key input

type Scroller

type Scroller struct {
	// contains filtered or unexported fields
}

Scroller defines a scrollable scroller

func NewScroller

func NewScroller(contents Content) *Scroller

NewScroller creates a new Scroller with a specific content

func (*Scroller) GetEndLine

func (v *Scroller) GetEndLine() int

GetEndLine returns the current end line

func (*Scroller) GetLabel

func (v *Scroller) GetLabel() (string, error)

GetLabel returns the label from contents

func (*Scroller) GetLine

func (v *Scroller) GetLine(lineNumber int) (string, error)

GetLine returns the specified line from contents

func (*Scroller) GetSelectedLine

func (v *Scroller) GetSelectedLine() int

GetSelectedLine returns the currently selected line

func (*Scroller) GetStartLine

func (v *Scroller) GetStartLine() int

GetStartLine returns the current start line

func (*Scroller) HandleKey

func (v *Scroller) HandleKey(ui *UI, key interface{}, mod gocui.Modifier, lineNumber int) error

HandleKey updates the scroller based on key input

func (*Scroller) UpdateHeight

func (v *Scroller) UpdateHeight(height int) error

UpdateHeight recalculates start/end, and make sure that selected line is still visible

func (*Scroller) UpdateLinePos

func (v *Scroller) UpdateLinePos(dy int) error

UpdateLinePos moves the currently selected line up or down according to 'dy' dy < 0 moves the currently selected line up, dy > 0 moves the currently selected line down

type SingleLineEditor

type SingleLineEditor struct {
	OnClose EditorOnClose
}

SingleLineEditor implements the Editor interface, and can be used to edit single line entries. When Enter is pressed, OnClose() will be called, with ok set to true, and contents in s If Esc is pressed, OnClose() will be called with ok set to false

func (*SingleLineEditor) Edit

func (ed *SingleLineEditor) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier)

Edit updates the currently edited entry

type ThreadView

type ThreadView struct {
	// contains filtered or unexported fields
}

ThreadView displays a specific message thread

func NewThreadView

func NewThreadView(thread models.Thread) (*ThreadView, error)

NewThreadView creates a new view for displaying a specific thread

func (*ThreadView) GetLabel

func (v *ThreadView) GetLabel() (string, error)

GetLabel returns the label of the thread view

func (*ThreadView) GetLine

func (v *ThreadView) GetLine(lineNumber int) (string, error)

GetLine returns the contents of a specific line in the thread view

func (*ThreadView) GetMaxLines

func (v *ThreadView) GetMaxLines() (int, error)

GetMaxLines returns the total number of lines in the thread view

func (*ThreadView) HandleKey

func (v *ThreadView) HandleKey(ui *UI, key interface{}, mod gocui.Modifier, lineNumber int) error

HandleKey updates the thread view based on key input

type UI

type UI struct {
	// contains filtered or unexported fields
}

UI defines the base handler for the user interface

func (*UI) AddView

func (ui *UI) AddView(v *Scroller)

AddView adds an additional view/tab to the ui

func (*UI) CloseView

func (ui *UI) CloseView() error

CloseView closes a specific view

func (*UI) KeyBindings

func (ui *UI) KeyBindings(g *gocui.Gui) error

KeyBindings registers all bindings

func (*UI) Layout

func (ui *UI) Layout(g *gocui.Gui) error

Layout is responsible for updating the complete contents of the screen

func (*UI) NextView

func (ui *UI) NextView()

NextView displays the next view from the list of available views

func (*UI) RenderHeader

func (ui *UI) RenderHeader(g *gocui.Gui) error

RenderHeader writes the contents of the current header to screen

func (*UI) RenderList

func (ui *UI) RenderList(g *gocui.Gui) error

RenderList writes the contents of a list implementation to screen

Jump to

Keyboard shortcuts

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