Browse Source

Ported Edit>Insert menu to ITextEditor.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4964 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
881a67359f
  1. 9
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 4
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/FormattingStrategy.cs
  3. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletionItemProvider.cs
  4. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
  5. 10
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  6. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlFormattingStrategy.cs
  7. 4
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  8. 6
      src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs
  9. 34
      src/Main/Base/Project/Src/Editor/Commands/InsertGuidCommand.cs
  10. 65
      src/Main/Base/Project/Src/Editor/Commands/PasteAsCommands.cs
  11. 55
      src/Main/Base/Project/Src/Editor/Commands/ShowColorDialog.cs
  12. 2
      src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs
  13. 4
      src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs
  14. 7
      src/Main/Base/Project/Src/Editor/ITextEditor.cs
  15. 2
      src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs
  16. 63
      src/Main/Base/Project/Src/TextEditor/Commands/ToolCommands.cs
  17. 6
      src/Main/Base/Project/Src/TextEditor/Gui/TextEditorAdapter.cs

9
AddIns/ICSharpCode.SharpDevelop.addin

@ -1303,20 +1303,20 @@ @@ -1303,20 +1303,20 @@
<MenuItem id = "Insert" label = "${res:XML.MainMenu.EditMenu.Insert}" type="Menu">
<MenuItem id = "PasteAsComment"
label = "${res:XML.MainMenu.EditMenu.Paste.AsComment}"
class="ICSharpCode.SharpDevelop.DefaultEditor.Commands.PasteAsCommentCommand"/>
class="ICSharpCode.SharpDevelop.Editor.Commands.PasteAsCommentCommand"/>
<MenuItem id = "PasteAsString"
label = "${res:XML.MainMenu.EditMenu.Paste.AsString}"
class="ICSharpCode.SharpDevelop.DefaultEditor.Commands.PasteAsStringCommand"/>
class="ICSharpCode.SharpDevelop.Editor.Commands.PasteAsStringCommand"/>
<MenuItem id="Separator1" type="Separator"/>
<MenuItem id = "InsertColor"
label = "${res:XML.MainMenu.ToolMenu.InsColor}"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.ShowColorDialog"/>
class = "ICSharpCode.SharpDevelop.Editor.Commands.ShowColorDialog"/>
<MenuItem id = "InsertGuid"
shortcut = "Control|Shift|G"
label = "${res:XML.MainMenu.ToolMenu.InsGUID}"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.InsertGuidCommand"/>
class = "ICSharpCode.SharpDevelop.Editor.Commands.InsertGuidCommand"/>
</MenuItem>
</Condition>
<MenuItem id = "SelectAll"
@ -1799,6 +1799,7 @@ @@ -1799,6 +1799,7 @@
<MenuItem id = "Comment"
icon = "Icons.16x16.CommentRegion"
label = "${res:XML.TextAreaContextMenu.CommentUncommentSelection}"
shortcut="Control|OemQuestion"
class = "ICSharpCode.SharpDevelop.Editor.Commands.CommentRegion"/>
<MenuItem id = "Indent"
label = "${res:XML.TextAreaContextMenu.Indent}"

4
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/FormattingStrategy.cs

@ -21,9 +21,9 @@ namespace Grunwald.BooBinding @@ -21,9 +21,9 @@ namespace Grunwald.BooBinding
IDocumentLine previousLine = document.GetLine(line.LineNumber - 1);
if (previousLine.Text.EndsWith(":", StringComparison.Ordinal)) {
string indentation = DocumentUtilitites.GetIndentation(document, previousLine.Offset);
string indentation = DocumentUtilitites.GetWhitespaceAfter(document, previousLine.Offset);
indentation += editor.Options.IndentationString;
string newIndentation = DocumentUtilitites.GetIndentation(document, line.Offset);
string newIndentation = DocumentUtilitites.GetWhitespaceAfter(document, line.Offset);
document.Replace(line.Offset, newIndentation.Length, indentation);
return;
}

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletionItemProvider.cs

