You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
// <file> |
|
// <copyright see="prj:///doc/copyright.txt"/> |
|
// <license see="prj:///doc/license.txt"/> |
|
// <author name="Daniel Grunwald"/> |
|
// <version>$Revision$</version> |
|
// </file> |
|
|
|
using ICSharpCode.AvalonEdit.Utils; |
|
using System; |
|
using ICSharpCode.AvalonEdit.Document; |
|
|
|
namespace ICSharpCode.AvalonEdit.Indentation |
|
{ |
|
/// <summary> |
|
/// Handles indentation by copying the indentation from the previous line. |
|
/// Does not support indenting multiple lines. |
|
/// </summary> |
|
public class DefaultIndentationStrategy : IIndentationStrategy |
|
{ |
|
/// <inheritdoc/> |
|
public virtual void IndentLine(DocumentLine line) |
|
{ |
|
if (line == null) |
|
throw new ArgumentNullException("line"); |
|
TextDocument document = line.Document; |
|
DocumentLine previousLine = line.PreviousLine; |
|
if (previousLine != null) { |
|
ISegment indentationSegment = TextUtilities.GetIndentation(document, previousLine.Offset); |
|
string indentation = document.GetText(indentationSegment); |
|
// copy indentation to line |
|
indentationSegment = TextUtilities.GetIndentation(document, line.Offset); |
|
document.Replace(indentationSegment, indentation); |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// Does nothing: indenting multiple lines is useless without a smart indentation strategy. |
|
/// </summary> |
|
public virtual void IndentLines(int beginLine, int endLine) |
|
{ |
|
} |
|
} |
|
}
|
|
|