예제 #1
0
        static public string UnpadBlock(this string item, string padding, int spaces_per_tab = StringExtensions_Space.DEFAULT_NUMBER_SPACES_PER_TAB)
        {
            int number_padding_tabs   = padding.Count("\t");
            int number_padding_spaces = padding.Count(" ");

            return(item.RegexReplace("(^|[\n\r]+)([ \t]+)", delegate(Match match){
                string indent = match.Groups[2].Value;

                int number_new_tabs = indent.Count("\t") - number_padding_tabs;
                int number_new_spaces = indent.Count(" ") - number_padding_spaces;

                if (number_new_tabs < 0)
                {
                    number_new_spaces += number_new_tabs * spaces_per_tab;
                }

                if (number_new_spaces < 0)
                {
                    number_new_tabs += number_new_spaces / spaces_per_tab;
                }

                return match.Groups[1].Value + StringIndentation_Tab.GetString(number_new_tabs) + StringIndentation_Space.GetString(number_new_spaces);
            }));
        }
예제 #2
0
 public TextDocumentCanvas()
 {
     string_builder = new StringBuilder();
     indentation    = new StringIndentation_Tab();
 }