Browse Source

Started work on new text editor options.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5073 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
d75b2d4a94
  1. 23
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 17
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.addin
  3. 15
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
  4. 4
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  5. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
  6. 38
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/BehaviorOptions.xaml
  7. 32
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/BehaviorOptions.xaml.cs
  8. 32
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
  9. 20
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml
  10. 32
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml.cs
  11. 54
      src/Main/ICSharpCode.Core.Presentation/OptionBinding.cs

23
AddIns/ICSharpCode.SharpDevelop.addin

@ -1926,24 +1926,11 @@ @@ -1926,24 +1926,11 @@
class = "ICSharpCode.SharpDevelop.BrowserDisplayBinding.NewWindow"/>
</Path>
<Path name = "/SharpDevelop/Dialogs/OptionsDialog">
<OptionPanel id = "TextEditorOptions"
insertafter = "CodingOptions"
insertbefore = "ToolsOptions"
label = "${res:Dialog.Options.IDEOptions.TextEditorOptionsText}">
<OptionPanel id = "General"
label = "${res:Dialog.Options.IDEOptions.General}"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels.GeneralTextEditorPanel"/>
<OptionPanel id = "Markers"
label = "${res:Dialog.Options.IDEOptions.TextEditor.Markers.PanelName}"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels.MarkersTextEditorPanel"/>
<OptionPanel id = "Behavior"
label = "${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.PanelName}"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels.BehaviorTextEditorPanel"/>
<OptionPanel id = "CodeCompletion"
label = "${res:Dialog.Options.IDEOptions.TextEditor.CodeCompletion.PanelName}"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels.CodeCompletionPanel"/>
</OptionPanel>
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/TextEditorOptions">
<OptionPanel id = "CodeCompletion"
insertafter="Behavior"
label = "${res:Dialog.Options.IDEOptions.TextEditor.CodeCompletion.PanelName}"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Gui.OptionPanels.CodeCompletionPanel"/>
</Path>
<Path name = "/SharpDevelop/Pads/BookmarkPad/Toolbar">

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

@ -81,4 +81,21 @@ @@ -81,4 +81,21 @@
label = "${res:Dialog.Options.CodeTemplatesText}"
class = "ICSharpCode.AvalonEdit.AddIn.Snippets.SnippetOptionPanel"/>
</Path>
<Path name = "/SharpDevelop/Dialogs/OptionsDialog">
<OptionPanel id = "TextEditorOptions"
insertafter = "CodingOptions"
insertbefore = "ToolsOptions"
label = "${res:Dialog.Options.IDEOptions.TextEditorOptionsText}">
<OptionPanel id = "General"
label = "${res:Dialog.Options.IDEOptions.General}"
class = "ICSharpCode.AvalonEdit.AddIn.Options.GeneralEditorOptions"/>
<OptionPanel id = "Markers"
label = "${res:Dialog.Options.IDEOptions.TextEditor.Markers.PanelName}"
class = "ICSharpCode.AvalonEdit.AddIn.Options.TextViewOptions"/>
<OptionPanel id = "Behavior"
label = "${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.PanelName}"
class = "ICSharpCode.AvalonEdit.AddIn.Options.BehaviorOptions"/>
</OptionPanel>
</Path>
</AddIn>

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

@ -55,6 +55,9 @@ @@ -55,6 +55,9 @@
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsFormsIntegration">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="AvalonEdit.AddIn.addin">
@ -78,6 +81,15 @@ @@ -78,6 +81,15 @@
<Compile Include="Src\CustomCommands.cs" />
<Compile Include="Src\IconBarManager.cs" />
<Compile Include="Src\IconBarMargin.cs" />
<Compile Include="Src\Options\BehaviorOptions.xaml.cs">
<DependentUpon>BehaviorOptions.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Options\GeneralEditorOptions.xaml.cs">
<DependentUpon>GeneralEditorOptions.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Options\CodeEditorOptions.cs" />
<Compile Include="Src\Snippets\CodeSnippet.cs" />
<Compile Include="Src\Snippets\CodeSnippetGroup.cs" />
<Compile Include="Src\Snippets\SnippetCompletionItem.cs" />
@ -97,6 +109,7 @@ @@ -97,6 +109,7 @@
<ItemGroup>
<Folder Include="Src" />
<Folder Include="Src\Commands" />
<Folder Include="Src\Options" />
<Folder Include="Src\Snippets" />
<ProjectReference Include="..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj">
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
@ -129,6 +142,8 @@ @@ -129,6 +142,8 @@
<Private>False</Private>
</ProjectReference>
<Page Include="Src\Commands\SortOptionsDialog.xaml" />
<Page Include="Src\Options\BehaviorOptions.xaml" />
<Page Include="Src\Options\GeneralEditorOptions.xaml" />
<Page Include="Src\Snippets\SnippetOptionPanel.xaml">
<DependentUpon>SnippetOptionPanel.cs</DependentUpon>
</Page>

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

