LRESULT CScriptEditView::OnFindReplaceCmd( UINT, WPARAM, LPARAM lParam, BOOL& ) { CFindReplaceDialog* pDlg = CFindReplaceDialog::GetNotifier(lParam); if( pDlg == NULL ) { ::MessageBeep( (UINT)-1 ); return 1; } ATLASSERT( pDlg == m_pFindDlg ); if( pDlg->IsTerminating() ) { m_pFindDlg = NULL; return 0; } lstrcpyn( m_fro.StrToFind, pDlg->m_fr.lpstrFindWhat, DIMOF(m_fro.StrToFind) ); m_fro.bMatchCase = (pDlg->MatchCase() != FALSE); m_fro.bWholeWord = (pDlg->MatchWholeWord() != FALSE); if( pDlg->FindNext() ) { if( !DoFindText() ) ::MessageBeep( (UINT)-1 ); } else if( pDlg->ReplaceCurrent() ) { long nStart, nEnd; GetSel( nStart, nEnd ); if( nStart != nEnd ) { LPTSTR szFind = (LPTSTR)_alloca( (nEnd - nStart + 1) * sizeof(TCHAR) ); GetSelText( szFind ); int nRet; if( m_fro.bMatchCase ) nRet = lstrcmp( szFind, m_fro.StrToFind ); else nRet = lstrcmpi( szFind, m_fro.StrToFind ); if(nRet == 0) ReplaceSel( pDlg->GetReplaceString(), TRUE ); } if( !DoFindText() ) ::MessageBeep( (UINT)-1 ); } else if( pDlg->ReplaceAll() ) { SetRedraw(FALSE); CWaitCursor wait; while( DoFindText(false) ) ReplaceSel( pDlg->GetReplaceString(), TRUE ); SetRedraw( TRUE ); Invalidate(); UpdateWindow(); } return 0; }
void CEditLogB::Update () { //LOCK_BLOCK (_lock); if (!_init) { SetLimitText(_maxLine*1024); _init = true; } int lineCount = GetLineCount (); if (_maxLine < lineCount) { LockWindowUpdate(); SetSel (0, LineIndex (lineCount - _maxLine*8/10)); ReplaceSel (""); _textLength = GetWindowTextLength(); LineScroll(_maxLine, 0); UnlockWindowUpdate(); } for (int i=0, n=_logList.size (); i<n; ++i) { string &smsg = _logList[i]; SetSel (_textLength, _textLength); ReplaceSel (smsg.c_str ()); _textLength += smsg.length (); } _logList.clear (); }
void NativeTextfieldWin::OnPaste() { if(textfield_->read_only() || !ViewDelegate::view_delegate) { return; } ui::Clipboard* clipboard = ViewDelegate::view_delegate->GetClipboard(); if(!clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), ui::Clipboard::BUFFER_STANDARD)) { return; } std::wstring clipboard_str; clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_str); if(!clipboard_str.empty()) { std::wstring collapsed(CollapseWhitespace(clipboard_str, false)); if(textfield_->style() & Textfield::STYLE_LOWERCASE) { collapsed = base::i18n::ToLower(collapsed); } // Force a Paste operation to trigger ContentsChanged, even if identical // contents are pasted into the text box. See http://crbug.com/79002 ReplaceSel(L"", false); textfield_->SyncText(); text_before_change_.clear(); ReplaceSel(collapsed.c_str(), true); } }
//删除字符 VOID CSkinRichEdit::OnDeleteString() { //删除字符 ReplaceSel(TEXT("")); return; }
void CHistoryEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { CString newchar = (TCHAR)nChar; if (nChar=='\r') { int n = m_cmdList.GetCount()-LASTCMDSIZE; if (n>0) { m_cmdList.RemoveHead();// remember last 10 commands } CString strTmp = m_strCmd, date; SYSTEMTIME st; GetLocalTime(&st); date.Format("\r\n%04d-%02d-%02d %02d:%02d:%02d:%03d, #",st.wYear,st.wMonth,st.wDay, st.wHour,st.wMinute,st.wSecond,st.wMilliseconds); m_strCmd.Empty(); ::SendMessage(GetParent()->m_hWnd, WM_DADA_SENDCMDMSG, (WPARAM)WM_MY_SENDCOMMAND, (LPARAM)(LPCTSTR)strTmp); m_cmdList.AddTail(strTmp); newchar = date; } else { m_strCmd += newchar; } int nLength = SendMessage(WM_GETTEXTLENGTH); SetSel(nLength, nLength); ReplaceSel(newchar); }
CRichEditCtrlX& CRichEditCtrlX::operator<<(UINT uVal) { CString strVal; strVal.Format(_T("%u"), uVal); ReplaceSel(strVal); return *this; }
CRichEditCtrlX& CRichEditCtrlX::operator<<(int iVal) { CString strVal; strVal.Format(_T("%d"), iVal); ReplaceSel(strVal); return *this; }
///////////////////////////////////////////////////////////////////////////// // 清除指定行 ///////////////////////////////////////////////////////////////////////////// void COutputCtrl::ClearLineFrom(INT dlineFrom, INT dlineTo) { int Num1 = LineIndex(dlineFrom); int Num2 = LineIndex(dlineTo+1); SetSel(Num1,Num2); ReplaceSel(""); }
void CSecureEditEx::_Paste(LPCTSTR lpSource) { ASSERT(lpSource != NULL); if(lpSource == NULL) return; ASSERT(lpSource[0] != 0); if(lpSource[0] == 0) return; ReplaceSel(lpSource, FALSE); }
CRichEditCtrlX& CRichEditCtrlX::operator<<(double fVal) { CString strVal; strVal.Format(_T("%.3f"), fVal); ReplaceSel(strVal); return *this; }
zBOOL ZMLE::HandleQuickKey( zACCEL_DEF ad ) { #ifdef DEBUG_ALL TraceLineS( "ZMLE::HandleQuickKey: ", *m_pzsTag ); #endif if ( ad.uVK == VK_TAB && ad.fAlt == 0 && ad.fCtrl == 1 ) { ReplaceSel( "\t", TRUE ); return( TRUE ); } else if ( ad.uVK == VK_TAB && ad.fAlt == 0 && ad.fCtrl == 0 ) { ZMapAct *pzma = m_pZSubtask-> GetFocusCtrlWithinComposite( 0, this, !ad.fShift ); if ( pzma && pzma->m_pCtrl && mIs_hWnd( pzma->m_pCtrl->m_hWnd ) ) { pzma->m_pCtrl->SetFocus( ); } return( TRUE ); } else if ( ad.uVK == VK_RETURN ) { if ( ad.fAlt == 0 ) { ReplaceSel( "\r\n", TRUE ); } else if ( ad.fAlt && m_pZSubtask->m_pCurrDfltBtn && m_pZSubtask->m_pCurrDfltBtn->m_pCtrl && mIs_hWnd( m_pZSubtask->m_pCurrDfltBtn->m_pCtrl->m_hWnd ) ) { m_pZSubtask->m_pCurrDfltBtn->m_pCtrl->SendMessage( WM_LBUTTONDOWN ); m_pZSubtask->m_pCurrDfltBtn->m_pCtrl->SendMessage( WM_LBUTTONUP ); } return( TRUE ); } return( FALSE ); }
//清除屏幕 bool CSkinRichEdit::CleanScreen() { //清除屏幕 SetSel(0,GetWindowTextLength()); ReplaceSel(TEXT("")); return true; }
//删除信息 VOID CSkinRichEdit::OnClearAll() { //删除信息 SetSel(0L,-1L); ReplaceSel(NULL); return; }
void CTWScriptEdit::ChangeCase(int nStart, int nEnd, LPCWSTR lpsz) { ASSERT((nEnd - nStart) == (int)_tcslen(lpsz)); if (!m_bCaseSensitive && m_bChangeCase) { SetSel(nStart, nEnd); ReplaceSel(GetMBCS(lpsz)); } }
void CTWScriptEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if (nChar == '\t' && GetKeyState(VK_CONTROL) >= 0) { ReplaceSel("\t"); return; } CRichEditCtrl::OnChar(nChar, nRepCnt, nFlags); }
void CHTRichEditCtrl::AddString(int nPos, LPCTSTR pszString, bool bLink, COLORREF cr,COLORREF bk, DWORD mask) { bool bRestoreFormat = false; m_bEnErrSpace = false; SetSel(nPos, nPos); if (bLink) { CHARFORMAT2 cf; memset(&cf, 0, sizeof cf); GetSelectionCharFormat(cf); cf.dwMask |= CFM_LINK; cf.dwEffects |= CFE_LINK; SetSelectionCharFormat(cf); } else if (cr != CLR_DEFAULT || bk != CLR_DEFAULT) { CHARFORMAT2 cf; memset(&cf, 0, sizeof(cf)); GetSelectionCharFormat(cf); if(cr != CLR_DEFAULT) { cf.dwMask |= CFM_COLOR; cf.dwEffects &= ~CFE_AUTOCOLOR; cf.crTextColor = cr; } if(bk != CLR_DEFAULT) { cf.dwMask |= CFM_BACKCOLOR; cf.dwEffects &= ~CFE_AUTOBACKCOLOR; cf.crBackColor = bk; } cf.dwMask |= mask; if(mask & CFM_BOLD) cf.dwEffects |= CFE_BOLD; //Checks if bold is set in the mask and then sets it in effects if it is else if(cf.dwEffects & CFE_BOLD) cf.dwEffects ^= CFE_BOLD; //Unset bold if(mask & CFM_ITALIC) cf.dwEffects |= CFE_ITALIC; //Checks if italic is set in the mask and then sets it in effects if it is else if(cf.dwEffects & CFE_ITALIC) cf.dwEffects ^= CFE_ITALIC; //Unset bold if(mask & CFM_UNDERLINE) cf.dwEffects |= CFE_UNDERLINE; //Checks if underlined is set in the mask and then sets it in effects if it is else if(cf.dwEffects & CFE_UNDERLINE) cf.dwEffects ^= CFE_UNDERLINE; //Unset italic SetSelectionCharFormat(cf); bRestoreFormat = true; } else if (m_bRestoreFormat) { SetSelectionCharFormat(m_cfDefault); } ReplaceSel(pszString); m_bRestoreFormat = bRestoreFormat; }
int RichEdit::Replace(int start, int end, const TCHAR *new_text) { CHARRANGE sel = GetSel(); CHARRANGE replace_sel = { start, end }; SetSel(replace_sel); ReplaceSel(new_text); int dif = FixSel(&sel, replace_sel, mir_tstrlen(new_text)); SetSel(sel); return dif; }
int RichEdit::Insert(int pos, const TCHAR *text) { CHARRANGE sel = GetSel(); CHARRANGE replace_sel = { pos, pos }; SetSel(replace_sel); ReplaceSel(text); int dif = FixSel(&sel, replace_sel, mir_tstrlen(text)); SetSel(sel); return dif; }
int RichEdit::Delete(int start, int end) { CHARRANGE sel = GetSel(); CHARRANGE replace_sel = { start, end }; SetSel(replace_sel); ReplaceSel(_T("")); int dif = FixSel(&sel, replace_sel, 0); SetSel(sel); return dif; }
void NativeTextfieldWin::OnCut() { if(textfield_->read_only() || textfield_->IsPassword()) { return; } OnCopy(); // This replace selection will have no effect (even on the undo stack) if the // current selection is empty. ReplaceSel(L"", true); }
// 增加字符 // CEdit显示内容有限制,当超过该限制时,需要删除原来的内容,再增加内容 void CConsoleEdit::AddTexts(const char* str, int len) { if(len == -1) len = strlen(str); //KDebug("%d %d", m_nLength, len); if ((m_nLength + len) > MAX_DATA_NUM) { SetSel(0, len + 128, TRUE); ReplaceSel(""); if (len > MAX_DATA_NUM) { CString result(str); result = result.Right(MAX_DATA_NUM); ReplaceSel(result); return; } } MoveToEnd(); ReplaceSel(str); if (strcmp(str,m_pretitle)==0) m_last_title_pos = SendMessage( WM_GETTEXTLENGTH ); }
void NativeTextfieldWin::OnAfterPossibleChange(bool should_redraw_text) { // Prevent the user from selecting the "phantom newline" at the end of the // edit. If they try, we just silently move the end of the selection back to // the end of the real text. CHARRANGE new_sel; GetSel(new_sel); const int length = GetTextLength(); if(new_sel.cpMax > length) { new_sel.cpMax = length; if(new_sel.cpMin > length) { new_sel.cpMin = length; } SetSel(new_sel); } std::wstring new_text(GetText()); if(new_text != text_before_change_) { if(ime_discard_composition_ && ime_composition_start_>=0 && ime_composition_length_>0) { // A string retrieved with a GetText() call contains a string being // composed by an IME. We remove the composition string from this search // string. new_text.erase(ime_composition_start_, ime_composition_length_); ime_composition_start_ = 0; ime_composition_length_ = 0; if(new_text.empty()) { return; } } textfield_->SyncText(); UpdateAccessibleValue(textfield_->text()); if(should_redraw_text) { CHARRANGE original_sel; GetSel(original_sel); std::wstring text = GetText(); ScopedSuspendUndo suspend_undo(GetTextObjectModel()); SelectAll(); ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true); SetSel(original_sel); } } }
/* ================ CSyntaxRichEditCtrl::AutoCompleteInsertText ================ */ void CSyntaxRichEditCtrl::AutoCompleteInsertText( void ) { long selStart, selEnd; int index; index = autoCompleteListBox.GetCurSel(); if ( index >= 0 ) { CString text; autoCompleteListBox.GetText( index, text ); GetSel( selStart, selEnd ); selStart = autoCompleteStart; SetSel( selStart, selEnd ); ReplaceSel( text, TRUE ); } }
void JHCEdit::DeleteLine(int line) { int n, lc, i; lc = GetLineCount(); if (line < 0) i = lc + line + 1; else i = line; if ((i < 0) || (i > lc)) return; i--; if (i < 0) i = LineFromChar(); i = LineIndex(i); n = LineLength(i); SetSel(i, i + n + 1); ReplaceSel(CString(""), TRUE); n = LineLength(i); SetSel(i, i); }
// // Purpose: // Appends a text string to the history buffer. // // Returns: // None. // void CHistoryEdit::AppendString(CString str) { // Get current time static CString time, newstr; static SYSTEMTIME st; GetLocalTime(&st); time.Format("%04d-%02d-%02d %02d:%02d:%02d:%03d, ",st.wYear,st.wMonth,st.wDay, st.wHour,st.wMinute,st.wSecond,st.wMilliseconds); newstr = time + str + _T("\r\n"); int nLength = SendMessage(WM_GETTEXTLENGTH); SetSel(nLength, nLength); ReplaceSel(newstr); // Scroll the edit control LineScroll (GetLineCount(), 0); }
BOOL CxEdit::InsertString(int nLine, LPCTSTR lpsz, BOOL bScroll /*= TRUE*/, BOOL bCanUndo /*= FALSE*/) { const int linecount = GetLineCount(); BOOL bOK = (nLine <= linecount); if (bOK) { if (nLine == linecount) { AddString(_T("\r\n"), FALSE, bCanUndo); } const int index = LineIndex(nLine); SetSel(index, index, !bScroll); ReplaceSel(lpsz, bCanUndo); } return bOK; }
void CEditCtrl::SetText(const CString& text, COLORREF color) { CHARFORMAT cf; ::memset(&cf, 0, sizeof(CHARFORMAT)); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_COLOR; cf.crTextColor = color; int iTotalLength = GetWindowTextLength(); HideSelection(TRUE, TRUE); SetSel(iTotalLength, iTotalLength); SetSelectionCharFormat(cf); ReplaceSel((LPCTSTR)text); HideSelection(FALSE, TRUE); }
///////////////////////////////////////////////////////////////////////////// // CNotifyShowCase message handlers void CNotifyShowCase::AddLine(LPCTSTR lpsz) { TCHAR szt[50]; int nLastChar; int cLines; if (GetLineCount() >= m_totalLines) { SetSel(0, LineLength(0), TRUE/*bNoScroll*/); // select the first line Clear(); // and remove it } nLastChar = LineIndex((cLines = GetLineCount() - 1)) + LineLength(cLines); _stprintf_s(szt, 50, _T("%s\x0D\x0A"), lpsz); SetSel(nLastChar, nLastChar, TRUE/*bNoScroll*/); ReplaceSel(szt); }
void CMyEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { switch (m_Type) { case MET_EDITOR: if (nChar == '\t') { ReplaceSel(_T("\t")); return; } break; case MET_FILENAME: break; case MET_FOLDER: break; } CEdit::OnKeyDown(nChar, nRepCnt, nFlags); }
BOOL CShaderEdit::PreTranslateMessage(MSG* pMsg) { if(m_acdlg.IsWindowVisible() && pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || pMsg->wParam == VK_PRIOR || pMsg->wParam == VK_NEXT || pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)) { int i = m_acdlg.m_list.GetCurSel(); if(pMsg->wParam == VK_RETURN && i >= 0) { CString str; m_acdlg.m_list.GetText(i, str); i = str.Find('(')+1; if(i > 0) str = str.Left(i); int nStartChar = 0, nEndChar = -1; GetSel(nStartChar, nEndChar); CString text; GetWindowText(text); while(nStartChar > 0 && _istalnum(text.GetAt(nStartChar-1))) nStartChar--; SetSel(nStartChar, nEndChar); ReplaceSel(str, TRUE); } else if(pMsg->wParam == VK_ESCAPE) { m_acdlg.ShowWindow(SW_HIDE); } else { m_acdlg.m_list.SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); } return TRUE; } return __super::PreTranslateMessage(pMsg); }