databrowser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: BSD-3-Clause Imports: 34 Imported by: 0

README

databrowser

  • metadata must be assembled by the user into a .toml file per data directory with the values, which can be assembled from other files in the directory etc.

  • maybe a master top-level .toml with the config for the tables with the column names

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MapTypes = map[reflect.Value][]reflect.Type{}

MapTypes variable contains a map of functions which have an interface{} as parameter but do something special if the parameter implements a given interface.

View Source
var Symbols = map[string]map[string]reflect.Value{}

Symbols variable stores the map of stdlib symbols per package.

Functions

func CleanCatTSV

func CleanCatTSV(filename string, sorts []string) error

CleanCatTSV cleans a TSV file formed by concatenating multiple files together. Removes redundant headers and then sorts by given set of columns

func FirstComment

func FirstComment(sc string) string

FirstComment returns the first comment lines from given .cosh file, which is used to set the tooltip for scripts.

func IsTableFile

func IsTableFile(fname string) bool

func NewDiffBrowserDirs

func NewDiffBrowserDirs(pathA, pathB string)

NewDiffBrowserDirs returns a new diff browser for files that differ within the two given directories. Excludes Job and .tsv data files.

func PromptOKCancel

func PromptOKCancel(ctx core.Widget, prompt string, fun func())

PromptOKCancel prompts the user for whether to do something, calling the given function if the user clicks OK.

func PromptString

func PromptString(ctx core.Widget, str string, prompt string, fun func(s string))

PromptString prompts the user for a string value (initial value given), calling the given function if the user clicks OK.

func PromptStruct

func PromptStruct(ctx core.Widget, stru any, prompt string, fun func())

PromptStruct prompts the user for the values in given struct (pass a pointer), calling the given function if the user clicks OK.

func TrimOrderPrefix

func TrimOrderPrefix(s string) string

TrimOrderPrefix trims any optional #- prefix from given string, used for ordering items by name.

Types

type Browser

type Browser struct {
	core.Frame

	// DataRoot is the path to the root of the data to browse
	DataRoot string

	// StartDir is the starting directory, where the numbers app
	// was originally started.
	StartDir string

	// ScriptsDir is the directory containing scripts for toolbar actions.
	// It defaults to DataDir/dbscripts
	ScriptsDir string

	// Scripts
	Scripts map[string]string `set:"-"`

	// ScriptInterp is the interpreter to use for running Browser scripts
	ScriptInterp *numshell.Interpreter `set:"-"`
}

Browser is a data browser, for browsing data typically organized into separate directories, with .cosh Scripts as toolbar actions to perform regular tasks on the data. Scripts are ordered alphabetically and any leading #- prefix is automatically removed from the label, so you can use numbers to specify a custom order.

var TheBrowser *Browser

TheBrowser is the current browser, which is valid immediately after NewBrowserWindow where it is used to get a local variable for subsequent use.

func NewBrowser

func NewBrowser(parent ...tree.Node) *Browser

NewBrowser returns a new Browser with the given optional parent: Browser is a data browser, for browsing data typically organized into separate directories, with .cosh Scripts as toolbar actions to perform regular tasks on the data. Scripts are ordered alphabetically and any leading #- prefix is automatically removed from the label, so you can use numbers to specify a custom order.

func NewBrowserWindow

func NewBrowserWindow(dataDir string) *Browser

NewBrowserWindow opens a new data Browser for given data directory. By default the scripts for this data directory are located in dbscripts relative to the data directory.

func ParentBrowser

func ParentBrowser(tn tree.Node) (*Browser, bool)

ParentBrowser returns the Browser parent of given node

func (*Browser) FileNodeOpened

func (br *Browser) FileNodeOpened(fn *filetree.Node)

func (*Browser) FileNodeSelected

func (br *Browser) FileNodeSelected(fn *filetree.Node)

func (*Browser) FileTree

func (br *Browser) FileTree() *filetree.Tree

func (*Browser) FormatTableFromCSV

func (br *Browser) FormatTableFromCSV(dt *table.Table, format string) error

FormatTableFromCSV formats the columns of the given table according to the Name, Type values in given format CSV file.

func (*Browser) GetDataRoot

func (br *Browser) GetDataRoot() string

func (*Browser) Init

