* Add first comments
* Finish commenting for Compile and CompileUnit
* Write TODO sections
* Add a few clarifications
* splitted some functions from compile
* Written some methods from Compile to functions
* Update variable names
* Refactor - stage 1
Refactor GetUsesSection and IsPossibleNameSpace
* Refactor - stage 2
Rename a few functions and variables
* Correct an inaccuracy
* Added comments, look through CompileUnit
* Rename a few functions and add new comments
* Split CompileUnit to Subfunctions
Add IsUnitCompiled, IsUnitInPCU, InitializeNewUnit, GetSourceCode, GenSyntaxTree, GenUnitDocumentation, CheckDLLDirectiveOnlyForLibraries, MatchErrorsToBadNodes, CheckIfUnitModule, SetUseDLLForSystemUnits,
CompileInterfaceDependencies, CompileCurrentUnitInterface, GetImplementationUsesSection, CompileImplementationDependencies, CompileCurrentUnitImplementation
* Added some TODOs
* Return uses_unit_in original name
Renaming of syntax tree nodes leads to internal compiler errors
* Extract GenerateILCode method
* Add checking if recompilation needed method
Needs to be discussed and revised
* Add functions for catch blocks in Compile
* Extract building semantic tree method
Creating main function to be moved to another class
* Rename UnitsSortedList
* Edit CompileUnitsFromDelayedList method
* Change a few variable names, make CreateRCFile function and add comments
* Make code more "user-friendly"
* Add TODOs 31.11.23
* Create PrebuildSemanticTreeActionsMethod
* Refactor semantic checks section in initialize new unit method
* Refactor Adding standard units to uses method
* Return file_name and compiler_directives original names to avoid internal compilation errors
* Refactor GetReferences Method
* Initial refactoring of IncludeNamespaces function
* Create three more methods and wrap important code in regions
* Add TODO's
* Resolve merge conflicts
* Add returned value to ConstructSyntaxTree method
* Fix UnitsSortedList NotFoundError in PCUWriter
* Workaround commit
* Update PABCSystem after tests' changes
* Rename syntax trees in some methods
* Delete CurrentSyntaxUnit variable
* Revert unnecessary project files changes
* Squashed commit of the following:
commit f4d7599f1a39252feac97bd5391f46dfdc25f6f4
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 22 11:43:29 2023 +0300
added links to identarranger
commit 3bd5d33e2b2969884e61a3279ff9c353013b57fe
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 22 11:43:03 2023 +0300
Change extension for verybasic to yavb
commit 61294c6e7d405e1c68516cc81d3a109e8a1ee295
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Tue Nov 21 09:33:57 2023 +0300
Change Program Example
commit 86971488341ed6bf13c39e13a513d7ac0c51c285
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Tue Nov 21 09:28:59 2023 +0300
Add IndentArranger to Compile
commit 2ce50bbbf9db22c4243b247b870f6935ce206d26
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Fri Nov 17 10:00:31 2023 +0300
Add Semicolon After Each Statement
commit 796309d340e8d8ba730ff9418fa376f34fb7fd36
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Wed Nov 15 18:49:11 2023 +0300
Add Alpha Version of Python-style If-statement
commit 5eb88f946fe8254b4f5c5a56ed0a567b3be51227
Merge: ab4ce5b0 0162b637
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 15 16:54:26 2023 +0300
Merge branch 'IndentArranger' into VeryBasicLanguage
commit ab4ce5b0e32d42004726e3dc45cc0d8a65e53f56
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 15 16:53:51 2023 +0300
Fixes from seminar
commit af74012289d0d08517c13499a2a66cb543fc06d2
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Sun Nov 12 18:57:29 2023 +0300
finally working!
fully implemented compatibility
commit 58a39c313324b468d1eec207ba3f5f6eddf74ef2
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Sun Nov 12 11:58:16 2023 +0300
more compatibility with pabc
Now verybasic statements translate to pascal compiler
added .bat script for autobuilding verybasic
commit 0162b6376b8fe970704f26213bf9f0f670dfb12e
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Sun Nov 12 10:06:14 2023 +0300
Update test.txt
commit 1b759ab1cd7ee2ffeb14afff0418ddf0f30b0399
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Sun Nov 12 10:05:36 2023 +0300
Add Indent and Unindent Keywords to Generated File
commit cabda7f3985651cff2a8740f1a5bdea8fe7ac892
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Fri Nov 10 21:25:52 2023 +0300
Add Generation of Output File
commit 306f033d0176ab559e3622b8505427dbe2e0e203
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Thu Nov 9 20:42:18 2023 +0300
Update IndentArranger.sln
commit 60c0ceced1aa3a7d2e33de0facb1126e295f43b5
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Thu Nov 9 20:41:22 2023 +0300
Add IndentArranger
commit 1f4556c4573dae154fcc167b41ff6ab9e8122136
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Mon Nov 6 22:48:36 2023 +0300
Made my own VeryBasicParser project
Copied some code from SaushkinParser
Tried to compile it and implement into Pascal
Doesn't work due to grammatik issue
* Squashed commit of the following:
commit 4e73d9ac3ffef68312f06a74dc83afffcf3ccbee
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 22 15:08:10 2023 +0300
Fixed GPPG (i think so at least)
commit e5cfc220828b37fb2f35e565683019716ec3f0ce
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 22 11:44:27 2023 +0300
Update Compiler.cs
commit 4698e2e75a5f3b4f523a8bc7733a50e8abb4fca1
Merge: 22aaf2b2 f4d7599f
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 22 11:43:54 2023 +0300
Merge branch 'IndentArrangerTemp' into VeryBasicLanguage
commit f4d7599f1a39252feac97bd5391f46dfdc25f6f4
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 22 11:43:29 2023 +0300
added links to identarranger
commit 3bd5d33e2b2969884e61a3279ff9c353013b57fe
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 22 11:43:03 2023 +0300
Change extension for verybasic to yavb
commit 22aaf2b2508278a9ffce525ffed52419bf72c23f
Merge: c326174f 61294c6e
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 22 11:26:36 2023 +0300
Merge branch 'IndentArrangerTemp' into VeryBasicLanguage
commit 61294c6e7d405e1c68516cc81d3a109e8a1ee295
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Tue Nov 21 09:33:57 2023 +0300
Change Program Example
commit 86971488341ed6bf13c39e13a513d7ac0c51c285
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Tue Nov 21 09:28:59 2023 +0300
Add IndentArranger to Compile
commit c326174ff5ecccf9c4f76d58aea4653f047af049
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Sun Nov 19 15:03:19 2023 +0300
Added UniversalParserHelper and GPPG
ShiftReduceParser moved to another project
UniversalParserHelper project added, most of it copied from SaushkinParser
commit 2ce50bbbf9db22c4243b247b870f6935ce206d26
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Fri Nov 17 10:00:31 2023 +0300
Add Semicolon After Each Statement
commit 796309d340e8d8ba730ff9418fa376f34fb7fd36
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Wed Nov 15 18:49:11 2023 +0300
Add Alpha Version of Python-style If-statement
commit 5eb88f946fe8254b4f5c5a56ed0a567b3be51227
Merge: ab4ce5b0 0162b637
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 15 16:54:26 2023 +0300
Merge branch 'IndentArranger' into VeryBasicLanguage
commit ab4ce5b0e32d42004726e3dc45cc0d8a65e53f56
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Wed Nov 15 16:53:51 2023 +0300
Fixes from seminar
commit af74012289d0d08517c13499a2a66cb543fc06d2
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Sun Nov 12 18:57:29 2023 +0300
finally working!
fully implemented compatibility
commit 58a39c313324b468d1eec207ba3f5f6eddf74ef2
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Sun Nov 12 11:58:16 2023 +0300
more compatibility with pabc
Now verybasic statements translate to pascal compiler
added .bat script for autobuilding verybasic
commit 0162b6376b8fe970704f26213bf9f0f670dfb12e
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Sun Nov 12 10:06:14 2023 +0300
Update test.txt
commit 1b759ab1cd7ee2ffeb14afff0418ddf0f30b0399
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Sun Nov 12 10:05:36 2023 +0300
Add Indent and Unindent Keywords to Generated File
commit cabda7f3985651cff2a8740f1a5bdea8fe7ac892
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Fri Nov 10 21:25:52 2023 +0300
Add Generation of Output File
commit 306f033d0176ab559e3622b8505427dbe2e0e203
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Thu Nov 9 20:42:18 2023 +0300
Update IndentArranger.sln
commit 60c0ceced1aa3a7d2e33de0facb1126e295f43b5
Author: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Date: Thu Nov 9 20:41:22 2023 +0300
Add IndentArranger
commit 1f4556c4573dae154fcc167b41ff6ab9e8122136
Author: Владислав Крылов <krylov@sfedu.ru>
Date: Mon Nov 6 22:48:36 2023 +0300
Made my own VeryBasicParser project
Copied some code from SaushkinParser
Tried to compile it and implement into Pascal
Doesn't work due to grammatik issue
* Changed GPPG project NET Framework version, added .dll to gitignore
* Adding UniversalParserHelper to project, trying to include VeryBasic
* Managed dependencies and got VeryBasicLanguage to work
* Change extension of a test program
* Rebuild changes
What should be added to .gitignore?
* Fix bug related to err0524_res_unit.pas
* Rebuild Parser
* Change Indent and Unindent tokens
* Add Symbol Table to ParserABC.y
* Change Indent Space Number to 2
* Add While Loop
* Add Some Operations to Parser
* Make Initialization Node at the Beginning of a program
* Create Grammar.txt
* Test program added
* Add ELIF and SyntaxHighlight
* Fix TableSymbol
* Add Division
* Add Method Call
* Add For Loop
* Rename SPython Parser Folder
* Add documented comments for CompileUnit method
* Added Errors to SPython
Added Errors.cs
Removed link to PABCSaushkinParser
Minor fixes
* Create default constructor for SourceContext
* Move null check of currentUnit to upper level in CompileUnit
* Move CreateMainFunction method from Compiler to TreeConverter class
* Add gppg and parserhelper to visualpascalabcnet dependencies
* Updated installer files to include GPPG and UniversalParserHelper
* Rename GPPG to ShiftReduceParser
* Fix ShiftReduceParser project dependencies
* Fix ShiftReduceParserDependencies second iteration
* Workaround commit
* Update PABCSystem after tests' changes
* Refactor ConvertDirectives method
* Get rid of legacy standard modules code
* Return varBeginOffset and beginOffset calculation to Compiler class
Размещение метода в SyntaxTreeToSemanticTreeConverter не целесообразно. В комментарии видимо имелось в виду что-то другое.
* Workaround commit
* Update PABCSystem after tests' changes
* Revert SPython changes
Оставляем только изменения связанные с рефакторингом.
* Update .gitignore
Co-authored-by: Sun Serega <sunserega2@gmail.com>
* Resolve a few Sun Serega treds
* Delete comments in ParsersController.cs
* Replace specific path with path variable in Studio.bat
* Add comment in Studio.bat file and return FileName in CompilerError.cs
* Fix TreeSubsidiary.cs encoding and sectCore.nsh indents
* Return old version of TestRunner.exe
* Rename some variables and polish a few methods
* Uncomment accidentally commented code
* Replace spaces with tabs
* Changed dll name from GPPG
* Revert "Changed dll name from GPPG"
This reverts commit c485cc8cb787809b7e9dfa8a361e75f17ed39893.
* Update .gitignore
* Delete Libraries/ShiftReduceParser.dll
* Delete bin\ShiftReduceParser.dll
* Replace tabs with spaces
* Update encoding in Studio.bat
* Fix bug with PABCrtl excluded files
* Refactor StandardModule class
* Add null checks to make debuging easier
* Delete unnecessary null checks in SymTable.cs
---------
Co-authored-by: Владислав Крылов <krylov@sfedu.ru>
Co-authored-by: MovchanGitHub <92666028+MovchanGitHub@users.noreply.github.com>
Co-authored-by: Sun Serega <sunserega2@gmail.com>
722 lines
28 KiB
C#
722 lines
28 KiB
C#
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
//using ICSharpCode.FormsDesigner;
|
|
//using ICSharpCode.SharpDevelop.Gui;
|
|
using ICSharpCode.TextEditor;
|
|
using VisualPascalABC.OptionsContent;
|
|
using VisualPascalABCPlugins;
|
|
using WeifenLuo.WinFormsUI.Docking;
|
|
|
|
namespace VisualPascalABC
|
|
{
|
|
public partial class Form1 : Form, VisualPascalABCPlugins.IWorkbench, VisualPascalABCPlugins.IWorkbenchOperationsService
|
|
{
|
|
internal CodeFileDocumentControl LastSelectedTab, BakSelectedTab;
|
|
Dictionary<ICodeFileDocument, RichTextBox> OutputTextBoxs = new Dictionary<ICodeFileDocument, RichTextBox>();
|
|
|
|
private void AddOutputWindow()
|
|
{
|
|
if (OutputWindow == null)
|
|
{
|
|
OutputWindow = new OutputWindowForm(this);
|
|
Form1StringResources.SetTextForAllControls(OutputWindow);
|
|
}
|
|
//BottomPane = null;
|
|
//AddWindowToDockPanel(OutputWindow, MainDockPanel, DockStyle.Fill, DockState.DockBottom, OutputWindow.IsFloat, BottomPane, -1);
|
|
AddWindowToDockPanel(OutputWindow, BottomDockPanel, DockStyle.None, DockState.Document, false, null, -1);
|
|
//BottomPane = OutputWindow.Pane;
|
|
}
|
|
|
|
private void AddErrorsListWindow()
|
|
{
|
|
if (ErrorsListWindow == null)
|
|
{
|
|
ErrorsListWindow = new ErrorsListWindowForm(this);
|
|
Form1StringResources.SetTextForAllControls(ErrorsListWindow);
|
|
}
|
|
AddWindowToDockPanel(ErrorsListWindow, BottomDockPanel, OutputWindow.Dock, DockState.Document, false, null, int.MaxValue);
|
|
}
|
|
|
|
private void AddCompilerConsoleWindow()
|
|
{
|
|
if (CompilerConsoleWindow == null)
|
|
{
|
|
CompilerConsoleWindow = new CompilerConsoleWindowForm(this);
|
|
Form1StringResources.SetTextForAllControls(CompilerConsoleWindow);
|
|
}
|
|
AddWindowToDockPanel(CompilerConsoleWindow, BottomDockPanel, OutputWindow.Dock, DockState.Document, false, null, int.MaxValue);
|
|
}
|
|
|
|
private void AddFindSymbolsResultWindow()
|
|
{
|
|
if (FindSymbolsResultWindow == null)
|
|
{
|
|
FindSymbolsResultWindow = new FindSymbolsResultWindowForm(this);
|
|
Form1StringResources.SetTextForAllControls(FindSymbolsResultWindow);
|
|
}
|
|
AddWindowToDockPanel(FindSymbolsResultWindow, BottomDockPanel, OutputWindow.Dock, DockState.Document, OutputWindow.IsFloat, BottomPane, int.MaxValue);
|
|
}
|
|
|
|
private void AddImmediateWindow()
|
|
{
|
|
if (ImmediateWindow == null)
|
|
{
|
|
ImmediateWindow = new ImmediateWindow(this);
|
|
Form1StringResources.SetTextForAllControls(ImmediateWindow);
|
|
}
|
|
AddWindowToDockPanel(ImmediateWindow, BottomDockPanel, OutputWindow.Dock, DockState.Document, OutputWindow.IsFloat, BottomPane, int.MaxValue);
|
|
}
|
|
|
|
void AddDebugVariablesListWindow()
|
|
{
|
|
if (DebugVariablesListWindow == null)
|
|
{
|
|
DebugVariablesListWindow = new DebugVariablesListWindowForm(this);
|
|
Form1StringResources.SetTextForAllControls(DebugVariablesListWindow);
|
|
}
|
|
AddWindowToDockPanel(DebugVariablesListWindow, BottomDockPanel, OutputWindow.Dock, DockState.Document, OutputWindow.IsFloat, BottomPane, int.MaxValue);
|
|
}
|
|
|
|
void AddDisassemblyWindow()
|
|
{
|
|
if (DisassemblyWindow == null)
|
|
{
|
|
DisassemblyWindow = new DisassemblyWindow(this);
|
|
Form1StringResources.SetTextForAllControls(DisassemblyWindow);
|
|
}
|
|
|
|
AddWindowToDockPanel(DisassemblyWindow, MainDockPanel, OutputWindow.Dock, DockState.Document, OutputWindow.IsFloat, BottomPane, int.MaxValue);
|
|
}
|
|
|
|
void AddDebugWatchListWindow()
|
|
{
|
|
if (DebugWatchListWindow == null)
|
|
{
|
|
DebugWatchListWindow = new DebugWatchListWindowForm(this);
|
|
Form1StringResources.SetTextForAllControls(DebugWatchListWindow);
|
|
}
|
|
|
|
AddWindowToDockPanel(DebugWatchListWindow, BottomDockPanel, OutputWindow.Dock, DockState.Document, OutputWindow.IsFloat, BottomPane, int.MaxValue);
|
|
}
|
|
|
|
void AddProjectExplorerWindow()
|
|
{
|
|
if (ProjectExplorerWindow == null)
|
|
{
|
|
ProjectExplorerWindow = new ProjectExplorerForm();
|
|
Form1StringResources.SetTextForAllControls(ProjectExplorerWindow);
|
|
}
|
|
//ProjectPane = null;
|
|
AddWindowToDockPanel(ProjectExplorerWindow, BottomDockPanel, OutputWindow.Dock, DockState.Document, OutputWindow.IsFloat, ProjectPane, -1);
|
|
//ProjectPane = ProjectExplorerWindow.Pane;
|
|
}
|
|
|
|
private void AddOptionsContent()
|
|
{
|
|
optionsContentEngine = new OptionsContentEngine(this);
|
|
optionsContentEngine.AddContent(new ViewOptionsContent(this));
|
|
optionsContentEngine.AddContent(new EditorOptionsContent(this));
|
|
optionsContentEngine.AddContent(new CompilerOptionsContent(this));
|
|
optionsContentEngine.AddContent(new IntelliseseOptionsContent(this));
|
|
}
|
|
|
|
public void UpdateOptionsForm()
|
|
{
|
|
if (optionsContentEngine != null)
|
|
optionsContentEngine.UpdateOptionsForm();
|
|
}
|
|
|
|
public void AddWindowToDockPanel(DockContent dc, DockPanel dp, DockStyle dockStyle, DockState dockState, bool isFloat, DockPane dockToPane, int ind)
|
|
{
|
|
if (dc.Visible && dc.Pane != null)
|
|
return;
|
|
if (dp.DocumentStyle == DocumentStyle.SystemMdi)
|
|
{
|
|
dc.MdiParent = this;
|
|
dc.Show();
|
|
}
|
|
else
|
|
{
|
|
dc.Show(dp);
|
|
}
|
|
|
|
if (dockToPane != null)
|
|
if (ind == int.MaxValue)
|
|
dc.Pane.DockTo(dockToPane, dockStyle, dockToPane.Contents.Count - 1);
|
|
else
|
|
dc.Pane.DockTo(dockToPane, dockStyle, ind);
|
|
//MessageBox.Show(dockState.ToString() + " " + dc.ToString());
|
|
dc.DockState = dockState;
|
|
dc.IsFloat = isFloat;
|
|
}
|
|
|
|
/*public void AddToolBox()
|
|
{
|
|
if (ToolBoxWindow == null)
|
|
{
|
|
ToolBoxWindow = new ToolBoxForm();
|
|
//SharpDevelopSideBar sideBar = FormsDesignerViewContent.FormsDesignerToolBox;
|
|
//sideBar.Dock = DockStyle.Fill;
|
|
//sideBar.Parent = ToolBoxWindow;
|
|
AddWindowToDockPanel(ToolBoxWindow, MainDockPanel, OutputWindow.Dock, DockState.DockLeft, OutputWindow.IsFloat, null, -1);
|
|
ToolBoxWindow.Show();
|
|
}
|
|
else
|
|
ToolBoxWindow.Show();
|
|
}*/
|
|
|
|
public void AddPropertiesWindow()
|
|
{
|
|
/*if (PropertiesWindow == null)
|
|
{
|
|
PropertiesWindow = new PropertiesForm();
|
|
Form1StringResources.SetTextForAllControls(PropertiesWindow);
|
|
Panel properties = FormsDesignerViewContent.PropertyPad.PropertyPadPanel;
|
|
properties.Dock = DockStyle.Fill;
|
|
properties.Parent = PropertiesWindow;
|
|
AddWindowToDockPanel(PropertiesWindow, MainDockPanel, DockStyle.Fill, DockState.DockRight, OutputWindow.IsFloat, ProjectPane, int.MaxValue);
|
|
//PropertiesWindow.Show();
|
|
}
|
|
else */
|
|
PropertiesWindowVisible = true;
|
|
}
|
|
|
|
private CodeFileDocumentControl AddNewTab(DockPanel tabControl, DockStyle dockStyle = DockStyle.Fill)
|
|
{
|
|
CodeFileDocumentControl tp = new CodeFileDocumentControl(this);
|
|
// SSM 03.06.22 - это надо убрать здесь - почему-то не работает активация - надо туда
|
|
//_currentCodeFileDocument = tp; // должно по DockStateChanged - но мб неверно
|
|
//tp.BorderStyle=BorderStyle.Fixed3D;
|
|
//tp.Font = new System.Drawing.Font("MS Sans Serif", tp.Font.Size);
|
|
RichTextBox tb = OutputWindow.outputTextBox;
|
|
if (OpenDocuments.Count > 0)
|
|
tb = CopyTextBox(OutputWindow.outputTextBox);
|
|
AddWindowToDockPanel(tp, tabControl, tp.Dock != dockStyle?dockStyle:tp.Dock, DockState.Document, tp.IsFloat, null, 0);
|
|
tb.Font = tp.TextEditor.Font;
|
|
OutputTextBoxs.Add(tp, tb);
|
|
|
|
WorkbenchServiceFactory.CodeCompletionParserController.ParseInformationUpdated += tp.TextEditor.UpdateFolding;
|
|
return tp;
|
|
//tabControl.SelectedTab = tp;
|
|
}
|
|
|
|
public CodeFileDocumentControl FindTab(string FileName)
|
|
{
|
|
if (FileName == null) return null;
|
|
CodeFileDocumentControl tp = null;
|
|
OpenDocuments.TryGetValue(Tools.FileNameToLower(FileName), out tp);
|
|
return tp;
|
|
}
|
|
|
|
public ICodeFileDocument GetDocument(string FileName)
|
|
{
|
|
return FindTab(FileName);
|
|
}
|
|
|
|
bool VisualPascalABCPlugins.IWorkbenchDocumentService.ContainsTab(string FileName)
|
|
{
|
|
return FindTab(FileName) != null;
|
|
}
|
|
|
|
public void CloseBrowserTab(string text)
|
|
{
|
|
if (OpenBrowserDocuments.ContainsKey(text))
|
|
OpenBrowserDocuments.Remove(text);
|
|
}
|
|
|
|
public void AddTabWithUrl(string title, string url)
|
|
{
|
|
AddTabWithUrl(MainDockPanel, title, url);
|
|
}
|
|
|
|
public void AddTabWithUrl(DockPanel tabControl, string title, string url)
|
|
{
|
|
WebBrowserControl tp = null;//new WebBrowserControl();
|
|
if (!OpenBrowserDocuments.TryGetValue(title, out tp))
|
|
{
|
|
tp = new WebBrowserControl();
|
|
tp.OpenPage(title, url);
|
|
AddWindowToDockPanel(tp, tabControl, tp.Dock, DockState.Document, tp.IsFloat, null, 0);
|
|
OpenBrowserDocuments.Add(title, tp);
|
|
}
|
|
else
|
|
tp.Activate();
|
|
}
|
|
|
|
private CodeFileDocumentControl AddNewProgramToTab(DockPanel tabControl, string FileName)
|
|
{
|
|
CodeFileDocumentControl edit = AddNewTab(tabControl);
|
|
|
|
edit.FileName = FileName;
|
|
SetTabPageText(edit);
|
|
edit.SetHighlightingStrategyForFile(FileName);
|
|
OpenDocuments.Add(Tools.FileNameToLower(FileName), edit);
|
|
//this.codeCompletionParserController.SetAsChanged(file_name);
|
|
//ivan
|
|
AddBreakPointHandler(edit, FileName);
|
|
var RunService = WorkbenchServiceFactory.RunService;
|
|
if (!RunService.HasRunArgument(FileName.ToLower()))
|
|
RunService.AddRunArgument(FileName.ToLower(), "");
|
|
if (!WorkbenchServiceFactory.DebuggerManager.IsRunning)
|
|
{
|
|
AddEditorHandlers(edit);
|
|
}
|
|
CodeCompletionKeyHandler.Attach(edit.TextEditor);
|
|
edit.TextEditor.ActiveTextAreaControl.TextArea.KeyEventHandler += TextArea_KeyEventHandler;
|
|
|
|
//HostCallbackImplementation.Register(this);
|
|
|
|
//\ivan
|
|
return edit;
|
|
}
|
|
|
|
private void AddDebugPage(CodeFileDocumentControl tp)
|
|
{
|
|
if (TabStack.Count > 0 && !TabStack.Contains(tp))
|
|
{
|
|
CodeFileDocumentControl cfdc = TabStack[TabStack.Count - 1];
|
|
//TabStack.RemoveAt(TabStack.Count-1);
|
|
RichTextBox tb = null;
|
|
if (OutputTextBoxs.ContainsKey(cfdc))
|
|
{
|
|
tb = OutputTextBoxs[cfdc];
|
|
RichTextBox new_tb = OutputTextBoxs[tp];
|
|
new_tb.Text = tb.Text;
|
|
}
|
|
OutputWindow.OutputTextBoxScrolToEnd();
|
|
}
|
|
if (!TabStack.Contains(tp))
|
|
{
|
|
TabStack.Add(tp);
|
|
OutputBoxStack.Add(OutputTextBoxs[tp]);
|
|
}
|
|
if (DebugTabs[tp] != null) return;
|
|
DebugTabs[tp] = tp.TextEditor.ActiveTextAreaControl.TextArea;
|
|
TextAreaHelper.TextAreas[tp.TextEditor.ActiveTextAreaControl.TextArea] = tp.FileName;
|
|
tp.TextEditor.ActiveTextAreaControl.TextArea.ToolTipRequest += WorkbenchServiceFactory.DebuggerManager.TextAreaToolTipRequest;
|
|
|
|
}
|
|
|
|
private RichTextBox CopyTextBox(RichTextBox orig)
|
|
{
|
|
RichTextBox res = new RichTextBox();
|
|
res.Visible = false;
|
|
res.Font = orig.Font;
|
|
res.Size = orig.Size;
|
|
res.Location = orig.Location;
|
|
res.ScrollBars = orig.ScrollBars;
|
|
res.ReadOnly = orig.ReadOnly;
|
|
res.Dock = orig.Dock;
|
|
res.Multiline = orig.Multiline;
|
|
res.ForeColor = orig.ForeColor;
|
|
res.BackColor = orig.BackColor;
|
|
res.Parent = orig.Parent;
|
|
res.ContextMenuStrip = orig.ContextMenuStrip;
|
|
return res;
|
|
}
|
|
|
|
private void RestoreWatch()
|
|
{
|
|
DebugWatchListWindow.RemoveAll();
|
|
foreach (string s in watches)
|
|
{
|
|
AddVariable(s, false);
|
|
}
|
|
watches.Clear();
|
|
}
|
|
|
|
private void RestoreDesktop()
|
|
{
|
|
AddOutputWindow();
|
|
AddErrorsListWindow();
|
|
AddCompilerConsoleWindow();
|
|
|
|
AddFindSymbolsResultWindow();
|
|
AddDisassemblyWindow(); // Это нельзя убирать - почему то оболочка закрывается при запуске программы!!!
|
|
HideContent(FindSymbolsResultWindow);
|
|
HideContent(DisassemblyWindow);
|
|
AddDebugVariablesListWindow();
|
|
HideContent(DebugVariablesListWindow);
|
|
AddDebugWatchListWindow();
|
|
HideContent(DebugWatchListWindow);
|
|
/*AddImmediateWindow();
|
|
|
|
|
|
if (!Tools.IsUnix())
|
|
{
|
|
AddProjectExplorerWindow();
|
|
AddPropertiesWindow();
|
|
}
|
|
//SelectContent(OutputWindow, false);
|
|
//if (!Tools.IsUnix())
|
|
// SelectContent(ProjectExplorerWindow, false);
|
|
|
|
//HideContent(ImmediateWindow);
|
|
|
|
//HideContent(DebugWatchListWindow);
|
|
|
|
if (!Tools.IsUnix())
|
|
{
|
|
//HideContent(PropertiesWindow);
|
|
HideContent(ProjectExplorerWindow);
|
|
}*/
|
|
OutputWindow.Activate();
|
|
}
|
|
|
|
bool VisualPascalABCPlugins.IWorkbenchDocumentService.ContainsTab(VisualPascalABCPlugins.ICodeFileDocument tab)
|
|
{
|
|
return TabStack.Contains(tab as CodeFileDocumentControl);
|
|
}
|
|
|
|
internal void HideContent(DockContent dc)
|
|
{
|
|
if (!dc.IsDisposed)
|
|
dc.Hide();
|
|
}
|
|
|
|
internal void ShowContent(DockContent dc, bool activate)
|
|
{
|
|
if (activate || dc.Pane == null)
|
|
dc.Show();
|
|
else
|
|
{
|
|
IDockContent a = dc.Pane.ActiveContent;
|
|
dc.Show();
|
|
if (a != null)
|
|
dc.Pane.ActiveContent = a;
|
|
}
|
|
}
|
|
|
|
internal void SelectContent(DockContent dc, bool Activate)
|
|
{
|
|
dc.Activate();
|
|
}
|
|
|
|
public void ChangedSelectedTab()
|
|
{
|
|
if (HealthLabel.Text != "")
|
|
HealthLabel.Text = "";
|
|
if (BrowserTabSelected)
|
|
{
|
|
BottomTabsVisible = true;
|
|
BrowserTabSelected = false;
|
|
CurrentWebBrowserControl = null;
|
|
SetFocusToEditor();
|
|
}
|
|
if (BakSelectedTab == CurrentCodeFileDocument)
|
|
return;
|
|
LastSelectedTab = BakSelectedTab;
|
|
BakSelectedTab = CurrentCodeFileDocument;
|
|
|
|
if (LastSelectedTab != null && LastSelectedTab.DesignerAndCodeTabs != null)
|
|
{
|
|
//LastSelectedTab.Designer.host.HideCombo();
|
|
}
|
|
|
|
if (CurrentCodeFileDocument != null && CurrentCodeFileDocument.DesignerAndCodeTabs != null)
|
|
{
|
|
// CurrentCodeFileDocument.Designer.host.ShowCombo();
|
|
}
|
|
|
|
if (OutputTextBoxs[CurrentCodeFileDocument] != OutputWindow.outputTextBox)
|
|
{
|
|
OutputTextBoxs[CurrentCodeFileDocument].Visible = true;
|
|
OutputWindow.outputTextBox.Visible = false;
|
|
OutputWindow.outputTextBox = OutputTextBoxs[CurrentCodeFileDocument];
|
|
}
|
|
CodeCompletion.CodeCompletionController.SetParser(Path.GetExtension(CurrentCodeFileDocument.FileName));
|
|
SetFocusToEditor();
|
|
bool run = WorkbenchServiceFactory.RunService.IsRun(CurrentEXEFileName);
|
|
WorkbenchServiceFactory.DebuggerManager.SetAsPossibleDebugPage(CurrentCodeFileDocument);
|
|
bool debug = WorkbenchServiceFactory.DebuggerManager.IsRunAndInThisTabPage(CurrentEXEFileName, CurrentCodeFileDocument);
|
|
if (!debug)
|
|
{
|
|
SetStopEnabled(run);
|
|
}
|
|
else SetStopEnabled(debug);
|
|
//if (debug) SetStopEnabled(debug);
|
|
if (VisualEnvironmentCompiler != null)
|
|
if (!debug)
|
|
{
|
|
SetCompilingButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded);
|
|
SetDebugButtonsEnabled(!run && VisualEnvironmentCompiler.compilerLoaded);
|
|
}
|
|
else
|
|
{
|
|
SetCompilingButtonsEnabled(!debug);
|
|
SetDebugButtonsAsByDebug();
|
|
}
|
|
else
|
|
SetCompilingButtonsEnabled(false);
|
|
SaveButtonsEnabled = CurrentCodeFileDocument.DocumentChanged;
|
|
UpdateUndoRedoEnabled();
|
|
UpdateCutCopyButtonsEnabled();
|
|
UpdateLineColPosition();
|
|
WorkbenchServiceFactory.RunService.UpdateReadRequest(true);
|
|
//UpdateDesignerIsActive();
|
|
}
|
|
|
|
public void OpenTabWithText(string tabName, string Text)
|
|
{
|
|
CodeFileDocumentControl edit = FindTab(tabName + ".pas");
|
|
if (edit != null)
|
|
{
|
|
CurrentCodeFileDocument = edit;
|
|
return;
|
|
}
|
|
edit = AddNewTab(MainDockPanel);
|
|
edit.FromMetadata = true;
|
|
OpenDocuments.Add(Tools.FileNameToLower(tabName + ".pas"), edit);
|
|
CloseButtonsEnabled = OpenDocuments.Count > 1;
|
|
edit.FileName = tabName + ".pas";
|
|
edit.Text = tabName;
|
|
edit.SetHighlightingStrategyForFile("prog.pas");
|
|
edit.TextEditor.Document.Insert(0, Text);
|
|
if (!WorkbenchServiceFactory.DebuggerManager.IsRunning)
|
|
{
|
|
AddEditorHandlers(edit);
|
|
}
|
|
WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(tabName + ".pas");
|
|
//edit.file_name = file_name;
|
|
//SetTabPageText(edit);
|
|
}
|
|
|
|
public ICodeFileDocument GetTabPageForMainFile()
|
|
{
|
|
return OpenFileAndNoSelection(ProjectFactory.Instance.CurrentProject.MainFile);
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
void AddTextToOutputWindow(string ExeFileName, string Text)
|
|
{
|
|
//OutputWindow.outputTextBox.SelectionColor = System.Drawing.Color.Green;
|
|
//MessageBox.Show(Text + " ! " + Text.Length.ToString());
|
|
//if ((DateTime.Now - dt).TotalSeconds >= 1)
|
|
// Application.DoEvents()
|
|
ExeFileName = Tools.FileNameToLower(ExeFileName);
|
|
if (WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow)
|
|
{
|
|
WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow = false;
|
|
CurrentCodeFileDocument = WorkbenchServiceFactory.RunService.GetRunTab(ExeFileName) as CodeFileDocumentControl;
|
|
}
|
|
BottomTabsVisible = true;
|
|
if (BottomActiveContent != OutputWindow)
|
|
{
|
|
OutputWindow.Activate();
|
|
CurrentCodeFileDocument.Activate();
|
|
OutputWindow.Activate();
|
|
}
|
|
TextBoxBase textBox = OutputTextBoxs[WorkbenchServiceFactory.RunService.GetRunTab(ExeFileName) as CodeFileDocumentControl];
|
|
textBox.BeginInvoke(new AppendTextInternalAsyncDelegate(AppendTextInternalAsync), textBox, Text);
|
|
if (textBox == OutputWindow.outputTextBox)
|
|
OutputWindow.OutputTextBoxScrolToEnd();
|
|
if (WorkbenchServiceFactory.DebuggerManager.IsRun(ExeFileName))
|
|
{
|
|
for (int i = 0; i < TabStack.Count; i++)
|
|
{
|
|
TextBoxBase tb = OutputTextBoxs[TabStack[i]];
|
|
if (textBox != tb)
|
|
tb.BeginInvoke(new AppendTextInternalAsyncDelegate(AppendTextInternalAsync), tb, Text);
|
|
}
|
|
}
|
|
if (!WorkbenchServiceFactory.RunService.IsRun(ExeFileName))
|
|
SetFocusToEditor();
|
|
}
|
|
|
|
delegate void AppendTextInternalAsyncDelegate(TextBoxBase textBox, string Text);
|
|
|
|
private void AppendTextInternalAsync(TextBoxBase textBox, string Text)
|
|
{
|
|
//MessageBox.Show(string.Join(" ", Text.Select(c => ((int)c).ToString())));
|
|
textBox.AppendText(Text);
|
|
}
|
|
|
|
delegate void InternalWriteToOutputBoxDel(string exc);
|
|
|
|
private void InternalWriteToOutputBox(string exc)
|
|
{
|
|
OutputWindow.outputTextBox.AppendText(exc);
|
|
}
|
|
|
|
public void WriteToOutputBox(string excep, bool is_exc)
|
|
{
|
|
if (is_exc)
|
|
SelectContent(OutputWindow, false);
|
|
OutputWindow.outputTextBox.Invoke(new InternalWriteToOutputBoxDel(InternalWriteToOutputBox), excep);//AppendText(excep);
|
|
}
|
|
|
|
public void AddTextToOutputWindowSync(string fileName, string text)
|
|
{
|
|
//BeginInvoke(new SetFileNameAndTextDelegate(AddTextToOutputWindow), file_name, text);
|
|
Invoke(new SetFileNameAndTextDelegate(AddTextToOutputWindow), fileName, text);
|
|
}
|
|
|
|
private void AppendTextToConsoleCompiler(object text)
|
|
{
|
|
CompilerConsoleWindow.AppendTextToConsoleCompiler(text);
|
|
}
|
|
|
|
public void AddTextToCompilerMessages(string text)
|
|
{
|
|
CompilerConsoleWindow.AddTextToCompilerMessages(text);
|
|
}
|
|
|
|
public void AddTextToCompilerMessagesSync(string text)
|
|
{
|
|
BeginInvoke(new SetTextDelegate(AddTextToCompilerMessages), text);
|
|
}
|
|
|
|
public void ClearErrorList()
|
|
{
|
|
ErrorsListWindow.lvErrorsList.Items.Clear();
|
|
//lvErrorsList.Update();
|
|
WorkbenchServiceFactory.BuildService.ErrorsList.Clear();
|
|
}
|
|
|
|
void CheckErrorListAndClear(string FileName)
|
|
{
|
|
if (WorkbenchServiceFactory.BuildService.ErrorsList.Count > 0)
|
|
{
|
|
PascalABCCompiler.Errors.LocatedError er = WorkbenchServiceFactory.BuildService.ErrorsList[0] as PascalABCCompiler.Errors.LocatedError;
|
|
if (er != null && er.SourceLocation != null && er.SourceLocation.FileName.ToLower() == FileName.ToLower())
|
|
ClearErrorList();
|
|
|
|
}
|
|
}
|
|
|
|
public void ClearOutputTextBoxForTabPage(ICodeFileDocument tabPage)
|
|
{
|
|
ClearTextBox(OutputTextBoxs[tabPage]);
|
|
}
|
|
|
|
public void SendNewLineToInputTextBox()
|
|
{
|
|
if (WorkbenchServiceFactory.DebuggerManager.IsRun(CurrentEXEFileName) && OutputBoxStack.Contains(OutputWindow.outputTextBox))
|
|
{
|
|
|
|
foreach (TextBoxBase tb in OutputBoxStack)
|
|
if (tb != OutputWindow.outputTextBox)
|
|
{
|
|
tb.AppendText(Environment.NewLine);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ClearAndSaveWatch()
|
|
{
|
|
watches.AddRange(DebugWatchListWindow.GetExpressions());
|
|
DebugWatchListWindow.RemoveAll();
|
|
}
|
|
|
|
private void ClearTextBox(RichTextBox rtb)
|
|
{
|
|
var zoomf = rtb.ZoomFactor;
|
|
rtb.Clear();
|
|
rtb.ZoomFactor = zoomf;
|
|
}
|
|
|
|
public void ClearTabStack()
|
|
{
|
|
foreach (CodeFileDocumentControl cfdc in TabStack)
|
|
{
|
|
if (cfdc != debuggedPage)
|
|
{
|
|
if (OutputTextBoxs.ContainsKey(cfdc))
|
|
{
|
|
ClearTextBox(OutputTextBoxs[cfdc]);
|
|
}
|
|
}
|
|
}
|
|
OutputBoxStack.Clear();
|
|
TabStack.Clear();
|
|
}
|
|
|
|
public void ClearWatch()
|
|
{
|
|
if (DebugWatchListWindow == null)
|
|
return;
|
|
for (int i = 0; i < this.WdataGridView1.Rows.Count; i++)
|
|
{
|
|
DebugWatchListWindow.SetUndefinedValue(i);
|
|
}
|
|
}
|
|
|
|
public void DisplayDisassembledCode(string code)
|
|
{
|
|
if (DisassemblyWindow != null)
|
|
DisassemblyWindow.SetDisassembledCode(code);
|
|
}
|
|
|
|
public void ClearDebugTabs()
|
|
{
|
|
foreach (TextArea ta in DebugTabs.Values)
|
|
{
|
|
ta.ToolTipRequest -= WorkbenchServiceFactory.DebuggerManager.TextAreaToolTipRequest;
|
|
}
|
|
DebugTabs.Clear();
|
|
}
|
|
|
|
public void ClearLocalVarTree()
|
|
{
|
|
if (DebugVariablesListWindow != null)
|
|
DebugVariablesListWindow.ClearAllSubTrees();
|
|
}
|
|
|
|
private delegate void RefreshPadDelegate(IList<IListItem> items);
|
|
|
|
private void RefreshPadInvoke(IList<IListItem> items)
|
|
{
|
|
try
|
|
{
|
|
if (DebugWatchListWindow != null)
|
|
DebugWatchListWindow.RefreshWatch();
|
|
AdvancedDataGridView.TreeGridNode.UpdateNodesForLocalList(DebugVariablesListWindow.watchList, DebugVariablesListWindow.watchList.Nodes, items);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
#if (DEBUG)
|
|
Console.WriteLine(ex.Message + " " + ex.StackTrace);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public void RefreshPad(IList<IListItem> items)
|
|
{
|
|
Invoke(new RefreshPadDelegate(RefreshPadInvoke), items);
|
|
}
|
|
|
|
public void GotoWatch()
|
|
{
|
|
BottomTabsVisible = true;
|
|
SelectContent(DebugWatchListWindow, true);
|
|
DebugWatchListWindow.AddNewEntry("");
|
|
}
|
|
}
|
|
}
|