Browse Source

Merge #280 - ClipboardRing, CurrentLineHighlighting, SelectionLength, OverstrikeMode, HideMouseCursorWhileTyping

pull/331/head
Daniel Grunwald 12 years ago
parent
commit
c8df4f6514
  1. 26
      data/resources/StringResources.resx
  2. 18
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.addin
  3. 3
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
  4. 27
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  5. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
  6. 61
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRing.cs
  7. 53
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingAction.cs
  8. 73
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingPopup.cs
  9. 8
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsControl.xaml
  10. 14
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsControl.xaml.cs
  11. 15
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsHeaderedControl.xaml.cs
  12. 3
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/BehaviorOptions.xaml
  13. 3
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml
  14. 15
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs
  15. 5
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml
  16. 13
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs
  17. 35
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
  18. 15
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretLayer.cs
  19. 67
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs
  20. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  21. 103
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CurrentLineHighlightRenderer.cs
  22. 44
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  23. 48
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
  24. 5
      src/Main/Base/Project/Editor/ContextActions/ContextActionViewModel.cs
  25. 41
      src/Main/Base/Project/Src/Gui/Components/SideBar/TextEditorSideBar.cs
  26. 13
      src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs
  27. 10
      src/Main/SharpDevelop/Workbench/SDStatusBar.cs
  28. 24
      src/Main/SharpDevelop/Workbench/StatusBarService.cs

26
data/resources/StringResources.resx

@ -2397,6 +2397,12 @@ system. I don't think that it needs translation.</comment> @@ -2397,6 +2397,12 @@ system. I don't think that it needs translation.</comment>
<data name="Dialog.Options.IDEOptions.TextEditor.General.MouseWheelZoomCheckBoxCheckBox" xml:space="preserve">
<value>M&amp;ouse wheel zooming</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.General.HideCursorWhileTypingCheckBoxCheckBox" xml:space="preserve">
<value>Hide cursor while typing</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.General.AllowOverstrikeModeCheckBox" xml:space="preserve">
<value>Allow overstrike mode</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.General.ShowQuickClassBrowserCheckBox" xml:space="preserve">
<value>Show &amp;Quick ClassBrowser Panel</value>
</data>
@ -2425,9 +2431,12 @@ system. I don't think that it needs translation.</comment> @@ -2425,9 +2431,12 @@ system. I don't think that it needs translation.</comment>
<data name="Dialog.Options.IDEOptions.TextEditor.Markers.HighlightSymbolCheckBox" xml:space="preserve">
<value>Highlight symbols</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.Markers.HiglightBracketCheckBox" xml:space="preserve">
<data name="Dialog.Options.IDEOptions.TextEditor.Markers.HighlightBracketCheckBox" xml:space="preserve">
<value>Highlight &amp;matching bracket</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.Markers.HighlightCurrentLineCheckBox" xml:space="preserve">
<value>Highlight current line</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.Markers.HorizontalRulerCheckBox" xml:space="preserve">
<value>Show &amp;horizontal ruler</value>
</data>
@ -6434,6 +6443,15 @@ Removed the end part of the original message ", reason '${Message}'" since this @@ -6434,6 +6443,15 @@ Removed the end part of the original message ", reason '${Message}'" since this
<value>Classes deriving from ${Name}</value>
<comment>Title for search results for derived classes</comment>
</data>
<data name="SharpDevelop.Refactoring.ClipboardRing" xml:space="preserve">
<value>Clipboard ring</value>
</data>
<data name="SharpDevelop.Refactoring.ClipboardRingEmpty" xml:space="preserve">
<value>Clipboard ring is empty</value>
</data>
<data name="SharpDevelop.Refactoring.ClipboardRingCommand" xml:space="preserve">
<value>From clipboard ring</value>
</data>
<data name="SharpDevelop.Refactoring.ConvertToAutomaticProperty" xml:space="preserve">
<value>Convert to automatic property</value>
</data>
@ -6929,6 +6947,12 @@ The resources files have been renamed/moved accordingly.</value> @@ -6929,6 +6947,12 @@ The resources files have been renamed/moved accordingly.</value>
<data name="StatusBarService.CursorStatusBarPanelText" xml:space="preserve">
<value>ln ${Line} col ${Column} ch ${Character}</value>
</data>
<data name="StatusBarService.SelectionStatusBarPanelTextSingle" xml:space="preserve">
<value>len ${Lenght}</value>
</data>
<data name="StatusBarService.SelectionStatusBarPanelTextMulti" xml:space="preserve">
<value>len ${Rows} * ${Cols} (${Total})</value>
</data>
<data name="Templates.File.Categories.Misc" xml:space="preserve">
<value>Misc</value>
</data>

18
src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.addin

