app

package
v0.0.0-...-15a64de Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package app implements a terminal user interface (tui)

Index

Constants

View Source
const (

	// InfoDialog is an information dialog type
	InfoDialog = 0 + iota

	// ErrorDialog is an error dialog type
	ErrorDialog
)

Variables

This section is empty.

Functions

func NewChatBox

func NewChatBox(palette map[string]string, title string) *tview.TextView

NewChatBox initializes and returns a 'chatBox' to display incoming chat messages.

func NewChatForm

func NewChatForm(palette map[string]string, title string, acceptFn func(text string), cancelFn func()) *tview.Form

NewChatForm initializes and returns a 'chatForm' component that handles user input and creates a new chat with another user.

func NewChatInput

func NewChatInput(palette map[string]string, title string, handler InputHandler) *tview.InputField

NewChatInput initializes and returns a 'chatInput' component that handles user inputs and forwards chat messages.

func SetTerminalTitle

func SetTerminalTitle(format string, args ...interface{})

SetTerminalTitle sets the Terminal/Console's title

Types

type App

type App struct {
	sync.RWMutex
	*tview.Application
	// contains filtered or unexported fields
}

App is a terminal user inerface (TUI) using tview/tcell to provide an interface for a saltyim.Client (cli) client and provides a multi-chat experience allowing the user to switch between active chats.

func NewApp

func NewApp(cli *saltyim.Client) (*App, error)

NewApp initializes a new tui chat app

func (*App) ChatWith

func (app *App) ChatWith(user string) error

ChatWith sets the current chat with a specified user

func (*App) Run

func (app *App) Run() error

Run runs the main chat loop

type InputHandler

type InputHandler func(message string)

InputHandler handles input from tview.InputField.

type MessageDialog

type MessageDialog struct {
	*tview.Box
	// contains filtered or unexported fields
}

MessageDialog represents message dialog primitive.

func NewMessageDialog

func NewMessageDialog(dtype int) *MessageDialog

NewMessageDialog returns a new message dialog primitive.

func (*MessageDialog) Draw

func (d *MessageDialog) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*MessageDialog) Focus

func (d *MessageDialog) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*MessageDialog) HasFocus

func (d *MessageDialog) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*MessageDialog) InputHandler

func (d *MessageDialog) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns input handler function for this primitive.

func (*MessageDialog) MouseHandler

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

MouseHandler returns the mouse handler for this primitive.

func (*MessageDialog) SetBackgroundColor

func (d *MessageDialog) SetBackgroundColor(color tcell.Color)

SetBackgroundColor sets dialog background color.

func (*MessageDialog) SetBorder

func (d *MessageDialog) SetBorder(status bool)

SetBorder sets dialogs border - no effect always true.

func (*MessageDialog) SetDoneFunc

func (d *MessageDialog) SetDoneFunc(handler func()) *MessageDialog

SetDoneFunc sets callback function for when user clicked on the the button or presses "enter" or "esc".

func (*MessageDialog) SetMessage

func (d *MessageDialog) SetMessage(message string)

SetMessage sets the dialog message to display.

func (*MessageDialog) SetRect

func (d *MessageDialog) SetRect(x, y, width, height int)

SetRect sets rect for this primitive.

func (*MessageDialog) SetTextColor

func (d *MessageDialog) SetTextColor(color tcell.Color)

SetTextColor sets dialog's message text color.

func (*MessageDialog) SetTitle

func (d *MessageDialog) SetTitle(title string)

SetTitle sets title for this primitive.

func (*MessageDialog) SetType

func (d *MessageDialog) SetType(dtype int)

SetType sets dialog type to info or error.

Jump to

Keyboard shortcuts

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