Sfall-ScriptEditor
1360 строк · 58.0 Кб
1using System;2using System.Collections.Generic;3using System.Drawing;4using System.IO;5using System.Windows.Forms;6
7using ICSharpCode.TextEditor;8using ICSharpCode.TextEditor.Document;9
10using ScriptEditor.CodeTranslation;11
12using ScriptEditor.TextEditorUI;13using ScriptEditor.TextEditorUI.Nodes;14
15using ScriptEditor.TextEditorUtilities;16
17namespace ScriptEditor18{
19partial class TextEditor20{21#region Main functions22
23public enum OpenType { None, File, Text }24
25public TabInfo Open(string file, OpenType type, bool addToMRU = true, bool alwaysNew = false, bool recent = false, bool seltab = true,26bool commandline = false, bool fcdOpen = false, bool alreadyOpen = true, bool outputFolder = false, bool clearBuildLog = true)27{28bool decompileSuccess = false;29string infile = null;30
31if (type == OpenType.File) {32if (!Path.IsPathRooted(file))33file = Path.GetFullPath(file);34
35if (commandline && Path.GetExtension(file).ToLowerInvariant() == ".msg") {36if (currentTab == null)37wState = FormWindowState.Minimized;38MessageEditor.MessageEditorOpen(file, this).SendMsgLine += AcceptMsgLine;39return null;40}41// Check file42bool Exists;43if (!FileAssociation.CheckFileAllow(file, out Exists))44return null;45//Add this file to the recent files list46if (addToMRU) {47if (!Exists && recent && MessageBox.Show("This recent file not found. Delete recent link to file?", "Open file error", MessageBoxButtons.YesNo) == DialogResult.Yes)48recent = true;49else50recent = false; // don't delete file link from recent list51Settings.AddRecentFile(file, recent);52UpdateRecentList();53}54if (!Exists)55return null;56//If this is an int, decompile57if (string.Compare(Path.GetExtension(file), ".int", true) == 0) {58if (!this.Focused)59ShowMe();60
61infile = file;62if (clearBuildLog) tbOutput.Clear();63tabControl2.SelectedIndex = 1;64MaximizeLog();65
66string decomp = new Compiler(roundTrip).Decompile(file, this);67if (decomp == null) {68MessageBox.Show("Decompilation of '" + file + "' was not successful", "Error");69return null;70} else {71file = decomp;72decompileSuccess = true;73// fix for procedure begin74ParserInternal.FixProcedureBegin(file);75}76} else {77//Check if the file is already open78var tab = CheckTabs(tabs, file);79if (tab != null) {80if (seltab)81tabControl1.SelectTab(tab.index);82ShowMe();83if (!alreadyOpen || MessageBox.Show("This file is already open!\nDo you want to open another one same file?", "Question",84MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)85return tab;86}87}88}89//Create the text editor and set up the tab90ICSharpCode.TextEditor.TextEditorControl te = new ICSharpCode.TextEditor.TextEditorControl();91
92if (caretSoftwareModeToolStripMenuItem.CheckState == CheckState.Indeterminate)93caretSoftwareModeToolStripMenuItem.Checked = (Caret.GraphicsMode == ImplementationMode.SoftwareMode);94
95te.TextEditorProperties.LineViewerStyle = LineViewerStyle.FullRow;96te.TextEditorProperties.TabIndent = Settings.tabSize;97te.TextEditorProperties.IndentationSize = Settings.tabSize;98te.TextEditorProperties.ShowTabs = Settings.showTabsChar;99te.TextEditorProperties.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;100te.TextEditorProperties.NativeDrawText = Settings.winAPITextRender;101te.TextEditorProperties.DarkScheme = ColorTheme.IsDarkTheme;102
103if (type == OpenType.File && String.Compare(Path.GetExtension(file), ".msg", true) == 0) {104te.Document.TextEditorProperties.Encoding = Settings.EncCodePage;105te.SetHighlighting(ColorTheme.IsDarkTheme ? "MessageDark": "Message");106te.TextEditorProperties.EnableFolding = false;107te.TextEditorProperties.ConvertTabsToSpaces = false;108te.TextEditorProperties.ShowVerticalRuler = false;109te.TextEditorProperties.IndentStyle = IndentStyle.None;110te.TextEditorProperties.ShowLineNumbers = false;111te.TextEditorProperties.Font = new Font("Verdana", 10 + Settings.sizeFont, FontStyle.Regular, GraphicsUnit.Point);112} else {113te.SetHighlighting(ColorTheme.HighlightingScheme); // Activate the highlighting, use the name from the SyntaxDefinition node.114te.Document.FoldingManager.FoldingStrategy = new CodeFolder();115te.TextEditorProperties.ConvertTabsToSpaces = Settings.tabsToSpaces;116te.TextEditorProperties.ShowSpaces = Settings.showTabsChar;117te.TextEditorProperties.IndentStyle = IndentStyle.Smart;118te.TextEditorProperties.ShowVerticalRuler = Settings.showVRuler;119te.TextEditorProperties.VerticalRulerRow = Settings.tabSize;120te.TextEditorProperties.AllowCaretBeyondEOL = true;121//te.TextEditorProperties.CaretLine = true;122Settings.SetTextAreaFont(te);123}124
125if (type == OpenType.File)126te.LoadFile(file, false, true);127else if (type == OpenType.Text)128te.Text = file;129
130// set tabinfo131TabInfo ti = new TabInfo();132ti.index = tabControl1.TabCount;133ti.history.linePosition = new List<TextLocation>();134ti.history.pointerCur = -1;135ti.textEditor = te;136
137bool createNew = false;138if (type == OpenType.None) { // only for new create script139sfdScripts.FileName = "NewScript";140if (sfdScripts.ShowDialog() == DialogResult.OK) {141file = sfdScripts.FileName;142type = OpenType.File;143ti.changed = true;144te.Text = Properties.Resources.newScript;145} else146return null;147createNew = true;148} //else149// ti.changed = false;150
151if (type == OpenType.File ) { //&& !alwaysNew152if (alwaysNew) {153string temp = Path.Combine(Settings.scriptTempPath, unsaved);154File.Copy(file, temp, true);155file = temp;156}157ti.filepath = file;158ti.filename = Path.GetFileName(file);159} else {160ti.filepath = null;161ti.filename = unsaved;162}163
164tabs.Add(ti);165TabPage tp = new TabPage(ti.filename);166tp.ImageIndex = (ti.changed) ? 1 : 0;167tp.Controls.Add(te);168te.Dock = DockStyle.Fill;169tabControl1.TabPages.Add(tp);170if (tabControl1.TabPages.Count == 1)171EnableFormControls();172if (type == OpenType.File) {173if (!alwaysNew)174tp.ToolTipText = ti.filepath;175string ext = Path.GetExtension(file).ToLowerInvariant();176if (ext == ".ssl" || ext == ".h") {177te.Text = Utilities.NormalizeNewLine(te.Text);178if (formatCodeToolStripMenuItem.Checked)179te.Text = Utilities.FormattingCode(te.Text);180ti.shouldParse = true;181//ti.needsParse = true; // set 'true' only edit text182
183FirstParseScript(ti); // First Parse184
185if (!createNew && Settings.storeLastPosition) {186int pos = Settings.GetLastScriptPosition(ti.filename.ToLowerInvariant());187te.ActiveTextAreaControl.Caret.Line = pos;188te.ActiveTextAreaControl.CenterViewOn(pos, -1);189}190if (Settings.autoOpenMsgs && ti.filepath != null)191AssociateMsg(ti, false);192}193ti.FileTime = File.GetLastWriteTime(ti.filepath);194}195te.OptionsChanged();196// TE events197te.TextChanged += textChanged;198SetActiveAreaEvents(te);199te.ContextMenuStrip = editorMenuStrip;200//201if (tabControl1.TabPages.Count > 1) {202if (seltab)203tabControl1.SelectTab(tp);204} else205tabControl1_Selected(null, null);206
207if (fcdOpen)208dialogNodesDiagramToolStripMenuItem_Click(null, null);209
210if (!roundTrip && decompileSuccess) {211SaveFileDialog sfDecomp = new SaveFileDialog();212sfDecomp.Title = "Enter name to save decompile file";213sfDecomp.Filter = "Script files|*.ssl";214sfDecomp.RestoreDirectory = true;215sfDecomp.InitialDirectory = (!outputFolder || Settings.outputDir == null) ? Path.GetDirectoryName(infile) : Settings.outputDir;216sfDecomp.FileName = Path.GetFileNameWithoutExtension(infile);217
218if (sfDecomp.ShowDialog() == DialogResult.OK) {219ti.filename = Path.GetFileName(sfDecomp.FileName);220ti.filepath = sfDecomp.FileName;221
222File.Copy(file, ti.filepath, true);223File.Delete(file);224ti.FileTime = File.GetLastWriteTime(ti.filepath);225
226tabControl1.TabPages[ti.index].Text = tabs[ti.index].filename;227tabControl1.TabPages[ti.index].ToolTipText = tabs[ti.index].filepath;228this.Text = SSE + ti.filepath + ((pDefineStripComboBox.SelectedIndex > 0) ? " [" + pDefineStripComboBox.Text + "]" : "");229
230ForceParseScript();231}232sfDecomp.Dispose();233}234return ti;235}236
237private void CheckChandedFile()238{239if (!currentTab.CheckFileTime()) {240this.Activated -= TextEditor_Activated;241DialogResult result = MessageBox.Show(currentTab.filepath +242"\nThe script file was changed outside the editor." +243"\nDo you want to update the script file?",244"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);245if (result == DialogResult.Yes) {246currentTab.FileTime = File.GetLastWriteTime(currentTab.filepath);247int caretLine = currentActiveTextAreaCtrl.Caret.Line;248int scrollValue = currentActiveTextAreaCtrl.VScrollBar.Value;249currentTab.textEditor.BeginUpdate();250currentTab.textEditor.LoadFile(currentTab.filepath, false, true);251currentActiveTextAreaCtrl.VScrollBar.Value = scrollValue;252currentActiveTextAreaCtrl.Caret.Line = caretLine;253currentTab.textEditor.EndUpdate();254
255currentTab.changed = false;256SetTabTextChange(currentTab.index);257} else258currentTab.FileTime = File.GetLastWriteTime(currentTab.filepath);259this.Activated += TextEditor_Activated;260}261}262
263private void Save(TabInfo tab, bool close = false)264{265if (tab != null) {266if (tab.filepath == null) {267SaveAs(tab, close);268return;269}270while (bwSyntaxParser.IsBusy) {271System.Threading.Thread.Sleep(50); // Avoid stomping on files while the parser is running272Application.DoEvents();273}274savingRunning = true;275bool msg = (Path.GetExtension(tab.filename) == ".msg");276
277if (Settings.autoTrailingSpaces && !msg) {278new ICSharpCode.TextEditor.Actions.RemoveTrailingWS().Execute(currentActiveTextAreaCtrl.TextArea);279}280if (close && tab.textEditor.Document.FoldingManager.FoldMarker.Count > 0) {281CodeFolder.SetProceduresCollapsed(tab.textEditor.Document, tab.filename);282}283string saveText = tab.textEditor.Text;284if (msg && Settings.EncCodePage.CodePage == 866) {285saveText = saveText.Replace('\u0425', '\u0058'); // Replacement russian letter "X", to english letter286}287Utilities.ConvertToUnixPlatform(ref saveText);288
289tab.SaveInternal(saveText, tab.textEditor.Encoding, msg, close, tab.shouldParse);290
291if (tab.changed && Settings.pathHeadersFiles != null && Path.GetExtension(tab.filename).ToLowerInvariant() == ".h" &&292String.Equals(Settings.pathHeadersFiles, Path.GetDirectoryName(tab.filepath), StringComparison.OrdinalIgnoreCase)) {293GetMacros.GetGlobalMacros(Settings.pathHeadersFiles);294}295
296tab.changed = false;297SetTabTextChange(tab.index);298savingRunning = false;299}300}301
302private void SaveAs(TabInfo tab, bool close = false)303{304if (tab == null)305return;306
307switch (Path.GetExtension(tab.filename).ToLowerInvariant()) {308case ".ssl":309sfdScripts.FilterIndex = 1;310break;311case ".h":312sfdScripts.FilterIndex = 2;313break;314case ".msg":315sfdScripts.FilterIndex = 3;316break;317default:318sfdScripts.FilterIndex = 4;319break;320}321sfdScripts.FileName = tab.filename;322
323if (sfdScripts.ShowDialog() == DialogResult.OK) {324tab.filepath = sfdScripts.FileName;325tab.filename = Path.GetFileName(tab.filepath);326tabControl1.TabPages[tab.index].Text = tabs[tab.index].filename;327tabControl1.TabPages[tab.index].ToolTipText = tabs[tab.index].filepath;328Save(tab, close);329Settings.AddRecentFile(tab.filepath);330string ext = Path.GetExtension(tab.filepath).ToLowerInvariant();331if (Settings.enableParser && (ext == ".ssl" || ext == ".h")) {332tab.shouldParse = true;333tab.needsParse = true;334tab.parseInfo.reParseData = true;335parserLabel.Text = "Parser: Wait for update";336ParseScript();337}338this.Text = SSE + tab.filepath + ((pDefineStripComboBox.SelectedIndex > 0) ? " [" + pDefineStripComboBox.Text + "]" : "");339}340}341
342private void Close(TabInfo tab)343{344if (tab == null | tab.index == -1)345return;346
347int i = tab.index;348var tag = tabControl1.TabPages[i].Tag;349if (tag != null)350((NodeDiagram)tag).Close(); //also close diagram editor351
352while (tab.nodeFlowchartTE.Count > 0)353tab.nodeFlowchartTE[0].CloseEditor(true);354
355bool skip = tab.changed; // если изменен, то пропустить сохранение состояний Folds в методе KeepScriptSetting356if (tab.changed) {357switch (MessageBox.Show("Save changes to " + tab.filename + "?", "Message", MessageBoxButtons.YesNoCancel)) {358case DialogResult.Yes:359Save(tab, true);360if (tab.changed)361return;362break;363case DialogResult.No:364break;365default:366return;367}368}369KeepScriptSetting(tab, skip);370
371if (i == tabControl1.SelectedIndex && tabControl1.TabPages.Count >= 3) {372if (previousTabIndex != -1) {373tabControl1.SelectedIndex = previousTabIndex; // переход к предыдущей выбранной вкладке374}375else if (tabControl1.SelectedIndex < tabControl1.TabPages.Count - 1) {376if (i > 0) tabControl1.SelectedIndex++; // переход к следущей по номеру вкладки377} else {378tabControl1.SelectedIndex--;379}380}381tabControl1.TabPages.RemoveAt(i);382tabs.RemoveAt(i);383
384for (int j = i; j < tabs.Count; j++) tabs[j].index--;385
386for (int j = 0; j < tabs.Count; j++)387{388if (tabs[j].msgFileTab == tab) {389tabs[j].msgFileTab = null;390tabs[j].messages.Clear();391}392}393tab.index = -1;394previousTabIndex = -1; // сбросить после удаления вкладки395}396
397private bool Compile(TabInfo tab, out string msg, bool showMessages = true, bool preprocess = false, bool showIcon = true)398{399msg = String.Empty;400if (string.Compare(Path.GetExtension(tab.filename), ".ssl", true) != 0) {401if (showMessages) MessageBox.Show("You cannot compile this file.", "Compile Error");402return false;403}404if (!Settings.ignoreCompPath && !preprocess && Settings.outputDir == null) {405if (showMessages) MessageBox.Show("No output path selected.\nPlease select your scripts directory before compiling", "Compile Error");406return false;407}408if (tab.changed) Save(tab);409if (tab.changed || tab.filepath == null) return false;410
411bool success = new Compiler(roundTrip).Compile(tab.filepath, out msg, tab.buildErrors, preprocess, tab.parseInfo.ShortCircuitEvaluation);412
413foreach (ErrorType et in new ErrorType[] { ErrorType.Error, ErrorType.Warning, ErrorType.Message })414{415foreach (Error e in tab.buildErrors)416{417if (e.type == et) {418dgvErrors.Rows.Add(e.type.ToString(), Path.GetFileName(e.fileName), e.line, e);419if (et == ErrorType.Error) dgvErrors.Rows[dgvErrors.Rows.Count - 1].Cells[0].Style.ForeColor = Color.Red;420}421}422}423
424if (dgvErrors.RowCount > 0) dgvErrors.Rows[0].Cells[0].Selected = false;425
426if (preprocess) return success;427
428if (!success) {429parserLabel.Text = "Failed to compiled: " + tab.filename;430parserLabel.ForeColor = Color.Firebrick;431msg += "\r\n Compilation Failed! (See the output build and errors window log for details).";432CompileFail.Play();433
434if (showMessages) {435if (Settings.warnOnFailedCompile) {436tabControl2.SelectedIndex = 2 - Convert.ToInt32(Settings.userCmdCompile);437MaximizeLog();438}// else439// new CompiledStatus(false, this).ShowCompileStatus();440}441} else {442if (showMessages && showIcon)443new CompiledStatus(true, this).ShowCompileStatus();444parserLabel.Text = "Compiled: " + tab.filename + " at " + DateTime.Now.ToString("HH:mm:ss");445parserLabel.ForeColor = Color.DarkGreen;446msg += "\r\n Compilation Successfully!\r\n";447}448return success;449}450#endregion451
452#region Tabs control functions453
454internal static TabInfo CheckTabs(List<TabInfo> tabs, string filepath)455{456foreach (TabInfo tab in tabs)457{458if (String.Equals(tab.filepath, filepath, StringComparison.OrdinalIgnoreCase)) return tab;459}460return null;461}462
463internal static bool CheckTabs(string filepath, List<TabInfo> tabs)464{465return CheckTabs(tabs, filepath) != null;466}467
468private void SetTabTextChange(int i) { tabControl1.TabPages[i].ImageIndex = (tabs[i].changed ? 1 : 0); }469
470private void SwitchToTab(int index)471{472if (tabControl1.TabPages.Count > 1) tabControl1.SelectTab(index);473}474
475// Called when creating a new document and when switching tabs476private void tabControl1_Selected(object sender, TabControlEventArgs e)477{478// останавливаем таймеры парсеров479intParserTimer.Stop();480extParserTimer.Stop();481
482if (tabControl1.SelectedIndex == -1) {483currentTab = null;484parserLabel.Text = (Settings.enableParser) ? "Parser: No file" : parseoff;485SetFormControlsOff();486} else {487if (currentTab != null) {488previousTabIndex = currentTab.index;489}490currentTab = tabs[tabControl1.SelectedIndex];491//if (!Settings.enableParser && currentTab.parseInfo != null)492// currentTab.parseInfo.parseData = false;493
494if (currentTab.msgFileTab != null)495MessageFile.ParseMessages(currentTab);496
497// Create or Delete Variable treeview498if (!Settings.enableParser && tabControl3.TabPages.Count > 2) {499if (currentTab.parseInfo != null) {500if (!currentTab.parseInfo.parseData) {501tabControl3.TabPages.RemoveAt(1);502}503} else {504tabControl3.TabPages.RemoveAt(1);505}506} else if (tabControl3.TabPages.Count < 3 && (Settings.enableParser || currentTab.parseInfo != null)) {507if (currentTab.parseInfo != null && currentTab.parseInfo.parseData) {508CreateTabVarTree();509}510}511if (currentTab.shouldParse) {512if (Settings.enableParser && currentTab.parseInfo.parseError && !currentTab.needsParse) {513parserLabel.Text = "Parser: Parsing script error (see parser errors log)";514} else515if (currentTab.needsParse) {516parserLabel.Text = (Settings.enableParser) ? "Parser: Waiting to update..." : parseoff;517// Update parse info518ParseScript();519} else520parserLabel.Text = (Settings.enableParser) ? "Parser: Idle" : parseoff;521} else522parserLabel.Text = (Settings.enableParser) ? "Parser: Not an SSL file" : parseoff;523
524UpdateLog();525currentHighlightProc = null;526UpdateNames(true);527// text editor set focus528currentActiveTextAreaCtrl.Select();529ControlFormStateOn_Off();530this.Text = SSE + currentTab.filepath + ((pDefineStripComboBox.SelectedIndex > 0) ? " [" + pDefineStripComboBox.Text + "]" : "");531
532if (sender != null) CheckChandedFile();533}534}535#endregion536
537// Goto script text of selected Variable or Procedure in treeview538public void SelectLine(string file, int line, bool pselect = false, int column = -1, int sLen = -1)539{540if (line <= 0) return;541
542bool not_this = false;543if (currentTab == null || file != currentTab.filepath) {544if (Open(file, OpenType.File, false, alreadyOpen: false) == null) {545MessageBox.Show("Could not open file '" + file + "'", "Error");546return;547}548not_this = true;549}550LineSegment ls;551if (line > currentDocument.TotalNumberOfLines)552ls = currentDocument.GetLineSegment(currentDocument.TotalNumberOfLines - 1);553else554ls = currentDocument.GetLineSegment(line - 1);555
556TextLocation start, end;557if (column == -1 || column > ls.Length) {558start = new TextLocation(0, ls.LineNumber);559if (column == -1)560end = new TextLocation(ls.Length, ls.LineNumber);561else562end = new TextLocation(0, ls.LineNumber);563} else {564column--;565if (sLen == -1) {566foreach (var w in ls.Words)567{568if (w.Type != TextWordType.Word)569continue;570int pos = w.Offset + w.Length;571if ((column >= w.Offset) && (column <= pos)) {572column = w.Offset;573sLen = w.Length;574break;575}576}577}578start = new TextLocation(column, ls.LineNumber);579end = new TextLocation(start.Column + sLen, ls.LineNumber);580}581// Expand or Collapse folding582foreach (FoldMarker fm in currentDocument.FoldingManager.FoldMarker) {583if (OnlyProcStripButton.Checked) {584if (fm.FoldType == FoldType.MemberBody || fm.FoldType == FoldType.Region) {585if (fm.StartLine == start.Line)586fm.IsFolded = false;587else if (fm.FoldType != FoldType.Region)588fm.IsFolded = true;589}590} else {591if (fm.StartLine == start.Line) {592fm.IsFolded = false;593break;594}595}596}597// Scroll and select598currentActiveTextAreaCtrl.Caret.Position = start;599if (not_this || !pselect || !OnlyProcStripButton.Checked)600currentActiveTextAreaCtrl.SelectionManager.SetSelection(start, end);601else602currentActiveTextAreaCtrl.SelectionManager.ClearSelection();603
604if (!not_this) {605if (pselect)606currentActiveTextAreaCtrl.TextArea.TextView.FirstVisibleLine = start.Line - 1;607else608currentActiveTextAreaCtrl.CenterViewOn(start.Line + 10, 0);609} else610currentActiveTextAreaCtrl.CenterViewOn(start.Line - 15, 0);611currentTab.textEditor.Refresh();612}613
614#region Tree browser control615
616private void CreateTabVarTree() { tabControl3.TabPages.Insert(1, VarTab); }617
618private enum TreeStatus { idle, update, freeze }619
620internal static Procedure currentHighlightProc = null;621private static TreeNode currentHighlightNode = null;622private bool updateHighlightPocedure = true;623
624// подсветить процедуру в дереве625private void HighlightCurrentPocedure(int curLine)626{627Procedure proc;628if (curLine == -2) {629proc = currentHighlightProc;630currentHighlightProc = null;631currentHighlightNode = null;632} else {633proc = currentTab.parseInfo.GetProcedureFromPosition(curLine);634}635if (proc != null && proc != currentHighlightProc) {636if (currentHighlightProc != null && currentHighlightProc.name.Equals(proc.name, StringComparison.OrdinalIgnoreCase)) return;637TreeNodeCollection nodes;638if (ProcTree.Nodes.Count > 1)639nodes = ProcTree.Nodes[1].Nodes;640else641nodes = ProcTree.Nodes[0].Nodes; // for parser off642foreach (TreeNode node in nodes)643{644string name = ((Procedure)node.Tag).name;645if (name == proc.name) {646node.Text = node.Text.Insert(0, "► ");647node.ForeColor = ColorTheme.HighlightProcedureTree;648if (currentHighlightNode != null) {649currentHighlightNode.ForeColor = ProcTree.ForeColor;650currentHighlightNode.Text = currentHighlightNode.Text.Substring(2);651}652currentHighlightProc = proc;653currentHighlightNode = node;654break;655}656}657} else if (currentHighlightProc != null && currentHighlightProc != proc) {658currentHighlightNode.Text = currentHighlightNode.Text.Substring(2);659currentHighlightNode.ForeColor = ProcTree.ForeColor;660currentHighlightProc = null;661currentHighlightNode = null;662}663}664
665// Create names for procedures and variables in treeview666private void UpdateNames(bool newCreate = false)667{668if (ProcTree.Tag != null && (TreeStatus)ProcTree.Tag == TreeStatus.freeze) {669ProcTree.Tag = TreeStatus.idle;670return;671}672
673if (currentTab == null || !currentTab.shouldParse || currentTab.parseInfo == null) return;674
675object selectedNode = null;676if (ProcTree.SelectedNode != null)677selectedNode = ProcTree.SelectedNode.Tag;678
679ProcTree.Tag = TreeStatus.update;680
681string scrollNode = null;682if (!newCreate && ProcTree.Nodes.Count != 0) {683for (int i = ProcTree.Nodes.Count -1; i >= 0; i--)684{685if (!ProcTree.Nodes[i].IsExpanded) continue;686for (int j = ProcTree.Nodes[i].Nodes.Count - 1; j >= 0; j--)687{688if (ProcTree.Nodes[i].Nodes[j].IsVisible) {689scrollNode = ProcTree.Nodes[i].Nodes[j].Name;690break;691}692}693if (scrollNode != null) break;694}695}696ProcTree.BeginUpdate();697ProcTree.Nodes.Clear();698
699TreeNode rootNode;700foreach (var s in TREEPROCEDURES) {701rootNode = ProcTree.Nodes.Add(s, s);702rootNode.ForeColor = Color.DodgerBlue;703rootNode.NodeFont = new Font("Arial", 9F, FontStyle.Bold, GraphicsUnit.Point);704}705ProcTree.Nodes[0].ToolTipText = "Procedures declared and located in headers files." + treeTipProcedure;706ProcTree.Nodes[0].Tag = 0; // global tag707ProcTree.Nodes[1].ToolTipText = "Procedures declared and located in this script." + treeTipProcedure;708ProcTree.Nodes[1].Tag = 1; // local tag709
710foreach (Procedure p in currentTab.parseInfo.procs) {711// TODO: Это нужно только для отключенного парсера?712if (!Settings.enableParser && p.d.end == -1) continue; //skip imported or broken procedures713
714TreeNode tn = new TreeNode((!ViewArgsStripButton.Checked)? p.name : p.ToString(false));715tn.Name = p.name;716tn.Tag = p;717foreach (Variable var in p.variables) {718TreeNode tn2 = new TreeNode(var.name);719tn2.Name = var.name;720tn2.Tag = var;721tn2.ToolTipText = var.ToString();722tn.Nodes.Add(tn2);723}724if (p.filename.Equals(currentTab.filename, StringComparison.OrdinalIgnoreCase) == false || p.IsImported) {725tn.ToolTipText = p.ToString() + "\ndeclarate file: " + p.filename;726ProcTree.Nodes[0].Nodes.Add(tn);727ProcTree.Nodes[0].Expand();728} else {729tn.ToolTipText = p.ToString();730ProcTree.Nodes[1].Nodes.Add(tn);731ProcTree.Nodes[1].Expand();732}733}734
735if (!Settings.enableParser && !currentTab.parseInfo.parseData) {736ProcTree.Nodes.RemoveAt(0);737if (tabControl3.TabPages.Count > 2) // удалить и вкладку если отсутсвует информация738tabControl3.TabPages.RemoveAt(1);739} else {740VarTree.BeginUpdate();741VarTree.Nodes.Clear();742
743foreach (var s in TREEVARIABLES) {744rootNode = VarTree.Nodes.Add(s);745rootNode.ForeColor = Color.DodgerBlue;746rootNode.NodeFont = new Font("Arial", 9F, FontStyle.Bold, GraphicsUnit.Point);747}748VarTree.Nodes[0].ToolTipText = "Variables declared and located in headers files." + treeTipVariable;749VarTree.Nodes[1].ToolTipText = "Variables declared and located in this script." + treeTipVariable;750
751foreach (Variable var in currentTab.parseInfo.vars) {752TreeNode tn = new TreeNode(var.name);753tn.Tag = var;754if (var.filename.Equals(currentTab.filename, StringComparison.OrdinalIgnoreCase) == false) {755tn.ToolTipText = var.ToString() + "\ndeclarate file: " + var.filename;756VarTree.Nodes[0].Nodes.Add(tn);757VarTree.Nodes[0].Expand();758} else {759tn.ToolTipText = var.ToString();760VarTree.Nodes[1].Nodes.Add(tn);761VarTree.Nodes[1].Expand();762}763}764if (VarTree.Nodes[0].Nodes.Count == 0) VarTree.Nodes[0].ForeColor = Color.Gray;765if (VarTree.Nodes[1].Nodes.Count == 0) VarTree.Nodes[1].ForeColor = Color.Gray;766
767foreach (TreeNode node in VarTree.Nodes)768SetNodeCollapseStatus(node);769
770VarTree.EndUpdate();771}772foreach (TreeNode node in ProcTree.Nodes)773SetNodeCollapseStatus(node);774
775if (ProcTree.Nodes[0].Nodes.Count == 0) ProcTree.Nodes[0].ForeColor = Color.Gray;776if (ProcTree.Nodes.Count > 1) {777if (ProcTree.Nodes[1].Nodes.Count == 0)778ProcTree.Nodes[1].ForeColor = Color.Gray;779//ProcTree.Nodes[1].EnsureVisible();780}781
782if (selectedNode != null) {783TreeNode[] nodes = null;784if (selectedNode is Procedure)785nodes = ProcTree.Nodes.Find(((Procedure)selectedNode).name, true);786else if (selectedNode is Variable)787nodes = ProcTree.Nodes.Find(((Variable)selectedNode).name, true);788if (nodes != null && nodes.Length > 0)789ProcTree.SelectedNode = nodes[0];790}791ProcTree.EndUpdate();792HighlightCurrentPocedure((currentHighlightProc == null) ? currentActiveTextAreaCtrl.Caret.Line : -2);793
794// scroll to node795if (scrollNode != null) {796foreach (TreeNode nodes in ProcTree.Nodes) {797foreach (TreeNode node in nodes.Nodes) {798if (node.Name == scrollNode) {799if (node.PrevNode != null) node.PrevNode.EnsureVisible();800scrollNode = null;801break;802}803}804if (scrollNode == null) break;805}806if (scrollNode != null && currentHighlightNode != null) currentHighlightNode.EnsureVisible();807}808ProcTree.Tag = TreeStatus.idle;809}810
811// обновляет процедуры в nodes.Tag812private void UpdateNodesTags()813{814// Avoid stomping on files while the parser is running815while (parserIsRunning) System.Threading.Thread.Sleep(10);816
817TreeNodeCollection nodes;818if (ProcTree.Nodes.Count > 1)819nodes = ProcTree.Nodes[1].Nodes;820else821nodes = ProcTree.Nodes[0].Nodes; // for parser off822
823for (int i = 0; i < nodes.Count; i++)824{825Procedure np = nodes[i].Tag as Procedure;826if (np == null) continue;827
828foreach (Procedure p in currentTab.parseInfo.procs)829{830if (p.Name == np.Name) {831//if (p.d.declared != np.d.declared)832nodes[i].Tag = p;833break;834}835}836}837}838
839private string GetCorrectNodeKeyName(TreeNode node)840{841string nodeKey = node.FullPath;842int n = nodeKey.IndexOf('\\');843if (n != -1) nodeKey = nodeKey.Remove(n + 1) + node.Name;844return nodeKey;845}846
847private void SetNodeCollapseStatus(TreeNode node)848{849string nodeKey = GetCorrectNodeKeyName(node);850if (currentTab.treeExpand.ContainsKey(nodeKey)) {851if (currentTab.treeExpand[nodeKey])852node.Collapse();853else854node.Expand();855}856foreach (TreeNode nd in node.Nodes) SetNodeCollapseStatus(nd);857}858
859bool treeExpandCollapse = false;860
861private void TreeExpandCollapse(TreeViewEventArgs e)862{863TreeNode tn = e.Node;864if (tn == null) return;865
866bool collapsed = (e.Action == TreeViewAction.Collapse);867string nodeKey = GetCorrectNodeKeyName(tn);868if (!currentTab.treeExpand.ContainsKey(nodeKey))869currentTab.treeExpand.Add(nodeKey, collapsed);870else871currentTab.treeExpand[nodeKey] = collapsed;872if (tn.Parent == null) treeExpandCollapse = true;873}874
875private void TreeView_DClickMouse(object sender, MouseEventArgs e) {876if (e.X <= 20) return;877TreeNode node = (!treeExpandCollapse) ? ((TreeView)sender).GetNodeAt(e.Location) : null;878treeExpandCollapse = false;879if (node != null) TreeView_ClickBehavior(node);880}881
882// Click on node tree Procedures/Variables883private void TreeView_AfterSelect(object sender, TreeViewEventArgs e)884{885if (!ctrlKeyPress || e.Action == TreeViewAction.Unknown) return;886TreeView_ClickBehavior(e.Node);887}888
889private void TreeView_ClickBehavior(TreeNode node)890{891string file = null, name = null;892int line = 0;893bool pSelect = false;894if (node.Tag is Variable) {895Variable var = (Variable)node.Tag;896if (!ctrlKeyPress) {897file = var.fdeclared;898line = var.d.declared;899} else {900name = var.name;901}902} else if (node.Tag is Procedure) {903Procedure proc = (Procedure)node.Tag;904if (!ctrlKeyPress) {905file = proc.fstart;906line = proc.d.start;907if (line == -1 || file == null) { // goto declared908file = proc.fdeclared;909line = proc.d.declared;910}911pSelect = true;912} else {913name = proc.name;914}915}916if (file != null) {917SelectLine(file, line, pSelect);918} else if (name != null) {919Utilities.InsertText(name, currentActiveTextAreaCtrl);920}921}922
923void Tree_AfterExpandCollapse(object sender, TreeViewEventArgs e)924{925if ((TreeStatus)ProcTree.Tag == TreeStatus.idle)926TreeExpandCollapse(e);927}928
929private void ProcTree_Leave(object sender, EventArgs e)930{931ProcTree.SelectedNode = null;932}933
934private void ProcTree_MouseDown(object sender, MouseEventArgs e)935{936dbClick = false;937if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left && e.Clicks == 2) {938TreeNode tn = ProcTree.GetNodeAt(e.X, e.Y);939if (tn != null) dbClick = true;940if (e.Button == MouseButtons.Right) {941ProcTree.SelectedNode = tn;942}943}944}945
946private void ProcTree_BeforeExpandCollapse(object sender, TreeViewCancelEventArgs e) {947if (e.Action == TreeViewAction.Expand || e.Action == TreeViewAction.Collapse) {948if (dbClick || ctrlKeyPress) {949if (e.Node.Tag is Procedure) e.Cancel = true;950dbClick = false;951}952}953}954#endregion955
956#region Refactoring Control957
958private void UpdateEditorToolStripMenu()959{960TextLocation tl = currentActiveTextAreaCtrl.Caret.Position;961
962// includes963string line = TextUtilities.GetLineAsString(currentDocument, tl.Line).Trim();964if (!line.TrimStart().StartsWith(ParserInternal.INCLUDE)) {965openIncludeToolStripMenuItem.Enabled = false;966}967
968// skip for specific color text969if (ColorTheme.CheckColorPosition(currentDocument, tl))970return;971
972//Refactor name973if (!Settings.enableParser) {974renameToolStripMenuItem.Text += ": Disabled";975renameToolStripMenuItem.ToolTipText = "It is required to enable the parser in the settings.";976return;977}978
979if (currentTab.parseInfo != null) {980NameType itemType = NameType.None;981IParserInfo item = null;982
983string word = TextUtilities.GetWordAt(currentDocument, currentDocument.PositionToOffset(tl));984item = currentTab.parseInfo.Lookup(word, currentTab.filepath, tl.Line + 1);985if (item != null) {986itemType = item.Type();987renameToolStripMenuItem.Tag = item;988if (!currentTab.needsParse)989renameToolStripMenuItem.Enabled = true;990}991
992switch (itemType)993{994case NameType.LVar: // variable procedure995case NameType.GVar: // variable script996findReferencesToolStripMenuItem.Enabled = true;997findDeclerationToolStripMenuItem.Enabled = true;998findDefinitionToolStripMenuItem.Enabled = false;999renameToolStripMenuItem.Text += (itemType == NameType.LVar)1000? (((Variable)item).IsArgument ? ": Argument variable" : ": Local variable")1001: ": Script variable";1002if (item.IsExported)1003renameToolStripMenuItem.ToolTipText = "Note: Renaming exported variables will result in an error in the scripts using this variable.";1004break;1005
1006case NameType.Proc:1007findReferencesToolStripMenuItem.Enabled = currentTab.parseInfo.parseData; //true;1008findDeclerationToolStripMenuItem.Enabled = true;1009findDefinitionToolStripMenuItem.Enabled = !item.IsImported;1010renameToolStripMenuItem.Text += ": Procedure";1011if (item.IsExported)1012renameToolStripMenuItem.ToolTipText = "Note: Renaming exported procedures will result in an error in the scripts using this procedure.";1013break;1014
1015case NameType.Macro:1016findReferencesToolStripMenuItem.Enabled = false;1017findDeclerationToolStripMenuItem.Enabled = true;1018findDefinitionToolStripMenuItem.Enabled = false;1019Macro macro = (Macro)item;1020if (!ProgramInfo.macrosGlobal.ContainsKey(macro.token) && macro.fdeclared == currentTab.filepath)1021renameToolStripMenuItem.Text += ": Local macro";1022else1023renameToolStripMenuItem.Text += ": Global macro";1024break;1025
1026default:1027if (!currentTab.parseInfo.parseData) {1028renameToolStripMenuItem.Text += ": Out of data";1029renameToolStripMenuItem.ToolTipText = "The parser data is missing.";1030} else1031renameToolStripMenuItem.Text += ": None";1032break;1033}1034if (item != null && item.IsImported) {1035renameToolStripMenuItem.Enabled = !item.IsImported;1036renameToolStripMenuItem.ToolTipText = "The feature is disabled, will be available in future versions.";1037}1038} else {1039renameToolStripMenuItem.Text += ": Out of data";1040renameToolStripMenuItem.ToolTipText = "The parser data is missing.";1041}1042}1043
1044private void editorMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)1045{1046if (currentTab == null /*&& !treeView1.Focused*/) {1047e.Cancel = true;1048return;1049}1050if (currentActiveTextAreaCtrl.SelectionManager.HasSomethingSelected) {1051highlightToolStripMenuItem.Visible = true;1052renameToolStripMenuItem.Visible = false;1053} else {1054highlightToolStripMenuItem.Visible = false;1055renameToolStripMenuItem.Visible = true;1056renameToolStripMenuItem.Text = "Rename";1057renameToolStripMenuItem.Enabled = false;1058renameToolStripMenuItem.ToolTipText = (currentTab.needsParse) ? "Waiting get parsing data..." : "";1059}1060//openIncludeToolStripMenuItem.Enabled = false;1061findReferencesToolStripMenuItem.Enabled = false;1062findDeclerationToolStripMenuItem.Enabled = false;1063findDefinitionToolStripMenuItem.Enabled = false;1064UpdateEditorToolStripMenu();1065}1066
1067private void editorMenuStrip_Closed(object sender, ToolStripDropDownClosedEventArgs e)1068{1069findReferencesToolStripMenuItem.Enabled = true;1070findDeclerationToolStripMenuItem.Enabled = true;1071findDefinitionToolStripMenuItem.Enabled = true;1072openIncludeToolStripMenuItem.Enabled = true;1073}1074#endregion1075
1076private void AssociateMsg(TabInfo tab, bool create)1077{1078if (tab.filepath == null || tab.msgFileTab != null)1079return;1080
1081if (Settings.autoOpenMsgs && msgAutoOpenEditorStripMenuItem.Checked && !create) {1082MessageEditor.MessageEditorInit(tab, this);1083Focus();1084} else {1085string path;1086if (MessageFile.GetAssociatePath(tab, create, out path)) {1087tab.msgFilePath = path;1088tab.msgFileTab = Open(tab.msgFilePath, OpenType.File, false);1089}1090}1091}1092
1093public void AcceptMsgLine(string line)1094{1095if (currentTab != null) {1096Utilities.InsertText(line, currentActiveTextAreaCtrl);1097this.Focus();1098}1099}1100
1101private void UpdateRecentList()1102{1103string[] items = Settings.GetRecent();1104int count = Open_toolStripSplitButton.DropDownItems.Count-1;1105for (int i = 3; i <= count; i++) {1106Open_toolStripSplitButton.DropDownItems.RemoveAt(3);1107}1108for (int i = items.Length - 1; i >= 0; i--) {1109Open_toolStripSplitButton.DropDownItems.Add(items[i], null, recentItem_Click);1110}1111}1112
1113private void AddSearchTextComboBox(string world)1114{1115if (world.Length == 0) return;1116
1117bool addSearchText = true;1118foreach (var item in SearchTextComboBox.Items)1119{1120if (world == item.ToString()) {1121addSearchText = false;1122break;1123}1124}1125if (addSearchText) {1126SearchTextComboBox.Items.Insert(0, world);1127if (sf != null) sf.cbSearch.Items.Insert(0, world); // add to advanced search form1128}1129}1130
1131private void KeepScriptSetting(TabInfo tab, bool skip)1132{1133if (!skip && tab.filepath != null && tab.textEditor.Document.FoldingManager.FoldMarker.Count > 0) {1134CodeFolder.SetProceduresCollapsed(tab.textEditor.Document, tab.filename);1135}1136// store last script position1137if (Path.GetExtension(tab.filepath).ToLowerInvariant() == ".ssl" && tab.filename != unsaved)1138Settings.SetLastScriptPosition(tab.filename.ToLowerInvariant(), tab.textEditor.ActiveTextAreaControl.Caret.Line);1139}1140
1141#region Dialog System1142
1143private void dialogNodesDiagramToolStripMenuItem_Click(object sender, EventArgs e)1144{1145if (currentTab == null || currentTab.parseInfo == null) return;1146
1147if (!Path.GetExtension(currentTab.filename).Equals(".ssl", StringComparison.OrdinalIgnoreCase)) {1148MessageBox.Show(MessageFile.WrongTypeFile, currentTab.filename);1149return;1150}1151
1152var tag = tabControl1.TabPages[currentTab.index].Tag;1153if (tag != null) {1154NodeDiagram ndForm = ((NodeDiagram)tag);1155if (ndForm.WindowState == FormWindowState.Minimized)1156ndForm.WindowState = FormWindowState.Maximized;1157ndForm.Activate();1158return;1159}1160
1161string msgPath;1162if (!MessageFile.GetAssociatePath(currentTab, false, out msgPath)) {1163MessageBox.Show(MessageFile.MissingFile, "Nodes Flowchart Editor");1164return;1165}1166ScriptEditor.TextEditorUI.Function.DialogFunctionsRules.BuildOpcodesDictionary();1167
1168currentTab.msgFilePath = msgPath;1169
1170NodeDiagram NodesView = new NodeDiagram(currentTab);1171NodesView.FormClosed += delegate { tabControl1.TabPages[currentTab.index].Tag = null; };1172NodesView.ChangeNodes += delegate { ForceParseScript(); }; //Force Parse Script;1173NodesView.Show();1174
1175tabControl1.TabPages[currentTab.index].Tag = NodesView;1176
1177this.ParserUpdatedInfo += delegate1178{1179if (NodesView != null)1180NodesView.NeedUpdate = true;1181};1182}1183
1184private void previewDialogToolStripMenuItem_Click(object sender, EventArgs e)1185{1186if (currentTab == null || currentTab.parseInfo == null) return;1187
1188if (!Path.GetExtension(currentTab.filename).Equals(".ssl", StringComparison.OrdinalIgnoreCase)) {1189MessageBox.Show(MessageFile.WrongTypeFile, currentTab.filename) ;1190return;1191}1192
1193string msgPath;1194if (!MessageFile.GetAssociatePath(currentTab, false, out msgPath)) {1195MessageBox.Show(MessageFile.MissingFile, "Dialog Preview");1196return;1197}1198currentTab.msgFilePath = msgPath;1199
1200ScriptEditor.TextEditorUI.Function.DialogFunctionsRules.BuildOpcodesDictionary();1201
1202DialogPreview DialogView = new DialogPreview(currentTab);1203if (!DialogView.InitReady) {1204DialogView.Dispose();1205MessageBox.Show("This script does not contain dialog procedures.", "Dialog Preview");1206}1207else1208DialogView.Show(this);1209}1210
1211private void dialogFunctionConfigToolStripMenuItem_Click(object sender, EventArgs e) {1212ScriptEditor.TextEditorUI.Function.DialogFunctionsRules.BuildOpcodesDictionary();1213new ScriptEditor.TextEditorUI.Function.FunctionsRules().ShowDialog(this);1214}1215
1216private void editNodeCodeToolStripMenuItem_Click(object sender, EventArgs e)1217{1218Procedure proc = (Procedure)ProcTree.SelectedNode.Tag;1219
1220if (currentTab.messages.Count == 0) {1221string msgPath;1222if (!MessageFile.GetAssociatePath(currentTab, false, out msgPath)) {1223MessageBox.Show(MessageFile.MissingFile, "Node Editor");1224return;1225}1226currentTab.msgFilePath = msgPath;1227MessageFile.ParseMessages(currentTab, File.ReadAllLines(currentTab.msgFilePath, Settings.EncCodePage));1228}1229
1230foreach (var nodeTE in currentTab.nodeFlowchartTE)1231{1232if (nodeTE.NodeName == proc.name) {1233nodeTE.Activate();1234return;1235}1236}1237
1238ScriptEditor.TextEditorUI.Function.DialogFunctionsRules.BuildOpcodesDictionary();1239
1240FlowchartTE nodeEditor = new FlowchartTE(proc, currentTab);1241nodeEditor.Disposed += delegate(object s, EventArgs e1) { currentTab.nodeFlowchartTE.Remove((FlowchartTE)s); };1242nodeEditor.ApplyCode += new EventHandler<FlowchartTE.CodeArgs>(nodeEditor_ApplyCode);1243nodeEditor.ShowEditor(this);1244
1245currentTab.nodeFlowchartTE.Add(nodeEditor);1246}1247
1248private void nodeEditor_ApplyCode(object sender, FlowchartTE.CodeArgs e)1249{1250if (e.Change) {1251if (Utilities.ReplaceProcedureCode(currentDocument, currentTab.parseInfo, e.Name, e.Code)) {1252MessageBox.Show("In the source script, there is no dialog node with this name.", "Apply code error");1253return;1254}1255e.Change = false;1256ForceParseScript();1257}1258}1259#endregion1260
1261#region Misc Control1262
1263private void ShowTabsSpaces()1264{1265if (currentTab == null)1266return;1267
1268if (Path.GetExtension(currentTab.filename).ToLowerInvariant() != ".msg")1269currentDocument.TextEditorProperties.ShowSpaces = showTabsAndSpacesToolStripMenuItem.Checked;1270
1271currentDocument.TextEditorProperties.ShowTabs = showTabsAndSpacesToolStripMenuItem.Checked;;1272currentTab.textEditor.Refresh();1273}1274
1275private void SizeFontToString()1276{1277// base 10 (min 5, max 30)1278float percent = (float)((10 + Settings.sizeFont) / 10.0f) * 100.0f;1279FontSizeStripStatusLabel.Text = percent.ToString() + '%';1280
1281if (currentTab != null) {1282var fontName = currentTab.textEditor.TextEditorProperties.Font.Name;1283var font = new Font(fontName, 10.0f + Settings.sizeFont, FontStyle.Regular);1284currentTab.textEditor.TextEditorProperties.Font = font;1285currentTab.textEditor.Refresh();1286currentActiveTextAreaCtrl.Caret.RecreateCaret();1287}1288}1289
1290public void SetFocusDocument()1291{1292TextArea_SetFocus(null, null);1293}1294
1295private Control FindFocus(Control cnt)1296{1297if (cnt == null)1298return null;1299
1300foreach (Control c in cnt.Controls)1301{1302if (c.CanFocus && c.Focused)1303return c;1304
1305Control fc = FindFocus(c);1306
1307if (fc != null)1308return fc;1309}1310return null;1311}1312
1313private void SetProjectFolderText()1314{1315tslProject.Text = "Project: " + Settings.solutionProjectFolder;1316tslProject.Enabled = true;1317}1318#endregion1319
1320#region Log1321
1322private void MaximizeLog()1323{1324if (currentTab == null && splitContainer1.Panel2Collapsed) {1325showLogWindowToolStripMenuItem.Checked = true;1326splitContainer1.Panel2Collapsed = false;1327}1328if (minimizeLogSize == 0) return;1329
1330if (Settings.editorSplitterPosition == -1) {1331Settings.editorSplitterPosition = Size.Height - (Size.Height / 4);1332}1333splitContainer1.SplitterDistance = Settings.editorSplitterPosition;1334minimizeLogSize = 0;1335}1336
1337private void UpdateLog()1338{1339if (autoRefreshToolStripMenuItem.Checked &&1340(currentTab.parserErrors.Count > 0 || currentTab.buildErrors.Count > 0))1341{1342OutputErrorLog(currentTab);1343} else {1344if (Settings.enableParser)1345tbOutputParse.Text = currentTab.parserLog;1346
1347if (currentTab.buildLog != null)1348tbOutput.Text = currentTab.buildLog;1349}1350}1351
1352public void PrintBuildLog(object sender, System.Diagnostics.DataReceivedEventArgs e)1353{1354tbOutput.BeginInvoke((MethodInvoker)(() =>1355tbOutput.AppendText(e.Data + Environment.NewLine))1356);1357}1358#endregion1359}1360}
1361