ide: Insert clipboard as C string, convert text to C string

git-svn-id: svn://ultimatepp.org/upp/trunk@4995 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-05-22 13:00:27 +00:00
parent 832424d8f0
commit 6ecaedceb1
5 changed files with 23 additions and 0 deletions

View file

@ -81,6 +81,13 @@ void Ide::InsertText(const String& text)
editor.Paste(text.ToWString());
}
void Ide::InsertCString()
{
String txt = ReadClipboardText();
if(txt.GetCount())
editor.Paste(AsCString(txt).ToWString());
}
void Ide::InsertMenu(Bar& bar)
{
if(bar.IsScanKeys())
@ -123,6 +130,7 @@ void Ide::InsertMenu(Bar& bar)
bar.Add(s, THISBACK1(InsertText, s));
}
}
bar.Add("Insert clipboard as C string", THISBACK(InsertCString));
}
void Ide::EditorMenu(Bar& bar)

View file

@ -847,6 +847,7 @@ public:
void InsertLay(const String& fn);
void InsertIml(const String& fn, String classname);
void InsertText(const String& text);
void InsertCString();
void InsertMenu(Bar& bar);
void EditorMenu(Bar& bar);
@ -870,6 +871,7 @@ public:
void TextToAscii();
void TextInitCaps();
void SwapCase();
void ToCString();
void MacroMenu(Bar& menu);
bool HasMacros();

View file

@ -103,6 +103,7 @@ KEY(TOLOWER, "To lowercase", 0)
KEY(INITCAPS, "Capitalize the first character of words", 0)
KEY(SWAPCASE, "Swap case", 0)
KEY(TOASCII, "To ASCII", 0)
KEY(TOCSTRING, "Convert to C string", 0)
KEY(DIFF, "Compare with file..", 0)
KEY(SVNDIFF, "Show svn history of file..", 0)

View file

@ -117,6 +117,8 @@ void Ide::EditSpecial(Bar& menu)
.Help("Capitalize the first character of words in selection");
menu.Add(AK_SWAPCASE, THISBACK(SwapCase))
.Help("Swap the case of letters in selection");
menu.Add(AK_TOCSTRING, THISBACK(ToCString))
.Help("Convert selection to CString");
}
void Ide::SearchMenu(Bar& menu)

View file

@ -283,6 +283,16 @@ void Ide::SwapCase()
AlterText(sSwapCase);
}
static WString sCString(const WString& s)
{
return AsCString(s.ToString()).ToWString();
}
void Ide::ToCString()
{
AlterText(sCString);
}
void Ide::Times()
{
WithStatisticsLayout<TopWindow> statdlg;