tabs

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tabs contains helper functions for managing tabs in Altid services

go get github.com/altid/server/tabs

example

t, _ := tabs.FromFile("/path/to/a/service")

t.Remove("tab1")
tab := t.Add("tab2")
tab.SetState(Active|Alert)
fmt.Println("%s\n", tab)

Index

Constants

View Source
const (
	Alert uint8 = 1 << iota
	Active
	ClearUnread
)

Track the internal tab state

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager is used to manage tabs accurately for a service

func FromFile

func FromFile(dir string) (*Manager, error)

FromFile returns a Manager with all tabs listed in a file added

func (*Manager) List

func (m *Manager) List() []*Tab

List returns all currently tracked tabs

func (*Manager) Remove

func (m *Manager) Remove(name string) error

Remove a named tab from the internal list

func (*Manager) Tab

func (m *Manager) Tab(name string) *Tab

Tab returns a named tab, creating and appending to our list if none exists

type Tab

type Tab struct {
	Name   string
	Alert  bool
	Active bool
	Unread uint16
}

Tab represents the state of one open buffer

func (*Tab) SetState

func (t *Tab) SetState(mask uint8)

SetState will set Alert and Active flags of a tag based on the mask

func (*Tab) String

func (t *Tab) String() string

Jump to

Keyboard shortcuts

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