@ -144,9 +144,6 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -144,9 +144,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor));
Debug.Assert(primaryTextEditorAdapter != null);
// always support scrolling below the end of the document - it's better when folding is enabled
primaryTextEditor.Options.AllowScrollBelowDocument = true;
this.primaryBracketRenderer = new BracketHighlightRenderer(primaryTextEditor.TextArea.TextView);
this.Document = primaryTextEditor.Document;
@ -248,7 +245,6 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -248,7 +245,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
secondaryTextEditor.SetBinding(TextEditor.DocumentProperty,
new Binding(TextEditor.DocumentProperty.Name) { Source = primaryTextEditor });
secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting;
secondaryTextEditor.Options = primaryTextEditor.Options;
gridSplitter = new GridSplitter {
Height = 4,

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

@ -37,6 +37,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -37,6 +37,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public CodeEditorView()
{
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted));
this.Options = ICSharpCode.AvalonEdit.AddIn.Options.CodeEditorOptions.Instance;
this.MouseHover += TextEditorMouseHover;
this.MouseHoverStopped += TextEditorMouseHoverStopped;

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

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<gui:OptionPanel
x:Class="ICSharpCode.AvalonEdit.AddIn.Options.BehaviorOptions" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" xmlns:local="clr-namespace:ICSharpCode.AvalonEdit.AddIn.Options">
<StackPanel>
<GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.TabsGroupBox}">
<StackPanel>
<StackPanel
Orientation="Horizontal">
<Label
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentLabel}" />
<TextBox
Text="{core:OptionBinding local:CodeEditorOptions.IndentationSize}"
Width="40"/>
</StackPanel>
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.ConvertTabsToSpaces}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.ConvertTabsToSpacesCheckBox}" />
<CheckBox
Content="(TODO: translate) Use smart indentation" />
</StackPanel>
</GroupBox>
<GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.BehaviourGroupBox}">
<StackPanel>
<CheckBox
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.MouseWheelZoomCheckBoxCheckBox}" />
<CheckBox
IsChecked="{core:OptionBinding local:CodeEditorOptions.CutCopyWholeLine}"
Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.Behaviour.CutCopyWholeLine}" />
<CheckBox
Content="(TODO: translate) Word-wrap" />
<CheckBox
Content="(TODO: translate) Use Ctrl+Click for &quot;Go to Definition&quot;" />
</StackPanel>
</GroupBox>
</StackPanel>
</gui:OptionPanel>

32
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/BehaviorOptions.xaml.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.AvalonEdit.AddIn.Options
{
/// <summary>
/// Interaction logic for BehaviorOptions.xaml
/// </summary>
public partial class BehaviorOptions : OptionPanel
{
public BehaviorOptions()
{
InitializeComponent();
}
}
}

32
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.ComponentModel;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.AvalonEdit.AddIn.Options
{
[Serializable]
public class CodeEditorOptions : TextEditorOptions
{
public static CodeEditorOptions Instance {
get { return PropertyService.Get("CodeEditorOptions", new CodeEditorOptions()); }
}
// always support scrolling below the end of the document - it's better when folding is enabled
[DefaultValue(true)]
public override bool AllowScrollBelowDocument {
get { return true; }
set {
if (value == false)
throw new NotSupportedException();
}
}
}
}

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

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<gui:OptionPanel
x:Class="ICSharpCode.AvalonEdit.AddIn.Options.GeneralEditorOptions" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:winforms="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop">
<StackPanel>
<GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FontGroupBox}">
<winforms:WindowsFormsHost>
<gui:FontSelectionPanel x:Name="fontSelectionPanel" />
</winforms:WindowsFormsHost>
</GroupBox>
<GroupBox
Header="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.GeneralOptionsGroupBox}">
<StackPanel>
<CheckBox Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.FoldingCheckBox}" />
<CheckBox Content="{core:Localize Dialog.Options.IDEOptions.TextEditor.General.ShowQuickClassBrowserCheckBox}" />
<CheckBox Content="(TODO: translate) show line numbers" />
</StackPanel>
</GroupBox>
</StackPanel>
</gui:OptionPanel>

