コード例 #1
0
 public void SetTabPageText(ICodeFileDocument tp)
 {
     //(ssyy) TODO: ðàçîáðàòüñÿ ñ ýòèì.
     tp.Text        = Path.GetFileName(tp.FileName);
     tp.ToolTipText = tp.FileName;
     if (tp.DocumentChanged && !tp.FromMetadata)
     {
         tp.Text += "*";
     }
     if (tp.FromMetadata)
     {
         tp.Text += string.Format(" [{0}]", PascalABCCompiler.StringResources.Get("VP_MF_FROM_METADATA"));
     }
     if (!ProjectFactory.Instance.ProjectLoaded && !tp.FromMetadata)
     {
         if (tp.Run && (!WorkbenchServiceFactory.DebuggerManager.IsRun(tp.EXEFileName) || !WorkbenchServiceFactory.DebuggerManager.ShowDebugTabs))
         {
             tp.Text += string.Format(" [{0}]", PascalABCCompiler.StringResources.Get("VP_MF_TS_RUN"));
         }
         else
         if (WorkbenchServiceFactory.DebuggerManager.IsRun(tp.EXEFileName, tp.FileName))
         {
             tp.Text += string.Format(" [{0}]", PascalABCCompiler.StringResources.Get("VP_MF_MR_DEBUG"));
         }
     }
     if (tp == ActiveCodeFileDocument && !tp.FromMetadata)
     {
         tp.Text = Convert.ToChar(0x25CF) + tp.Text;//25CF //2022
     }
 }
コード例 #2
0
        public override string GetLine(int lineIndex)
        {
            ICodeFileDocument doc  = (_wb as IWorkbenchDocumentService).CurrentCodeFileDocument;
            string            text = doc.TextEditor.Text;

            text = text.Split('\n')[lineIndex - 1];
            return(text);
        }
コード例 #3
0
 void RunTabsAdd(string name, ICodeFileDocument p)
 {
     name = Tools.FileNameToLower(name);
     if (RunTabs.ContainsKey(name))
     {
         RunTabs[name] = p;
     }
     else
     {
         RunTabs.Add(name, p);
     }
 }
コード例 #4
0
        public override QUT.Gppg.LexLocation GetCursorPosition()
        {
            ICodeFileDocument doc = (_wb as IWorkbenchDocumentService).CurrentCodeFileDocument;
            List <ICSharpCode.TextEditor.Document.ISelection> sel = doc.TextEditor.ActiveTextAreaControl.SelectionManager.SelectionCollection;

            if (sel.Count > 0)
            {
                return(new QUT.Gppg.LexLocation(sel[0].StartPosition.Line + 1, sel[0].StartPosition.Column + 1, sel[0].EndPosition.Line + 1, sel[0].EndPosition.Column + 1));
            }
            ICSharpCode.TextEditor.Caret caret = doc.TextEditor.ActiveTextAreaControl.Caret;
            return(new QUT.Gppg.LexLocation(caret.Line + 1, caret.Column, caret.Line + 1, caret.Column));
        }
コード例 #5
0
 void IWorkbenchFileService.CloseAllButThis(ICodeFileDocument nonCloseTab)
 {
     this.CloseAllButThis(nonCloseTab as CodeFileDocumentControl);
 }
コード例 #6
0
 public void ClearOutputTextBoxForTabPage(ICodeFileDocument tabPage)
 {
     ClearTextBox(OutputTextBoxs[tabPage]);
 }
コード例 #7
0
 public void SetTabPageText(ICodeFileDocument tp)
 {
     //(ssyy) TODO: ðàçîáðàòüñÿ ñ ýòèì.
     tp.Text = Path.GetFileName(tp.FileName);
     tp.ToolTipText = tp.FileName;
     if (tp.DocumentChanged && !tp.FromMetadata)
         tp.Text += "*";
     if (tp.FromMetadata)
         tp.Text += string.Format(" [{0}]", PascalABCCompiler.StringResources.Get("VP_MF_FROM_METADATA"));
     if (!ProjectFactory.Instance.ProjectLoaded && !tp.FromMetadata)
     {
         if (tp.Run && (!WorkbenchServiceFactory.DebuggerManager.IsRun(tp.EXEFileName) || !WorkbenchServiceFactory.DebuggerManager.show_debug_tabs))
             tp.Text += string.Format(" [{0}]", PascalABCCompiler.StringResources.Get("VP_MF_TS_RUN"));
         else
             if (WorkbenchServiceFactory.DebuggerManager.IsRun(tp.EXEFileName, tp.FileName))
                 tp.Text += string.Format(" [{0}]", PascalABCCompiler.StringResources.Get("VP_MF_MR_DEBUG"));
     }
     if (tp == ActiveCodeFileDocument && !tp.FromMetadata)
         tp.Text = Convert.ToChar(0x25CF) + tp.Text;//25CF //2022
 }
