ui

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ui consists of console ui components

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package ui consists of console ui components

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package ui consists of console ui components

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package ui consists of console ui components

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package ui consists of console ui components

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package ui consists of console ui components

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectTabable

func ConnectTabable(prev, next Tabable)

ConnectTabable connects two Tabalbe components

func ErrorDialog

func ErrorDialog(pages *FocusPages, err error)

ErrorDialog shows a modal dialog with a message

func InfoDialog

func InfoDialog(pages *FocusPages, message string)

InfoDialog shows a modal dialog with a message

func NewPadded

func NewPadded(p tview.Primitive, left, top int) tview.Primitive

NewPadded returns a new

func OpenFileDialog

func OpenFileDialog(pages *FocusPages, selectedFunc func(string))

OpenFileDialog opens a new file dialog

Types

type FocusFlex

type FocusFlex struct {
	*tview.Flex
	Last tview.Primitive
}

FocusFlex stores the Last primitive with focus and returns the focus to it if method Focus have been called

func NewFocusFlex

func NewFocusFlex() *FocusFlex

NewFocusFlex creates an initialized FocusFlex object

func (*FocusFlex) Focus

func (f *FocusFlex) Focus(delegate func(p tview.Primitive))

Focus overrules the original Flex Focus method

type FocusPages

type FocusPages struct {
	*tview.Pages
}

FocusPages fixes a problem with greedy MouseHandler implementations. If you want to switch a page in a SelectFunc called by the MouseHandler, then this is not possible. Table for example sets back the focus to itself after the execution and that is not what we want.

func NewFocusPages

func NewFocusPages() *FocusPages

NewFocusPages returns an initialized FocusPages object

func (*FocusPages) MouseHandler

func (f *FocusPages) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler implements the fix. If the numer of pages changes then the focus will be set to the current page.

type FormButton

type FormButton struct {
	*tview.Button
	Focused func()
	Parent  *FocusFlex
	// contains filtered or unexported fields
}

FormButton implements a button for home-made forms

func NewFormButton

func NewFormButton(label string) *FormButton

NewFormButton creates an initialzed FormButton object

func (*FormButton) After

func (f *FormButton) After(previous Tabable) *FormButton

After connects this button with the previous Tabable

func (*FormButton) Focus

func (f *FormButton) Focus(delegate func(p tview.Primitive))

Focus calls the original Button Focus function, stores this FormButton as last focused object and calls the Focused function if set

func (*FormButton) InputHandler

func (f *FormButton) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler handles the keyboard input

func (*FormButton) Primitive

func (f *FormButton) Primitive() tview.Primitive

Primitive returns the this object with the tview.Primitive interface

func (*FormButton) SetFocusedFunc

func (f *FormButton) SetFocusedFunc(ff *FocusFlex, focused func()) *FormButton

SetFocusedFunc sets the function which will be called when this FormButton receives the focus

func (*FormButton) SetNext

func (f *FormButton) SetNext(next Tabable)

SetNext sets the next tview.Primitive in the navigation order

func (*FormButton) SetPrev

func (f *FormButton) SetPrev(prev Tabable)

SetPrev sets the previous tview.Primitive in the navigation order

type FormField

type FormField struct {
	*tview.Box
	Input       *focusedInputField
	Button      *focusedButton
	ButtonFirst bool
	// contains filtered or unexported fields
}

FormField consists of an input fiels and a button.

func NewFileField

func NewFileField(label string, pages *FocusPages) *FormField

NewFileField returns a textfield with a file

func NewPasteField

func NewPasteField(label string) *FormField

NewPasteField returns a textfield with a past button

func (*FormField) After

func (f *FormField) After(previous Tabable) *FormField

After connects this button with the previous Tabable

func (*FormField) Blur

func (f *FormField) Blur()

Blur forwards the call to the Inputform and Button

func (*FormField) Draw

func (f *FormField) Draw(screen tcell.Screen)

Draw draws this primitive

func (*FormField) Focus

func (f *FormField) Focus(delegate func(p tview.Primitive))

Focus sets the focus to the InputForm or Button

func (*FormField) GetText

func (f *FormField) GetText() string

GetText returns the text of the InputField

func (*FormField) HasFocus

func (f *FormField) HasFocus() bool

HasFocus returns true if this primitve has the focus

func (*FormField) InputHandler

func (f *FormField) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler handles the keyboard input

func (*FormField) MouseHandler

func (f *FormField) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler handles mouse input

func (*FormField) Primitive

func (f *FormField) Primitive() tview.Primitive

Primitive returns the this object with the tview.Primitive interface

func (*FormField) SetFocusedFunc

func (f *FormField) SetFocusedFunc(ff *FocusFlex, focused ...func()) *FormField

SetFocusedFunc sets the Focused functions for the InpurtForm and the Button

func (*FormField) SetNext

func (f *FormField) SetNext(next Tabable)

SetNext sets the next tview.Primitive in the navigation order

func (*FormField) SetPrev

func (f *FormField) SetPrev(prev Tabable)

SetPrev sets the previous tview.Primitive in the navigation order

func (*FormField) SetText

func (f *FormField) SetText(text string) *FormField

SetText sets the text

type TabButton

type TabButton struct {
	*tview.Button
	// contains filtered or unexported fields
}

TabButton extends the tview.Button with a tab navigatioin

func NewTabButton

func NewTabButton(label string) *TabButton

NewTabButton creates an initialized TabButton object

func (*TabButton) InputHandler

func (t *TabButton) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler captures the tab events, other events are handled by the orignial InputHandler

func (*TabButton) Primitive

func (t *TabButton) Primitive() tview.Primitive

Primitive returns the this object with the tview.Primitive interface

func (*TabButton) SetNext

func (t *TabButton) SetNext(next Tabable)

SetNext sets the next tview.Primitive in the navigation order

func (*TabButton) SetPrev

func (t *TabButton) SetPrev(prev Tabable)

SetPrev sets the previous tview.Primitive in the navigation order

type Tabable

type Tabable interface {
	SetNext(Tabable)
	SetPrev(Tabable)
	Primitive() tview.Primitive
}

Tabable should be implemented by components supporting the tab key for navigation

Jump to

Keyboard shortcuts

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