@ -254,7 +254,7 @@ namespace CSharpBinding @@ -254,7 +254,7 @@ namespace CSharpBinding
editor.Language.FormattingStrategy.IndentLines(editor, region.EndLine, editor.Caret.Line);
IDocumentLine line = editor.Document.GetLine(editor.Caret.Line - 1);
int indentationLength = DocumentUtilitites.GetIndentation(editor.Document, line.Offset).Length;
int indentationLength = DocumentUtilitites.GetWhitespaceAfter(editor.Document, line.Offset).Length;
editor.Select(line.Offset + indentationLength, line.Length - indentationLength);
}

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs

@ -279,7 +279,7 @@ namespace CSharpBinding.FormattingStrategy @@ -279,7 +279,7 @@ namespace CSharpBinding.FormattingStrategy
curLineText = curLine.Text;
string lineAboveText = lineAbove == null ? "" : lineAbove.Text;
if (curLineText != null && curLineText.EndsWith("///") && (lineAboveText == null || !lineAboveText.Trim().StartsWith("///"))) {
string indentation = DocumentUtilitites.GetIndentation(textArea.Document, curLine.Offset);
string indentation = DocumentUtilitites.GetWhitespaceAfter(textArea.Document, curLine.Offset);
object member = GetMemberAfter(textArea, lineNr);
if (member != null) {
StringBuilder sb = new StringBuilder();

10
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs

@ -165,7 +165,7 @@ namespace VBNetBinding @@ -165,7 +165,7 @@ namespace VBNetBinding
"\"");
}
} else {
string indent = DocumentUtilitites.GetIndentation(editor.Document, lineAbove.Offset);
string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset);
if (indent.Length > 0) {
string newLineText = indent + currentLine.Text.Trim();
editor.Document.Replace(currentLine.Offset, currentLine.Length, newLineText);
@ -223,7 +223,7 @@ namespace VBNetBinding @@ -223,7 +223,7 @@ namespace VBNetBinding
// check #Region statements
if (Regex.IsMatch(textToReplace.Trim(), "^#Region", RegexOptions.IgnoreCase) && LookForEndRegion(editor)) {
string indentation = DocumentUtilitites.GetIndentation(editor.Document, lineAbove.Offset);
string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset);
textToReplace += indentation + "\r\n" + indentation + "#End Region";
editor.Document.Replace(currentLine.Offset, currentLine.Length, textToReplace);
}
@ -231,7 +231,7 @@ namespace VBNetBinding @@ -231,7 +231,7 @@ namespace VBNetBinding
foreach (VBStatement statement_ in statements) {
VBStatement statement = statement_; // allow passing statement byref
if (Regex.IsMatch(textToReplace.Trim(), statement.StartRegex, RegexOptions.IgnoreCase)) {
string indentation = DocumentUtilitites.GetIndentation(editor.Document, lineAbove.Offset);
string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineAbove.Offset);
if (IsEndStatementNeeded(editor, ref statement, lineNr)) {
editor.Document.Replace(currentLine.Offset, currentLine.Length, terminator + indentation + statement.EndStatement);
}
@ -273,7 +273,7 @@ namespace VBNetBinding @@ -273,7 +273,7 @@ namespace VBNetBinding
string lineAboveText = previousLine == null ? null : previousLine.Text;
if (curLineText != null && curLineText.EndsWith("'''") && (lineAboveText == null || !lineAboveText.Trim().StartsWith("'''"))) {
string indentation = DocumentUtilitites.GetIndentation(editor.Document, currentLine.Offset);
string indentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, currentLine.Offset);
object member = GetMemberAfter(editor, lineNr);
if (member != null) {
StringBuilder sb = new StringBuilder();
@ -774,7 +774,7 @@ namespace VBNetBinding @@ -774,7 +774,7 @@ namespace VBNetBinding
if (i < selBegin || i > selEnd) {
indentation.PopOrDefault();
indentation.Push(DocumentUtilitites.GetIndentation(editor.Document, curLine.Offset));
indentation.Push(DocumentUtilitites.GetWhitespaceAfter(editor.Document, curLine.Offset));
}
// change indentation before (indent this line)

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlFormattingStrategy.cs

@ -163,7 +163,7 @@ namespace ICSharpCode.XmlEditor @@ -163,7 +163,7 @@ namespace ICSharpCode.XmlEditor
if (r.NodeType == XmlNodeType.Element) {
tagStack.Push(currentIndentation);
if (r.LineNumber < begin)
currentIndentation = DocumentUtilitites.GetIndentation(editor.Document, editor.Document.PositionToOffset(r.LineNumber, 1));
currentIndentation = DocumentUtilitites.GetWhitespaceAfter(editor.Document, editor.Document.PositionToOffset(r.LineNumber, 1));
if (r.Name.Length < 16)
attribIndent = currentIndentation + new string(' ', 2 + r.Name.Length);
else

4
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -98,6 +98,9 @@ @@ -98,6 +98,9 @@
<Compile Include="Src\Editor\Commands\GoToDefinition.cs" />
<Compile Include="Src\Editor\Commands\GoToMatchingBrace.cs" />
<Compile Include="Src\Editor\Commands\IndentSelection.cs" />
<Compile Include="Src\Editor\Commands\InsertGuidCommand.cs" />
<Compile Include="Src\Editor\Commands\PasteAsCommands.cs" />
<Compile Include="Src\Editor\Commands\ShowColorDialog.cs" />
<Compile Include="Src\Editor\DocumentUtilitites.cs" />
<Compile Include="Src\Editor\IBracketSearcher.cs" />
<Compile Include="Src\Editor\IDocument.cs" />
@ -598,7 +601,6 @@ @@ -598,7 +601,6 @@
<Compile Include="Src\TextEditor\Commands\GenerateCodeCommand.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\TextEditor\Commands\PasteAsCommands.cs" />
<Compile Include="Src\TextEditor\Commands\SearchCommands.cs" />
<Compile Include="Src\TextEditor\Commands\TextAreaContextmenuCommands.cs" />
<Compile Include="Src\TextEditor\Commands\ToolCommands.cs" />

6
src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditTextEditorAdapter.cs

@ -143,6 +143,12 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit @@ -143,6 +143,12 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit
return avalonEditOptions.IndentationSize;
}
}
public int VerticalRulerColumn {
get {
return 120;
}
}
}
public virtual string FileName {

34
src/Main/Base/Project/Src/Editor/Commands/InsertGuidCommand.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Gui;
using System;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Editor.Commands
{
public class InsertGuidCommand : AbstractMenuCommand
{
public override void Run()
{
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
if (viewContent == null || !(viewContent is ITextEditorProvider)) {
return;
}
ITextEditor textEditor = ((ITextEditorProvider)viewContent).TextEditor;
if (textEditor == null) {
return;
}
string newGuid = Guid.NewGuid().ToString().ToUpperInvariant();
textEditor.SelectedText = newGuid;
textEditor.Select(textEditor.SelectionStart + textEditor.SelectionLength, 0);
}
}
}

65
src/Main/Base/Project/Src/TextEditor/Commands/PasteAsCommands.cs → src/Main/Base/Project/Src/Editor/Commands/PasteAsCommands.cs

@ -5,23 +5,21 @@ @@ -5,23 +5,21 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.AstBuilder;
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.AstBuilder;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.Refactoring;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Actions;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
namespace ICSharpCode.SharpDevelop.Editor.Commands
{
public abstract class PasteAsCommand : AbstractMenuCommand
{
@ -32,32 +30,24 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -32,32 +30,24 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
return;
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
if (viewContent == null || !(viewContent is ITextEditorControlProvider)) {
if (viewContent == null || !(viewContent is ITextEditorProvider)) {
return;
}
TextEditorControl textEditor = ((ITextEditorControlProvider)viewContent).TextEditorControl;
ITextEditor textEditor = ((ITextEditorProvider)viewContent).TextEditor;
if (textEditor == null) {
return;
}
textEditor.BeginUpdate();
textEditor.Document.UndoStack.StartUndoGroup();
try {
using (textEditor.Document.OpenUndoGroup())
Run(textEditor, clipboardText);
} finally {
textEditor.Document.UndoStack.EndUndoGroup();
textEditor.EndUpdate();
}
textEditor.Refresh();
}
protected abstract void Run(TextEditorControl editor, string clipboardText);
protected abstract void Run(ITextEditor editor, string clipboardText);
protected string GetIndentation(ICSharpCode.TextEditor.Document.IDocument document, int line)
protected string GetIndentation(IDocument document, int line)
{
string lineText = document.GetText(document.GetLineSegment(line));
return lineText.Substring(0, lineText.Length - lineText.TrimStart().Length);
return DocumentUtilitites.GetWhitespaceAfter(document, document.GetLine(line).Offset);
}
}
@ -73,25 +63,25 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -73,25 +63,25 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
/// </summary>
public class PasteAsCommentCommand : PasteAsCommand
{
protected override void Run(TextEditorControl editor, string clipboardText)
protected override void Run(ITextEditor editor, string clipboardText)
{
TextArea textArea = editor.ActiveTextAreaControl.TextArea;
string indentation = GetIndentation(editor.Document, textArea.Caret.Line);
string indentation = GetIndentation(editor.Document, editor.Caret.Line);
IAmbience ambience = AmbienceService.GetCurrentAmbience();
int maxLineLength = textArea.TextEditorProperties.VerticalRulerRow - VisualIndentationLength(textArea, indentation);
StringBuilder insertedText = new StringBuilder();
int maxLineLength = editor.Options.VerticalRulerColumn - VisualIndentationLength(editor, indentation);
StringWriter insertedText = new StringWriter();
insertedText.NewLine = DocumentUtilitites.GetLineTerminator(editor.Document, editor.Caret.Line);
using (StringReader reader = new StringReader(clipboardText)) {
string line;
while ((line = reader.ReadLine()) != null) {
AppendTextLine(indentation, ambience, maxLineLength, insertedText, line);
}
}
var document = textArea.Document;
int insertionPos = document.GetLineSegment(textArea.Caret.Line).Offset + indentation.Length;
IDocument document = editor.Document;
int insertionPos = document.GetLine(editor.Caret.Line).Offset + indentation.Length;
document.Insert(insertionPos, insertedText.ToString());
}
void AppendTextLine(string indentation, IAmbience ambience, int maxLineLength, StringBuilder insertedText, string line)
void AppendTextLine(string indentation, IAmbience ambience, int maxLineLength, StringWriter insertedText, string line)
{
const int minimumLineLength = 10;
string commentedLine;
@ -104,15 +94,15 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -104,15 +94,15 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
int pos = FindWrapPositionBefore(line, maxLineLength - commentingOverhead);
if (pos < minimumLineLength)
break;
insertedText.AppendLine(ambience.WrapComment(line.Substring(0, pos)));
insertedText.Append(indentation);
insertedText.WriteLine(ambience.WrapComment(line.Substring(0, pos)));
insertedText.Write(indentation);
line = line.Substring(pos + 1);
} else {
break;
}
}
insertedText.AppendLine(commentedLine);
insertedText.Append(indentation); // indentation for next line
insertedText.WriteLine(commentedLine);
insertedText.Write(indentation); // indentation for next line
}
int FindWrapPositionBefore(string line, int pos)
@ -120,12 +110,12 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -120,12 +110,12 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
return line.LastIndexOf(' ', pos);
}
int VisualIndentationLength(TextArea textArea, string indentation)
int VisualIndentationLength(ITextEditor editor, string indentation)
{
int length = 0;
foreach (char c in indentation) {
if (c == '\t')
length += textArea.TextEditorProperties.TabIndent;
length += editor.Options.IndentationSize;
else
length += 1;
}
@ -143,7 +133,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -143,7 +133,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
/// </summary>
public class PasteAsStringCommand : PasteAsCommand
{
protected override void Run(TextEditorControl editor, string clipboardText)
protected override void Run(ITextEditor editor, string clipboardText)
{
CodeGenerator codeGenerator = ParserService.CurrentProjectContent.Language.CodeGenerator;
if (codeGenerator == null)
@ -166,9 +156,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -166,9 +156,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
}
if (expression == null)
return;
TextArea textArea = editor.ActiveTextAreaControl.TextArea;
string indentation = GetIndentation(editor.Document, textArea.Caret.Line);
textArea.InsertString(codeGenerator.GenerateCode(expression, indentation).Trim());
string indentation = GetIndentation(editor.Document, editor.Caret.Line);
editor.Document.Insert(editor.Caret.Offset, codeGenerator.GenerateCode(expression, indentation).Trim());
}
}
}