32
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/GeneralEditorOptions.xaml.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.AvalonEdit.AddIn.Options
{
/// <summary>
/// Interaction logic for GeneralEditorOptions.xaml
/// </summary>
public partial class GeneralEditorOptions : OptionPanel
{
public GeneralEditorOptions()
{
InitializeComponent();
}
}
}

54
src/Main/ICSharpCode.Core.Presentation/OptionBinding.cs

@ -39,8 +39,10 @@ namespace ICSharpCode.Core.Presentation @@ -39,8 +39,10 @@ namespace ICSharpCode.Core.Presentation
DependencyObject target;
DependencyProperty dp;
bool isStatic;
Type propertyDeclaringType;
object propertyInfo;
MemberInfo propertyInfo;
public OptionBinding(string propertyName)
{
@ -65,9 +67,21 @@ namespace ICSharpCode.Core.Presentation @@ -65,9 +67,21 @@ namespace ICSharpCode.Core.Presentation
string[] name = PropertyName.Split('.');
IXamlTypeResolver typeResolver = provider.GetService(typeof(IXamlTypeResolver)) as IXamlTypeResolver;
Type t = typeResolver.Resolve(name[0]);
this.propertyInfo = t.GetProperty(name[1]);
propertyDeclaringType = typeResolver.Resolve(name[0]);
if (propertyDeclaringType == null)
throw new ArgumentException("Could not find type " + name[0]);
this.propertyInfo = propertyDeclaringType.GetProperty(name[1]);
if (this.propertyInfo != null) {
isStatic = (propertyInfo as PropertyInfo).GetGetMethod().IsStatic;
} else {
this.propertyInfo = propertyDeclaringType.GetField(name[1]);
if (this.propertyInfo != null) {
isStatic = (propertyInfo as FieldInfo).IsStatic;
} else {
throw new ArgumentException("Could not find property " + name[1]);
}
}
IOptionBindingContainer container = TryFindContainer(target as FrameworkElement);
@ -76,22 +90,37 @@ namespace ICSharpCode.Core.Presentation @@ -76,22 +90,37 @@ namespace ICSharpCode.Core.Presentation
container.AddBinding(this);
object instance = isStatic ? null : FetchInstance(propertyDeclaringType);
try {
object result = null;
if (this.propertyInfo is PropertyInfo)
result = (propertyInfo as PropertyInfo).GetValue(null, null);
else {
this.propertyInfo = t.GetField(name[1]);
if (this.propertyInfo is PropertyInfo) {
result = (propertyInfo as PropertyInfo).GetValue(instance, null);
} else {
if (this.propertyInfo is FieldInfo)
result = (propertyInfo as FieldInfo).GetValue(null);
result = (propertyInfo as FieldInfo).GetValue(instance);
}
return ConvertOnDemand(result, dp.PropertyType);
} catch (Exception e) {
throw new Exception("Failing to convert " + dp.Name + " " + dp.PropertyType, e);
throw new Exception("Failing to convert " + this.PropertyName + " to " +
dp.OwnerType.Name + "." + dp.Name + " (" + dp.PropertyType + ")", e);
}
}
/// <summary>
/// Gets the 'Instance' from a singleton type.
/// </summary>
static object FetchInstance(Type type)
{
PropertyInfo instanceProp = type.GetProperty("Instance", type);
if (instanceProp != null)
return instanceProp.GetValue(null, null);
FieldInfo instanceField = type.GetField("Instance");
if (instanceField != null)
return instanceField.GetValue(null);
throw new ArgumentException("Type " + type.FullName + " has no 'Instance' property. Only singletons can be used with OptionBinding.");
}
object ConvertOnDemand(object result, Type returnType)
{
@ -138,13 +167,14 @@ namespace ICSharpCode.Core.Presentation @@ -138,13 +167,14 @@ namespace ICSharpCode.Core.Presentation
value = ConvertOnDemand(value, returnType);
object instance = isStatic ? null : FetchInstance(propertyDeclaringType);
if (propertyInfo is PropertyInfo) {
(propertyInfo as PropertyInfo).SetValue(null, value, null);
(propertyInfo as PropertyInfo).SetValue(instance, value, null);
return true;
}
if (propertyInfo is FieldInfo) {
(propertyInfo as FieldInfo).SetValue(null, value);
(propertyInfo as FieldInfo).SetValue(instance, value);
return true;
}

Loading…
Cancel
Save