@ -42,6 +42,14 @@ @@ -42,6 +42,14 @@
class = "ICSharpCode.AvalonEdit.AddIn.TextMarkerToolTipProvider"/>
</Path>
<Path name = "/SharpDevelop/ViewContent/TextEditor/ContextMenu">
<Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.Editor.ITextEditor">
<Include id="ClipboardRing"
insertafter="Delete"
item="/SharpDevelop/Workbench/MainMenu/Edit/Insert/ClipboardRing" />
</Condition>
</Path>
<!--
<Path name = "/SharpDevelop/ViewContent/TextEditor/ContextMenu">
<Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.Editor.ITextEditor">
@ -64,6 +72,16 @@ @@ -64,6 +72,16 @@
</Condition>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Edit/Insert">
<Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.Editor.ITextEditor" action="Disable">
<MenuItem id = "Separator1" type = "Separator"/>
<MenuItem id = "ClipboardRing"
label = "${res:SharpDevelop.Refactoring.ClipboardRingCommand}"
shortcut = "Ctrl+Shift+V"
class = "ICSharpCode.AvalonEdit.AddIn.ContextActions.ClipboardRing"/>
</Condition>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Edit/Format">
<Condition name = "WindowActive" activewindow="ICSharpCode.SharpDevelop.Editor.ITextEditor" action="Disable">
<MenuItem id = "RemoveLeadingWs"

3
src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj

@ -87,6 +87,9 @@ @@ -87,6 +87,9 @@
<Compile Include="Src\ChangeMarkerMargin\DocumentSequence.cs" />
<Compile Include="Src\ChangeMarkerMargin\IChangeWatcher.cs" />
<Compile Include="Src\ChangeMarkerMargin\LineChangeInfo.cs" />
<Compile Include="Src\ContextActions\ClipboardRing.cs" />
<Compile Include="Src\ContextActions\ClipboardRingAction.cs" />
<Compile Include="Src\ContextActions\ClipboardRingPopup.cs" />
<Compile Include="Src\ContextActions\ContextActionOptionPanelDoozer.cs" />
<Compile Include="Src\ContextActions\ContextActionOptions.xaml.cs">
<DependentUpon>ContextActionOptions.xaml</DependentUpon>

27
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

@ -226,6 +226,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -226,6 +226,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
codeEditorView.TextArea.TextEntering += TextAreaTextEntering;
codeEditorView.TextArea.TextEntered += TextAreaTextEntered;
codeEditorView.TextArea.Caret.PositionChanged += TextAreaCaretPositionChanged;
codeEditorView.TextArea.SelectionChanged += TextAreaSelectionChanged;
codeEditorView.TextArea.DefaultInputHandler.CommandBindings.Add(
new CommandBinding(CustomCommands.CtrlSpaceCompletion, OnCodeCompletion));
SearchPanel.Install(codeEditorView.TextArea);
@ -396,6 +397,32 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -396,6 +397,32 @@ namespace ICSharpCode.AvalonEdit.AddIn
SD.StatusBar.SetCaretPosition(col, this.Line, chOffset);
}
void TextAreaSelectionChanged(object sender, EventArgs e)
{
if (document == null)
return;
if (sender == this.ActiveTextEditor.TextArea) {
HandleSelectionChanged();
}
}
void HandleSelectionChanged()
{
TextArea textArea = this.ActiveTextEditor.TextArea;
if (textArea == null)
return;
Selection selection = textArea.Selection;
if (selection is RectangleSelection) {
int rows = Math.Abs(selection.EndPosition.Line - selection.StartPosition.Line) + 1;
int cols = Math.Abs(selection.EndPosition.VisualColumn - selection.StartPosition.VisualColumn);
SD.StatusBar.SetSelectionMulti(rows, cols);
} else {
SD.StatusBar.SetSelectionSingle(selection.Length);
}
}
public INavigationPoint BuildNavPoint()
{
int lineNumber = this.Line;

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs

@ -160,6 +160,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -160,6 +160,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
}
#endregion
#region Custom Tab command (code snippet expansion)

61
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRing.cs

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.Commands;
using ICSharpCode.SharpDevelop.Editor.ContextActions;
using ICSharpCode.SharpDevelop.Refactoring;
namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
{
public class ClipboardRing : ResolveResultMenuCommand
{
public override void Run(ResolveResult symbol)
{
ITextEditor editor = SD.GetActiveViewContentService<ITextEditor>();
if(editor == null)
return;
EditorRefactoringContext context = new EditorRefactoringContext(editor);
MakePopupWithClipboardOptions(context).OpenAtCaretAndFocus();
}
static ContextActionsPopup MakePopupWithClipboardOptions(EditorRefactoringContext context)
{
var popupViewModel = new ContextActionsPopupViewModel();
var actions = BuildClipboardRingData(context);
string labelSource = "${res:SharpDevelop.Refactoring.ClipboardRing}";
if (actions == null || actions.Count == 0)
labelSource = "${res:SharpDevelop.Refactoring.ClipboardRingEmpty}";
popupViewModel.Title = MenuService.ConvertLabel(StringParser.Parse(labelSource));
popupViewModel.Actions = actions;
return new ClipboardRingPopup { Actions = popupViewModel };
}
static ObservableCollection<ContextActionViewModel> BuildClipboardRingData(EditorRefactoringContext context)
{
var clipboardRing = ICSharpCode.SharpDevelop.Gui.TextEditorSideBar.Instance;
var clipboardRingItems = clipboardRing.GetClipboardRingItems();
var list = new ObservableCollection<ContextActionViewModel>();
foreach (var item in clipboardRingItems) {
list.Add(new ContextActionViewModel(new ClipboardRingAction(item), context));
}
return list;
}
}
}