55
src/Main/Base/Project/Src/Editor/Commands/ShowColorDialog.cs

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using System.IO;
using System.Windows.Forms;
namespace ICSharpCode.SharpDevelop.Editor.Commands
{
public class ShowColorDialog : AbstractMenuCommand
{
public override void Run()
{
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
if (viewContent == null || !(viewContent is ITextEditorProvider)) {
return;
}
ITextEditor textEditor = ((ITextEditorProvider)viewContent).TextEditor;
using (SharpDevelopColorDialog cd = new SharpDevelopColorDialog()) {
if (cd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) {
string ext = Path.GetExtension(textEditor.FileName).ToLowerInvariant();
string colorstr;
if (ext == ".cs" || ext == ".vb" || ext == ".boo") {
if (cd.Color.IsKnownColor) {
colorstr = "Color." + cd.Color.ToKnownColor().ToString();
} else if (cd.Color.A < 255) {
colorstr = "Color.FromArgb(0x" + cd.Color.ToArgb().ToString("x") + ")";
} else {
colorstr = string.Format("Color.FromArgb({0}, {1}, {2})", cd.Color.R, cd.Color.G, cd.Color.B);
}
} else {
if (cd.Color.IsKnownColor) {
colorstr = cd.Color.ToKnownColor().ToString();
} else if (cd.Color.A < 255) {
colorstr = "#" + cd.Color.ToArgb().ToString("X");
} else {
colorstr = string.Format("#{0:X2}{1:X2}{2:X2}", cd.Color.R, cd.Color.G, cd.Color.B);
}
}
textEditor.SelectedText = colorstr;
textEditor.Select(textEditor.SelectionStart + textEditor.SelectionLength, 0);
}
}
}
}
}

