workspace

package
v5.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const AssociatedUUIDKey = "associated_uuid"

AssociatedUUIDKey is the key used with CloseUUID().

Variables

PrintMgr is our PrintManager singleton.

Functions

func ActiveDockable

func ActiveDockable() unison.Dockable

ActiveDockable returns the currently active dockable in the active window.

func CloseGroup

func CloseGroup(d unison.Dockable) bool

CloseGroup attempts to close any grouped Dockables associated with the given Dockable. Returns false if a dockable refused to close.

func CloseUUID

func CloseUUID(ids map[uuid.UUID]bool) bool

CloseUUID attempts to close any Dockables associated with the given UUIDs. Returns false if a dockable refused to close.

func DisplayNewDockable

func DisplayNewDockable(wnd *unison.Window, dockable unison.Dockable)

DisplayNewDockable adds the Dockable to the dock and gives it the focus.

func DockContainerHoldsExtension

func DockContainerHoldsExtension(dc *unison.DockContainer, ext ...string) bool

DockContainerHoldsExtension returns true if an immediate child of the given DockContainer has a FileBackedDockable with the given extension.

func MayAttemptCloseOfGroup

func MayAttemptCloseOfGroup(d unison.Dockable) bool

MayAttemptCloseOfGroup returns true if the grouped Dockables associated with the given dockable may be closed.

func OpenFile

func OpenFile(wnd *unison.Window, filePath string) (dockable unison.Dockable, wasOpen bool)

OpenFile attempts to open the given file path in the given window, which should contain a workspace. May pass nil for wnd to let it pick the first such window it discovers.

func OpenFiles

func OpenFiles(filePaths []string)

OpenFiles attempts to open the given file paths.

func PromptForDestination

func PromptForDestination[T FileBackedDockable](choices []T) []T

PromptForDestination puts up a modal dialog to choose one or more destinations if choices contains more than one choice. Return an empty list if canceled or there are no selections made.

func RegisterFileTypes

func RegisterFileTypes()

RegisterFileTypes registers special navigator file types.

func SaveDockable

func SaveDockable(d FileBackedDockable, saver func(filePath string) error, setUnmodified func()) bool

SaveDockable attempts to save the contents of the dockable using its existing path.

func SaveDockableAs

func SaveDockableAs(d FileBackedDockable, extension string, saver func(filePath string) error, setUnmodifiedAndNewPath func(filePath string)) bool

SaveDockableAs attempts to save the contents of the dockable, prompting for a new path.

func ShowUnableToLocateWorkspaceError

func ShowUnableToLocateWorkspaceError()

ShowUnableToLocateWorkspaceError displays an error dialog.

Types

type DocumentDock

type DocumentDock struct {
	*unison.Dock
}

DocumentDock holds the document dock.

func NewDocumentDock

func NewDocumentDock() *DocumentDock

NewDocumentDock creates a new DocumentDock.

func (*DocumentDock) Modified

func (d *DocumentDock) Modified() bool

Modified implements unison.Dockable

func (*DocumentDock) Title

func (d *DocumentDock) Title() string

Title implements unison.Dockable

func (*DocumentDock) TitleIcon

func (d *DocumentDock) TitleIcon(suggestedSize unison.Size) unison.Drawable

TitleIcon implements unison.Dockable

func (*DocumentDock) Tooltip

func (d *DocumentDock) Tooltip() string

Tooltip implements unison.Dockable

type FileBackedDockable

type FileBackedDockable interface {
	unison.Dockable
	unison.TabCloser
	BackingFilePath() string
	SetBackingFilePath(p string)
}

FileBackedDockable defines methods a Dockable that is based on a file should implement.

type Navigator struct {
	unison.Panel
	// contains filtered or unexported fields
}

Navigator holds the workspace navigation panel.

func (n *Navigator) ApplyDisclosedPaths(paths []string)

ApplyDisclosedPaths closes all nodes except the ones provided, which are explicitly opened.

func (n *Navigator) ApplySelectedPaths(paths []string)

ApplySelectedPaths replaces the selection with the nodes that match the given paths.

func (n *Navigator) DisclosedPaths() []string

DisclosedPaths returns a list of paths that are currently disclosed.

func (n *Navigator) EventuallyReload()

EventuallyReload calls Reload() after a small delay, collapsing intervening requests to do the same.

func (n *Navigator) InitialFocus()

InitialFocus causes the navigator to focus its initial component.

func (n *Navigator) Modified() bool

Modified implements unison.Dockable

func (n *Navigator) Reload()

