// this opens the sed question window public void sedCommentsCommand() { SedResult sed = SedWindow.Prompt(); if (sed != null) { sedCommentsDoSomething(sed); } }
public void sedCommentsReplaceDeck(int step) { Char ch_in = 'A'.Next(step - 1); Char ch_out = ch_in.Next(1); String st_in = String.Format(" {0} ", ch_in); String st_out = String.Format(" {0} ", ch_out); SedResult sed = new SedResult(st_in, st_out); sedCommentsDoSomething(sed); }
public void sedCommentsDoSomething(SedResult sed) { foreach (var m in _mappings) { String cur = m.Comment; String new_st = cur; String search = (String)sed._search; String replace = (String)sed._replace; if (sed._oper == SedOperation.regular) { // add whitespace, to remove later if (sed.do_trim) { new_st = String.Format(" {0} ", new_st); } if (search != "") { new_st = new_st.Replace(search, replace); } } else if (sed._oper == SedOperation.start) { if (replace != "") { new_st = replace + " " + new_st; } } else if (sed._oper == SedOperation.end) { if (replace != "") { new_st = new_st + " " + replace; } } if (sed._capitalize == SedCapitalize.none) { // pass } else if (sed._capitalize == SedCapitalize.lowercase) { new_st = new_st.ToLower(); } else if (sed._capitalize == SedCapitalize.uppercase) { new_st = new_st.ToUpper(); } else if (sed._capitalize == SedCapitalize.titlecase) { // https://stackoverflow.com/questions/1206019/converting-string-to-title-case new_st = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo. ToTitleCase(new_st.ToLower()); //new_st.ToTitleCase(); } if (sed.do_trim) { new_st = new_st.Trim(); } m.Comment = new_st; } }
// automated search/replace public void sedCommentsReplaceString(String st_in, String st_out) { SedResult sed = new SedResult(st_in, st_out); sedCommentsDoSomething(sed); }