2
src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs

@ -129,7 +129,7 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -129,7 +129,7 @@ namespace ICSharpCode.SharpDevelop.Editor
/// <param name="document">The document.</param>
/// <param name="offset">The offset where the indentation starts.</param>
/// <returns>The indentation text.</returns>
public static string GetIndentation(ITextBuffer textBuffer, int offset)
public static string GetWhitespaceAfter(ITextBuffer textBuffer, int offset)
{
ISegment segment = TextUtilities.GetWhitespaceAfter(GetTextSource(textBuffer), offset);
return textBuffer.GetText(segment.Offset, segment.Length);

4
src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs

@ -51,9 +51,9 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -51,9 +51,9 @@ namespace ICSharpCode.SharpDevelop.Editor
int lineNumber = line.LineNumber;
if (lineNumber > 1) {
IDocumentLine previousLine = document.GetLine(lineNumber - 1);
string indentation = DocumentUtilitites.GetIndentation(document, previousLine.Offset);
string indentation = DocumentUtilitites.GetWhitespaceAfter(document, previousLine.Offset);
// copy indentation to line
string newIndentation = DocumentUtilitites.GetIndentation(document, line.Offset);
string newIndentation = DocumentUtilitites.GetWhitespaceAfter(document, line.Offset);
document.Replace(line.Offset, newIndentation.Length, indentation);
}
}

