def _showDeclaration(self, event, declFile, declPlace): rem = remgr.RichEditorManager() openFiles = rem.getOpenFileNames() if not declFile in openFiles: pub.sendMessage(constants.PUB_ADDFILE, fullname=declFile) rem.showRichEditorForFile(declFile) fre = rem.getFocusedRichEditor() if fre is not None: fre.styledText.GotoLine(declPlace[0]-1) fre.styledText.SetFocus()
def removeContext(self, context): """remove a context from the tree""" logging.info("Removing context %s", context) contextNode = self.getContextNode(context) richEditorManager = remgr.RichEditorManager() fullnames = [ self.tree.GetItemPyData(fileNode)[FULLNAME] for fileNode in self.getChildren(contextNode) ] assert len(fullnames) > 0 if richEditorManager.ensureFilesAreSavedToPoceed(fullnames): for fullname in fullnames: richEditorManager.handleCloseFileRequest(fullname)
def onCloseFile(event): """close an open file""" logging.debug("Starting") richEditor = remgr.RichEditorManager().getFocusedRichEditor() if richEditor is not None: canClose = True if richEditor.styledText.GetModify(): choice = self.askYesNoCancelQuestion( "This file has been modified. Save changes?") if choice == wx.ID_YES: richEditor.saveFile() elif choice == wx.ID_CANCEL: canClose = False if canClose: fullname = richEditor.getFilename() util.closeFile(fullname) else: logging.warn("No rich editor is open")
def onFindText(event): """called to handle 'find text' request""" logging.debug("Starting") #TODO: Fix Find/Replace in a good manner. focus = util.getMainFrame().FindFocus() #page = remgr.RichEditorManager().getFocusedRichEditor() if focus is not None and (isinstance(focus, wx.TextCtrl) or isinstance(focus, stc.StyledTextCtrl)): pass else: focus = remgr.RichEditorManager().getFocusedRichEditor() if focus is not None: focus = focus.styledText if focus is not None: selected = focus.GetSelectedText() if selected is None: selected = "" FindReplaceManager(selected, EMPTY_STRING).show()
def onSaveAsFile(event): """save the active file (an active file is one whose tab is visible)""" logging.debug("Starting") frame = util.getMainFrame() filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION dialog = wx.FileDialog(frame, "Save File As...", wildcard=filters, style=wx.SAVE | wx.OVERWRITE_PROMPT) if dialog.ShowModal() == wx.ID_OK: fullname = dialog.GetPath() if not fullname.endswith(PVS_EXTENSION): fullname = fullname + PVS_EXTENSION logging.info("Saving file as %s", fullname) richEditor = remgr.RichEditorManager().getFocusedRichEditor() if richEditor is not None: richEditor.saveFile(fullname) else: logging.info("Nothing was selected.") dialog.Destroy()
def onSaveFile(event): """save the active file (an active file is one whose tab is visible)""" logging.debug("Starting") richEditor = remgr.RichEditorManager().getFocusedRichEditor() if richEditor is not None: richEditor.saveFile()
def onTypecheck(event): """called to handle 'typecheck' request""" logging.debug("Starting") fullname = remgr.RichEditorManager().getFocusedRichEditor().getFilename() pvscomm.PVSCommandManager().typecheck(fullname)
def onSaveAllFiles(event): """save all the open files""" logging.debug("Starting") remgr.RichEditorManager().saveAllFiles()
def getActiveFileName(): return remgr.RichEditorManager().getFocusedRichEditor().getFilename()
def onCloseFile(self, event): """onCloseFile is called when the user selects Close in the context menu""" nodeFullname = self.getSelectedNodeData()[FULLNAME] remgr.RichEditorManager().handleCloseFileRequest(nodeFullname)