mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-10-06 00:30:10 -06:00
ide: Comment/Uncomment block, Core: WString::Replace issue fixed
git-svn-id: svn://ultimatepp.org/upp/trunk@7085 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2a8a97e7cb
commit
b109812220
6 changed files with 71 additions and 11 deletions
|
|
@ -240,14 +240,14 @@ String FormatElapsedTime(double run)
|
|||
|
||||
void Ide::AlterText(WString (*op)(const WString& in))
|
||||
{
|
||||
if(designer)
|
||||
if(designer || !editor.IsSelection())
|
||||
return;
|
||||
editor.NextUndo();
|
||||
if(!editor.IsSelection())
|
||||
editor.SelectAll();
|
||||
WString w = editor.GetSelectionW();
|
||||
editor.RemoveSelection();
|
||||
int l = editor.GetCursor();
|
||||
editor.Paste((*op)(w));
|
||||
editor.SetSelection(l, editor.GetCursor());
|
||||
}
|
||||
|
||||
void Ide::TextToUpper()
|
||||
|
|
@ -294,6 +294,52 @@ void Ide::ToCString()
|
|||
AlterText(sCString);
|
||||
}
|
||||
|
||||
static WString sComment(const WString& s)
|
||||
{
|
||||
return "/*" + s + "*/";
|
||||
}
|
||||
|
||||
void Ide::ToComment()
|
||||
{
|
||||
AlterText(sComment);
|
||||
}
|
||||
|
||||
static WString sCommentLines(const WString& s)
|
||||
{
|
||||
String r;
|
||||
StringStream ss(s.ToString());
|
||||
for(;;) {
|
||||
String line = ss.GetLine();
|
||||
if(ss.IsError())
|
||||
return s;
|
||||
else
|
||||
if(!line.IsVoid())
|
||||
r << "//" << line << "\n";
|
||||
if(ss.IsEof())
|
||||
break;
|
||||
}
|
||||
return r.ToWString();
|
||||
}
|
||||
|
||||
void Ide::CommentLines()
|
||||
{
|
||||
AlterText(sCommentLines);
|
||||
}
|
||||
|
||||
static WString sUncomment(const WString& s)
|
||||
{
|
||||
WString h = s;
|
||||
h.Replace("/*", "");
|
||||
h.Replace("//", "");
|
||||
h.Replace("*/", "");
|
||||
return h;
|
||||
}
|
||||
|
||||
void Ide::UnComment()
|
||||
{
|
||||
AlterText(sUncomment);
|
||||
}
|
||||
|
||||
void Ide::Times()
|
||||
{
|
||||
WithStatisticsLayout<TopWindow> statdlg;
|
||||
|
|
|
|||
Loading…
Reference in a new issue