Documentation ¶
Overview ¶
Package piv provides the PiView object for the full GUI view of the interactive parser (pi) system.
Index ¶
- Constants
- Variables
- func InitPrefs()
- func OpenPaths()
- func QuitReq() bool
- func SavePaths()
- type PiView
- func (pv *PiView) ApplyPrefs()
- func (pv *PiView) AstTree() *giv.TreeView
- func (pv *PiView) AstTreeToEnd()
- func (pv *PiView) CloseWindowReq() bool
- func (pv *PiView) Config()
- func (pv *PiView) ConfigSplitView()
- func (pv *PiView) ConfigStatusBar()
- func (pv *PiView) ConfigTextView(ly *gi.Layout, out bool) *giv.TextView
- func (pv *PiView) ConfigToolbar()
- func (ge *PiView) ConnectEvents2D()
- func (pv *PiView) CurPanel() int
- func (pv *PiView) EditPassTwo()
- func (pv *PiView) EditTrace()
- func (pv *PiView) FileNodeClosed(fn *giv.FileNode, tvn *giv.FileTreeView)
- func (pv *PiView) FileNodeOpened(fn *giv.FileNode, tvn *giv.FileTreeView)
- func (pv *PiView) FocusNextPanel()
- func (pv *PiView) FocusOnPanel(panel int) bool
- func (pv *PiView) FocusPrevPanel()
- func (pv *PiView) GetPrefs()
- func (pv *PiView) IsConfiged() bool
- func (pv *PiView) IsEmpty() bool
- func (ge *PiView) KeyChordEvent()
- func (pv *PiView) LexAll()
- func (pv *PiView) LexInit()
- func (pv *PiView) LexNext() *lex.Rule
- func (pv *PiView) LexNextLine() *lex.Rule
- func (pv *PiView) LexStopped()
- func (pv *PiView) LexTree() *giv.TreeView
- func (pv *PiView) MainTabByName(label string) gi.Node2D
- func (pv *PiView) MainTabByNameTry(label string) (gi.Node2D, error)
- func (pv *PiView) MainTabTextViewByName(tabnm string) (*giv.TextView, bool)
- func (pv *PiView) MainTabs() *gi.TabView
- func (pv *PiView) MonitorOut()
- func (pv *PiView) NewProj() (*gi.Window, *PiView)
- func (pv *PiView) OpenConsoleTab()
- func (pv *PiView) OpenLexTab()
- func (pv *PiView) OpenOutTab()
- func (pv *PiView) OpenParseTab()
- func (pv *PiView) OpenParser(filename gi.FileName)
- func (pv *PiView) OpenProj(filename gi.FileName) *PiView
- func (pv *PiView) OpenRecent(filename gi.FileName)
- func (pv *PiView) OpenTest(filename gi.FileName)
- func (pv *PiView) OpenTestTextTab()
- func (pv *PiView) ParseAll()
- func (pv *PiView) ParseInit()
- func (pv *PiView) ParseNext() *parse.Rule
- func (pv *PiView) ParseStopped()
- func (pv *PiView) ParseTree() *giv.TreeView
- func (pv *PiView) PassTwo()
- func (ge *PiView) PiViewKeys(kt *key.ChordEvent)
- func (pv *PiView) RecycleMainTab(label string, typ reflect.Type, sel bool) gi.Node2D
- func (pv *PiView) RecycleMainTabTextView(label string, sel bool, out bool) *giv.TextView
- func (pv *PiView) Render2D()
- func (pv *PiView) SaveParser()
- func (pv *PiView) SaveParserAs(filename gi.FileName)
- func (pv *PiView) SaveProj()
- func (pv *PiView) SaveProjAs(filename gi.FileName)
- func (pv *PiView) SaveTestAs(filename gi.FileName)
- func (pv *PiView) SelectLexRule(rule *lex.Rule)
- func (pv *PiView) SelectMainTabByName(label string) gi.Node2D
- func (pv *PiView) SelectParseRule(rule *parse.Rule)
- func (pv *PiView) SetChanged()
- func (pv *PiView) SetStatus(msg string)
- func (pv *PiView) SplitView() *gi.SplitView
- func (pv *PiView) SplitViewConfig() kit.TypeAndNameList
- func (pv *PiView) StatusBar() *gi.Frame
- func (pv *PiView) StatusLabel() *gi.Label
- func (pv *PiView) StructView() *giv.StructView
- func (pv *PiView) TestTextView() (*giv.TextView, bool)
- func (pv *PiView) ToolBar() *gi.ToolBar
- func (pv *PiView) UpdtLexBuf()
- func (pv *PiView) UpdtParseBuf()
- func (pv *PiView) ViewNode(tv *giv.TreeView)
- func (pv *PiView) ViewParseState()
- type ProjPrefs
Constants ¶
const ( LexRulesIdx = iota ParseRulesIdx StructViewIdx AstOutIdx MainTabsIdx )
These are then the fixed indices of the different elements in the splitview
Variables ¶
var KiT_PiView = kit.Types.AddType(&PiView{}, PiViewProps)
var KiT_ProjPrefs = kit.Types.AddType(&ProjPrefs{}, nil)
var PiViewProps = ki.Props{ "EnumType:Flag": gi.KiT_NodeFlags, "background-color": &gi.Prefs.Colors.Background, "color": &gi.Prefs.Colors.Font, "max-width": -1, "max-height": -1, "#title": ki.Props{ "max-width": -1, "horizontal-align": gist.AlignCenter, "vertical-align": gist.AlignTop, }, "ToolBar": ki.PropSlice{ {"SaveProj", ki.Props{ "shortcut": gi.KeyFunMenuSave, "label": "Save Project", "desc": "Save GoPi project file to standard JSON-formatted file", "updtfunc": giv.ActionUpdateFunc(func(pvi interface{}, act *gi.Action) { pv := pvi.(*PiView) act.SetActiveState(pv.Prefs.ProjFile != "") }), }}, {"sep-parse", ki.BlankProp{}}, {"OpenParser", ki.Props{ "label": "Open Parser...", "icon": "file-open", "desc": "Open lexer and parser rules from standard JSON-formatted file", "Args": ki.PropSlice{ {"File Name", ki.Props{ "default-field": "Prefs.ParserFile", "ext": ".pi", }}, }, }}, {"SaveParser", ki.Props{ "icon": "file-save", "desc": "Save lexer and parser rules from file standard JSON-formatted file", "updtfunc": giv.ActionUpdateFunc(func(pvi interface{}, act *gi.Action) { pv := pvi.(*PiView) act.SetActiveStateUpdt(pv.Prefs.ParserFile != "") }), }}, {"SaveParserAs", ki.Props{ "label": "Save Parser As...", "icon": "file-save", "desc": "Save As lexer and parser rules from file standard JSON-formatted file", "Args": ki.PropSlice{ {"File Name", ki.Props{ "default-field": "Prefs.ParserFile", "ext": ".pi", }}, }, }}, {"sep-file", ki.BlankProp{}}, {"OpenTest", ki.Props{ "label": "Open Test", "icon": "file-open", "desc": "Open test file", "Args": ki.PropSlice{ {"File Name", ki.Props{ "default-field": "Prefs.TestFile", }}, }, }}, {"SaveTestAs", ki.Props{ "label": "Save Test As", "icon": "file-save", "desc": "Save current test file as", "Args": ki.PropSlice{ {"File Name", ki.Props{ "default-field": "Prefs.TestFile", }}, }, }}, {"sep-lex", ki.BlankProp{}}, {"LexInit", ki.Props{ "icon": "update", "desc": "Init / restart lexer", }}, {"LexNext", ki.Props{ "icon": "play", "desc": "do next single step of lexing", }}, {"LexNextLine", ki.Props{ "icon": "play", "desc": "do next line of lexing", }}, {"LexAll", ki.Props{ "icon": "fast-fwd", "desc": "do all remaining lexing", }}, {"sep-passtwo", ki.BlankProp{}}, {"EditPassTwo", ki.Props{ "icon": "edit", "desc": "edit the settings of the PassTwo -- second pass after lexing", }}, {"PassTwo", ki.Props{ "icon": "play", "desc": "perform second pass after lexing -- computes nesting depth globally and finds EOS tokens", }}, {"sep-parse", ki.BlankProp{}}, {"EditTrace", ki.Props{ "icon": "edit", "desc": "edit the parse tracing options for seeing how the parsing process is working", }}, {"ParseInit", ki.Props{ "icon": "update", "desc": "initialize parser -- this also performs lexing, PassTwo, assuming that is all working", }}, {"ParseNext", ki.Props{ "icon": "play", "desc": "do next step of parsing", }}, {"ParseAll", ki.Props{ "icon": "fast-fwd", "desc": "do remaining parsing", }}, {"ViewParseState", ki.Props{ "icon": "edit", "desc": "view the parser state, including symbols recorded etc", }}, }, "MainMenu": ki.PropSlice{ {"AppMenu", ki.BlankProp{}}, {"File", ki.PropSlice{ {"OpenRecent", ki.Props{ "submenu": &SavedPaths, "Args": ki.PropSlice{ {"File Name", ki.Props{}}, }, }}, {"OpenProj", ki.Props{ "shortcut": gi.KeyFunMenuOpen, "label": "Open Project...", "desc": "open a GoPi project that has full settings", "Args": ki.PropSlice{ {"File Name", ki.Props{ "default-field": "Prefs.ProjFile", "ext": ".pip", }}, }, }}, {"NewProj", ki.Props{ "shortcut": gi.KeyFunMenuNew, "label": "New Project...", "desc": "create a new project", }}, {"SaveProj", ki.Props{ "shortcut": gi.KeyFunMenuSave, "label": "Save Project", "desc": "Save GoPi project file to standard JSON-formatted file", "updtfunc": giv.ActionUpdateFunc(func(pvi interface{}, act *gi.Action) { pv := pvi.(*PiView) act.SetActiveState(pv.Prefs.ProjFile != "") }), }}, {"SaveProjAs", ki.Props{ "shortcut": gi.KeyFunMenuSaveAs, "label": "Save Project As...", "desc": "Save GoPi project to file standard JSON-formatted file", "Args": ki.PropSlice{ {"File Name", ki.Props{ "default-field": "Prefs.ProjFile", "ext": ".pip", }}, }, }}, {"sep-parse", ki.BlankProp{}}, {"OpenParser", ki.Props{ "shortcut": gi.KeyFunMenuOpenAlt1, "label": "Open Parser...", "desc": "Open lexer and parser rules from standard JSON-formatted file", "Args": ki.PropSlice{ {"File Name", ki.Props{ "default-field": "Prefs.ParserFile", "ext": ".pi", }}, }, }}, {"SaveParser", ki.Props{ "shortcut": gi.KeyFunMenuSaveAlt, "desc": "Save lexer and parser rules to file standard JSON-formatted file", "updtfunc": giv.ActionUpdateFunc(func(pvi interface{}, act *gi.Action) { pv := pvi.(*PiView) act.SetActiveState(pv.Prefs.ParserFile != "") }), }}, {"SaveParserAs", ki.Props{ "label": "Save Parser As...", "desc": "Save As lexer and parser rules to file standard JSON-formatted file", "Args": ki.PropSlice{ {"File Name", ki.Props{ "default-field": "Prefs.ParserFile", "ext": ".pi", }}, }, }}, {"sep-close", ki.BlankProp{}}, {"Close Window", ki.BlankProp{}}, {"OpenConsoleTab", ki.Props{}}, }}, {"Edit", "Copy Cut Paste"}, {"Window", "Windows"}, }, }
var SavedPaths gi.FilePaths
SavedPaths is a slice of strings that are file paths
var SavedPathsFileName = "gopi_saved_paths.json"
SavedPathsFileName is the name of the saved file paths file in GoPi prefs directory
Functions ¶
Types ¶
type PiView ¶
type PiView struct { gi.Frame Parser pi.Parser `desc:"the parser we are viewing"` Prefs ProjPrefs `desc:"project preferences -- this IS the project file"` Changed bool `json:"-" desc:"has the root changed? we receive update signals from root for changes"` FileState pi.FileState `json:"-" desc:"our own dedicated filestate for controlled parsing"` TestBuf giv.TextBuf `json:"-" desc:"test file buffer"` OutBuf giv.TextBuf `json:"-" desc:"output buffer -- shows all errors, tracing"` LexBuf giv.TextBuf `json:"-" desc:"buffer of lexified tokens"` ParseBuf giv.TextBuf `json:"-" desc:"buffer of parse info"` KeySeq1 key.Chord `desc:"first key in sequence if needs2 key pressed"` OutMonRunning bool `json:"-" desc:"is the output monitor running?"` OutMonMu sync.Mutex `json:"-" desc:"mutex for updating, checking output monitor run status"` }
PiView provides the interactive GUI view for constructing and testing the lexer and parser
func (*PiView) ApplyPrefs ¶
func (pv *PiView) ApplyPrefs()
ApplyPrefs applies project-level prefs (e.g., after opening)
func (*PiView) CloseWindowReq ¶
CloseWindowReq is called when user tries to close window -- we automatically save the project if it already exists (no harm), and prompt to save open files -- if this returns true, then it is OK to close -- otherwise not
func (*PiView) ConfigSplitView ¶
func (pv *PiView) ConfigSplitView()
ConfigSplitView configures the SplitView.
func (*PiView) ConfigStatusBar ¶
func (pv *PiView) ConfigStatusBar()
ConfigStatusBar configures statusbar with label
func (*PiView) ConfigTextView ¶
ConfigTextView configures text view
func (*PiView) ConfigToolbar ¶
func (pv *PiView) ConfigToolbar()
ConfigToolbar adds a PiView toolbar.
func (*PiView) ConnectEvents2D ¶
func (ge *PiView) ConnectEvents2D()
func (*PiView) EditPassTwo ¶
func (pv *PiView) EditPassTwo()
EditPassTwo shows the PassTwo settings to edit -- does nest depth and finds the EOS end-of-statements
func (*PiView) EditTrace ¶
func (pv *PiView) EditTrace()
EditTrace shows the parse.Trace options for detailed tracing output
func (*PiView) FileNodeClosed ¶
func (pv *PiView) FileNodeClosed(fn *giv.FileNode, tvn *giv.FileTreeView)
func (*PiView) FileNodeOpened ¶
func (pv *PiView) FileNodeOpened(fn *giv.FileNode, tvn *giv.FileTreeView)
func (*PiView) FocusNextPanel ¶
func (pv *PiView) FocusNextPanel()
FocusNextPanel moves the keyboard focus to the next panel to the right
func (*PiView) FocusOnPanel ¶
FocusOnPanel moves keyboard focus to given panel -- returns false if nothing at that tab
func (*PiView) FocusPrevPanel ¶
func (pv *PiView) FocusPrevPanel()
FocusPrevPanel moves the keyboard focus to the previous panel to the left
func (*PiView) GetPrefs ¶
func (pv *PiView) GetPrefs()
GetPrefs gets the current values of things for prefs
func (*PiView) IsConfiged ¶ added in v0.5.8
IsConfiged returns true if the view is fully configured
func (*PiView) KeyChordEvent ¶
func (ge *PiView) KeyChordEvent()
func (*PiView) LexAll ¶
func (pv *PiView) LexAll()
LexAll does all remaining lexing until end or error
func (*PiView) LexInit ¶
func (pv *PiView) LexInit()
LexInit initializes / restarts lexing process for current test file
func (*PiView) LexNextLine ¶
LexLine does next line of lexing
func (*PiView) LexStopped ¶
func (pv *PiView) LexStopped()
LexStopped tells the user why the lexer stopped
func (*PiView) MainTabByName ¶
MainTabByName returns a MainTabs (first set of tabs) tab with given name
func (*PiView) MainTabByNameTry ¶ added in v0.5.7
MainTabByNameTry returns a MainTabs (first set of tabs) tab with given name, err if not found
func (*PiView) MainTabTextViewByName ¶
MainTabTextViewByName returns the textview for given main tab, if it exists
func (*PiView) MonitorOut ¶
func (pv *PiView) MonitorOut()
MonitorOut sets up the OutBuf monitor -- must call as separate goroutine using go
func (*PiView) OpenConsoleTab ¶
func (pv *PiView) OpenConsoleTab()
OpenConsoleTab opens a main tab displaying console output (stdout, stderr)
func (*PiView) OpenLexTab ¶
func (pv *PiView) OpenLexTab()
OpenLexTab opens a main tab displaying lexer output
func (*PiView) OpenOutTab ¶
func (pv *PiView) OpenOutTab()
OpenOutTab opens a main tab displaying all output
func (*PiView) OpenParseTab ¶
func (pv *PiView) OpenParseTab()
OpenParseTab opens a main tab displaying parser output
func (*PiView) OpenParser ¶
OpenParser opens lexer and parser rules to current filename, in a standard JSON-formatted file
func (*PiView) OpenProj ¶
OpenProj opens lexer and parser rules to current filename, in a standard JSON-formatted file if current is not empty, opens in a new window
func (*PiView) OpenRecent ¶
OpenRecent opens a recently-used project
func (*PiView) OpenTestTextTab ¶
func (pv *PiView) OpenTestTextTab()
OpenTestTextTab opens a main tab displaying test text
func (*PiView) ParseAll ¶
func (pv *PiView) ParseAll()
ParseAll does all remaining lexing until end or error
func (*PiView) ParseInit ¶
func (pv *PiView) ParseInit()
ParseInit initializes / restarts lexing process for current test file
func (*PiView) ParseStopped ¶
func (pv *PiView) ParseStopped()
ParseStopped tells the user why the lexer stopped
func (*PiView) PassTwo ¶
func (pv *PiView) PassTwo()
PassTwo does the second pass after lexing, per current settings
func (*PiView) PiViewKeys ¶
func (ge *PiView) PiViewKeys(kt *key.ChordEvent)
func (*PiView) RecycleMainTab ¶ added in v0.5.11
RecycleMainTab returns a MainTabs (first set of tabs) tab with given name, first by looking for an existing one, and if not found, making a new one with widget of given type. if sel, then select it. returns widget
func (*PiView) RecycleMainTabTextView ¶ added in v0.5.11
RecycleMainTabTextView returns a MainTabs (first set of tabs) tab with given name, first by looking for an existing one, and if not found, making a new one with a Layout and then a TextView in it. if sel, then select it. returns widget
func (*PiView) SaveParser ¶
func (pv *PiView) SaveParser()
SaveParser saves lexer and parser rules to current filename, in a standard JSON-formatted file
func (*PiView) SaveParserAs ¶
SaveParserAs saves lexer and parser rules to current filename, in a standard JSON-formatted file
func (*PiView) SaveProj ¶
func (pv *PiView) SaveProj()
SaveProj saves project prefs to current filename, in a standard JSON-formatted file also saves the current parser
func (*PiView) SaveProjAs ¶
SaveProjAs saves lexer and parser rules to current filename, in a standard JSON-formatted file also saves the current parser
func (*PiView) SaveTestAs ¶
SaveTestAs saves the test file as..
func (*PiView) SelectLexRule ¶
SelectLexRule selects given lex rule in Lexer
func (*PiView) SelectMainTabByName ¶
SelectMainTabByName Selects given main tab, and returns all of its contents as well.
func (*PiView) SelectParseRule ¶
SelectParseRule selects given lex rule in Parser
func (*PiView) SetChanged ¶
func (pv *PiView) SetChanged()
func (*PiView) SetStatus ¶
SetStatus updates the statusbar label with given message, along with other status info
func (*PiView) SplitViewConfig ¶
func (pv *PiView) SplitViewConfig() kit.TypeAndNameList
SplitViewConfig returns a TypeAndNameList for configuring the SplitView
func (*PiView) StatusLabel ¶
StatusLabel returns the statusbar label widget
func (*PiView) StructView ¶
func (pv *PiView) StructView() *giv.StructView
StructView returns the StructView for editing rules
func (*PiView) TestTextView ¶
TextTextView returns the textview for TestBuf TextView
func (*PiView) UpdtLexBuf ¶
func (pv *PiView) UpdtLexBuf()
UpdtLexBuf sets the LexBuf to current lex content
func (*PiView) UpdtParseBuf ¶
func (pv *PiView) UpdtParseBuf()
UpdtParseBuf sets the ParseBuf to current parse rule output
type ProjPrefs ¶
type ProjPrefs struct { ProjFile gi.FileName `desc:"filename for project (i.e, these preference)"` ParserFile gi.FileName `desc:"filename for parser"` TestFile gi.FileName `desc:"the file for testing"` TraceOpts parse.TraceOpts `desc:"the options for tracing parsing"` }
ProjPrefs are the preferences for saving for a project -- this IS the project file