53
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingAction.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Refactoring;
namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
{
public class ClipboardRingAction : IContextAction
{
readonly int maxLength = 50;
readonly string endString = "...";
public string Text { get; private set; }
public string DisplayName { get; private set; }
public IEntity Entity { get; private set; }
public IContextActionProvider Provider { get { return null; } }
public ClipboardRingAction(string text)
{
string entry = text.Trim();
if(entry.Length > maxLength)
entry = entry.Substring(0, maxLength-endString.Length) + endString;
this.DisplayName = entry;
this.Text = text;
}
public string GetDisplayName(EditorRefactoringContext context)
{
return DisplayName;
}
public void Execute(EditorRefactoringContext context)
{
/* insert to editor */
ITextEditor editor = context.Editor;
editor.Document.Insert(context.CaretOffset, this.Text);
/* update clipboard ring */
var clipboardRing = ICSharpCode.SharpDevelop.Gui.TextEditorSideBar.Instance;
if (clipboardRing != null) {
clipboardRing.PutInClipboardRing(this.Text);
}
}
}
}

73
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingPopup.cs

@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using ICSharpCode.SharpDevelop.Editor.ContextActions;
namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
{
public class ClipboardRingPopup : ContextActionsPopup
{
ToolTip toolTip;
public ClipboardRingPopup() : base()
{
this.toolTip = new ToolTip();
this.toolTip.PlacementTarget = this.ActionsControl;
this.toolTip.Placement = PlacementMode.Right;
this.toolTip.Closed += new RoutedEventHandler(ClipboardRingPopup_Closed);
this.ActionsControl.ActionExecuted += delegate
{
if(this.toolTip != null)
this.toolTip.IsOpen = false;
};
this.ActionsControl.ActionSelected += new RoutedEventHandler(ClipboardRingPopup_ActionSelected);
this.ActionsControl.ActionUnselected += new RoutedEventHandler(ClipboardRingPopup_ActionUnselected);
}
#region ToolTip handling
string ExtractTextFromEvent(RoutedEventArgs args)
{
var button = args.Source as Button;
if (button == null)
return null;
var command = button.Command as ContextActionCommand;
if (command == null)
return null;
var clipboardRingAction = command.ContextAction as ClipboardRingAction;
if (clipboardRingAction == null)
return null;
return clipboardRingAction.Text;
}
void ClipboardRingPopup_ActionSelected(object sender, RoutedEventArgs e)
{
if (this.toolTip != null) {
var text = ExtractTextFromEvent(e);
this.toolTip.Content = text;
this.toolTip.IsOpen = (text != null);
}
}
void ClipboardRingPopup_ActionUnselected(object sender, RoutedEventArgs e)
{
}
void ClipboardRingPopup_Closed(object sender, RoutedEventArgs e)
{
if(toolTip != null)
toolTip.Content = null;
}
#endregion
}
}

8
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsControl.xaml

@ -66,7 +66,13 @@ @@ -66,7 +66,13 @@
<ControlTemplate TargetType="TreeViewItem">
<StackPanel>
<!-- ActionButtonClick event is used just to close the Popup -->
<Button Command="{Binding ActionCommand}" Style="{StaticResource ClearButton}" Click="ActionButtonClick">
<Button
Command="{Binding ActionCommand}"
Style="{StaticResource ClearButton}"
Click="ActionButtonClick"
GotFocus="ActionGotFocus"
LostFocus="ActionLostFocus"
>
<Border SnapsToDevicePixels="True">
<ContentPresenter Content="{TemplateBinding HeaderedContentControl.Header}" ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}" ContentStringFormat="{TemplateBinding HeaderedItemsControl.HeaderStringFormat}" ContentSource="Header" Name="PART_Header"
HorizontalAlignment="Stretch" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />

14
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsControl.xaml.cs

@ -35,6 +35,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -35,6 +35,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
}
public event EventHandler ActionExecuted;
public event RoutedEventHandler ActionSelected;
public event RoutedEventHandler ActionUnselected;
public new void Focus()
{
@ -58,6 +60,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -58,6 +60,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
ActionExecuted(this, EventArgs.Empty);
}
void ActionGotFocus(object sender, RoutedEventArgs e)
{
if (ActionSelected != null)
ActionSelected(this, e);
}
void ActionLostFocus(object sender, RoutedEventArgs e)
{
if (ActionUnselected != null)
ActionUnselected(this, e);
}
public static readonly DependencyProperty ItemTemplateProperty =
DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), typeof(ContextActionsControl),
new FrameworkPropertyMetadata());