コード例 #8
0
ファイル: Debugger.cs プロジェクト: lisiynos/pascalabcnet
        /// <summary>
        /// Перейти к следующей строке при отладке
        /// </summary>
        private void JumpToCurrentLine()
        {
            workbench.MainForm.Activate();
            CurrentLineBookmark.Remove();//udalajem zheltyj kursor otladki
            //System.Threading.Thread.Sleep(70);
            if (debuggedProcess != null)
            {
                SourcecodeSegment nextStatement = debuggedProcess.NextStatement;
                //debuggedProcess.Modules[0].SymReader.GetMethod(debuggedProcess.SelectedFunction.Token);
                if (nextStatement != null)
                {
                    string save_PrevFullFileName = PrevFullFileName;
                    //CodeFileDocumentControl page = null;
                    //DebuggerService.JumpToCurrentLine(nextStatement.SourceFullFilename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn);
                    if (!show_debug_tabs)//esli eshe ne pokazany watch i lokal, pokazyvaem
                    {
                        show_debug_tabs = true;
                        workbench.WidgetController.SetDebugTabsVisible(true);
                        workbench.WidgetController.SetAddExprMenuVisible(true);
                    }
                    if (debuggedProcess.NextStatement.StartLine == 0xFFFFFF)
                    {
                        //sjuda popadem, esli vyzyvaem Test(arr), gde arr - massiv peredavaemyj po znacheniju
                        //metod $Copy ne imeet sequence pointov, poetomu chtoby vojti v proceduru vyzovy $Copy my pomechaem 0xFFFFFFF
                        //dolgo s etoj badjagoj muchalsja
                        is_out = true;
                        debuggedProcess.StepInto();//vhodim neposredstvenno v proceduru
                        return;
                    }
                    else if (AssemblyHelper.IsDebuggerStepThrough(debuggedProcess.SelectedFunction))
                    {
                        MustDebug = true;
                        debuggedProcess.StepOut();
                        
                        return;
                    }
                    else if (is_out == true)
                    {
                        is_out = false;
                        if (stepin_stmt.SourceFullFilename == debuggedProcess.NextStatement.SourceFullFilename && stepin_stmt.StartLine != debuggedProcess.NextStatement.StartLine)
                            stepin_stmt = debuggedProcess.NextStatement;
                        else
                        {
                            debuggedProcess.StepInto();
                            return;
                        }
                    }
                    if (debuggedProcess.NextStatement.SourceFullFilename != this.PrevFullFileName || !WorkbenchServiceFactory.DocumentService.ContainsTab(debuggedProcess.NextStatement.SourceFullFilename))
                    {
                        tab_changed = true;
                        curPage = WorkbenchServiceFactory.FileService.OpenFileForDebug(debuggedProcess.NextStatement.SourceFullFilename);
                        if (curPage == null)
                        {
                            MustDebug = true;
                            return;
                        }
                        PrevFullFileName = debuggedProcess.NextStatement.SourceFullFilename;
                    }
                    else if (curPage != WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument)
                        WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument = curPage;
                    bool remove_breakpoints = true;
                    IDocument doc = curPage.TextEditor.Document;
                    curTextArea = curPage.TextEditor.ActiveTextAreaControl.TextArea;
                    LineSegment lseg = curPage.TextEditor.ActiveTextAreaControl.Document.GetLineSegment(debuggedProcess.NextStatement.StartLine - 1);
                    int len = lseg.Length + 1;
                    /*if (lseg.Words.Count == 1 && string.Compare(lseg.Words[0].Word,"begin",true)==0)
                    {
                    	debuggedProcess.StepOver();
                        return;
                    }*/
                    //eto badjaga prepjatstvuet popadaniju na begin
                    //luchshego sposoba naverno net
                    bool in_comm = false;
                    bool beg = false;
                    bool in_str = false;
                    for (int i = 0; i < lseg.Words.Count; i++)
                    {
                        if (lseg.Words[i].Type == TextWordType.Word)
                        {
                            string word = lseg.Words[i].Word;
                            if (string.Compare(word, "begin", true) == 0 && !in_str && !in_comm)
                                beg = true;
                            else if (string.Compare(word, "{") == 0)
                            {
                                if (!in_str) in_comm = true;
                            }
                            else if (string.Compare(word, "}") == 0)
                            {
                                if (!in_str && in_comm) in_comm = false;
                            }
                            else if (string.Compare(word, "'") == 0)
                                in_str = !in_str;
                            else if (string.Compare(word, "/") == 0)
                            {
                                if (i < lseg.Words.Count - 1 && string.Compare(lseg.Words[i + 1].Word, "/") == 0)
                                    break;
                            }
                            else if (string.Compare(word, "(") == 0)
                            {
                                if (i < lseg.Words.Count - 1 && string.Compare(lseg.Words[i + 1].Word, "*") == 0)
                                {
                                    beg = false;
                                    break;
                                }
                            }
                            else if (!in_str && !in_comm)
                            {
                                beg = false;
                                break;
                            }
                        }
                    }
                    if (beg)
                    {
                        if (debuggedProcess.PausedReason != PausedReason.Exception)
                            debuggedProcess.StepOver();
                        return;
                    }
                    if (debuggedProcess.PausedReason == PausedReason.Breakpoint)
                    {
                        Breakpoint br = dbg.GetBreakpoint(debuggedProcess.NextStatement.SourceFullFilename, nextStatement.StartLine);
                        if (br != null && !BreakPointFactory.MustHit(br))
                        {
                            if (Status == DebugStatus.StepOver || Status == DebugStatus.StepIn)
                            {
                                remove_breakpoints = false;
                            }
                            else
                            {
                                debuggedProcess.Continue();
                                return;
                            }
                        }
                    }
                    //for (int i=0; i<lseg.Words.Count; i++)
                    CurrentLineBookmark.SetPosition(debuggedProcess.NextStatement.SourceFilename, curPage.TextEditor.Document, nextStatement.StartLine, 1, nextStatement.StartLine,
                       len);
                    curPage.TextEditor.ActiveTextAreaControl.JumpTo(nextStatement.StartLine - 1, 0);

                    if ((Status == DebugStatus.StepOver || Status == DebugStatus.StepIn) && (CurrentLine == nextStatement.StartLine && save_PrevFullFileName == debuggedProcess.NextStatement.SourceFilename))
                    {
                        if (curILOffset != nextStatement.ILOffset)
                        {
                            curILOffset = nextStatement.ILOffset;
                            //debuggedProcess.StepOver();
                            MustDebug = true;
                        }
                        CurrentLine = nextStatement.StartLine;
                        //return;
                    }
                    else
                    {
                        curILOffset = nextStatement.ILOffset;
                        CurrentLine = nextStatement.StartLine;
                        MustDebug = false;
                        //MustDebug = ((nextStatement.ILOffset + 1) == nextStatement.ILEnd);
                    }
                    //MustDebug = false;
                    //if (remove_breakpoints)
                    {
                        RemoveBreakpoints();
                        if (currentBreakpoint != null)
                        {
                            dbg.RemoveBreakpoint(currentBreakpoint);
                            currentBreakpoint = null; //RemoveBreakpoints();
                        }
                    }
                }

            }
        }
