Esempio n. 1
0
 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()
Esempio n. 2
0
 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)
Esempio n. 3
0
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")
Esempio n. 4
0
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()
Esempio n. 5
0
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()
Esempio n. 6
0
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()
Esempio n. 7
0
def onTypecheck(event):
    """called to handle 'typecheck' request"""
    logging.debug("Starting")
    fullname = remgr.RichEditorManager().getFocusedRichEditor().getFilename()
    pvscomm.PVSCommandManager().typecheck(fullname)
Esempio n. 8
0
def onSaveAllFiles(event):
    """save all the open files"""
    logging.debug("Starting")
    remgr.RichEditorManager().saveAllFiles()
Esempio n. 9
0
def getActiveFileName():
    return remgr.RichEditorManager().getFocusedRichEditor().getFilename()
Esempio n. 10
0
 def onCloseFile(self, event):
     """onCloseFile is called when the user selects Close in the context menu"""
     nodeFullname = self.getSelectedNodeData()[FULLNAME]
     remgr.RichEditorManager().handleCloseFileRequest(nodeFullname)