15
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsHeaderedControl.xaml.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
using System.Windows.Controls;
namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
@ -25,7 +26,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -25,7 +26,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
/// Interaction logic for ContextActionsHeaderedControl.xaml
/// </summary>
public partial class ContextActionsHeaderedControl : UserControl
{
{
public ContextActionsHeaderedControl()
{
InitializeComponent();
@ -37,6 +38,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions @@ -37,6 +38,18 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions
remove { this.ActionsTreeView.ActionExecuted -= value; }
}
public event RoutedEventHandler ActionSelected
{
add { this.ActionsTreeView.ActionSelected += value; }
remove { this.ActionsTreeView.ActionSelected -= value; }
}
public event RoutedEventHandler ActionUnselected
{
add { this.ActionsTreeView.ActionUnselected += value; }
remove { this.ActionsTreeView.ActionUnselected -= value; }
}
public new void Focus()
{
if (this.ActionsTreeView != null)

3
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/BehaviorOptions.xaml

@ -33,6 +33,9 @@ @@ -33,6 +33,9 @@
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.MouseWheelZoom}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.MouseWheelZoomCheckBoxCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.HideCursorWhileTyping}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.HideCursorWhileTypingCheckBoxCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.CutCopyWholeLine}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.CutCopyWholeLine}" />

3
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml

@ -27,6 +27,9 @@ @@ -27,6 +27,9 @@
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.ShowHiddenDefinitions}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.ShowHiddenDefinitionsCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.AllowOverstrikeMode}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.AllowOverstrikeModeCheckBox}" />
</widgets:StackPanelWithSpacing>
</GroupBox>
</StackPanel>

15
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs

@ -366,6 +366,21 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -366,6 +366,21 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
bracketHighlight.PropertyChanged += item_PropertyChanged;
items.Add(bracketHighlight);
// Create entry for "Current Line highlight"
IHighlightingItem currentLineHighlight = new SimpleHighlightingItem(
CustomizingHighlighter.CurrentLineHighlighter,
ta => {
ta.Document.Text = "example text line";
ta.TextView.Options.HighlightCurrentLine = true;
})
{
Foreground = Color.FromArgb(52, 0, 255, 110),
Background = Color.FromArgb(22, 20, 220, 224)
};
currentLineHighlight = new CustomizedHighlightingItem(customizationList, currentLineHighlight, language, canSetFont: false);
currentLineHighlight.PropertyChanged += item_PropertyChanged;
items.Add(currentLineHighlight);
// Create entry for "Folding controls"
IHighlightingItem foldingControls = new SimpleHighlightingItem(
FoldingControls,

5
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml

@ -20,7 +20,10 @@ @@ -20,7 +20,10 @@
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.UnderLineErrorsCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.HighlightBrackets}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.HiglightBracketCheckBox}" />
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.HighlightBracketCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.HighlightCurrentLine}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.HighlightCurrentLineCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.HighlightSymbol}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Markers.HighlightSymbolCheckBox}" />

13
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SyntaxHighlighting/CustomizingHighlighter.cs

@ -44,6 +44,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -44,6 +44,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public const string BreakpointMarker = "Breakpoint";
public const string InstructionPointerMarker = "Current statement";
public const string ColumnRuler = "Column ruler";
public const string CurrentLineHighlighter = "Current line highlighting";
public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable<CustomizedHighlightingColor> customizations)
{
@ -57,6 +58,8 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -57,6 +58,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
textEditor.TextArea.TextView.ClearValue(TextView.LinkTextForegroundBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.LinkTextBackgroundBrushProperty);
textEditor.TextArea.TextView.ClearValue(TextView.ColumnRulerPenProperty);
textEditor.TextArea.TextView.ClearValue(TextView.CurrentLineBorderProperty);
textEditor.TextArea.TextView.ClearValue(TextView.CurrentLineBackgroundProperty);
// 'assigned' flags are used so that the first matching customization wins.
// This is necessary because more specific customizations come first in the list
@ -67,6 +70,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -67,6 +70,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
bool assignedLineNumbers = false;
bool assignedLinkText = false;
bool assignedColumnRulerColor = false;
bool assignedCurrentLineHighlighter = false;
foreach (CustomizedHighlightingColor color in customizations) {
switch (color.Name) {
@ -130,6 +134,15 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -130,6 +134,15 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (color.Foreground != null)
textEditor.TextArea.TextView.ColumnRulerPen = CreateFrozenPen(color.Foreground.Value);
break;
case CurrentLineHighlighter:
if (assignedCurrentLineHighlighter)
continue;
assignedCurrentLineHighlighter = true;
if (color.Background != null)
textEditor.TextArea.TextView.CurrentLineBackground = CreateFrozenBrush(color.Background.Value);
if (color.Foreground != null)
textEditor.TextArea.TextView.CurrentLineBorder = CreateFrozenPen(color.Foreground.Value);
break;
}
}
}