コード例 #9
0
ファイル: RunService.cs プロジェクト: lisiynos/pascalabcnet
 void RunTabsAdd(string name, ICodeFileDocument p)
 {
     name = Tools.FileNameToLower(name);
     if (RunTabs.ContainsKey(name))
         RunTabs[name] = p;
     else
         RunTabs.Add(name, p);
 }
コード例 #10
0
        public bool Run(ICodeFileDocument tabPage, bool forDebugging, bool startWithGoto, bool needFirstBreakpoint)
        {
            lock (o)
            {
                bool attachdbg      = forDebugging || startWithGoto || needFirstBreakpoint; //|| WorkbenchServiceFactory.DebuggerManager.HasBreakpoints();
                bool fictive_attach = false;
                BuildService.CompilerOptions.UseDllForSystemUnits = false;
                BuildService.CompilerOptions.OutputFileType       = PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton;
                if (ProjectFactory.Instance.ProjectLoaded)
                {
                    tabPage = DocumentService.GetTabPageForMainFile();
                }
                if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart)
                {
                    fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints();
                }
                WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage);
                Workbench.ErrorsListWindow.ClearErrorList();
                DesignerService.GenerateAllDesignersCode();
                string runtimeModule;
                string ModeName;
                bool   RunWithPause = false;
                if (Workbench.UserOptions.RedirectConsoleIO || forDebugging)
                {
                    runtimeModule = RedirectIOModeModuleName;
                    ModeName      = RedirectIOModeName;
                    if (Workbench.UserOptions.UseDllForSystemUnits && !Workbench.UserOptions.PABCDllChecked)
                    {
                        if (typeof(System.Runtime.CompilerServices.ExtensionAttribute).Assembly != typeof(int).Assembly || PascalABCCompiler.Compiler.get_assembly_path("PABCRtl.dll", false) == null)
                        {
                            Workbench.UserOptions.UseDllForSystemUnits = false;
                        }
                        Workbench.UserOptions.PABCDllChecked = true;
                    }
                    // SSM 09.02.20 - UseDllForSystemUnits включать когда флаг установлен - безо всяких доп. условий
                    if (/*Workbench.UserOptions.DeleteEXEAfterExecute &&*/ Workbench.UserOptions.UseDllForSystemUnits && !startWithGoto && !needFirstBreakpoint)
                    {
                        BuildService.CompilerOptions.UseDllForSystemUnits = true;
                    }
                }
                else
                {
                    runtimeModule = RunModeModuleName;
                    ModeName      = RunModeName;
                    RunWithPause  = Workbench.UserOptions.PauseInRunModeIfConsole;
                }
                bool debug = BuildService.CompilerOptions.Debug;
                if (forDebugging)
                {
                    BuildService.CompilerOptions.Debug        = true;
                    BuildService.CompilerOptions.ForDebugging = true;
                    Workbench.UserOptions.RedirectConsoleIO   = true;
                }
                string OutputFileName = null;
                if (!forDebugging)
                {
                    if (!ProjectFactory.Instance.ProjectLoaded)
                    {
                        OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO);
                    }
                    else
                    {
                        OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO);
                    }
                }
                else
                {
                    if (!ProjectFactory.Instance.ProjectLoaded)
                    {
                        OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, true);
                    }
                    else
                    {
                        OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, true);
                    }
                }
                if (RunWithPause)
                {
                    RunWithPause = RunWithPause && Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType == PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton;
                }
                if (OutputFileName != null)
                {
                    switch (Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType)
                    {
                    case PascalABCCompiler.CompilerOptions.OutputType.ClassLibrary:
                        if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run)
                        {
                            if (!RunActiveTabPage)
                            {
                                RunActiveTabPage = true;
                                return(Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint));
                            }
                        }
                        MessageBox.Show(Form1StringResources.Get("RUN_DLL_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        RunActiveTabPage = false;
                        break;

                    case PascalABCCompiler.CompilerOptions.OutputType.PascalCompiledUnit:
                        if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run)
                        {
                            if (!RunActiveTabPage)
                            {
                                RunActiveTabPage = true;
                                return(Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint));
                            }
                        }
                        RunActiveTabPage = false;
                        MessageBox.Show(Form1StringResources.Get("RUN_PCU_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;

                    case PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton:
                    case PascalABCCompiler.CompilerOptions.OutputType.WindowsApplication:
                        if (forDebugging)
                        {
                            BuildService.CompilerOptions.Debug        = debug;
                            BuildService.CompilerOptions.ForDebugging = false;
                            if (startWithGoto)
                            {
                                DebuggerManager.ShowDebugTabs = true;
                                DebuggerManager.UpdateBreakpoints();
                                DebuggerManager.CurrentBreakpoint = DebuggerManager.AddBreakPoint(DocumentService.CurrentCodeFileDocument.FileName, DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1, false);
                                DebuggerManager.AddGoToBreakPoint(DebuggerManager.CurrentBreakpoint);
                            }
                            else if (needFirstBreakpoint)
                            {
                                DebuggerManager.ShowDebugTabs = true;
                                DebuggerManager.UpdateBreakpoints();
                                if (Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset != 0)
                                {
                                    DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset);
                                    DebuggerManager.AddGoToBreakPoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset);
                                }
                                else
                                {
                                    DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset);
                                }
                            }
                            else
                            {
                                DebuggerManager.UpdateBreakpoints();
                                DebuggerManager.ShowDebugTabs = false;
                            }
                        }
                        RunActiveTabPage = false;
                        try
                        {
                            RunTabsAdd(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, tabPage);
                            RunnerManager.Run(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName,
                                              Workbench.UserOptions.RedirectConsoleIO, ModeName, RunWithPause,
                                              // Path.GetDirectoryName(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName), // SSM 21.05.19 - исправил. Теперь текущим является каталог, в котором расположен исходник.
                                              // Если компилировать программы на сетевом диске, а exe создавать локально, то работает шустро
                                              Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.SourceFileDirectory,
                                              RunArgumentsTable[tabPage.FileName.ToLower()], attachdbg, fictive_attach);
                        }
                        catch (System.Exception e)
                        {
                            // SSM 22/04/19 - исправляю вылет оболочки при отсутствии exe файла
                            // this.RunnerManager_Exited(OutputFileName); // - это всё равно не срабатывает. Кнопки оказываются в заблокированном состоянии
                            WorkbenchServiceFactory.OperationsService.AddTextToOutputWindowSync(OutputFileName, "Произошла непредвиденная ошибка. Вероятно, на диске отсутствует .exe-файл. Повторите запуск");
                            //throw;
                        }
                        if (!ProjectFactory.Instance.ProjectLoaded)
                        {
                            DocumentService.ActiveCodeFileDocument = tabPage;
                        }
                        if (forDebugging)
                        {
                            DebuggerOperationsService.AddDebugPage(tabPage);
                        }
                        WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow = Workbench.UserOptions.RedirectConsoleIO;
                        //if (UserOptions1.ConsoleOutput)
                        //AddTextToOutputWindow("Ïðîãðàììà çàïóùåíà");
                        return(true);
                    }
                }
                RunActiveTabPage = false;
                return(false);
            }
        }
