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
This commit is contained in:
thoysg 2010-05-02 12:11:43 +00:00
parent 464587f8c6
commit 5a3a5a8611
3 changed files with 53 additions and 37 deletions

View file

@ -487,7 +487,7 @@ namespace LSLEditor
{ {
} }
EndUpdate(); EndUpdate(false);
this.Focus(); this.Focus();
} }
@ -521,9 +521,10 @@ namespace LSLEditor
eventMask = SendMessage(this.Handle, EM_GETEVENTMASK, 0, IntPtr.Zero); 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); intUpdate = Math.Max(0, intUpdate - 1);
if (intUpdate > 0) // only the last one if (intUpdate > 0) // only the last one
@ -655,7 +656,7 @@ namespace LSLEditor
this.SelectionStart = intStart; this.SelectionStart = intStart;
this.SelectionLength = intLength; this.SelectionLength = intLength;
AutoFormat(true); AutoFormat(true);
EndUpdate(); EndUpdate(true);
} }
private void ProcessEnter() private void ProcessEnter()
@ -678,7 +679,7 @@ namespace LSLEditor
} }
} }
} }
EndUpdate(); EndUpdate(true);
} }
private void SmartIndenting() private void SmartIndenting()
@ -727,7 +728,7 @@ namespace LSLEditor
BracketHighlichting(); BracketHighlichting();
} }
EndUpdate(); EndUpdate(false);
} }
public void Delete() public void Delete()
@ -736,7 +737,7 @@ namespace LSLEditor
if (this.SelectionLength == 0) if (this.SelectionLength == 0)
this.SelectionLength = 1; this.SelectionLength = 1;
this.ColoredText = ""; this.ColoredText = "";
EndUpdate(); EndUpdate(true);
OnTextChanged(null); OnTextChanged(null);
} }
@ -745,7 +746,7 @@ namespace LSLEditor
BeginUpdate(); BeginUpdate();
this.Copy(); this.Copy();
this.ColoredText = ""; this.ColoredText = "";
EndUpdate(); EndUpdate(true);
OnTextChanged(null); OnTextChanged(null);
} }
@ -789,7 +790,7 @@ namespace LSLEditor
ColorLine(intStart, intStop - intStart); ColorLine(intStart, intStop - intStart);
} }
EndUpdate(); EndUpdate(true);
this.Focus(); this.Focus();
} }
@ -825,7 +826,7 @@ namespace LSLEditor
ColorLine(intStart, intStop - intStart); ColorLine(intStart, intStop - intStart);
} }
EndUpdate(); EndUpdate(true);
this.Focus(); this.Focus();
} }
@ -879,7 +880,7 @@ namespace LSLEditor
this.SelectionStart = intBackupSelectionStart; this.SelectionStart = intBackupSelectionStart;
this.SelectionLength = intBackupSelectionLength; this.SelectionLength = intBackupSelectionLength;
this.HighLightLine = -1; this.HighLightLine = -1;
EndUpdate(); EndUpdate(false);
} }
private void CursorPositionChanged() private void CursorPositionChanged()
@ -1061,7 +1062,7 @@ namespace LSLEditor
this.SelectionStart = this.GetFirstCharIndexOfCurrentLine(); this.SelectionStart = this.GetFirstCharIndexOfCurrentLine();
int intLine = this.GetLineFromCharIndex(this.SelectionStart); int intLine = this.GetLineFromCharIndex(this.SelectionStart);
this.SelectionLength = this.Lines[intLine].Length + 1; this.SelectionLength = this.Lines[intLine].Length + 1;
EndUpdate(); EndUpdate(true);
} }
} }
this.Copy(); this.Copy();
@ -1135,7 +1136,7 @@ namespace LSLEditor
if (this.SelectionLength == 0) if (this.SelectionLength == 0)
this.SelectionLength = 1; this.SelectionLength = 1;
this.ColoredText = ""; this.ColoredText = "";
EndUpdate(); EndUpdate(true);
OnTextChanged(null); OnTextChanged(null);
CursorPositionChanged(); CursorPositionChanged();
} }
@ -1482,7 +1483,7 @@ namespace LSLEditor
this.SelectionStart = SelectionStartBackup; this.SelectionStart = SelectionStartBackup;
this.SelectionColor = this.ForeColor; this.SelectionColor = this.ForeColor;
EndUpdate(); EndUpdate(false);
} }
private int AutoFormat(bool OnlySelectedText) private int AutoFormat(bool OnlySelectedText)
@ -1515,7 +1516,7 @@ namespace LSLEditor
this.SelectionStart = intBackupStart; this.SelectionStart = intBackupStart;
this.SelectionLength = intSelectionLength; this.SelectionLength = intSelectionLength;
this.RTBScrollPos = scrollPoint; this.RTBScrollPos = scrollPoint;
EndUpdate(); EndUpdate(false);
} }
public void FormatDocument() public void FormatDocument()
@ -1526,7 +1527,7 @@ namespace LSLEditor
AutoFormat(false); AutoFormat(false);
this.SelectionStart = Math.Max(0,this.GetFirstCharIndexFromLine(intLine)); this.SelectionStart = Math.Max(0,this.GetFirstCharIndexFromLine(intLine));
this.RTBScrollPos = scrollPoint; this.RTBScrollPos = scrollPoint;
EndUpdate(); EndUpdate(false);
} }
public void ClearUndoStack() public void ClearUndoStack()
@ -1549,7 +1550,7 @@ namespace LSLEditor
this.SelectionLength = this.Text.Length; //TODO this.SelectionLength = this.Text.Length; //TODO
this.ColoredText = value; this.ColoredText = value;
this.SelectionStart = intBackup; this.SelectionStart = intBackup;
EndUpdate(); EndUpdate(true);
} }
} }
@ -1609,7 +1610,7 @@ namespace LSLEditor
this.ColoredText = strSelected; this.ColoredText = strSelected;
this.SelectionStart += intOffset; this.SelectionStart += intOffset;
EndUpdate(); EndUpdate(true);
// if any // if any
ShowKeyBoardHint(); ShowKeyBoardHint();
@ -1757,7 +1758,7 @@ namespace LSLEditor
this.ColoredText = strSelectedText; this.ColoredText = strSelectedText;
this.SelectionStart = intBackup; this.SelectionStart = intBackup;
this.SelectionLength = strSelectedText.Length; this.SelectionLength = strSelectedText.Length;
EndUpdate(); EndUpdate(true);
} }
public void MultiLineTab(bool blnAdd) public void MultiLineTab(bool blnAdd)
@ -1902,7 +1903,7 @@ namespace LSLEditor
this.RTBScrollPos = scrollPoint; this.RTBScrollPos = scrollPoint;
EndUpdate(); EndUpdate(false);
} }
private void BracketHighlichting() private void BracketHighlichting()
@ -1975,7 +1976,7 @@ namespace LSLEditor
this.RTBScrollPos = scrollPoint; this.RTBScrollPos = scrollPoint;
EndUpdate(); EndUpdate(false);
} }
public override string SelectedText public override string SelectedText
@ -2019,7 +2020,7 @@ namespace LSLEditor
this.SelectionLength = 0; this.SelectionLength = 0;
this.SelectionStart += value.Length; this.SelectionStart += value.Length;
} }
EndUpdate(); EndUpdate(true);
} }
} }
public void doOutline() public void doOutline()

