tuix

package module
v0.0.0-...-953ce41 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: MPL-2.0 Imports: 2 Imported by: 0

README

Tuix

Tuix is a mouse-oriented terminal user interface library built on tview written in Go. Tuix gives you a desktop and multi-window user experience in the terminal.

This project is experimental and is subject to change!

You can see it in action via ssh: ssh mouse-test@a.cmiller.me

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultWindowManager = defWinMgr

DefaultWindowManager is the default window manager. Most likely when making your own window manager, you'll want to embed this one.

View Source
var DefaultWindowTheme = WindowTheme{
	TitleAlign:               tview.AlignLeft,
	ActiveCaptionTextColor:   tcell.ColorValid + 230,
	ActiveCaptionColor:       tcell.ColorValid + 26,
	InactiveCaptionTextColor: tcell.ColorValid + 15,
	InactiveCaptionColor:     tcell.ColorValid + 239,
}

DefaultWindowTheme is the default desktop theme. These colors were chosen to look decent and readable in most color counts.

Functions

This section is empty.

Types

type Desktop

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

Desktop represents an area where windows go.

func NewDesktop

func NewDesktop() *Desktop

NewDesktop creates a new desktop, it needs to be added to an Application.

func (*Desktop) AddWindow

func (d *Desktop) AddWindow(win *Window) *Desktop

AddWindow adds a window to the desktop. If the window already belongs to a desktop, it is first removed. The window is added to the top of the stack, but it is not activated.

func (*Desktop) BottomWindow

func (d *Desktop) BottomWindow() *Window

BottomWindow gets the bottom window, lowest in z-order.

func (*Desktop) Draw

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

func (*Desktop) Focus

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

func (*Desktop) GetClient

func (d *Desktop) GetClient() tview.Primitive

GetClient gets the client primitive previously set by SetClient, or nil.

func (*Desktop) HasFocus

func (d *Desktop) HasFocus() bool

func (*Desktop) InputHandler

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

func (*Desktop) MouseHandler

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

func (*Desktop) RemoveWindow

func (d *Desktop) RemoveWindow(win *Window) *Desktop

RemoveWindow removes a window from the desktop. The window should be blurred before calling this.

func (*Desktop) SetBorder

func (d *Desktop) SetBorder(show bool) *Desktop

func (*Desktop) SetClient

func (d *Desktop) SetClient(client tview.Primitive, fullSize bool)

SetClient sets a desktop client primitive. A desktop client can be a way to show desktop icons or widgets behind windows. The client can avoid drawing its background to inherit the desktop background.

func (*Desktop) SetRect

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

func (*Desktop) SetWindowManager

func (d *Desktop) SetWindowManager(wm WindowManager)

SetWindowManager changes the WindowManager; see DefaultWindowManager

func (*Desktop) TopWindow

func (d *Desktop) TopWindow() *Window

TopWindow gets the top window, highest in z-order.

type Window

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

Window is a window.

func NewWindow

func NewWindow() *Window

func (*Window) Activate

func (win *Window) Activate(setFocus func(p tview.Primitive)) *Window

func (*Window) BringToFront

func (win *Window) BringToFront() *Window

func (*Window) Desktop

func (win *Window) Desktop(d *Desktop)

Desktop is called by the Desktop, do not call it directly.

func (*Window) Draw

func (win *Window) Draw(screen tcell.Screen)

func (*Window) Focus

func (win *Window) Focus(delegate func(p tview.Primitive))

func (*Window) GetChildren

func (win *Window) GetChildren() []tview.Primitive

func (*Window) GetClient

func (win *Window) GetClient() tview.Primitive

GetClient gets the client primitive previously set by SetClient, or nil.

func (*Window) GetDesktop

func (win *Window) GetDesktop() *Desktop

GetDesktop gets the desktop, or nil.

func (*Window) GetRestoredRect

func (win *Window) GetRestoredRect() (int, int, int, int)

GetRestoredRect gets the rect of the window as if it were restored.

func (*Window) GetState

func (win *Window) GetState() WindowState

func (*Window) GetTitle

func (win *Window) GetTitle() string

func (*Window) HasFocus

func (win *Window) HasFocus() bool

func (*Window) InitWindow

func (win *Window) InitWindow()

InitWindow is called by the Desktop to initialize the window. Do not call directly!

func (*Window) InputHandler

func (win *Window) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

func (*Window) MouseHandler

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

func (*Window) NextWindow

func (win *Window) NextWindow() *Window

func (*Window) PrevWindow

func (win *Window) PrevWindow() *Window

func (*Window) SetAutoActivate

func (win *Window) SetAutoActivate(on bool) *Window

SetAutoActivate determines if the window will automatically activate.

func (*Window) SetAutoPosition

func (win *Window) SetAutoPosition(on bool) *Window

SetAutoPosition sets whether or not the desktop decides where to put the window.

func (*Window) SetBorder

func (win *Window) SetBorder(show bool) *Window

func (*Window) SetClient

func (win *Window) SetClient(client tview.Primitive, fullSize bool)

SetClient sets the window's client primitive.

func (*Window) SetRect

func (win *Window) SetRect(x, y, width, height int)

func (*Window) SetResizable

func (win *Window) SetResizable(on bool) *Window

SetResizable determines if the user is able to resize the window directly.

func (*Window) SetRestoredRect

func (win *Window) SetRestoredRect(x, y, width, height int)

SetRestoredRect sets the rect of the restored window, if it is not restored, it will be the size when it is later restored.

func (*Window) SetState

func (win *Window) SetState(state WindowState) *Window

func (*Window) SetTitle

func (win *Window) SetTitle(title string) *Window

type WindowManager

type WindowManager interface {
	Added(win *Window)        // window added to desktop
	Removed(win *Window)      // window removed from desktop
	Resized(win *Window)      // window resized
	TitleChanged(win *Window) // window title changed
	StateChanged(win *Window) // window state changed
	GetTheme() WindowTheme
	SetTheme(theme WindowTheme)
	DesktopResized(d *Desktop)
	DesktopDraw(d *Desktop, screen tcell.Screen)  // allows drawing a wallpaper, etc
	DefaultDraw(win *Window, screen tcell.Screen) // for a window
	DefaultInputHandler(win *Window, event *tcell.EventKey, setFocus func(p tview.Primitive)) (consumed bool)
	DefaultMouseHandler(win *Window, action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)
}

WindowManager represents the management of windows on a desktop. Note that many Window calls call into the window manager, so if the window manager needs to make changes, it could call back recursively.

type WindowState

type WindowState byte

WindowState is a state of the window, managed by the window manager.

const (
	Restored WindowState = iota
	Minimized
	Maximized
)

type WindowTheme

type WindowTheme struct {
	TitleAlign               int
	ActiveCaptionTextColor   tcell.Color
	ActiveCaptionColor       tcell.Color
	InactiveCaptionTextColor tcell.Color
	InactiveCaptionColor     tcell.Color
}

Directories

Path Synopsis
demos

Jump to

Keyboard shortcuts

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