コード例 #11
0
 public bool Run(ICodeFileDocument tabPage)
 {
     return(Run(tabPage, false, false, false));
 }
コード例 #12
0
 public void ClearOutputTextBoxForTabPage(ICodeFileDocument tabPage)
 {
     ClearTextBox(OutputTextBoxs[tabPage]);
 }
コード例 #13
0
        public override string GetCurrentTextDocument()
        {
            ICodeFileDocument doc = (_wb as IWorkbenchDocumentService).CurrentCodeFileDocument;

            return(doc.TextEditor.Text);
        }
コード例 #14
0
        public bool Run(ICodeFileDocument tabPage, bool forDebugging, bool startWithGoto, bool needFirstBreakpoint)
        {
            bool attachdbg      = forDebugging || startWithGoto || needFirstBreakpoint; //|| WorkbenchServiceFactory.DebuggerManager.HasBreakpoints();
            bool fictive_attach = false;

            BuildService.CompilerOptions.UseDllForSystemUnits = false;
            BuildService.CompilerOptions.OutputFileType       = PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton;
            if (ProjectFactory.Instance.ProjectLoaded)
            {
                tabPage = DocumentService.GetTabPageForMainFile();
            }
            if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart)
            {
                fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints();
            }
            WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage);
            Workbench.ErrorsListWindow.ClearErrorList();
            DesignerService.GenerateAllDesignersCode();
            string runtimeModule;
            string ModeName;
            bool   RunWithPause = false;

            if (Workbench.UserOptions.RedirectConsoleIO || forDebugging)
            {
                runtimeModule = RedirectIOModeModuleName;
                ModeName      = RedirectIOModeName;
                if (Workbench.UserOptions.UseDllForSystemUnits && !Workbench.UserOptions.PABCDllChecked)
                {
                    if (typeof(System.Runtime.CompilerServices.ExtensionAttribute).Assembly != typeof(int).Assembly || PascalABCCompiler.Compiler.get_assembly_path("PABCRtl.dll", false) == null)
                    {
                        Workbench.UserOptions.UseDllForSystemUnits = false;
                    }
                    Workbench.UserOptions.PABCDllChecked = true;
                }
                if (Workbench.UserOptions.DeleteEXEAfterExecute && Workbench.UserOptions.UseDllForSystemUnits && !startWithGoto && !needFirstBreakpoint)
                {
                    BuildService.CompilerOptions.UseDllForSystemUnits = true;
                }
            }
            else
            {
                runtimeModule = RunModeModuleName;
                ModeName      = RunModeName;
                RunWithPause  = Workbench.UserOptions.PauseInRunModeIfConsole;
            }
            bool debug = BuildService.CompilerOptions.Debug;

            if (forDebugging)
            {
                BuildService.CompilerOptions.Debug        = true;
                BuildService.CompilerOptions.ForDebugging = true;
                Workbench.UserOptions.RedirectConsoleIO   = true;
            }
            string OutputFileName = null;

            if (!forDebugging)
            {
                if (!ProjectFactory.Instance.ProjectLoaded)
                {
                    OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO);
                }
                else
                {
                    OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO);
                }
            }
            else
            {
                if (!ProjectFactory.Instance.ProjectLoaded)
                {
                    OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, true);
                }
                else
                {
                    OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, true);
                }
            }
            if (RunWithPause)
            {
                RunWithPause = RunWithPause && Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType == PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton;
            }
            if (OutputFileName != null)
            {
                switch (Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType)
                {
                case PascalABCCompiler.CompilerOptions.OutputType.ClassLibrary:
                    if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run)
                    {
                        if (!RunActiveTabPage)
                        {
                            RunActiveTabPage = true;
                            return(Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint));
                        }
                    }
                    MessageBox.Show(Form1StringResources.Get("RUN_DLL_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    RunActiveTabPage = false;
                    break;

                case PascalABCCompiler.CompilerOptions.OutputType.PascalCompiledUnit:
                    if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run)
                    {
                        if (!RunActiveTabPage)
                        {
                            RunActiveTabPage = true;
                            return(Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint));
                        }
                    }
                    RunActiveTabPage = false;
                    MessageBox.Show(Form1StringResources.Get("RUN_PCU_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;

                case PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton:
                case PascalABCCompiler.CompilerOptions.OutputType.WindowsApplication:
                    if (forDebugging)
                    {
                        BuildService.CompilerOptions.Debug        = debug;
                        BuildService.CompilerOptions.ForDebugging = false;
                        if (startWithGoto)
                        {
                            DebuggerManager.ShowDebugTabs     = true;
                            DebuggerManager.CurrentBreakpoint = DebuggerManager.AddBreakPoint(DocumentService.CurrentCodeFileDocument.FileName, DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1, false);
                            DebuggerManager.AddGoToBreakPoint(DebuggerManager.CurrentBreakpoint);
                        }
                        else if (needFirstBreakpoint)
                        {
                            DebuggerManager.ShowDebugTabs = true;
                            if (Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset != 0)
                            {
                                DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset);
                                DebuggerManager.AddGoToBreakPoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset);
                            }
                            else
                            {
                                DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset);
                            }
                        }
                        else
                        {
                            DebuggerManager.ShowDebugTabs = false;
                        }
                    }
                    RunActiveTabPage = false;
                    try
                    {
                        RunTabsAdd(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, tabPage);
                        RunnerManager.Run(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, Workbench.UserOptions.RedirectConsoleIO, ModeName, RunWithPause, Path.GetDirectoryName(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName), RunArgumentsTable[tabPage.FileName.ToLower()], attachdbg, fictive_attach);
                    }
                    catch (System.Exception e)
                    {
                        throw;
                    }
                    if (!ProjectFactory.Instance.ProjectLoaded)
                    {
                        DocumentService.ActiveCodeFileDocument = tabPage;
                    }
                    if (forDebugging)
                    {
                        DebuggerOperationsService.AddDebugPage(tabPage);
                    }
                    WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow = Workbench.UserOptions.RedirectConsoleIO;
                    //if (UserOptions1.ConsoleOutput)
                    //AddTextToOutputWindow("Ïðîãðàììà çàïóùåíà");
                    return(true);
                }
            }
            RunActiveTabPage = false;
            return(false);
        }