35
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -47,7 +47,7 @@ namespace ICSharpCode.AvalonEdit.Editing
this.textView = textArea.TextView;
position = new TextViewPosition(1, 1, 0);
caretAdorner = new CaretLayer(textView);
caretAdorner = new CaretLayer(textArea);
textView.InsertLayer(caretAdorner, KnownLayer.Caret, LayerInsertionPosition.Replace);
textView.VisualLinesChanged += TextView_VisualLinesChanged;
textView.ScrollOffsetChanged += TextView_ScrollOffsetChanged;
@ -382,6 +382,29 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -382,6 +382,29 @@ namespace ICSharpCode.AvalonEdit.Editing
lineBottom - lineTop);
}
Rect CalcCaretOverstrikeRectangle(VisualLine visualLine)
{
if (!visualColumnValid) {
RevalidateVisualColumn(visualLine);
}
TextLine textLine = visualLine.GetTextLine(position.VisualColumn, position.IsAtEndOfLine);
double xPos = visualLine.GetTextLineVisualXPosition(textLine, position.VisualColumn);
double lineTop = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.TextTop);
double lineBottom = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.TextBottom);
int currentPos = position.VisualColumn;
int nextPos = visualLine.GetNextCaretPosition(currentPos, LogicalDirection.Forward, CaretPositioningMode.Normal, true);
double charSize = Math.Abs(
visualLine.GetTextLineVisualXPosition(textLine, currentPos) -
visualLine.GetTextLineVisualXPosition(textLine, nextPos) );
return new Rect(xPos,
lineTop,
charSize,
lineBottom - lineTop);
}
/// <summary>
/// Returns the caret rectangle. The coordinate system is in device-independent pixels from the top of the document.
/// </summary>
@ -389,7 +412,8 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -389,7 +412,8 @@ namespace ICSharpCode.AvalonEdit.Editing
{
if (textView != null && textView.Document != null) {
VisualLine visualLine = textView.GetOrConstructVisualLine(textView.Document.GetLineByNumber(position.Line));
return CalcCaretRectangle(visualLine);
return (this.textView.Options.AllowOverstrikeMode && this.textArea.OverstrikeMode)
? CalcCaretOverstrikeRectangle(visualLine) : CalcCaretRectangle(visualLine);
} else {
return Rect.Empty;
}
@ -444,7 +468,12 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -444,7 +468,12 @@ namespace ICSharpCode.AvalonEdit.Editing
if (caretAdorner != null && textView != null) {
VisualLine visualLine = textView.GetVisualLine(position.Line);
if (visualLine != null) {
Rect caretRect = CalcCaretRectangle(visualLine);
Rect caretRect;
if (this.textView.Options.AllowOverstrikeMode && this.textArea.OverstrikeMode) {
caretRect = CalcCaretOverstrikeRectangle(visualLine);
} else {
caretRect = CalcCaretRectangle(visualLine);
}
// Create Win32 caret so that Windows knows where our managed caret is. This is necessary for
// features like 'Follow text editing' in the Windows Magnifier.
if (!hasWin32Caret) {

15
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretLayer.cs

@ -30,14 +30,17 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -30,14 +30,17 @@ namespace ICSharpCode.AvalonEdit.Editing
{
sealed class CaretLayer : Layer
{
TextArea textArea;
bool isVisible;
Rect caretRectangle;
DispatcherTimer caretBlinkTimer = new DispatcherTimer();
bool blink;
public CaretLayer(TextView textView) : base(textView, KnownLayer.Caret)
public CaretLayer(TextArea textArea) : base(textArea.TextView, KnownLayer.Caret)
{
this.textArea = textArea;
this.IsHitTestVisible = false;
caretBlinkTimer.Tick += new EventHandler(caretBlinkTimer_Tick);
}
@ -90,6 +93,16 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -90,6 +93,16 @@ namespace ICSharpCode.AvalonEdit.Editing
Brush caretBrush = this.CaretBrush;
if (caretBrush == null)
caretBrush = (Brush)textView.GetValue(TextBlock.ForegroundProperty);
if (this.textArea.Options.AllowOverstrikeMode && this.textArea.OverstrikeMode) {
SolidColorBrush scBrush = caretBrush as SolidColorBrush;
if (scBrush != null) {
Color brushColor = scBrush.Color;
Color newColor = Color.FromArgb(100, brushColor.R, brushColor.G, brushColor.B);
caretBrush = new SolidColorBrush(newColor);
}
}
Rect r = new Rect(caretRectangle.X - textView.HorizontalOffset,
caretRectangle.Y - textView.VerticalOffset,
caretRectangle.Width,

67
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs

@ -84,6 +84,8 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -84,6 +84,8 @@ namespace ICSharpCode.AvalonEdit.Editing
caret = new Caret(this);
caret.PositionChanged += (sender, e) => RequestSelectionValidation();
caret.PositionChanged += CaretPositionChanged;
AttachTypingEvents();
ime = new ImeSupport(this);
leftMargins.CollectionChanged += leftMargins_CollectionChanged;
@ -574,6 +576,14 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -574,6 +576,14 @@ namespace ICSharpCode.AvalonEdit.Editing
get { return caret; }
}
void CaretPositionChanged(object sender, EventArgs e)
{
if (textView == null)
return;
this.textView.HighlightedLine = this.Caret.Line;
}
ObservableCollection<UIElement> leftMargins = new ObservableCollection<UIElement>();
/// <summary>
@ -871,8 +881,11 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -871,8 +881,11 @@ namespace ICSharpCode.AvalonEdit.Editing
if (!e.Handled) {
if (e.Text == "\n" || e.Text == "\r" || e.Text == "\r\n")
ReplaceSelectionWithNewLine();
else
else {
if (overstrikeMode && Selection.IsEmpty && Document.GetLineByNumber(Caret.Line).EndOffset > Caret.Offset)
Selection = Selection.Create(this, Caret.Offset, Caret.Offset+e.Text.Length);
ReplaceSelectionWithText(e.Text);
}
OnTextEntered(e);
caret.BringCaretToView();
}
@ -957,6 +970,17 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -957,6 +970,17 @@ namespace ICSharpCode.AvalonEdit.Editing
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
if (!this.Options.AllowOverstrikeMode) {
this.overstrikeMode = false;
} else if (!e.Handled && e.Key == Key.Insert) {
this.overstrikeMode = !this.overstrikeMode;
this.caret.Show();
e.Handled = true;
return;
}
HideMouseCursor();
foreach (TextAreaStackedInputHandler h in stackedInputHandlers) {
if (e.Handled)
break;
@ -980,6 +1004,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -980,6 +1004,7 @@ namespace ICSharpCode.AvalonEdit.Editing
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
HideMouseCursor();
TextView.InvalidateCursorIfMouseWithinTextView();
}
@ -991,6 +1016,46 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -991,6 +1016,46 @@ namespace ICSharpCode.AvalonEdit.Editing
}
#endregion
#region Hide Mouse Cursor While Typing
bool isMouseCursorHidden;
void AttachTypingEvents() {
this.MouseEnter += delegate { ShowMouseCursor(); };
this.MouseLeave += delegate { ShowMouseCursor(); };
this.MouseMove += delegate { ShowMouseCursor(); };
this.TouchEnter += delegate { ShowMouseCursor(); };
this.TouchLeave += delegate { ShowMouseCursor(); };
this.TouchMove += delegate { ShowMouseCursor(); };
}
void ShowMouseCursor() {
if (this.isMouseCursorHidden) {
System.Windows.Forms.Cursor.Show();
this.isMouseCursorHidden = false;
}
}
void HideMouseCursor() {
if (Options.HideCursorWhileTyping && !this.isMouseCursorHidden && this.IsMouseOver) {
this.isMouseCursorHidden = true;
System.Windows.Forms.Cursor.Hide();
}
}
#endregion
#region Overstrike mode
bool overstrikeMode = false;
public bool OverstrikeMode
{
get { return this.overstrikeMode; }
}
#endregion
/// <inheritdoc/>
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -245,6 +245,7 @@ @@ -245,6 +245,7 @@
<DependentUpon>IVisualLineTransformer.cs</DependentUpon>
</Compile>
<Compile Include="Rendering\ColumnRulerRenderer.cs" />
<Compile Include="Rendering\CurrentLineHighlightRenderer.cs" />
<Compile Include="Rendering\DefaultTextRunTypographyProperties.cs" />
<Compile Include="Rendering\DocumentColorizingTransformer.cs">
<DependentUpon>IVisualLineTransformer.cs</DependentUpon>

103
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CurrentLineHighlightRenderer.cs

@ -0,0 +1,103 @@ @@ -0,0 +1,103 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
namespace ICSharpCode.AvalonEdit.Rendering
{
sealed class CurrentLineHighlightRenderer : IBackgroundRenderer
{
#region Fields
int line;
TextView textView;
public static readonly Color DefaultBackground = Color.FromArgb(22, 20, 220, 224);
public static readonly Color DefaultBorder = Color.FromArgb(52, 0, 255, 110);
#endregion
#region Properties
public int Line {
get { return this.Line; }
set {
if (this.line != value) {
this.line = value;
this.textView.InvalidateLayer(this.Layer);
}
}
}
public KnownLayer Layer
{
get { return KnownLayer.Selection; }
}
public Brush BackgroundBrush {
get; set;
}
public Pen BorderPen {
get; set;
}
#endregion
public CurrentLineHighlightRenderer(TextView textView)
{
if (textView == null)
throw new ArgumentNullException("textView");
this.BorderPen = new Pen(new SolidColorBrush(DefaultBorder), 1);
this.BorderPen.Freeze();
this.BackgroundBrush = new SolidColorBrush(DefaultBackground);
this.BackgroundBrush.Freeze();
this.textView = textView;
this.textView.BackgroundRenderers.Add(this);
this.line = 0;
}
public void Draw(TextView textView, DrawingContext drawingContext)
{
if(!this.textView.Options.HighlightCurrentLine)
return;
BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();
builder.CornerRadius = 1;
builder.AlignToMiddleOfPixels = true;
var visualLine = this.textView.GetVisualLine(line);
if(visualLine == null) return;
var textViewPos = visualLine.GetTextViewPosition(0);
if(textViewPos == null) return;
var position = this.textView.GetVisualPosition(textViewPos, VisualYPosition.LineTop);
if(position == null) return;
var lineWidth = this.textView.ActualWidth;
var lineHeigth = visualLine.Height;
var linePosX = position.X;
var linePosY = position.Y - this.textView.ScrollOffset.Y;
builder.AddRectangle(textView, new Rect(linePosX, linePosY, lineWidth, lineHeigth));
Geometry geometry = builder.CreateGeometry();
if (geometry != null) {
drawingContext.DrawGeometry(this.BackgroundBrush, this.BorderPen, geometry);
}
}
}
}

44
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -57,6 +57,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -57,6 +57,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
}
ColumnRulerRenderer columnRulerRenderer;
CurrentLineHighlightRenderer currentLineHighlighRenderer;
/// <summary>
/// Creates a new TextView instance.
@ -69,6 +70,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -69,6 +70,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
lineTransformers = new ObserveAddRemoveCollection<IVisualLineTransformer>(LineTransformer_Added, LineTransformer_Removed);
backgroundRenderers = new ObserveAddRemoveCollection<IBackgroundRenderer>(BackgroundRenderer_Added, BackgroundRenderer_Removed);
columnRulerRenderer = new ColumnRulerRenderer(this);
currentLineHighlighRenderer = new CurrentLineHighlightRenderer(this);
this.Options = new TextEditorOptions();
Debug.Assert(singleCharacterElementGenerator != null); // assert that the option change created the builtin element generators
@ -2009,6 +2011,12 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -2009,6 +2011,12 @@ namespace ICSharpCode.AvalonEdit.Rendering
if (e.Property == ColumnRulerPenProperty) {
columnRulerRenderer.SetRuler(this.Options.ColumnRulerPosition, this.ColumnRulerPen);
}
if (e.Property == CurrentLineBorderProperty) {
currentLineHighlighRenderer.BorderPen = this.CurrentLineBorder;
}
if (e.Property == CurrentLineBackgroundProperty) {
currentLineHighlighRenderer.BackgroundBrush = this.CurrentLineBackground;
}
}
/// <summary>
@ -2034,5 +2042,41 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -2034,5 +2042,41 @@ namespace ICSharpCode.AvalonEdit.Rendering
get { return (Pen)GetValue(ColumnRulerPenProperty); }
set { SetValue(ColumnRulerPenProperty, value); }
}
/// <summary>
/// The <see cref="CurrentLineBackground"/> property.
/// </summary>
public static readonly DependencyProperty CurrentLineBackgroundProperty =
DependencyProperty.Register("CurrentLineBackground", typeof(Brush), typeof(TextView));
/// <summary>
/// Gets/Sets the background brush used by current line highlighter.
/// </summary>
public Brush CurrentLineBackground {
get { return (Brush)GetValue(CurrentLineBackgroundProperty); }
set { SetValue(CurrentLineBackgroundProperty, value); }
}
/// <summary>
/// The <see cref="CurrentLineBorder"/> property.
/// </summary>
public static readonly DependencyProperty CurrentLineBorderProperty =
DependencyProperty.Register("CurrentLineBorder", typeof(Pen), typeof(TextView));
/// <summary>
/// Gets/Sets the background brush used for the current line.
/// </summary>
public Pen CurrentLineBorder {
get { return (Pen)GetValue(CurrentLineBorderProperty); }
set { SetValue(CurrentLineBorderProperty, value); }
}
/// <summary>
/// Gets/Sets highlighted line number.
/// </summary>
public int HighlightedLine {
get { return this.currentLineHighlighRenderer.Line; }
set { this.currentLineHighlighRenderer.Line = value; }
}
}
}

