bool ScrollBar::HorzKey(dword key) { if(!IsVisible() || !IsEnabled() || GetRect().IsEmpty()) return false; switch(key) { case K_CTRL_LEFT: PrevPage(); break; case K_CTRL_RIGHT: NextPage(); break; case K_LEFT: PrevLine(); break; case K_RIGHT: NextLine(); break; case K_HOME: Begin(); break; case K_END: End(); break; default: return false; } return true; }
bool ScrollBar::VertKey(dword key, bool homeend) { if(!IsVisible() || !IsEnabled() || GetRect().IsEmpty()) return false; switch(key) { case K_PAGEUP: PrevPage(); break; case K_PAGEDOWN: NextPage(); break; case K_UP: PrevLine(); break; case K_DOWN: NextLine(); break; case K_HOME: if(!homeend) break; case K_CTRL_HOME: case K_CTRL_PAGEUP: Begin(); break; case K_END: if(!homeend) break; case K_CTRL_END: case K_CTRL_PAGEDOWN: End(); break; default: return false; } return true; }
/* * CLinePtr::RpSetCp(cp, fAtEnd) * * Purpose * Set this line ptr to cp allowing for ambigous cp and taking advantage * of _cpFirstVisible and _iliFirstVisible * * Arguments: * cp position to set this line ptr to * fAtEnd if ambiguous cp: * if fAtEnd = TRUE, set this line ptr to end of prev line; * else set to start of line (same cp, hence ambiguous) * Return: * TRUE iff able to set to cp */ BOOL CLinePtr::RpSetCp(LONG cp, BOOL fAtEnd, BOOL fSkipFrame) { Assert(_prgRun); BOOL fRet; // Adjust the cp to be relative to the txt site containting the disp cp -= _pdp->GetFlowLayout()->GetContentFirstCp(); { SetIRun(0); SetIch(0); fRet = RpAdvanceCp(cp, fSkipFrame); // Start from 0 } // Note(SujalP): As exposed in bug 50281, it can happen that the containing // txtsite contains no lines. In which case we cannot really position // ourselves anywhere. Return failure. if(!CurLine()) { fRet = FALSE; } // Note(SujalP): Problem exposed in bug34660 -- when we are positioned at a // frame line, then the fAtEnd flag is really meaning less, since we base // our decision to move to prev or next line based on where in the line // is the cp positioned. Since, frame lines contain to characters, we really // cannot make that decision at all. else if(!CurLine()->IsFrame()) { // Ambiguous-cp caret position, should we be at the end of the line? if(fAtEnd) { if(!GetIch() && PrevLine(fSkipFrame, FALSE)) { SetIch(GetCurrRun()->_cch); // the first, go to end of } } // Or the beginning of the next one? else { if(GetIch()==long(GetCurrRun()->_cch) && NextLine(fSkipFrame, FALSE)) { SetIch(0); // Beginning of next line. } } } return fRet; }
/* * CLinePtr::FindParagraph(fForward) * * Purpose * Move this line ptr to paragraph (fForward) ? end : start, and return * change in cp * * Arguments: * fForward TRUE move this line ptr to para end; else to para start * * Return: * change in cp */ long CLinePtr::FindParagraph(BOOL fForward) { LONG cch; if(!fForward) // Go to para start { cch = 0; // Default already at para start if(RpGetIch()!=(LONG)(*this)->_cch || !((*this)->_fHasEOP)) // It isn't at para start { cch = -RpGetIch(); // Go to start of current line while(!((*this)->_fFirstInPara) && (*this)>0) { if(!PrevLine(TRUE, FALSE)) // Go to start of prev line { break; } cch -= (*this)->_cch; // Subtract # chars in line } SetIch(0); // Leave *this at para start } } else // Go to para end { cch = (*this)->_cch - RpGetIch(); // Go to end of current line while(((*this)<_pdp->LineCount()-1 || _pdp->WaitForRecalcIli((LONG)*this+1)) && !((*this)->_fHasEOP)) { if(!NextLine(TRUE, FALSE)) // Go to start of next line { break; } cch += (*this)->_cch; // Add # chars in line } SetIch((*this)->_cch); // Leave *this at para end } return cch; }
char * DefBlk(void) { char *f; size_t size = 0; char *dir = NULL; char sep; f = blk; line = NextLine(); *f = '\0'; while (line != NULL) { size = strlen(line); if ((*line == MARK) && ((dir = substr(line + 1, " \t\n")) != NULL)) { sep = *dir; *dir = '\0'; if (lookup(line + 1)) break; *dir = sep; } if (f + size + 1 > blk + M_BLK) Fatal("Mx:Too long block, use extra directives:[%s:%d].\n", mx_file, mx_line); memcpy(f, line, size + 1); f += size; line = NextLine(); } if (line) { *dir = ' '; PrevLine(); } if (f == blk) return 0; return StrDup(blk); }
BOOL CEditBar::PreTranslateMessage(MSG* pMsg) { CWnd* pWnd; CEdit* pEdit; if ( pMsg->message == WM_KEYDOWN ) { if ( ((CMainFrame*)AfxGetMainWnd())->GetActiveView()->PreTranslateMessage(pMsg) ) return TRUE; switch ( pMsg->wParam ) { case VK_RETURN: { tokenSetup=0; if(GetKeyState(VK_SHIFT)&0x1000) {tokenSetup = 2;} if(GetKeyState(VK_CONTROL)&0x1000){tokenSetup = 1;} pWnd = ((CMainFrame*)AfxGetMainWnd())->GetActiveView(); if ( pWnd ) pWnd->PostMessage(WM_USER+100 , 0 , 0 ); return TRUE; } case VK_TAB: { // Check we are in extending mode pEdit = (CEdit*)GetDlgItem(IDC_EDIT); if ( m_bExtending ) { // substitute word by new value if ( !m_posCurPos ) m_posCurPos= m_lstTabWords.GetHeadPosition (); CString strWord = m_lstTabWords.GetNext(m_posCurPos); CString str = m_strStartLine; str += strWord; str+= m_strEndLine; m_bExtendingChange = TRUE; pEdit->SetWindowText (str); pEdit->SetSel (m_strStartLine.GetLength () + strWord.GetLength (), m_strStartLine.GetLength () + strWord.GetLength ()); m_bExtendingChange = FALSE; return TRUE; } // ok, get current line, word etc CString strText; pEdit->GetWindowText (strText); if ( !strText.GetLength () ) return TRUE; int start, end; pEdit->GetSel (start, end); if ( end <= 0 || strText[end-1] == ' ') return TRUE; m_strEndLine = strText.Right(strText.GetLength() - end); strText = strText.Left(end); int cpos = strText.ReverseFind(' '); CString strWord; if ( cpos < 0 ) { strWord = strText; m_strStartLine.Empty (); } else { strWord = strText.Right(strText.GetLength () - cpos-1); m_strStartLine = strText.Left (cpos +1); } m_lstTabWords.RemoveAll (); // now find all words same as this one CSmcDoc* pDoc = (CSmcDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument (); if ( !pDoc ) return TRUE; m_lstTabWords.AddHead(strWord ); POSITION pos = pDoc->m_lstTabWords.GetHeadPosition (); while ( pos ) { CString str = pDoc->m_lstTabWords.GetNext(pos); if ( !strnicmp(str, strWord, strWord.GetLength()) ) { m_lstTabWords.AddTail (str); } } if ( m_lstTabWords.GetCount () < 2 ) { m_lstTabWords.RemoveAll (); return TRUE; } m_bExtending = TRUE; m_posCurPos = m_lstTabWords.GetHeadPosition(); m_lstTabWords.GetNext (m_posCurPos); strWord = m_lstTabWords.GetNext (m_posCurPos); strText = m_strStartLine + strWord + m_strEndLine; m_bExtendingChange = TRUE; pEdit ->SetWindowText (strText); int selpos = m_strStartLine.GetLength () + strWord.GetLength (); pEdit->SetSel (selpos, selpos); m_bExtendingChange = FALSE; return TRUE; } break; case VK_UP: if ( GetKeyState(VK_CONTROL) >= 0 ) { PrevLine(); return TRUE; } else return FALSE; case VK_DOWN: if ( GetKeyState(VK_CONTROL) >= 0 ) { NextLine(); return TRUE; } else return FALSE; case 'C': if ( GetKeyState(VK_CONTROL)&0x1000){ pEdit = (CEdit*)GetDlgItem(IDC_EDIT); pEdit->Copy(); return TRUE; } break; case VK_DELETE: if ( GetKeyState(VK_SHIFT)&0x1000){ pEdit = (CEdit*)GetDlgItem(IDC_EDIT); pEdit->Cut(); return TRUE; } break; case 'X': if ( GetKeyState(VK_CONTROL)&0x1000){ pEdit = (CEdit*)GetDlgItem(IDC_EDIT); pEdit->Cut(); return TRUE; } break; case VK_INSERT: if ( GetKeyState(VK_CONTROL)&0x1000){ pEdit = (CEdit*)GetDlgItem(IDC_EDIT); pEdit->Copy(); return TRUE; } if ( GetKeyState(VK_SHIFT)&0x1000){ /*pEdit = (CEdit*)GetDlgItem(IDC_EDIT); pEdit->Paste();*/ DoPaste(); return TRUE; } break; case 'V': if ( GetKeyState(VK_CONTROL)&0x1000){ /*pEdit = (CEdit*)GetDlgItem(IDC_EDIT); pEdit->Paste();*/ DoPaste(); return TRUE; } break; default: break; }; } if ( pMsg->message == WM_SYSKEYDOWN ) { if ( ((CMainFrame*)AfxGetMainWnd())->GetActiveView()->PreTranslateMessage(pMsg) ) return TRUE; } return CDialogBar::PreTranslateMessage(pMsg); }
void MakeDefs(char *name) { Def *d; CmdCode dir; char *line, *cmd, *blk, *file; extern int pr_hide; int mod = 0, sec = 0, lino = 0; CmdCode lastdir = Continue; IoReadFile(name); d = NwDef(Bfile, mod, sec, 0, mx_file); d->d_cmd = name; while ((line = NextLine()) && *line != '@') ; PrevLine(); while (!EofFile()) { dir = DefDir(); lino = mx_line; file = mx_file; cmd = DefCmd(); blk = DefBlk(); switch (dir) { /* * conditional text and code * Syntax: * @if <macroId>\n <block> [@else <block> ] @endif */ case Ifdef: pushCond(GetDef(cmd) != NULL, cmd); if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; d->d_blk = NULL; if (allTrue()) { d = NwDef(lastdir, mod, sec, lino, file); d->d_cmd = NULL; d->d_blk = blk; } } break; case Ifndef: toggle(); if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_cmd = topMacro(); d->d_blk = NULL; d = NwDef(lastdir, mod, sec, lino, file); d->d_cmd = NULL; d->d_blk = blk; } break; case Endif: if (!topCond()) toggle(); if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_cmd = topMacro(); d->d_blk = NULL; } popCond(); if (allTrue()) { d = NwDef(lastdir, mod, sec, lino, file); d->d_cmd = NULL; d->d_blk = blk; } break; /* * Define index. * Syntax:@<n><string>\n@... */ case Index0: case Index1: case Index2: case Index3: case Index4: case Index5: case Index6: case Index7: case Index8: case Index9: if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; d->d_blk = blk; lastdir = Continue; } break; /* * Define title, author, date, version. * Syntax: @[tavd]<string>\n@... */ case Title: if (allTrue()) { mx_title = cmd; d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; lastdir = Continue; } break; case Version: if (allTrue()) { mx_version = cmd; d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; lastdir = Continue; } break; case Author: if (allTrue()) { mx_author = cmd; d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; lastdir = Continue; } break; case Date: if (allTrue()) { mx_date = cmd; d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; lastdir = Continue; } break; /* * Text directives: chapter, section, paragraph. * Syntax:@[*+ ]<string>\n<blok>@... * Synatx:@\n<blok>@... */ case Module: if (allTrue()) { if (!Hide()) { mod++; sec = 0; } d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; d->d_blk = blk; lastdir = Continue; } break; case Section: if (allTrue()) { if (!Hide()) sec++; d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; d->d_blk = blk; lastdir = Continue; } break; case Subsection: case Paragraph: if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_blk = blk; d->d_cmd = cmd; lastdir = Continue; } break; case Qcode: case Continue: if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_blk = blk; lastdir = Continue; } break; /* * Code directives, * Pool: spec, impl * C: .h, .c, .cc, .y, .l * Basename * Syntax:@[sihcylfp]\n<blk>\n@... */ case Ofile: if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); /* specially for Windows: replace all /'s with DIR_SEP's */ #if DIR_SEP != '/' { char *tmp = cmd; while ((tmp = strchr(tmp, '/')) != NULL) *tmp++ = DIR_SEP; } #endif d->d_cmd = cmd; lastdir = Continue; } break; case Pspec: case Pimpl: case Cdef: case Csrc: case Cyacc: case Clex: case Prolog: case Haskell: case MALcode: case HTML: case ODLspec: case OQLspec: case SQL: case Java: case Qnap: case ProC: case Shell: case fGrammar: case Macro: case XML: case DTD: case XSL: case Config: case CCyacc: case CClex: if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; d->d_blk = blk; lastdir = dir; } break; /* * Macro definitions. * Syntax:@=<def>\n<blok>\n@... */ case Mxmacro: if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; d->d_blk = blk; /*add information */ lastdir = Continue; } break; case InHide: d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; d->d_blk = blk; HideOn(); break; case OutHide: d = NwDef(dir, mod, sec, lino, file); d->d_cmd = cmd; d->d_blk = blk; HideOff(); break; /* * Comment statement * Syntax:@/<blk>\n... */ case Comment: if (allTrue()) { d = NwDef(dir, mod, sec, lino, file); d->d_cmd = NULL; d->d_blk = blk; } break; default: Fatal("MakeDefs", "Unknown directive:%c%c", MARK, dir); } } d = NwDef(Efile, mod, sec, mx_line, mx_file); CloseFile(); pr_hide = 0; }
void Field::HistoryPrev() { std::string current = Str::UTF32To8(GetText()); PrevLine(hist, current); SetText(Str::UTF8To32(current)); }
void PrevChar() { if ( !m_xCaret-- ) { End(); PrevLine(); } }
void scSelection::MoveSelect( eSelectMove moveSelect ) { int setmax = 1; switch ( moveSelect ) { case ePrevChar: case eNextChar: case ePrevCharInPara: case eNextCharInPara: SLCCharacterMove( *this, moveSelect ); break; case ePrevWord: PrevWord( ); break; case eNextWord: NextWord( ); break; case ePrevSpellWord: PrevSpellWord( ); break; case eNextSpellWord: NextSpellWord( ); break; case eStartWord: StartWord( ); break; case eEndWord: EndWord( ); break; case ePrevEntireLine: PrevEntireLine(); break; case eNextEntireLine: NextEntireLine(); break; case ePrevLine: PrevLine(); setmax = 0; break; case eNextLine: NextLine(); setmax = 0; break; case eStartLine: StartLine(); break; case eEndLine: EndLine(); break; case ePrevPara: case eNextPara: case eFirstPara: case eLastPara: Para( moveSelect ); break; case eBeginPara: BeginPara(); break; case eEndPara: EndPara(); break; case ePrevEntireColumn: PrevColumn(); break; case eNextEntireColumn: NextColumn(); break; case eBeginColumn: StartColumn( ); break; case eEndColumn: EndColumn(); break; case eStartStream: fMark.SelectStartStream(); fPoint.SelectStartStream(); break; case eEndStream: fMark.SelectEndStream(); fPoint.SelectEndStream(); break; default: SCDebugBreak(); break; } fMark.UpdateInfo( setmax ); fPoint.UpdateInfo( setmax ); }