tilman

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 4 Imported by: 0

README

Tilman - go Tile Window Manager for terminal UIs

Tilman is a basic yet powerfull tile window manager in go for terminal-based user interfaces that plugs into tview

Documentation

Index

Constants

View Source
const (
	AutoSize = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClipRegion

type ClipRegion struct {
	tcell.Screen
	// contains filtered or unexported fields
}

ClipRegion implements tcell.Screen and only allows setting content within a defined region

func NewClipRegion

func NewClipRegion(screen tcell.Screen, x, y, width, height int) *ClipRegion

New creates a new clipped screen with the given rectangular coordinates

func (*ClipRegion) Clear

func (cr *ClipRegion) Clear()

Clear clears the clipped region

func (*ClipRegion) Fill

func (cr *ClipRegion) Fill(ch rune, style tcell.Style)

Fill implements tcell.Screen.Fill

func (*ClipRegion) InRect

func (cr *ClipRegion) InRect(x, y int) bool

InRect returns true if the given coordinates are within this clipped region

func (*ClipRegion) SetCell

func (cr *ClipRegion) SetCell(x int, y int, style tcell.Style, ch ...rune)

SetCell is an older API, and will be removed. Please use SetContent instead; SetCell is implemented in terms of SetContent.

func (*ClipRegion) SetContent

func (cr *ClipRegion) SetContent(x int, y int, mainc rune, combc []rune, style tcell.Style)

SetContent sets the contents of the given cell location. If the coordinates are out of range, then the operation is ignored.

The first rune is the primary non-zero width rune. The array that follows is a possible list of combining characters to append, and will usually be nil (no combining characters.)

The results are not displayed until Show() or Sync() is called.

Note that wide (East Asian full width) runes occupy two cells, and attempts to place character at next cell to the right will have undefined effects. Wide runes that are printed in the last column will be replaced with a single width space on output.

func (*ClipRegion) ShowCursor

func (cr *ClipRegion) ShowCursor(x int, y int)

ShowCursor is used to display the cursor at a given location. If the coordinates -1, -1 are given or are otherwise outside the dimensions of the screen, the cursor will be hidden.

type Direction

type Direction int
const (
	VerticalLayout Direction = iota
	HorizontalLayout
)

type Item

type Item struct {
	tview.Primitive

	Size int
}

type Layout

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

func NewLayout

func NewLayout() *Layout

func (*Layout) AddItem

func (l *Layout) AddItem(p tview.Primitive, size int) *Layout

func (*Layout) Blur

func (l *Layout) Blur()

func (*Layout) ClearItems

func (l *Layout) ClearItems() *Layout

func (*Layout) CountItems

func (l *Layout) CountItems() int

func (*Layout) Draw

func (l *Layout) Draw(screen tcell.Screen)

func (*Layout) Focus

func (l *Layout) Focus(delegate func(p tview.Primitive))

func (*Layout) GetBackgroundColor

func (l *Layout) GetBackgroundColor() tcell.Color

GetBackgroundColor returns the layout's background color.

func (*Layout) GetDirection

func (l *Layout) GetDirection() Direction

func (*Layout) GetInputCapture

func (l *Layout) GetInputCapture() func(event *tcell.EventKey) *tcell.EventKey

GetInputCapture returns the function installed with SetInputCapture() or nil if no such function has been installed.

func (*Layout) GetItem

func (l *Layout) GetItem(i int) *Item

func (*Layout) GetMouseCapture

func (l *Layout) GetMouseCapture() func(action tview.MouseAction, event *tcell.EventMouse) (tview.MouseAction, *tcell.EventMouse)

GetMouseCapture returns the function installed with SetMouseCapture() or nil if no such function has been installed.

func (*Layout) GetRect

func (l *Layout) GetRect() (int, int, int, int)

func (*Layout) GetSplitterAttributes

func (l *Layout) GetSplitterAttributes() tcell.AttrMask

GetSplitterAttributes returns the splitter's style attributes.

func (*Layout) GetSplitterColor

func (l *Layout) GetSplitterColor() tcell.Color

GetSplitterColor returns the layout's splitter color.

func (*Layout) HasFocus

func (l *Layout) HasFocus() bool

func (*Layout) InRect

func (l *Layout) InRect(x, y int) bool

InRect returns true if the given coordinate is within the bounds of the box's rectangle.

func (*Layout) InputHandler

func (l *Layout) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

func (*Layout) MouseHandler

func (l *Layout) 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 (*Layout) RemoveItem

func (l *Layout) RemoveItem(i int) *Layout

func (*Layout) SetBackgroundColor

func (l *Layout) SetBackgroundColor(color tcell.Color) *Layout

SetBackgroundColor sets the layout's background color.

func (*Layout) SetDirection

func (l *Layout) SetDirection(d Direction) *Layout

func (*Layout) SetInputCapture

func (l *Layout) SetInputCapture(capture func(event *tcell.EventKey) *tcell.EventKey) *Layout

SetInputCapture installs a function which captures key events before they are forwarded to the primitive's default key event handler. This function can then choose to forward that key event (or a different one) to the default handler by returning it. If nil is returned, the default handler will not be called.

Providing a nil handler will remove a previously existing handler.

Note that this function will not have an effect on primitives composed of other primitives, such as Form, Flex, or Grid. Key events are only captured by the primitives that have focus (e.g. InputField) and only one primitive can have focus at a time. Composing primitives such as Form pass the focus on to their contained primitives and thus never receive any key events themselves. Therefore, they cannot intercept key events.

func (*Layout) SetMouseCapture

func (l *Layout) SetMouseCapture(capture func(action tview.MouseAction, event *tcell.EventMouse) (tview.MouseAction, *tcell.EventMouse)) *Layout

SetMouseCapture sets a function which captures mouse events (consisting of the original tcell mouse event and the semantic mouse action) before they are forwarded to the primitive's default mouse event handler. This function can then choose to forward that event (or a different one) by returning it or returning a nil mouse event, in which case the default handler will not be called.

Providing a nil handler will remove a previously existing handler.

func (*Layout) SetRect

func (l *Layout) SetRect(x, y, width, height int)

func (*Layout) SetSplitter

func (l *Layout) SetSplitter(show bool) *Layout

SetSplitter sets the flag indicating whether or not the layout should render a splitters between primitives

func (*Layout) SetSplitterAttributes

func (l *Layout) SetSplitterAttributes(attr tcell.AttrMask) *Layout

SetSplitterAttributes sets the splitter's style attributes. You can combine different attributes using bitmask operations:

layout.SetSplitterAttributes(tcell.AttrUnderline | tcell.AttrBold)

func (*Layout) SetSplitterColor

func (l *Layout) SetSplitterColor(color tcell.Color) *Layout

SetSplitterColor sets the layout's splitter color.

func (*Layout) WrapInputHandler

func (l *Layout) WrapInputHandler(inputHandler func(*tcell.EventKey, func(p tview.Primitive))) func(*tcell.EventKey, func(p tview.Primitive))

WrapInputHandler wraps an input handler (see InputHandler()) with the functionality to capture input (see SetInputCapture()) before passing it on to the provided (default) input handler.

This is only meant to be used by subclassing primitives.

func (*Layout) WrapMouseHandler

func (l *Layout) WrapMouseHandler(mouseHandler func(tview.MouseAction, *tcell.EventMouse, func(p tview.Primitive)) (bool, tview.Primitive)) func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

WrapMouseHandler wraps a mouse event handler (see MouseHandler()) with the functionality to capture mouse events (see SetMouseCapture()) before passing them on to the provided (default) event handler.

This is only meant to be used by subclassing primitives.

type Manager

type Manager struct {
	*tview.Box
	sync.Mutex
	// contains filtered or unexported fields
}

func NewWindowManager

func NewWindowManager() *Manager

func (*Manager) Draw

func (m *Manager) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*Manager) Focus