48
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

@ -445,5 +445,53 @@ namespace ICSharpCode.AvalonEdit @@ -445,5 +445,53 @@ namespace ICSharpCode.AvalonEdit
}
}
}
bool highlightCurrentLine = false;
/// <summary>
/// Gets/Sets if current line should be shown.
/// </summary>
[DefaultValue(false)]
public virtual bool HighlightCurrentLine {
get { return highlightCurrentLine; }
set {
if (highlightCurrentLine != value) {
highlightCurrentLine = value;
OnPropertyChanged("HighlightCurrentLine");
}
}
}
bool hideCursorWhileTyping = true;
[DefaultValue(true)]
/// <summary>
/// Gets/Sets if mouse cursor should be shown when user is typing
/// </summary>
public bool HideCursorWhileTyping {
get { return hideCursorWhileTyping; }
set {
if (hideCursorWhileTyping != value) {
hideCursorWhileTyping = value;
OnPropertyChanged("HideCursorWhileTyping");
}
}
}
bool allowOverstrikeMode = false;
[DefaultValue(false)]
/// <summary>
/// Gets/Sets if overstrike mode is enabled to use
/// </summary>
public bool AllowOverstrikeMode {
get { return allowOverstrikeMode; }
set {
if (allowOverstrikeMode != value) {
allowOverstrikeMode = value;
OnPropertyChanged("AllowOverstrikeMode");
}
}
}
}
}