View file

@ -733,7 +733,7 @@ namespace LSLEditor
// optionsToolStripMenuItem // optionsToolStripMenuItem
// //
this.optionsToolStripMenuItem.Name = "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.Text = "Options...";
this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click); this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click);
// //
@ -1084,10 +1084,12 @@ namespace LSLEditor
// tvOutline // tvOutline
// //
this.tvOutline.Dock = System.Windows.Forms.DockStyle.Fill; this.tvOutline.Dock = System.Windows.Forms.DockStyle.Fill;
this.tvOutline.HideSelection = false;
this.tvOutline.Location = new System.Drawing.Point(3, 3); this.tvOutline.Location = new System.Drawing.Point(3, 3);
this.tvOutline.Name = "tvOutline"; this.tvOutline.Name = "tvOutline";
this.tvOutline.Size = new System.Drawing.Size(186, 438); this.tvOutline.Size = new System.Drawing.Size(186, 438);
this.tvOutline.TabIndex = 0; 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); this.tvOutline.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.tvOutline_NodeMouseClick);
// //
// LSLEditorForm // LSLEditorForm

View file

@ -1879,21 +1879,34 @@ namespace LSLEditor
private void tvOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) private void tvOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{ {
EditForm editForm = this.ActiveMdiForm as EditForm; this.BeginInvoke(new TreeNodeMouseClickEventHandler(
if (editForm == null) delegate(object sender2, TreeNodeMouseClickEventArgs e2)
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 editForm = this.ActiveMdiForm as EditForm;
editForm.TextBox.Select(); if (editForm == null)
editForm.TextBox.Goto(ohOutline.line + 1); 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)
{
} }
} }
} }