コード例 #15
0
 void IWorkbenchDebugService.AddDebugPage(ICodeFileDocument tabPage)
 {
     debuggedPage = tabPage;
     AddDebugPage(debuggedPage as CodeFileDocumentControl);
     DebugUtils.DebuggerManager.SetAsDebugPage(debuggedPage);
 }
コード例 #16
0
 void IWorkbenchDebuggerOperationsService.AddDebugPage(ICodeFileDocument tabPage)
 {
     debuggedPage = tabPage;
     AddDebugPage(debuggedPage as CodeFileDocumentControl);
     WorkbenchServiceFactory.DebuggerManager.SetAsDebugPage(debuggedPage);
 }
コード例 #17
0
 void IWorkbenchDebuggerOperationsService.AddDebugPage(ICodeFileDocument tabPage)
 {
     debuggedPage = tabPage;
     AddDebugPage(debuggedPage as CodeFileDocumentControl);
     WorkbenchServiceFactory.DebuggerManager.SetAsDebugPage(debuggedPage);
 }
コード例 #18
0
ファイル: RunService.cs プロジェクト: lisiynos/pascalabcnet
 public bool Run(ICodeFileDocument tabPage, bool forDebugging, bool startWithGoto, bool needFirstBreakpoint)
 {
     bool attachdbg = forDebugging || startWithGoto || needFirstBreakpoint; //|| WorkbenchServiceFactory.DebuggerManager.HasBreakpoints();
     bool fictive_attach = false;
     BuildService.CompilerOptions.UseDllForSystemUnits = false;
     BuildService.CompilerOptions.OutputFileType = PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton;
     if (ProjectFactory.Instance.ProjectLoaded)
         tabPage = DocumentService.GetTabPageForMainFile();
     if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart)
         fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints();
     WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage);
     Workbench.ErrorsListWindow.ClearErrorList();
     DesignerService.GenerateAllDesignersCode();
     //this.Refresh();
     //            new System.Threading.Thread(new System.Threading.ThreadStart(RunCompile)).Start();;
     string runtimeModule;
     string ModeName;
     bool RunWithPause = false;
     if (Workbench.UserOptions.RedirectConsoleIO || forDebugging)
     {
         runtimeModule = RedirectIOModeModuleName;
         ModeName = RedirectIOModeName;
         if (Workbench.UserOptions.UseDllForSystemUnits && !Workbench.UserOptions.PABCDllChecked)
         {
             if (typeof(System.Runtime.CompilerServices.ExtensionAttribute).Assembly != typeof(int).Assembly || PascalABCCompiler.Compiler.get_assembly_path("PABCRtl.dll", false) == null)
                 Workbench.UserOptions.UseDllForSystemUnits = false;
             Workbench.UserOptions.PABCDllChecked = true;
         }
         if (Workbench.UserOptions.DeleteEXEAfterExecute && Workbench.UserOptions.UseDllForSystemUnits && !startWithGoto && !needFirstBreakpoint)
             BuildService.CompilerOptions.UseDllForSystemUnits = true;
     }
     else
     {
         runtimeModule = RunModeModuleName;
         ModeName = RunModeName;
         RunWithPause = Workbench.UserOptions.PauseInRunModeIfConsole;
     }
     bool debug = BuildService.CompilerOptions.Debug;
     if (forDebugging)
     {
         BuildService.CompilerOptions.Debug = true;
         BuildService.CompilerOptions.ForDebugging = true;
         Workbench.UserOptions.RedirectConsoleIO = true;
     }
     string OutputFileName = null;
     if (!forDebugging)
     {
         if (!ProjectFactory.Instance.ProjectLoaded)
             OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO);
         else
             OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO);
     }
     else
     {
         if (!ProjectFactory.Instance.ProjectLoaded)
             OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, true);
         else
             OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, true);
     }
     if (RunWithPause)
         RunWithPause = RunWithPause && Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType == PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton;
     if (OutputFileName != null)
     {
         switch (Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType)
         {
             case PascalABCCompiler.CompilerOptions.OutputType.ClassLibrary:
                 MessageBox.Show(Form1StringResources.Get("RUN_DLL_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 RunActiveTabPage = false;
                 break;
             case PascalABCCompiler.CompilerOptions.OutputType.PascalCompiledUnit:
                 if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run)
                     if (!RunActiveTabPage)
                     {
                         RunActiveTabPage = true;
                         return Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint);
                     }
                 RunActiveTabPage = false;
                 MessageBox.Show(Form1StringResources.Get("RUN_PCU_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 break;
             case PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton:
             case PascalABCCompiler.CompilerOptions.OutputType.WindowsApplication:
                 if (forDebugging)
                 {
                     BuildService.CompilerOptions.Debug = debug;
                     BuildService.CompilerOptions.ForDebugging = false;
                     if (startWithGoto)
                     {
                         DebuggerManager.show_debug_tabs = true;
                         DebuggerManager.CurrentBreakpoint = DebuggerManager.AddBreakPoint(DocumentService.CurrentCodeFileDocument.FileName, DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1, false);
                         DebuggerManager.AddGoToBreakPoint(DebuggerManager.CurrentBreakpoint);
                     }
                     else if (needFirstBreakpoint)
                     {
                         DebuggerManager.show_debug_tabs = true;
                         if (Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset != 0)
                         {
                             DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset);
                             DebuggerManager.AddGoToBreakPoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset);
                         }
                         else
                             DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset);
                     }
                     else
                         DebuggerManager.show_debug_tabs = false;
                 }
                 RunActiveTabPage = false;
                 try
                 {
                     RunTabsAdd(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, tabPage);
                     RunnerManager.Run(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, Workbench.UserOptions.RedirectConsoleIO, ModeName, RunWithPause, Path.GetDirectoryName(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName), RunArgumentsTable[tabPage.FileName.ToLower()], attachdbg, fictive_attach);
                 }
                 catch (System.Exception e)
                 {
                     throw;
                 }
                 if (!ProjectFactory.Instance.ProjectLoaded)
                     DocumentService.ActiveCodeFileDocument = tabPage;
                 if (forDebugging)
                 {
                     DebuggerOperationsService.AddDebugPage(tabPage);
                 }
                 WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow = Workbench.UserOptions.RedirectConsoleIO;
                 //if (UserOptions1.ConsoleOutput)
                 //AddTextToOutputWindow("Ïðîãðàììà çàïóùåíà");
                 return true;
         }
     }
     return false;
 }