7
src/Main/Base/Project/Src/Editor/ITextEditor.cs

@ -141,6 +141,13 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -141,6 +141,13 @@ namespace ICSharpCode.SharpDevelop.Editor
/// Gets the size of an indentation level.
/// </summary>
int IndentationSize { get; }
/// <summary>
/// Gets the column of the vertical ruler (line that signifies the maximum line length
/// defined by the coding style)
/// This property returns a valid value even if the vertical ruler is set to be invisible.
/// </summary>
int VerticalRulerColumn { get; }
}
public interface ITextEditorCaret

2
src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs

@ -119,7 +119,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -119,7 +119,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
}
// no bookmark at that line: create a new bookmark
int lineStartOffset = editor.Document.GetLine(line).Offset;
int column = 1 + DocumentUtilitites.GetIndentation(editor.Document, lineStartOffset).Length;
int column = 1 + DocumentUtilitites.GetWhitespaceAfter(editor.Document, lineStartOffset).Length;
BookmarkManager.AddMark(bookmarkFactory(new Location(column, line)));
}

63
src/Main/Base/Project/Src/TextEditor/Commands/ToolCommands.cs

@ -21,49 +21,6 @@ using ICSharpCode.TextEditor.Document; @@ -21,49 +21,6 @@ using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{
public class ShowColorDialog : AbstractMenuCommand
{
public override void Run()
{
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
if (viewContent == null || !(viewContent is ITextEditorControlProvider)) {
return;
}
TextEditorControl textarea = ((ITextEditorControlProvider)viewContent).TextEditorControl;
using (SharpDevelopColorDialog cd = new SharpDevelopColorDialog()) {
if (cd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) {
string ext = Path.GetExtension(textarea.FileName).ToLowerInvariant();
string colorstr;
if (ext == ".cs" || ext == ".vb" || ext == ".boo") {
if (cd.Color.IsKnownColor) {
colorstr = "Color." + cd.Color.ToKnownColor().ToString();
} else if (cd.Color.A < 255) {
colorstr = "Color.FromArgb(0x" + cd.Color.ToArgb().ToString("x") + ")";
} else {
colorstr = string.Format("Color.FromArgb({0}, {1}, {2})", cd.Color.R, cd.Color.G, cd.Color.B);
}
} else {
if (cd.Color.IsKnownColor) {
colorstr = cd.Color.ToKnownColor().ToString();
} else if (cd.Color.A < 255) {
colorstr = "#" + cd.Color.ToArgb().ToString("X");
} else {
colorstr = string.Format("#{0:X2}{1:X2}{2:X2}", cd.Color.R, cd.Color.G, cd.Color.B);
}
}
textarea.Document.Insert(textarea.ActiveTextAreaControl.Caret.Offset, colorstr);
int lineNumber = textarea.Document.GetLineNumberForOffset(textarea.ActiveTextAreaControl.Caret.Offset);
textarea.ActiveTextAreaControl.Caret.Column += colorstr.Length;
textarea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, new TextLocation(0, lineNumber)));
textarea.Document.CommitUpdate();
}
}
}
}
public class QuickDocumentation : AbstractMenuCommand
{
public override void Run()
@ -206,24 +163,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -206,24 +163,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
}
}
}
public class InsertGuidCommand : AbstractMenuCommand
{
public override void Run()
{
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
if (viewContent == null || !(viewContent is ITextEditorControlProvider)) {
return;
}
TextEditorControl textEditor = ((ITextEditorControlProvider)viewContent).TextEditorControl;
if (textEditor == null) {
return;
}
string newGuid = Guid.NewGuid().ToString().ToUpperInvariant();
textEditor.ActiveTextAreaControl.TextArea.InsertString(newGuid);
}
}
}

6
src/Main/Base/Project/Src/TextEditor/Gui/TextEditorAdapter.cs

@ -113,6 +113,12 @@ namespace ICSharpCode.SharpDevelop @@ -113,6 +113,12 @@ namespace ICSharpCode.SharpDevelop
return properties.IndentationSize;
}
}
public int VerticalRulerColumn {
get {
return properties.VerticalRulerRow;
}
}
}
static ICSharpCode.NRefactory.Location ToLocation(TextLocation position)

Loading…
Cancel
Save