本文整理汇总了C++中WString::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ WString::GetLength方法的具体用法?C++ WString::GetLength怎么用?C++ WString::GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WString
的用法示例。
在下文中一共展示了WString::GetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AlignChar
void LineEdit::AlignChar() {
int c = GetCursor();
if(c == 0)
return;
Point pos = GetColumnLine(c);
if(pos.x == 0)
return;
for(int d = 1; d <= pos.y && d < 100; d++) {
int lny = pos.y - d;
WString above = GetWLine(lny);
int offset = GetGPos(lny, pos.x) - GetPos(lny);
int end = offset;
char ch = GetChar(c - 1);
if(ch == ' ')
{
offset++;
while(end < above.GetLength() && above[end] != ' ')
end++;
while(end < above.GetLength() && above[end] == ' ')
end++;
}
else
while(end < above.GetLength() && above[end] != ch)
end++;
if(end < above.GetLength()) {
int count = end - offset + 1;
WString s(' ', count);
Insert(c - 1, s, true);
SetCursor(c + count);
return;
}
}
}
示例2: ReplaceOnce
bool WString::ReplaceOnce(const WString &findWhat,const WString &replaceWith)
{
int pos = Find(findWhat);
if (pos == -1) return false;
(*this) = Left(pos)+replaceWith+Right(pos+replaceWith.GetLength());
return true;
}
示例3: GetCursorPos
int DocEdit::GetCursorPos(Point p) {
int pos = 0;
for(int i = 0; i < para.GetCount(); i++) {
int h = GetHeight(i);
if(p.y < h) {
WString text = line[i];
Fmt fmt = Format(text);
int x = 0;
int l = p.y / fmt.fi.GetHeight();
if(l < 0)
return pos;
if(l >= fmt.line.GetCount())
return pos + text.GetLength();
const int *w = fmt.width + fmt.line[l];
const int *e = fmt.width + fmt.LineEnd(l);
while(w < e) {
if(p.x < x + *w / 2)
return int(w - fmt.width) + pos;
x += *w++;
}
int p = int(e - fmt.width);
if(p > 0 && text[p - 1] == ' ' && l < fmt.line.GetCount() - 1)
p--;
return p + pos;
}
p.y -= h;
pos += line[i].GetLength() + 1;
}
return GetLength();
}
示例4: Flush
void RichQtfParser::Flush() {
if(text.GetLength()) {
ASSERT(!istable);
paragraph.Cat(text, format);
text.Clear();
}
}
示例5: AppendClipboardUnicodeText
void AppendClipboardUnicodeText(const WString& s)
{
#ifndef PLATFORM_WINCE
AppendClipboardText(s.ToString());
#endif
AppendClipboard("wtext", (byte *)~s, 2 * s.GetLength());
}
示例6: sMergeWith
static void sMergeWith(WString& dest, const wchar *delim, const WString& s)
{
if(s.GetLength()) {
if(dest.GetCount())
dest.Cat(delim);
dest.Cat(s);
}
}
示例7: LineHasColon
bool PythonSyntax::LineHasColon(const WString& line)
{
for(int i = line.GetLength() - 1; i >= 0; i--) {
if(line[i] == ':')
return true;
}
return false;
}
示例8: SaveStreamBOM
bool SaveStreamBOM(Stream& out, const WString& data) {
if(!out.IsOpen() || out.IsError())
return false;
word w = 0xfeff;
out.Put(&w, 2);
out.Put(~data, 2 * data.GetLength());
out.Close();
return out.IsOK();
}
示例9: FindPos
int RichEdit::FindPos()
{
RichFindIterator fi;
WString w = findreplace.find.GetText();
if(findreplace.ignorecase) {
fi.upperw = ToUpper(w);
fi.lowerw = ToLower(w);
}
else
fi.upperw = fi.lowerw = w;
fi.len = w.GetLength();
fi.ww = findreplace.wholeword;
if(w.GetLength()) {
fi.cursor = cursor;
if(text.Iterate(fi))
return fi.fpos;
}
return -1;
}
示例10: Format
DocEdit::Fmt DocEdit::Format(const WString& text) const
{
FontInfo fi = font.Info();
Fmt fmt;
int tcx = fi['x'] * 4;
fmt.len = text.GetLength();
fmt.text.Alloc(text.GetLength());
memcpy(fmt.text, text, text.GetLength() * sizeof(wchar));
fmt.width.Alloc(text.GetLength());
fmt.line.Add(0);
int *w = fmt.width;
int x = 0;
const wchar *space = NULL;
int spacex = 0;
for(wchar *s = fmt.text; s < fmt.text + fmt.len; s++) {
int cw;
if(*s == '\t')
cw = (x + tcx) / tcx * tcx - x;
else
cw = fi[*s];
*w++ = cw;
if(*s == ' ' || *s == '\t') {
space = s;
spacex = x + cw;
*s = ' ';
}
x += cw;
if(x > cx) {
if(space && space <= s) {
space++;
fmt.line.Add(int(space - fmt.text));
space = NULL;
x -= spacex;
}
else {
fmt.line.Add(int(s - fmt.text));
x = cw;
}
}
}
fmt.fi = fi;
return fmt;
}
示例11: operator
virtual bool operator()(int pos, const RichPara& para)
{
WString ptext = para.GetText();
if(pos + ptext.GetLength() > cursor && ptext.GetLength() >= len) {
const wchar *q = ptext;
const wchar *e = ptext.End() - len;
if(cursor >= pos)
q += cursor - pos;
while(q <= e) {
if(compare3(q, upperw, lowerw, len) &&
(!ww || (q + len == e || !IsLetter(q[len])) &&
(q == ptext || !IsLetter(q[-1])))) {
fpos = int(q - ~ptext + pos);
return true;
}
q++;
}
}
return false;
}
示例12: CalculateLineIndetations
int PythonSyntax::CalculateLineIndetations(const WString& line, Identation::Type type)
{
int count = 0;
for(int i = 0; i < line.GetLength(); i++) {
if(type == Identation::Tab && line[i] == '\t')
count++;
else
if(type == Identation::Space && line[i] == ' ')
count++;
else
break;
}
return count;
}
示例13: ReplaceAll
bool WString::ReplaceAll(const WString &findWhat,const WString &replaceWith)
{
WString process = *this;
WString result;
int pos;
bool processed = false;
while ((pos = process.Find(findWhat)) != -1)
{
result = result+process.Left(pos)+replaceWith;
process = process.Right(pos+findWhat.GetLength());
processed = true;
}
*this = result+process;
return processed;
}
示例14: ComposeTab
void FileTabs::ComposeTab(Tab& tab, const Font &font, Color ink, int style)
{
if(PaintIcons() && tab.HasIcon())
{
tab.AddImage(tab.img);
tab.AddSpace(TB_SPACEICON);
}
WString txt = IsString(tab.value) ? tab.value : StdConvert().Format(tab.value);
int extpos = txt.ReverseFind('.');
tab.AddText(extpos >= 0 ? txt.Left(extpos) : txt, font, filecolor);
if (extpos >= 0) {
tab.AddText(txt.Right(txt.GetLength() - extpos), font, extcolor);
}
}
示例15: CalculateSpaceIndetationSize
int PythonSyntax::CalculateSpaceIndetationSize(CodeEditor& editor)
{
int current = 0;
for(int i = 0; i < editor.GetLineCount(); i++) {
WString line = editor.GetWLine(i);
for(int j = 0; j < line.GetLength(); j++) {
if(line[j] == ' ')
current++;
else
break;
}
if(current > 0)
break;
}
// TODO: 4 is magic numer - try to find the way to get this number from ide constants
return current > 0 ? current : 4;
}