diff --git a/data/options/SharpDevelopProperties.xml b/data/options/SharpDevelopProperties.xml index ed82fbd7a1..9d44108c96 100644 --- a/data/options/SharpDevelopProperties.xml +++ b/data/options/SharpDevelopProperties.xml @@ -1,3 +1,8 @@ + + + + + \ No newline at end of file diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 2fe14ca824..d397ef4f0d 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -13,6 +13,13 @@ True Resources\ICSharpCode.SharpDevelop.snk File + False + False + Auto + 4194304 + AnyCPU + 4096 + false False diff --git a/src/Main/Base/Project/Src/Commands/BuildCommands.cs b/src/Main/Base/Project/Src/Commands/BuildCommands.cs index cb4d2567d0..14dc916473 100644 --- a/src/Main/Base/Project/Src/Commands/BuildCommands.cs +++ b/src/Main/Base/Project/Src/Commands/BuildCommands.cs @@ -20,7 +20,9 @@ namespace ICSharpCode.SharpDevelop.Project.Commands public static void BeforeBuild() { TaskService.BuildMessageViewCategory.ClearText(); + TaskService.InUpdate = true; TaskService.ClearExceptCommentTasks(); + TaskService.InUpdate = false; ICSharpCode.SharpDevelop.Commands.SaveAllFiles.SaveAll(); } @@ -32,6 +34,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands if (results != null) { LastErrorCount = 0; LastWarningCount = 0; + TaskService.InUpdate = true; foreach (CompilerError error in results.Errors) { TaskService.Add(new Task(error)); if (error.IsWarning) @@ -39,6 +42,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands else LastErrorCount++; } + TaskService.InUpdate = false; if (results.Errors.Count > 0) { WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront(); } @@ -112,26 +116,13 @@ namespace ICSharpCode.SharpDevelop.Project.Commands public class BuildProject : AbstractMenuCommand { - - public static void ShowResults(CompilerResults results) - { - if (results != null) { - foreach (CompilerError error in results.Errors) { - TaskService.Add(new Task(error)); - } - if (results.Errors.Count > 0) { - WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront(); - } - } - } - public override void Run() { Build.BeforeBuild(); if (ProjectService.OpenSolution == null) { Build.AddNoSingleFileCompilationError(); } else { - BuildProject.ShowResults(ProjectService.CurrentProject.Build()); + Build.ShowResults(ProjectService.CurrentProject.Build()); } Build.AfterBuild(); } @@ -145,7 +136,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands if (ProjectService.OpenSolution == null) { Build.AddNoSingleFileCompilationError(); } else { - BuildProject.ShowResults(ProjectService.CurrentProject.Rebuild()); + Build.ShowResults(ProjectService.CurrentProject.Rebuild()); } Build.AfterBuild(); } @@ -159,7 +150,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands if (ProjectService.OpenSolution == null) { Build.AddNoSingleFileCompilationError(); } else { - BuildProject.ShowResults(ProjectService.CurrentProject.Clean()); + Build.ShowResults(ProjectService.CurrentProject.Clean()); } } } @@ -172,7 +163,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands if (ProjectService.OpenSolution == null) { Build.AddNoSingleFileCompilationError(); } else { - BuildProject.ShowResults(ProjectService.CurrentProject.Publish()); + Build.ShowResults(ProjectService.CurrentProject.Publish()); } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/OutputWindowOptionsPanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/OutputWindowOptionsPanel.cs index 8f20d146a6..d70c04ea76 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/OutputWindowOptionsPanel.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/OutputWindowOptionsPanel.cs @@ -51,8 +51,5 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels PropertyService.Set(OutputWindowsProperty, properties); return true; } - - - } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs index e07eb510b6..4230d1d959 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs @@ -37,8 +37,10 @@ namespace ICSharpCode.SharpDevelop.Gui } } - TextEditorControl textEditorControl = new TextEditorControl(); - Panel myPanel = new Panel(); + //TextEditorControl textEditorControl = new TextEditorControl(); + RichTextBox textEditorControl = new RichTextBox(); + Panel myPanel = new Panel(); + ToolStrip toolStrip; List messageCategories = new List(); @@ -51,7 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (selectedCategory != value) { selectedCategory = value; textEditorControl.Text = (value < 0) ? "" : messageCategories[value].Text; - textEditorControl.Refresh(); + //textEditorControl.Refresh(); OnSelectedCategoryIndexChanged(EventArgs.Empty); } } @@ -76,7 +78,7 @@ namespace ICSharpCode.SharpDevelop.Gui } // The compiler message view properties. - Properties properties = null; + Properties properties = null; public List MessageCategories { get { @@ -97,8 +99,10 @@ namespace ICSharpCode.SharpDevelop.Gui AddCategory(TaskService.BuildMessageViewCategory); myPanel.SuspendLayout(); - textEditorControl.Dock = DockStyle.Fill; - textEditorControl.ShowLineNumbers = false; + textEditorControl.Dock = DockStyle.Fill; + textEditorControl.BorderStyle = BorderStyle.FixedSingle; + textEditorControl.BackColor = SystemColors.Window; + /*textEditorControl.ShowLineNumbers = false; textEditorControl.ShowInvalidLines = false; textEditorControl.EnableFolding = false; textEditorControl.IsIconBarVisible = false; @@ -107,18 +111,20 @@ namespace ICSharpCode.SharpDevelop.Gui textEditorControl.ShowVRuler = false; textEditorControl.ShowSpaces = false; textEditorControl.ShowTabs = false; - textEditorControl.ShowEOLMarkers = false; + textEditorControl.ShowEOLMarkers = false;*/ + textEditorControl.ReadOnly = true; textEditorControl.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/CompilerMessageView/ContextMenu"); properties = (Properties)PropertyService.Get(OutputWindowOptionsPanel.OutputWindowsProperty, new Properties()); - textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString()); + textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString()); properties.PropertyChanged += new PropertyChangedEventHandler(PropertyChanged); - textEditorControl.ActiveTextAreaControl.TextArea.DoubleClick += TextEditorControlDoubleClick; + //textEditorControl.ActiveTextAreaControl.TextArea.DoubleClick += TextEditorControlDoubleClick; + textEditorControl.DoubleClick += TextEditorControlDoubleClick; - ToolStrip toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/CompilerMessageView/Toolbar"); + toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/CompilerMessageView/Toolbar"); toolStrip.Stretch = true; toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; @@ -131,13 +137,13 @@ namespace ICSharpCode.SharpDevelop.Gui void SetWordWrap() { -// bool wordWrap = properties.Get("WordWrap", true); -// textEditorControl.WordWrap = wordWrap; -// if (wordWrap) { -// textEditorControl.ScrollBars = RichTextBoxScrollBars.ForcedBoth; -// } else { -// textEditorControl.ScrollBars = RichTextBoxScrollBars.ForcedVertical; -// } + bool wordWrap = this.WordWrap; + textEditorControl.WordWrap = wordWrap; + if (wordWrap) { + textEditorControl.ScrollBars = RichTextBoxScrollBars.ForcedBoth; + } else { + textEditorControl.ScrollBars = RichTextBoxScrollBars.ForcedVertical; + } } public override void RedrawContent() @@ -167,7 +173,7 @@ namespace ICSharpCode.SharpDevelop.Gui { if (messageCategories[SelectedCategoryIndex] == category) { textEditorControl.Text = String.Empty; - textEditorControl.Refresh(); + //textEditorControl.Refresh(); } } @@ -176,25 +182,67 @@ namespace ICSharpCode.SharpDevelop.Gui WorkbenchSingleton.SafeThreadAsyncCall(this, "SetText", (MessageViewCategory)sender, e.Text); } + object appendCallLock = new object(); + volatile int pendingAppendCalls = 0; + void CategoryTextAppended(object sender, TextEventArgs e) { - WorkbenchSingleton.SafeThreadAsyncCall(this, "AppendText", (MessageViewCategory)sender, ((MessageViewCategory)sender).Text, e.Text); + lock (appendCallLock) { + pendingAppendCalls += 1; + if (pendingAppendCalls < 5) { + WorkbenchSingleton.SafeThreadAsyncCall(this, "AppendText", sender, ((MessageViewCategory)sender).Text, e.Text); + } else if (pendingAppendCalls == 5) { + WorkbenchSingleton.SafeThreadAsyncCall(this, "AppendTextCombined", sender); + } + } + } + + const int WM_SETREDRAW = 0x00B; + + [System.Security.SuppressUnmanagedCodeSecurityAttribute] + [System.Runtime.InteropServices.DllImport("user32.dll")] + static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam); + + void SetUpdate(bool update) + { + SendMessage(textEditorControl.Handle, WM_SETREDRAW, update ? 1 : 0, IntPtr.Zero); + } + + void AppendTextCombined(MessageViewCategory category) + { + Application.DoEvents(); + Thread.Sleep(50); + Application.DoEvents(); + lock (appendCallLock) { + SetUpdate(false); + SetText(category, category.Text); + SetUpdate(true); + textEditorControl.SelectionStart = textEditorControl.TextLength; + LoggingService.Debug("Replaced " + pendingAppendCalls + " appends with one set call"); + pendingAppendCalls = 0; + } } void AppendText(MessageViewCategory category, string fullText, string text) { + lock (appendCallLock) { + if (pendingAppendCalls >= 5) { + return; + } + } if (messageCategories[SelectedCategoryIndex] != category) { SelectCategory(category.Category, fullText); return; } - if (text != null) { text = StringParser.Parse(text); - textEditorControl.Document.ReadOnly = false; + textEditorControl.AppendText(text); + textEditorControl.SelectionStart = textEditorControl.TextLength; + /*textEditorControl.Document.ReadOnly = false; textEditorControl.Document.Insert(textEditorControl.Document.TextLength, text); textEditorControl.Document.ReadOnly = true; textEditorControl.ActiveTextAreaControl.Caret.Position = new Point(0, textEditorControl.Document.TotalNumberOfLines); - textEditorControl.ActiveTextAreaControl.ScrollTo(textEditorControl.Document.TotalNumberOfLines); + textEditorControl.ActiveTextAreaControl.ScrollTo(textEditorControl.Document.TotalNumberOfLines);*/ } } @@ -210,7 +258,7 @@ namespace ICSharpCode.SharpDevelop.Gui text = StringParser.Parse(text); } textEditorControl.Text = text; - textEditorControl.Refresh(); + //textEditorControl.Refresh(); } public void SelectCategory(string categoryName) @@ -234,7 +282,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (category.Category == categoryName) { selectedCategory = i; textEditorControl.Text = text; - textEditorControl.Refresh(); + //textEditorControl.Refresh(); OnSelectedCategoryIndexChanged(EventArgs.Empty); break; } @@ -268,10 +316,20 @@ namespace ICSharpCode.SharpDevelop.Gui /// void TextEditorControlDoubleClick(object sender, EventArgs e) { + string fullText = textEditorControl.Text; // Any text? - if (textEditorControl.Text.Length > 0) { - int line = textEditorControl.ActiveTextAreaControl.Caret.Line; - string textLine = TextUtilities.GetLineAsString(textEditorControl.Document, line); + if (fullText.Length > 0) { + //int line = textEditorControl.ActiveTextAreaControl.Caret.Line; + //string textLine = TextUtilities.GetLineAsString(textEditorControl.Document, line); + Point clickPos = textEditorControl.PointToClient(Control.MousePosition); + int index = textEditorControl.GetCharIndexFromPosition(clickPos); + int start = index; + // find start of current line + while (--start > 0 && fullText[start - 1] != '\n'); + // find end of current line + while (++index < fullText.Length && fullText[index] != '\r'); + + string textLine = fullText.Substring(start, index - start); FileLineReference lineReference = OutputTextLineParser.GetFileLineReference(textLine); if (lineReference != null) { @@ -288,6 +346,7 @@ namespace ICSharpCode.SharpDevelop.Gui { if (e.Key == "WordWrap") { SetWordWrap(); + ToolbarService.UpdateToolbar(toolStrip); } if (e.Key == "DefaultFont") { textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", ResourceService.CourierNew10.ToString()).ToString()); @@ -320,7 +379,8 @@ namespace ICSharpCode.SharpDevelop.Gui public bool EnableCopy { get { - return textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCopy; + //return textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableCopy; + return textEditorControl.SelectionLength > 0; } } @@ -338,7 +398,8 @@ namespace ICSharpCode.SharpDevelop.Gui public bool EnableSelectAll { get { - return textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableSelectAll; + //return textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.EnableSelectAll; + return textEditorControl.TextLength > 0; } } @@ -348,7 +409,8 @@ namespace ICSharpCode.SharpDevelop.Gui public void Copy() { - textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Copy(null, null); + //textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.Copy(null, null); + textEditorControl.Copy(); } public void Paste() @@ -361,9 +423,9 @@ namespace ICSharpCode.SharpDevelop.Gui public void SelectAll() { - textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.SelectAll(null, null); + //textEditorControl.ActiveTextAreaControl.TextArea.ClipboardHandler.SelectAll(null, null); + textEditorControl.SelectAll(); } #endregion - } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/MessageViewCategory.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/MessageViewCategory.cs index 039e83f543..20bbf70b13 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/MessageViewCategory.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/MessageViewCategory.cs @@ -20,7 +20,7 @@ using ICSharpCode.Core; namespace ICSharpCode.SharpDevelop.Gui { /// - /// This class represents a category with its text content used in the + /// This class represents a category with its text content used in the /// output pad (CompilerMessageView). /// public class MessageViewCategory @@ -43,7 +43,9 @@ namespace ICSharpCode.SharpDevelop.Gui public string Text { get { - return textBuilder.ToString(); + lock (textBuilder) { + return textBuilder.ToString(); + } } } @@ -59,24 +61,30 @@ namespace ICSharpCode.SharpDevelop.Gui public void AppendText(string text) { - textBuilder.Append(text); + lock (textBuilder) { + textBuilder.Append(text); + } OnTextAppended(new TextEventArgs(text)); } public void SetText(string text) { - textBuilder.Length = 0; - textBuilder.Append(text); + lock (textBuilder) { + textBuilder.Length = 0; + textBuilder.Append(text); + } OnTextSet(new TextEventArgs(text)); } public void ClearText() { - textBuilder.Length = 0; + lock (textBuilder) { + textBuilder.Length = 0; + } OnCleared(EventArgs.Empty); } - protected virtual void OnTextAppended(TextEventArgs e) + protected virtual void OnTextAppended(TextEventArgs e) { if (TextAppended != null) { TextAppended(this, e); diff --git a/src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorListPad.cs b/src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorListPad.cs index ab737d3169..2a9283846e 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorListPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorListPad.cs @@ -76,15 +76,19 @@ namespace ICSharpCode.SharpDevelop.Gui instance = this; RedrawContent(); - + TaskService.Cleared += new EventHandler(TaskServiceCleared); TaskService.Added += new TaskEventHandler(TaskServiceAdded); TaskService.Removed += new TaskEventHandler(TaskServiceRemoved); + TaskService.InUpdateChanged += delegate { + if (!TaskService.InUpdate) + InternalShowResults(); + }; ProjectService.EndBuild += ProjectServiceEndBuild; ProjectService.SolutionLoaded += OnCombineOpen; ProjectService.SolutionClosed += OnCombineClosed; - + taskView.CreateControl(); contentPanel.Controls.Add(taskView); @@ -125,7 +129,7 @@ namespace ICSharpCode.SharpDevelop.Gui } UpdateToolstripStatus(); } - + public CompilerResults CompilerResults = null; void AddTask(Task task) @@ -149,25 +153,31 @@ namespace ICSharpCode.SharpDevelop.Gui default: return; } - + taskView.AddTask(task); } void TaskServiceCleared(object sender, EventArgs e) { + if (TaskService.InUpdate) + return; taskView.ClearTasks(); UpdateToolstripStatus(); } void TaskServiceAdded(object sender, TaskEventArgs e) { + if (TaskService.InUpdate) + return; AddTask(e.Task); UpdateToolstripStatus(); } void TaskServiceRemoved(object sender, TaskEventArgs e) { + if (TaskService.InUpdate) + return; taskView.RemoveTask(e.Task); UpdateToolstripStatus(); } diff --git a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs index ebffad896c..fcaf303f16 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs @@ -5,7 +5,7 @@ // $Revision$ // -// much of TaskView's code has been refactored from +// much of TaskView's code has been refactored from // TaskList.cs (formerly OpenTaskView.cs) & ErrorList.cs using System; @@ -120,7 +120,7 @@ namespace ICSharpCode.Core } protected override void OnColumnClick(ColumnClickEventArgs e) - { + { SortBy(e.Column); base.OnColumnClick(e); } @@ -130,7 +130,7 @@ namespace ICSharpCode.Core System.Diagnostics.Debug.Assert(SelectedTask != null); SelectedTask.JumpToPosition(); } - base.OnItemActivate(e); + base.OnItemActivate(e); } ListViewItem currentListViewItem = null; @@ -199,7 +199,7 @@ namespace ICSharpCode.Core int right = this.Items.Count - 1; while (left <= right) { int m = left + (right - left) / 2; - if (this.ListViewItemSorter.Compare(item, this.Items[m]) > 0) { + if (this.mySorter.Compare(item, this.Items[m]) > 0) { left = m + 1; } else { right = m - 1; @@ -228,7 +228,7 @@ namespace ICSharpCode.Core Items.RemoveAt(i); break; } - } + } } public void UpdateResults(System.Collections.Generic.IEnumerable taskSet) @@ -242,7 +242,6 @@ namespace ICSharpCode.Core this.EndUpdate(); } - #endregion #region Custom IComparer for sorting TaskView. @@ -251,8 +250,8 @@ namespace ICSharpCode.Core SortOrder currentSortOrder = SortOrder.Ascending; /// - /// Applies the specified sort request by creating, - /// configuring, and installing a + /// Applies the specified sort request by creating, + /// configuring, and installing a /// . /// private void SortBy(TaskViewCols col) @@ -273,10 +272,13 @@ namespace ICSharpCode.Core currentSortOrder = SortOrder.Ascending; } - this.ListViewItemSorter = - new TaskViewSorter(currentSortColumn, currentSortOrder); + this.mySorter = new TaskViewSorter(currentSortColumn, currentSortOrder); + this.ListViewItemSorter = mySorter; + this.ListViewItemSorter = null; } + TaskViewSorter mySorter; + /// /// Custom for TaskView. /// @@ -290,7 +292,7 @@ namespace ICSharpCode.Core sortCol = col; sortOrder = order; } - + protected int CompareLineNumbers(ListViewItem a, ListViewItem b) { return ((Task)a.Tag).Line.CompareTo(((Task)b.Tag).Line); @@ -315,8 +317,8 @@ namespace ICSharpCode.Core /// A signed integer indicating the relative sort ranking /// of item relative to item /// . - /// Return value greater than zero: x > y. - /// Return value is zero: x == y. + /// Return value greater than zero: x > y. + /// Return value is zero: x == y. /// Return value is less than zero: x \< y. /// public int Compare(object x, object y) { diff --git a/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs b/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs index 56862b54e2..69bb7612b2 100644 --- a/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs +++ b/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs @@ -228,6 +228,24 @@ namespace ICSharpCode.Core public static event TaskEventHandler Added; public static event TaskEventHandler Removed; public static event EventHandler Cleared; + + static bool inUpdate; + + public static bool InUpdate { + get { + return inUpdate; + } + set { + if (inUpdate != value) { + inUpdate = value; + + if (InUpdateChanged != null) { + InUpdateChanged(null, EventArgs.Empty); + } + } + } + } + + public static event EventHandler InUpdateChanged; } - }