コード例 #19
0
ファイル: DebugService.cs プロジェクト: lisiynos/pascalabcnet
 void IWorkbenchDebugService.AddDebugPage(ICodeFileDocument tabPage)
 {
     debuggedPage = tabPage;
     AddDebugPage(debuggedPage as CodeFileDocumentControl);
     DebugUtils.DebuggerManager.SetAsDebugPage(debuggedPage);
 }
コード例 #20
0
ファイル: Debugger.cs プロジェクト: lisiynos/pascalabcnet
 /// <summary>
 /// Проверяет, запущен ли процесс с именем ExeFileName на отладку
 /// </summary>
 public bool IsRunAndInThisTabPage(string ExeFileName, ICodeFileDocument cfdc)
 {
 	if (WorkbenchServiceFactory.DocumentService.ContainsTab(cfdc))
 		return true;
 	return IsRunning && (/*string.Compare(this.ExeFileName,ExeFileName,true)==0 || */WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument == this.curPage);
 }
コード例 #21
0
ファイル: Debugger.cs プロジェクト: lisiynos/pascalabcnet
 public void SetAsPossibleDebugPage(CodeFileDocumentControl ctrl)
 {
 	if (IsRunning && tab_changed && ctrl != this.curPage)
 	{
 		curPage = ctrl;
 	}
 	tab_changed = false;
 }
コード例 #22
0
ファイル: Debugger.cs プロジェクト: lisiynos/pascalabcnet
 public void SetAsDebugPage(ICodeFileDocument ctrl)
 {
 	curPage = ctrl;
 }
コード例 #23
0
 void IWorkbenchFileService.CloseAllButThis(ICodeFileDocument nonCloseTab)
 {
     this.CloseAllButThis(nonCloseTab as CodeFileDocumentControl);
 }
コード例 #24
0
ファイル: RunService.cs プロジェクト: lisiynos/pascalabcnet
 public bool Run(ICodeFileDocument tabPage)
 {
     return Run(tabPage, false, false, false);
 }