int CParseString::ParseRev2(CString& item1, CString& item2, CString separ) { InitRev(separ); GetPrevWord(item2); GetHead(item1); return (!item1.IsEmpty()) + (!item2.IsEmpty()); }
//************************************************************************************ int CBCGPOutlineParser::GetNameOffset (const CString& strIn, int nStartFrom, int nSearchTo, const BlockType* pBlockType, CObList& lstIgnore, CString& strName) { ASSERT (nStartFrom >= 0); ASSERT (nSearchTo >= 0); ASSERT (pBlockType != NULL); int nOffset = nStartFrom - 1; const int nCharsMaxNum = 256; nSearchTo = max (nSearchTo, nStartFrom - nCharsMaxNum); LPCTSTR lpszDelimiters = _T(";{}"); const CStringList* pListKeywords = &(pBlockType->m_lstKeywords); ASSERT_VALID (pListKeywords); if (pListKeywords->GetCount () == 0) { // if no keywords then nameoffset = 0 nSearchTo = nStartFrom; } while (nOffset >= nSearchTo) { CString strWord; nOffset = GetPrevWord (strIn, nOffset, nSearchTo, lpszDelimiters, strWord); if (nOffset >= nSearchTo && !IsInRange (lstIgnore, nOffset, nOffset + strWord.GetLength ())) { // Compare strWord with keywords if (pListKeywords->Find (strWord) != NULL) { strName = strWord; return nStartFrom - nOffset; } else if (IsBlockName (strIn, strWord, nOffset, nStartFrom)) { strName = strWord; return nStartFrom - nOffset; } } nOffset--; } strName = _T(""); return 0; }
bool LineEdit::Key(dword key, int count) { NextUndo(); switch(key) { case K_CTRL_UP: ScrollUp(); return true; case K_CTRL_DOWN: ScrollDown(); return true; case K_INSERT: OverWriteMode(!IsOverWriteMode()); break; } bool sel = key & K_SHIFT; switch(key & ~K_SHIFT) { case K_CTRL_LEFT: { PlaceCaret(GetPrevWord(cursor), sel); break; } case K_CTRL_RIGHT: { PlaceCaret(GetNextWord(cursor), sel); break; } case K_LEFT: MoveLeft(sel); break; case K_RIGHT: MoveRight(sel); break; case K_HOME: MoveHome(sel); break; case K_END: MoveEnd(sel); break; case K_UP: MoveUp(sel); break; case K_DOWN: MoveDown(sel); break; case K_PAGEUP: MovePageUp(sel); break; case K_PAGEDOWN: MovePageDown(sel); break; case K_CTRL_PAGEUP: case K_CTRL_HOME: MoveTextBegin(sel); break; case K_CTRL_PAGEDOWN: case K_CTRL_END: MoveTextEnd(sel); break; case K_CTRL_C: case K_CTRL_INSERT: Copy(); break; case K_CTRL_A: SelectAll(); break; default: if(IsReadOnly()) return MenuBar::Scan(WhenBar, key); switch(key) { case K_DELETE: DeleteChar(); break; case K_BACKSPACE: case K_SHIFT|K_BACKSPACE: Backspace(); break; case K_SHIFT_TAB: AlignChar(); break; case K_CTRL_Y: case K_CTRL_L: if(cutline) { CutLine(); break; } default: if(InsertChar(key, count, true)) return true; return MenuBar::Scan(WhenBar, key); } return true; } Sync(); return true; }
bool DocEdit::Key(dword key, int cnt) { NextUndo(); bool h; int q; bool select = key & K_SHIFT; int pgsk = max(8, 6 * GetSize().cy / 8); switch(key & ~K_SHIFT) { case K_CTRL_LEFT: PlaceCaret(GetPrevWord(cursor), select); break; case K_CTRL_RIGHT: PlaceCaret(GetNextWord(cursor), select); break; case K_HOME: HomeEnd(0, select); break; case K_END: HomeEnd(cx, select); break; case K_CTRL_HOME: case K_CTRL_PAGEUP: PlaceCaret(0, select); break; case K_CTRL_END: case K_CTRL_PAGEDOWN: PlaceCaret(total, select); break; case K_UP: if(GetCursor() == 0) return !updownleave; VertMove(-8, select, false); return true; case K_DOWN: if(GetCursor() == GetLength()) return !updownleave; VertMove(8, select, false); return true; case K_PAGEUP: VertMove(-pgsk, select, true); return true; case K_PAGEDOWN: VertMove(pgsk, select, true); return true; case K_LEFT: if(cursor) PlaceCaret(cursor - 1, select); break; case K_RIGHT: if(cursor < total) PlaceCaret(cursor + 1, select); break; default: if(IsReadOnly()) return MenuBar::Scan(WhenBar, key); switch(key) { case K_BACKSPACE: case K_SHIFT|K_BACKSPACE: if(RemoveSelection()) break; if(cursor == 0) return true; cursor--; Remove(cursor, 1); break; case K_CTRL_BACKSPACE: if(RemoveSelection()) break; if(cursor <= 0) return true; q = cursor - 1; h = IsLetter(GetChar(q)); while(q > 0 && IsLetter(GetChar(q - 1)) == h) q--; Remove(q, cursor - q); SetCursor(q); break; case K_DELETE: if(RemoveSelection()) break; if(cursor >= total) return true; if(cursor < total) Remove(cursor, 1); break; case K_CTRL_DELETE: if(RemoveSelection()) break; if(cursor >= total) return true; q = cursor; h = IsLetter(GetChar(q)); while(IsLetter(GetChar(q)) == h && q < total) q++; Remove(cursor, q - cursor); break; case K_ENTER: if(!processenter) return true; key = '\n'; default: if(filter && key >= 32 && key < 65535) key = (*filter)(key); if(key >= ' ' && key < 65536 || key == '\n' || key == '\t' || key == K_SHIFT_SPACE) { if(key == K_TAB && !processtab) return false; if(key >= 128 && key < 65536 && (charset != CHARSET_UNICODE && charset != CHARSET_UTF8_BOM) && FromUnicode((wchar)key, charset) == DEFAULTCHAR) return true; RemoveSelection(); Insert(cursor, WString(key == K_SHIFT_SPACE ? ' ' : key, cnt), true); cursor += cnt; break; } return MenuBar::Scan(WhenBar, key); } UpdateAction(); } PlaceCaret(true); return true; }