void editor_TextChanged(object sender, EventArgs e) { MainWindow.inst().Dispatcher.BeginInvoke((System.Windows.Forms.MethodInvoker) delegate() { changeChecker.Recheck(); DepthScanner newScan = new DepthScanner(); newScan.Process(editor.Text); scanner = newScan; }); }
void editor_TextChanged(object sender, EventArgs e) { string text = editor.Text; new Thread(delegate() { DepthScanner newScan = new DepthScanner(); newScan.Process(text); MainWindow.inst().Dispatcher.BeginInvoke((System.Windows.Forms.MethodInvoker) delegate() { changeChecker.Recheck(); scanner = newScan; }); }).Start(); UpdateFoldings(); }
public override Globals Parse(string path, string fileCode, string[] includePaths) { Globals ret = new Globals(false); // Merge global app registered types into it ret.Parent = hlslGlobs; List<string> existingPaths = new List<string>(); // Inline #includes fileCode = ProcessIncludes(path, fileCode, includePaths, existingPaths); // Strip comments fileCode = StripComments(fileCode); DepthScanner scanner = new DepthScanner(); scanner.Process(fileCode); Parse(new StringReader(fileCode), scanner, ret); return ret; }
public override Globals Parse(string path, string fileCode, string[] includePaths) { Globals ret = new Globals(false); // Merge global app registered types into it ret.Parent = hlslGlobs; List <string> existingPaths = new List <string>(); // Inline #includes fileCode = ProcessIncludes(path, fileCode, includePaths, existingPaths); // Strip comments fileCode = StripComments(fileCode); DepthScanner scanner = new DepthScanner(); scanner.Process(fileCode); Parse(new StringReader(fileCode), scanner, ret); return(ret); }
public IDEEditor(FileBaseItem aItem) { InitializeComponent(); item = aItem; changeChecker = new DataChanged { editor = editor }; SetCode(aItem); editor.ShowLineNumbers = true; editor.Options.ConvertTabsToSpaces = true; editor.Options.IndentationSize = 4; editor.FontFamily = new FontFamily("Consolas"); editor.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDCDCCC")); editor.TextArea.TextView.BackgroundRenderers.Add(new LineHighlighter()); editor.TextArea.TextView.BackgroundRenderers.Add(new ErrorLineHighlighter(aItem)); // Buggy //editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(); Debugger.Editor.SearchPanel.Install(editor); editor.TextChanged += editor_TextChanged; scanner = new DepthScanner(); scanner.Process(editor.Text); editor.MouseHover += editor_MouseHover; editor.TextArea.MouseWheel += editor_MouseWheel; editor.KeyUp += editor_KeyUp; editor.MouseUp += editor_MouseUp; codeFolding = new BraceFoldingStrategy(); if (FOLDED_EXTENSIONS.Contains(System.IO.Path.GetExtension(aItem.Path))) { foldingManager = FoldingManager.Install(editor.TextArea); UpdateFoldings(); } intelSource = Intellisense.Sources.SourceBuilder.GetSourceForExtension(System.IO.Path.GetExtension(item.Path)); editor.ContextMenu = new ContextMenu(); // Hook the source, so we can get context menu commands from it if (intelSource != null) { intelSource.HookEditor(editor, item); } editor.ContextMenu.Items.Add(new MenuItem { Header = "Snippet", Command = new RelayCommand(p => { ObservableCollection <Snippets.CodeSnippet> snips = new ObservableCollection <Snippets.CodeSnippet>(); string ext = System.IO.Path.GetExtension(item.Path); foreach (Snippets.CodeSnippet snip in Snippets.SnippetData.inst().Snippets) { if (snip.Extension.Equals(ext)) { snips.Add(snip); } } if (snips.Count > 0) { Snippets.SnippetDlg dlg = new Snippets.SnippetDlg(editor, snips); dlg.ShowDialog(); } }, sp => { ObservableCollection <Snippets.CodeSnippet> snips = new ObservableCollection <Snippets.CodeSnippet>(); string exte = System.IO.Path.GetExtension(item.Path); foreach (Snippets.CodeSnippet snip in Snippets.SnippetData.inst().Snippets) { if (snip.Extension.Equals(exte)) { return(true); } } return(false); }) }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Cut", Command = ApplicationCommands.Cut }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Copy", Command = ApplicationCommands.Copy }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Paste", Command = ApplicationCommands.Paste }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Undo", Command = ApplicationCommands.Undo }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Redo", Command = ApplicationCommands.Redo }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Save", Command = ApplicationCommands.Save }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Save As", Command = ApplicationCommands.SaveAs }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Open", Command = ApplicationCommands.Open }); }
public IDEEditor(FileBaseItem aItem) { InitializeComponent(); item = aItem; changeChecker = new DataChanged { editor = editor }; SetCode(aItem); editor.ShowLineNumbers = true; if (aItem.Name.EndsWith(".as")) { editor.SyntaxHighlighting = LoadHighlightingDefinition("Debugger.Resources.Angelscript.xshd"); } else if (aItem.Name.EndsWith(".xml")) { editor.SyntaxHighlighting = LoadHighlightingDefinition("Debugger.Resources.XML.xshd"); } else { editor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinitionByExtension(item.Path.Substring(item.Path.LastIndexOf('.'))); } editor.FontFamily = new FontFamily("Consolas"); editor.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDCDCCC")); editor.TextArea.TextView.BackgroundRenderers.Add(new LineHighlighter()); editor.TextArea.TextView.BackgroundRenderers.Add(new ErrorLineHighlighter(aItem)); Debugger.Editor.SearchPanel.Install(editor); editor.TextChanged += editor_TextChanged; scanner = new DepthScanner(); scanner.Process(editor.Text); editor.MouseHover += editor_MouseHover; editor.KeyUp += editor_KeyUp; editor.ContextMenu = new ContextMenu(); editor.ContextMenu.Items.Add(new MenuItem { Header = "Compile", Command = new RelayCommand(p => { IDEView.Compile(); }) }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "New ScriptObject", Command = new RelayCommand(p => { editor.Document.BeginUpdate(); editor.Document.Insert(editor.CaretOffset, SOScript); editor.Document.EndUpdate(); }) }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Insert #include", Command = new RelayCommand(p => { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = "*"; dlg.Filter = "All files (*.*)|*.*"; if (dlg.ShowDialog() == true) { editor.Document.BeginUpdate(); editor.Document.Insert(editor.CaretOffset, string.Format("#include \"{0}\"", dlg.FileName)); editor.Document.EndUpdate(); } }) }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Doxygen Comment", Command = new RelayCommand(p => { editor.Document.BeginUpdate(); editor.Document.Insert(editor.CaretOffset, @"///////////////////////////////////////////////// /// DOCUMENT_HERE /////////////////////////////////////////////////", AnchorMovementType.AfterInsertion); editor.Document.EndUpdate(); }) }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Property Comment", Command = new RelayCommand(p => { editor.Document.BeginUpdate(); editor.Document.Insert(editor.CaretOffset, "///< DOCUMENT", AnchorMovementType.AfterInsertion); editor.Document.EndUpdate(); }) }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Snippet", Command = new RelayCommand(p => { ObservableCollection <Snippets.CodeSnippet> snips = new ObservableCollection <Snippets.CodeSnippet>(); string ext = System.IO.Path.GetExtension(item.Path); foreach (Snippets.CodeSnippet snip in Snippets.SnippetData.inst().Snippets) { if (snip.Extension.Equals(ext)) { snips.Add(snip); } } if (snips.Count > 0) { Snippets.SnippetDlg dlg = new Snippets.SnippetDlg(editor, snips); dlg.ShowDialog(); } }, sp => { ObservableCollection <Snippets.CodeSnippet> snips = new ObservableCollection <Snippets.CodeSnippet>(); string exte = System.IO.Path.GetExtension(item.Path); foreach (Snippets.CodeSnippet snip in Snippets.SnippetData.inst().Snippets) { if (snip.Extension.Equals(exte)) { return(true); } } return(false); }) }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Cut", Command = ApplicationCommands.Cut }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Copy", Command = ApplicationCommands.Copy }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Paste", Command = ApplicationCommands.Paste }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Undo", Command = ApplicationCommands.Undo }); editor.ContextMenu.Items.Add(new MenuItem { Header = "Redo", Command = ApplicationCommands.Redo }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Save", Command = ApplicationCommands.Save }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Save As", Command = ApplicationCommands.SaveAs }); editor.ContextMenu.Items.Add(new Separator()); editor.ContextMenu.Items.Add(new MenuItem { Header = "Open", Command = ApplicationCommands.Open }); }