return;
int selectionStart = this.SelectionStart;
string insertStr = this.IndentMode == IndentMode.Space ? this.GetIndentSpace(0) : "\t";
- string text = this.RemoveLineHead(GetTextFromLineSelectArea(this.View.Selections), insertStr);
+ string text = this.RemoveLineHead(GetTextFromLineSelectArea(this.View.Selections), insertStr, insertStr.Length);
this.RepleaceSelectionArea(this.View.Selections, text);
this.Document.Select(selectionStart, text.Length);
}
return output.ToString();
}
- public string RemoveLineHead(string s, string str)
+ public string RemoveLineHead(string s, string str,int remove_count)
{
string[] lines = s.Split(new string[] { Document.NewLine.ToString() }, StringSplitOptions.None);
StringBuilder output = new StringBuilder();
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].StartsWith(str))
- output.Append(lines[i].Substring(1) + Document.NewLine);
+ output.Append(lines[i].Substring(remove_count) + Document.NewLine);
else if (i < lines.Length - 1)
output.Append(lines[i] + Document.NewLine);
}
<MenuItem Header="URL Mark" IsChecked="{Binding MarkURL,ElementName=fooTextBox,Mode=TwoWay}" IsCheckable="True"/>
<MenuItem Header="GenerateFolding" Click="MenuItem_Click_9"/>
<MenuItem Header="Set Padding" Click="MenuItem_Click_11"/>
- <MenuItem Header="Indent As Space" IsChecked="{Binding IsSpaceIndent,Mode=TwoWay}" IsCheckable="True"/>
+ <MenuItem Header="Toggle Indent Mode" Click="MenuItem_Click12"/>
</MenuItem>
</Menu>
<MyNamespace:FooTextBox x:Name="fooTextBox" Grid.Row="1"/>
this.fooTextBox.Refresh();
}
}
+
+ private void MenuItem_Click12(object sender, RoutedEventArgs e)
+ {
+ if (this.fooTextBox.IndentMode == IndentMode.Space)
+ {
+ this.fooTextBox.IndentMode = IndentMode.Tab;
+ }
+ else
+ {
+ this.fooTextBox.IndentMode = IndentMode.Space;
+ }
+ this.fooTextBox.Refresh();
+ }
}
public class FlowDirectionConveter : System.Windows.Data.IValueConverter
{