From 5a3a5a86113f40750ea42ddabff26be6a43ca479 Mon Sep 17 00:00:00 2001 From: thoysg Date: Sun, 2 May 2010 12:11:43 +0000 Subject: [PATCH] Made selection in outline treeview possible Added parameter for EndUpdate in SyntaxRichTextBox, so it only updates outline when needed git-svn-id: https://lsleditor.svn.sourceforge.net/svnroot/lsleditor@15 3f4676ac-adda-40fd-8265-58d1435b1672 --- trunk/Editor/SyntaxRichTextBox.cs | 45 ++++++++++++++++--------------- trunk/LSLEditorForm.Designer.cs | 4 ++- trunk/LSLEditorForm.cs | 41 ++++++++++++++++++---------- 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/trunk/Editor/SyntaxRichTextBox.cs b/trunk/Editor/SyntaxRichTextBox.cs index ac0162c..25b271e 100644 --- a/trunk/Editor/SyntaxRichTextBox.cs +++ b/trunk/Editor/SyntaxRichTextBox.cs @@ -487,7 +487,7 @@ namespace LSLEditor { } - EndUpdate(); + EndUpdate(false); this.Focus(); } @@ -521,9 +521,10 @@ namespace LSLEditor eventMask = SendMessage(this.Handle, EM_GETEVENTMASK, 0, IntPtr.Zero); } - private void EndUpdate() + private void EndUpdate(bool update_outline) { - doOutline(); + if(update_outline) doOutline(); + intUpdate = Math.Max(0, intUpdate - 1); if (intUpdate > 0) // only the last one @@ -655,7 +656,7 @@ namespace LSLEditor this.SelectionStart = intStart; this.SelectionLength = intLength; AutoFormat(true); - EndUpdate(); + EndUpdate(true); } private void ProcessEnter() @@ -678,7 +679,7 @@ namespace LSLEditor } } } - EndUpdate(); + EndUpdate(true); } private void SmartIndenting() @@ -727,7 +728,7 @@ namespace LSLEditor BracketHighlichting(); } - EndUpdate(); + EndUpdate(false); } public void Delete() @@ -736,7 +737,7 @@ namespace LSLEditor if (this.SelectionLength == 0) this.SelectionLength = 1; this.ColoredText = ""; - EndUpdate(); + EndUpdate(true); OnTextChanged(null); } @@ -745,7 +746,7 @@ namespace LSLEditor BeginUpdate(); this.Copy(); this.ColoredText = ""; - EndUpdate(); + EndUpdate(true); OnTextChanged(null); } @@ -789,7 +790,7 @@ namespace LSLEditor ColorLine(intStart, intStop - intStart); } - EndUpdate(); + EndUpdate(true); this.Focus(); } @@ -825,7 +826,7 @@ namespace LSLEditor ColorLine(intStart, intStop - intStart); } - EndUpdate(); + EndUpdate(true); this.Focus(); } @@ -879,7 +880,7 @@ namespace LSLEditor this.SelectionStart = intBackupSelectionStart; this.SelectionLength = intBackupSelectionLength; this.HighLightLine = -1; - EndUpdate(); + EndUpdate(false); } private void CursorPositionChanged() @@ -1061,7 +1062,7 @@ namespace LSLEditor this.SelectionStart = this.GetFirstCharIndexOfCurrentLine(); int intLine = this.GetLineFromCharIndex(this.SelectionStart); this.SelectionLength = this.Lines[intLine].Length + 1; - EndUpdate(); + EndUpdate(true); } } this.Copy(); @@ -1135,7 +1136,7 @@ namespace LSLEditor if (this.SelectionLength == 0) this.SelectionLength = 1; this.ColoredText = ""; - EndUpdate(); + EndUpdate(true); OnTextChanged(null); CursorPositionChanged(); } @@ -1482,7 +1483,7 @@ namespace LSLEditor this.SelectionStart = SelectionStartBackup; this.SelectionColor = this.ForeColor; - EndUpdate(); + EndUpdate(false); } private int AutoFormat(bool OnlySelectedText) @@ -1515,7 +1516,7 @@ namespace LSLEditor this.SelectionStart = intBackupStart; this.SelectionLength = intSelectionLength; this.RTBScrollPos = scrollPoint; - EndUpdate(); + EndUpdate(false); } public void FormatDocument() @@ -1526,7 +1527,7 @@ namespace LSLEditor AutoFormat(false); this.SelectionStart = Math.Max(0,this.GetFirstCharIndexFromLine(intLine)); this.RTBScrollPos = scrollPoint; - EndUpdate(); + EndUpdate(false); } public void ClearUndoStack() @@ -1549,7 +1550,7 @@ namespace LSLEditor this.SelectionLength = this.Text.Length; //TODO this.ColoredText = value; this.SelectionStart = intBackup; - EndUpdate(); + EndUpdate(true); } } @@ -1609,7 +1610,7 @@ namespace LSLEditor this.ColoredText = strSelected; this.SelectionStart += intOffset; - EndUpdate(); + EndUpdate(true); // if any ShowKeyBoardHint(); @@ -1757,7 +1758,7 @@ namespace LSLEditor this.ColoredText = strSelectedText; this.SelectionStart = intBackup; this.SelectionLength = strSelectedText.Length; - EndUpdate(); + EndUpdate(true); } public void MultiLineTab(bool blnAdd) @@ -1902,7 +1903,7 @@ namespace LSLEditor this.RTBScrollPos = scrollPoint; - EndUpdate(); + EndUpdate(false); } private void BracketHighlichting() @@ -1975,7 +1976,7 @@ namespace LSLEditor this.RTBScrollPos = scrollPoint; - EndUpdate(); + EndUpdate(false); } public override string SelectedText @@ -2019,7 +2020,7 @@ namespace LSLEditor this.SelectionLength = 0; this.SelectionStart += value.Length; } - EndUpdate(); + EndUpdate(true); } } public void doOutline() diff --git a/trunk/LSLEditorForm.Designer.cs b/trunk/LSLEditorForm.Designer.cs index 0467535..095b486 100644 --- a/trunk/LSLEditorForm.Designer.cs +++ b/trunk/LSLEditorForm.Designer.cs @@ -733,7 +733,7 @@ namespace LSLEditor // optionsToolStripMenuItem // this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; - this.optionsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.optionsToolStripMenuItem.Size = new System.Drawing.Size(134, 22); this.optionsToolStripMenuItem.Text = "Options..."; this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click); // @@ -1084,10 +1084,12 @@ namespace LSLEditor // tvOutline // this.tvOutline.Dock = System.Windows.Forms.DockStyle.Fill; + this.tvOutline.HideSelection = false; this.tvOutline.Location = new System.Drawing.Point(3, 3); this.tvOutline.Name = "tvOutline"; this.tvOutline.Size = new System.Drawing.Size(186, 438); this.tvOutline.TabIndex = 0; + this.tvOutline.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvOutline_AfterSelect); this.tvOutline.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.tvOutline_NodeMouseClick); // // LSLEditorForm diff --git a/trunk/LSLEditorForm.cs b/trunk/LSLEditorForm.cs index e2709e5..25e42cb 100644 --- a/trunk/LSLEditorForm.cs +++ b/trunk/LSLEditorForm.cs @@ -1879,21 +1879,34 @@ namespace LSLEditor private void tvOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { - EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - if (e.Node.Tag is Helpers.OutlineHelper) - { - Helpers.OutlineHelper ohOutline = (Helpers.OutlineHelper)e.Node.Tag; - if (ohOutline.line < editForm.TextBox.Lines.Length) + this.BeginInvoke(new TreeNodeMouseClickEventHandler( + delegate(object sender2, TreeNodeMouseClickEventArgs e2) { - //editForm.Focus(); - editForm.TextBox.Select(); - editForm.TextBox.Goto(ohOutline.line + 1); - - - } - } + EditForm editForm = this.ActiveMdiForm as EditForm; + if (editForm == null) + return; + if (e.Node.Tag is Helpers.OutlineHelper) + { + Helpers.OutlineHelper ohOutline = (Helpers.OutlineHelper)e.Node.Tag; + if (ohOutline.line < editForm.TextBox.Lines.Length) + { + //editForm.Focus(); + //editForm.TextBox.Select(); + //editForm.TextBox.Goto(ohOutline.line + 1); + + //editForm.Focus(); + editForm.TextBox.Select(); + editForm.TextBox.SelectionStart = editForm.TextBox.GetFirstCharIndexFromLine(ohOutline.line); + + + } + } + }), sender, e); + } + + private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e) + { + } } } \ No newline at end of file