|
|
|
|
@ -17,11 +17,22 @@ namespace ICSharpCode.TextEditor.Actions
@@ -17,11 +17,22 @@ namespace ICSharpCode.TextEditor.Actions
|
|
|
|
|
public class Tab : AbstractEditAction |
|
|
|
|
{ |
|
|
|
|
public static string GetIndentationString(IDocument document) |
|
|
|
|
{ |
|
|
|
|
return GetIndentationString(document, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static string GetIndentationString(IDocument document, TextArea textArea) |
|
|
|
|
{ |
|
|
|
|
StringBuilder indent = new StringBuilder(); |
|
|
|
|
|
|
|
|
|
if (document.TextEditorProperties.ConvertTabsToSpaces) { |
|
|
|
|
indent.Append(new String(' ', document.TextEditorProperties.TabIndent)); |
|
|
|
|
int tabIndent = document.TextEditorProperties.TabIndent; |
|
|
|
|
if (textArea != null) { |
|
|
|
|
int column = textArea.TextView.GetVisualColumn(textArea.Caret.Line, textArea.Caret.Column); |
|
|
|
|
indent.Append(new String(' ', tabIndent - column % tabIndent)); |
|
|
|
|
} else { |
|
|
|
|
indent.Append(new String(' ', tabIndent)); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
indent.Append('\t'); |
|
|
|
|
} |
|
|
|
|
@ -57,10 +68,10 @@ namespace ICSharpCode.TextEditor.Actions
@@ -57,10 +68,10 @@ namespace ICSharpCode.TextEditor.Actions
|
|
|
|
|
{ |
|
|
|
|
switch (textArea.Caret.CaretMode) { |
|
|
|
|
case CaretMode.InsertMode: |
|
|
|
|
textArea.InsertString(GetIndentationString(textArea.Document)); |
|
|
|
|
textArea.InsertString(GetIndentationString(textArea.Document, textArea)); |
|
|
|
|
break; |
|
|
|
|
case CaretMode.OverwriteMode: |
|
|
|
|
string indentStr = GetIndentationString(textArea.Document); |
|
|
|
|
string indentStr = GetIndentationString(textArea.Document, textArea); |
|
|
|
|
textArea.ReplaceChar(indentStr[0]); |
|
|
|
|
if (indentStr.Length > 1) { |
|
|
|
|
textArea.InsertString(indentStr.Substring(1)); |
|
|
|
|
@ -131,7 +142,7 @@ namespace ICSharpCode.TextEditor.Actions
@@ -131,7 +142,7 @@ namespace ICSharpCode.TextEditor.Actions
|
|
|
|
|
/// else
|
|
|
|
|
/// there were no leading tabs or spaces on this line so do nothing
|
|
|
|
|
/// MS Visual Studio 6 strategy:
|
|
|
|
|
****/ |
|
|
|
|
****/ |
|
|
|
|
// string temp = document.GetText(line.Offset,line.Length);
|
|
|
|
|
if (line.Length > 0) { |
|
|
|
|
int charactersToRemove = 0; |
|
|
|
|
@ -222,7 +233,7 @@ namespace ICSharpCode.TextEditor.Actions
@@ -222,7 +233,7 @@ namespace ICSharpCode.TextEditor.Actions
|
|
|
|
|
if (textArea.Document.HighlightingStrategy.Properties.ContainsKey("LineComment")) { |
|
|
|
|
new ToggleLineComment().Execute(textArea); |
|
|
|
|
} else if (textArea.Document.HighlightingStrategy.Properties.ContainsKey("BlockCommentBegin") && |
|
|
|
|
textArea.Document.HighlightingStrategy.Properties.ContainsKey("BlockCommentBegin")) { |
|
|
|
|
textArea.Document.HighlightingStrategy.Properties.ContainsKey("BlockCommentBegin")) { |
|
|
|
|
new ToggleBlockComment().Execute(textArea); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -778,7 +789,7 @@ namespace ICSharpCode.TextEditor.Actions
@@ -778,7 +789,7 @@ namespace ICSharpCode.TextEditor.Actions
|
|
|
|
|
} |
|
|
|
|
// now delete from the caret to the beginning of the word
|
|
|
|
|
LineSegment line = |
|
|
|
|
textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset); |
|
|
|
|
textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset); |
|
|
|
|
// if we are not at the beginning of a line
|
|
|
|
|
if(textArea.Caret.Offset > line.Offset) { |
|
|
|
|
int prevWordStart = TextUtilities.FindPrevWordStart(textArea.Document, |
|
|
|
|
@ -793,7 +804,7 @@ namespace ICSharpCode.TextEditor.Actions
@@ -793,7 +804,7 @@ namespace ICSharpCode.TextEditor.Actions
|
|
|
|
|
if(textArea.Caret.Offset == line.Offset) { |
|
|
|
|
// if we are not on the first line
|
|
|
|
|
int curLineNr = |
|
|
|
|
textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset); |
|
|
|
|
textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset); |
|
|
|
|
if(curLineNr > 0) { |
|
|
|
|
// move to the end of the line above
|
|
|
|
|
LineSegment lineAbove = textArea.Document.GetLineSegment(curLineNr - |
|
|
|
|
@ -834,7 +845,7 @@ namespace ICSharpCode.TextEditor.Actions
@@ -834,7 +845,7 @@ namespace ICSharpCode.TextEditor.Actions
|
|
|
|
|
} |
|
|
|
|
// now delete from the caret to the beginning of the word
|
|
|
|
|
LineSegment line = |
|
|
|
|
textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset); |
|
|
|
|
textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset); |
|
|
|
|
if(textArea.Caret.Offset == line.Offset + line.Length) { |
|
|
|
|
// if we are at the end of a line
|
|
|
|
|
base.Execute(textArea); |
|
|
|
|
|