Reload the content of the navigator view.

func (n *Navigator) SelectedPaths() []string

SelectedPaths returns a list of paths that are currently selected.

func (n *Navigator) Title() string

Title implements unison.Dockable

func (n *Navigator) TitleIcon(suggestedSize unison.Size) unison.Drawable

TitleIcon implements unison.Dockable

func (n *Navigator) Tooltip() string

Tooltip implements unison.Dockable

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

NavigatorNode holds a library, directory or file.

func NewDirectoryNode

func NewDirectoryNode(nav *Navigator, lib *library.Library, dirPath string, parent *NavigatorNode) *NavigatorNode

NewDirectoryNode creates a new DirectoryNode.

func NewFileNode

func NewFileNode(lib *library.Library, filePath string, parent *NavigatorNode) *NavigatorNode

NewFileNode creates a new FileNode.

func NewLibraryNode

func NewLibraryNode(nav *Navigator, lib *library.Library) *NavigatorNode

NewLibraryNode creates a new library node.

func (n *NavigatorNode) CanHaveChildren() bool

CanHaveChildren implements unison.TableRowData.

func (n *NavigatorNode) CellDataForSort(col int) string

CellDataForSort implements unison.TableRowData.

func (n *NavigatorNode) Children() []*NavigatorNode

Children implements unison.TableRowData.

func (n *NavigatorNode) CloneForTarget(_ unison.Paneler, _ *NavigatorNode) *NavigatorNode

CloneForTarget implements unison.TableRowData. Not permitted at the moment.

func (n *NavigatorNode) ColumnCell(_, col int, foreground, _ unison.Ink, _, _, _ bool) unison.Paneler

ColumnCell implements unison.TableRowData.

func (n *NavigatorNode) IsOpen() bool

IsOpen implements unison.TableRowData.

func (n *NavigatorNode) Match(text string) bool

Match looks for the text in the node and return true if it is present. Note that calls to this method should always pass in text that has already been run through strings.ToLower().

func (n *NavigatorNode) Open(wnd *unison.Window)

Open the node.

func (n *NavigatorNode) Parent() *NavigatorNode

Parent implements unison.TableRowData.

func (n *NavigatorNode) Path() string

Path returns the full path on disk for this node.

func (n *NavigatorNode) Refresh()

Refresh the contents of this node.

func (n *NavigatorNode) SetChildren(_ []*NavigatorNode)

SetChildren implements unison.TableRowData.

func (n *NavigatorNode) SetOpen(open bool)

SetOpen implements unison.TableRowData.

func (n *NavigatorNode) SetParent(_ *NavigatorNode)

SetParent implements unison.TableRowData.

func (n *NavigatorNode) UUID() uuid.UUID

UUID implements unison.TableRowData.

type Workspace

type Workspace struct {
	Window       *unison.Window
	TopDock      *unison.Dock
	Navigator    *Navigator
	DocumentDock *DocumentDock
}

Workspace holds the data necessary to track the Workspace.

func Activate

func Activate(matcher func(d unison.Dockable) bool) (ws *Workspace, dc *unison.DockContainer, found bool)

Activate attempts to locate an existing dockable that 'matcher' returns true for. If found, it will have been activated and focused.

func Any

func Any() *Workspace

Any first tries to return the workspace for the active window. If that fails, then it looks for any available workspace and returns that.

func FromWindow

func FromWindow(wnd *unison.Window) *Workspace

FromWindow returns the Workspace associated with the given Window, or nil.

func FromWindowOrAny

func FromWindowOrAny(wnd *unison.Window) *Workspace

FromWindowOrAny first calls FromWindow(wnd) and if that fails to find a Workspace, then calls Any().

func NewWorkspace

func NewWorkspace(wnd *unison.Window) *Workspace

NewWorkspace creates a new Workspace for the given Window.

func (*Workspace) CurrentlyFocusedDockContainer

func (w *Workspace) CurrentlyFocusedDockContainer() *unison.DockContainer

CurrentlyFocusedDockContainer returns the currently focused DockContainer, if any.

func (*Workspace) LocateDockContainerForExtension

func (w *Workspace) LocateDockContainerForExtension(ext ...string) *unison.DockContainer

LocateDockContainerForExtension searches for the first FileBackedDockable with the given extension and returns its DockContainer.

func (*Workspace) LocateFileBackedDockable

func (w *Workspace) LocateFileBackedDockable(filePath string) FileBackedDockable

LocateFileBackedDockable searches for a FileBackedDockable with the given path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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