func (m *Manager) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus

func (*Manager) GetRoot

func (m *Manager) GetRoot() *Layout

func (*Manager) HasFocus

func (m *Manager) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*Manager) InputHandler

func (m *Manager) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns a handler which receives key events when it has focus.

func (*Manager) IsMaximazed

func (m *Manager) IsMaximazed(w *Window) bool

func (*Manager) Maximize

func (m *Manager) Maximize(w *Window) *Manager

func (*Manager) MouseHandler

func (m *Manager) 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 (*Manager) Restore

func (m *Manager) Restore() *Manager

func (*Manager) SetRoot

func (m *Manager) SetRoot(root *Layout) *Manager

type Window

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

Window defines a basic window

func NewWindow

func NewWindow() *Window

func (*Window) AddButton

func (w *Window) AddButton(symbol rune, alignment WindowButtonAlignment, onclick func(w *Window, b *WindowButton)) *Window

AddButton adds a new window button to the title bar

func (*Window) Blur

func (w *Window) Blur()

func (*Window) ClearButtons

func (w *Window) ClearButtons() *Window

func (*Window) CountButtons

func (w *Window) CountButtons() int

CountButtons returns the number of buttons in the window title bar

func (*Window) Draw

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

Draw draws this primitive on to the screen

func (*Window) Focus

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

Focus is called when this primitive receives focus.

func (*Window) GetButton

func (w *Window) GetButton(i int) *WindowButton

GetButton returns the given button

func (*Window) GetRoot

func (w *Window) GetRoot() tview.Primitive

GetRoot returns the primitive that represents the main content of the window

func (*Window) HasBorder

func (w *Window) HasBorder() bool

HasBorder returns true if this window has a border windows without border cannot be resized or dragged by the user

func (*Window) HasFocus

func (w *Window) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*Window) InputHandler

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

InputHandler returns a handler which receives key events when it has focus.

func (*Window) MouseHandler

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

MouseHandler returns a mouse handler for this primitive

func (*Window) RemoveButton

func (w *Window) RemoveButton(i int) *Window

func (*Window) SetBorder

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

SetBorder sets the flag indicating whether or not the box should have a border.

func (*Window) SetRoot

func (w *Window) SetRoot(root tview.Primitive) *Window

SetRoot sets the main content of the window

func (*Window) SetTitle

func (w *Window) SetTitle(text string) *Window

SetTitle sets the window title

type WindowButton

type WindowButton struct {
	Alignment WindowButtonAlignment
	Symbol    rune // icon for the button

	OnClick func(w *Window, b *WindowButton) // callback to be invoked when the button is clicked
	// contains filtered or unexported fields
}

WindowButton represents a button on the window title bar

type WindowButtonAlignment

type WindowButtonAlignment int
const (
	WindowButtonAlignLeft  WindowButtonAlignment = tview.AlignLeft
	WindowButtonAlignRight WindowButtonAlignment = tview.AlignRight
)

Directories

Path Synopsis
demos

Jump to

Keyboard shortcuts

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