5
src/Main/Base/Project/Editor/ContextActions/ContextActionViewModel.cs

@ -99,6 +99,11 @@ namespace ICSharpCode.SharpDevelop.Editor.ContextActions @@ -99,6 +99,11 @@ namespace ICSharpCode.SharpDevelop.Editor.ContextActions
remove { }
}
public IContextAction ContextAction
{
get { return action; }
}
public void Execute(object parameter)
{
if (action.Provider != null)

41
src/Main/Base/Project/Src/Gui/Components/SideBar/TextEditorSideBar.cs

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml;
@ -97,20 +99,55 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -97,20 +99,55 @@ namespace ICSharpCode.SharpDevelop.Gui
this.ActiveTab = clipboardRing;
}
public List<string> GetClipboardRingItems()
{
var list = new List<string>();
if (clipboardRing == null || clipboardRing.Items == null)
return list;
foreach (var item in clipboardRing.Items) {
string itemData = item.Tag as string;
if (itemData != null)
list.Add(itemData);
}
return list;
}
public void PutInClipboardRing(string text)
{
if (clipboardRing != null) {
string shortenedText = text.Trim();
if (shortenedText == String.Empty)
return;
if (shortenedText.Length > 50)
shortenedText = shortenedText.Substring(0, 47) + "...";
clipboardRing.Items.Add("Text:" + shortenedText, text);
RemoveFromClipboardRing(text);
clipboardRing.Items.Insert(0, shortenedText, text);
if (clipboardRing.Items.Count > 20) {
clipboardRing.Items.RemoveAt(0);
clipboardRing.Items.RemoveAt(clipboardRing.Items.Count - 1);
}
}
Refresh();
}
void RemoveFromClipboardRing(string text)
{
int pos = 0;
foreach (var item in clipboardRing.Items) {
string itemData = item.Tag as string;
if(itemData != null && itemData.Equals(text))
break;
pos++;
}
if (pos < clipboardRing.Items.Count) {
clipboardRing.Items.RemoveAt(pos);
}
}
public void SaveSideBarViewConfig()
{
XmlDocument doc = new XmlDocument();

13
src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs

@ -40,6 +40,19 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -40,6 +40,19 @@ namespace ICSharpCode.SharpDevelop.Gui
void SetCaretPosition(int x, int y, int charOffset);
//void SetInsertMode(bool insertMode);
/// <summary>
/// Sets the selection lenght in the status bar.
/// </summary>
/// <param name="lenght">selection lenght</param>
void SetSelectionSingle(int lenght);
/// <summary>
/// Sets rect selection size in the status bar.
/// </summary>
/// <param name="rows">vertical size of selecion</param>
/// <param name="cols">horizontal size of selection</param>
void SetSelectionMulti(int rows, int cols);
/// <summary>
/// Sets the message shown in the left-most pane in the status bar.
/// </summary>

10
src/Main/SharpDevelop/Workbench/SDStatusBar.cs

@ -38,6 +38,7 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -38,6 +38,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
StatusBarItem txtStatusBarPanel = new StatusBarItem();
StatusBarItem cursorStatusBarPanel = new StatusBarItem();
StatusBarItem selectionStatusBarPanel = new StatusBarItem();
StatusBarItem modeStatusBarPanel = new StatusBarItem();
public StatusBarItem CursorStatusBarPanel {
@ -46,6 +47,12 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -46,6 +47,12 @@ namespace ICSharpCode.SharpDevelop.Workbench
}
}
public StatusBarItem SelectionStatusBarPanel {
get {
return selectionStatusBarPanel;
}
}
public StatusBarItem ModeStatusBarPanel {
get {
return modeStatusBarPanel;
@ -55,6 +62,7 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -55,6 +62,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
public SDStatusBar()
{
cursorStatusBarPanel.Width = 150;
selectionStatusBarPanel.Content = 50;
modeStatusBarPanel.Width = 25;
statusProgressBar.Minimum = 0;
@ -67,11 +75,13 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -67,11 +75,13 @@ namespace ICSharpCode.SharpDevelop.Workbench
statusProgressBarItem.HorizontalContentAlignment = HorizontalAlignment.Stretch;
DockPanel.SetDock(modeStatusBarPanel, Dock.Right);
DockPanel.SetDock(selectionStatusBarPanel, Dock.Right);
DockPanel.SetDock(cursorStatusBarPanel, Dock.Right);
DockPanel.SetDock(statusProgressBarItem, Dock.Right);
DockPanel.SetDock(jobNamePanel, Dock.Right);
Items.Add(modeStatusBarPanel);
Items.Add(selectionStatusBarPanel);
Items.Add(cursorStatusBarPanel);
Items.Add(statusProgressBarItem);
Items.Add(jobNamePanel);

24
src/Main/SharpDevelop/Workbench/StatusBarService.cs

@ -57,6 +57,30 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -57,6 +57,30 @@ namespace ICSharpCode.SharpDevelop.Workbench
);
}
public void SetSelectionSingle(int lenght)
{
if (lenght > 0) {
statusBar.SelectionStatusBarPanel.Content = StringParser.Parse(
"${res:StatusBarService.SelectionStatusBarPanelTextSingle}",
new StringTagPair("Lenght", String.Format("{0,-10}", lenght)));
} else {
statusBar.SelectionStatusBarPanel.Content = null;
}
}
public void SetSelectionMulti(int rows, int cols)
{
if (rows > 0 && cols > 0) {
statusBar.SelectionStatusBarPanel.Content = StringParser.Parse(
"${res:StatusBarService.SelectionStatusBarPanelTextMulti}",
new StringTagPair("Rows", String.Format("{0}", rows)),
new StringTagPair("Cols", String.Format("{0}", cols)),
new StringTagPair("Total", String.Format("{0}", rows * cols)));
} else {
statusBar.SelectionStatusBarPanel.Content = null;
}
}
public void SetInsertMode(bool insertMode)
{
statusBar.ModeStatusBarPanel.Content = insertMode ? StringParser.Parse("${res:StatusBarService.CaretModes.Insert}") : StringParser.Parse("${res:StatusBarService.CaretModes.Overwrite}");

Loading…
Cancel
Save