本文整理汇总了C++中WDL_FastString::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ WDL_FastString::Insert方法的具体用法?C++ WDL_FastString::Insert怎么用?C++ WDL_FastString::Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WDL_FastString
的用法示例。
在下文中一共展示了WDL_FastString::Insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onChar
//.........这里部分代码省略.........
int x;
int indent_to_pos = -1;
for (x = 0; x < lines.GetSize(); x ++)
{
WDL_FastString *str=m_text.Get(m_curs_y);
const char *tstr=lines.Get(x);
if (!tstr) tstr="";
if (!x)
{
if (str)
{
if (m_curs_x < 0) m_curs_x=0;
int tmp=str->GetLength();
if (m_curs_x > tmp) m_curs_x=tmp;
poststr.Set(str->Get()+m_curs_x);
str->SetLen(m_curs_x);
const char *p = str->Get();
while (*p == ' ' || *p == '\t') p++;
if (!*p && p > str->Get())
{
if (lines.GetSize()>1)
{
while (*tstr == ' ' || *tstr == '\t') tstr++;
}
indent_to_pos = m_curs_x;
}
str->Append(tstr);
}
else
{
m_text.Insert(m_curs_y,(str=new WDL_FastString(tstr)));
}
if (lines.GetSize() > 1)
{
m_curs_y++;
}
else
{
m_curs_x = str->GetLength();
str->Append(poststr.Get());
}
}
else if (x == lines.GetSize()-1)
{
WDL_FastString *s=newIndentedFastString(tstr,indent_to_pos);
m_curs_x = s->GetLength();
s->Append(poststr.Get());
m_text.Insert(m_curs_y,s);
}
else
{
m_text.Insert(m_curs_y,newIndentedFastString(tstr,indent_to_pos));
m_curs_y++;
}
}
draw();
setCursor();
draw_message("Pasted");
saveUndoState();
}
else
{
setCursor();
示例2: OpenFileInTab
void MultiTab_Editor::OpenFileInTab(const char *fnp)
{
// try to find file to open
WDL_FastString s;
FILE *fp=NULL;
{
const char *ptr = fnp;
while (!fp && *ptr)
{
// first try same path as loading effect
if (m_filename.Get()[0])
{
s.Set(m_filename.Get());
const char *sp=s.Get()+s.GetLength();
while (sp>=s.Get() && *sp != '\\' && *sp != '/') sp--;
s.SetLen(sp + 1 - s.Get());
if (s.GetLength())
{
s.Append(ptr);
fp=fopenUTF8(s.Get(),"rb");
}
}
// scan past any / or \\, and try again
if (!fp)
{
while (*ptr && *ptr != '\\' && *ptr != '/') ptr++;
if (*ptr) ptr++;
}
}
}
if (!fp)
{
s.Set("");
fp = tryToFindOrCreateFile(fnp,&s);
}
if (!fp && s.Get()[0])
{
m_newfn.Set(s.Get());
if (COLS > 25)
{
int allowed = COLS-25;
if (s.GetLength()>allowed)
{
s.DeleteSub(0,s.GetLength() - allowed + 3);
s.Insert("...",0);
}
s.Insert("Create new file '",0);
s.Append("' (Y/n)? ");
}
else
s.Set("Create new file (Y/n)? ");
m_state=UI_STATE_SAVE_AS_NEW;
attrset(m_color_message);
bkgdset(m_color_message);
mvaddstr(LINES-1,0,s.Get());
clrtoeol();
attrset(0);
bkgdset(0);
}
else if (fp)
{
fclose(fp);
int x;
for (x=0;x<GetTabCount();x++)
{
MultiTab_Editor *e = GetTab(x);
if (e && !stricmp(e->GetFileName(),s.Get()))
{
SwitchTab(x,false);
return;
}
}
AddTab(s.Get());
}
}