func (br *Browser) Init()

Init initializes with the data and script directories

func (*Browser) InitInterp

func (br *Browser) InitInterp()

func (*Browser) MakeToolbar

func (br *Browser) MakeToolbar(p *tree.Plan)

func (*Browser) NewTabEditor

func (br *Browser) NewTabEditor(label, filename string) *texteditor.Editor

NewTabEditor opens an editor tab for given file

func (*Browser) NewTabEditorString

func (br *Browser) NewTabEditorString(label, content string) *texteditor.Editor

NewTabEditorString opens an editor tab to display given string

func (*Browser) NewTabPlot

func (br *Browser) NewTabPlot(label string) *plotcore.PlotEditor

NewTabPlot creates a tab with a SubPlot PlotEditor. Set the table and call br.Update after this.

func (*Browser) NewTabTable

func (br *Browser) NewTabTable(label string, slc any) *core.Table

NewTabTable creates a tab with a slice Table. Sets the slice if tab already exists

func (*Browser) NewTabTensorTable

func (br *Browser) NewTabTensorTable(label string) *tensorcore.Table

NewTabTensorTable creates a tab with a tensor table and a tensorcore table. Use tv.Table.Table to get the underlying *table.Table and tv.Table is the table.IndexView onto the table. Use tv.Table.Sequential to update the IndexView to view all of the rows when done updating the Table, and then call br.Update()

func (*Browser) OpenTOML

func (br *Browser) OpenTOML(filename string) (map[string]string, error)

OpenTOML opens given .toml formatted file with name = value entries, as a map.

func (*Browser) RunScript

func (br *Browser) RunScript(snm string)

func (*Browser) SetDataRoot

func (t *Browser) SetDataRoot(v string) *Browser

SetDataRoot sets the [Browser.DataRoot]: DataRoot is the path to the root of the data to browse

func (*Browser) SetScriptsDir

func (t *Browser) SetScriptsDir(v string) *Browser

SetScriptsDir sets the [Browser.ScriptsDir]: ScriptsDir is the directory containing scripts for toolbar actions. It defaults to DataDir/dbscripts

func (*Browser) SetStartDir

func (t *Browser) SetStartDir(v string) *Browser

SetStartDir sets the [Browser.StartDir]: StartDir is the starting directory, where the numbers app was originally started.

func (*Browser) Splits

func (br *Browser) Splits() *core.Splits

func (*Browser) TableWithNewKeyColumns

func (br *Browser) TableWithNewKeyColumns(dt *table.Table, args ...string) *table.Table

TableWithNewKeyColumns returns a copy of the Table with new columns having given values, inserted at the start, used as legend keys etc. args are column name, value pairs.

func (*Browser) Tabs

func (br *Browser) Tabs() *core.Tabs

func (*Browser) UpdateFiles

func (br *Browser) UpdateFiles()

UpdateFiles Updates the file picker with current files in DataRoot,

func (*Browser) UpdateScripts

func (br *Browser) UpdateScripts()

UpdateScripts updates the Scripts and updates the toolbar.

type FileNode

type FileNode struct {
	filetree.Node
}

FileNode is Code version of FileNode for FileTree

func NewFileNode

func NewFileNode(parent ...tree.Node) *FileNode

NewFileNode returns a new FileNode with the given optional parent: FileNode is Code version of FileNode for FileTree

func (*FileNode) ContextMenu

func (fn *FileNode) ContextMenu(m *core.Scene)

func (*FileNode) DiffDirs

func (fn *FileNode) DiffDirs()

DiffDirs displays a browser with differences between two selected directories

func (*FileNode) EditFile

func (fn *FileNode) EditFile()

EditFile pulls up this file in Code

func (*FileNode) EditFiles

func (fn *FileNode) EditFiles()

EditFiles calls EditFile on selected files

func (*FileNode) Init

func (fn *FileNode) Init()

func (*FileNode) OnDoubleClick

func (fn *FileNode) OnDoubleClick(e events.Event)

func (*FileNode) PlotFile

func (fn *FileNode) PlotFile()

PlotFile pulls up this file in Code

func (*FileNode) PlotFiles

func (fn *FileNode) PlotFiles()

PlotFiles calls PlotFile on selected files

Jump to

Keyboard shortcuts

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