void EditTextTask::DeleteBack() { m_posb = m_posa; DecrementPosition(m_posa); if(HasSelection())DeleteSelection(); }
void CEdit::ReplaceAllInBuffer() { CHourGlass wait( this ); CDelayRepaint delay( this ); if ( m_Buffer.GetLineCount() && g_FindReplaceData.m_pszFindText && *g_FindReplaceData.m_pszFindText ) { m_Selection.MakeEmpty(); int nStartRow = m_Selection.GetStartRow(); int nStartCol = m_Selection.GetStartCol(); m_Buffer.BeginEdit( nStartRow, nStartCol ); BOOL bFoundText = FALSE; int nFirstRow = 0, nFirstCol = 0; int nCol = 0; int nRow = 0; int cbFindText = _tcslen( g_FindReplaceData.m_pszFindText ); int cbReplaceText = _tcslen( g_FindReplaceData.m_pszReplaceText ); for ( ;; ) { BOOL bWrapped; int cbMatched; if ( m_Buffer.FindText( g_FindReplaceData.m_pszFindText, cbFindText, TRUE, g_FindReplaceData.m_bCaseSensitiveSearch, g_FindReplaceData.m_bWholeWordOnly, g_FindReplaceData.m_bRegExp, nRow, nCol, bWrapped, cbMatched ) ) { if ( !bFoundText ) { bFoundText = TRUE; nFirstRow = nRow; nFirstCol = nCol; } else if ( bWrapped && ( nRow >= nFirstRow ) && ( nCol >= nFirstCol ) ) { // have completely wrapped around and came back to the first occurrence. break; } m_Selection.SetExtendedSelection( nCol, nRow, nCol + cbMatched, nRow ); if ( g_FindReplaceData.m_pszReplaceText ) { FindReplaceSelection(); nCol += cbReplaceText; } else { DeleteSelection( FALSE, FALSE ); nCol += cbMatched; } } else { break; } } if ( bFoundText && !m_pActiveView->LineIsVisible( nFirstRow ) ) { // found occurrences of the find text. Go to the location of the first bookmark GoToLine( nFirstRow, TRUE ); } Repaint( FALSE ); m_Buffer.EndEdit( nStartRow, nStartCol ); } }
void DataListCtrl::OnKeyDown(wxKeyEvent& event) { if ( event.GetKeyCode() == WXK_DELETE || event.GetKeyCode() == WXK_BACK) DeleteSelection(); //event.Skip(); }
void TextManip::DeleteCharacter (int count) { if (_dot != _mark) { DeleteSelection(); } else { DeleteText(count); } }
void CPActionDragDrop::Redo(CMainFrame &MainFrm) { if (m_bDragDelete) DeleteSelection(*GET_SONG_VIEW(), m_pUndoState->Selection); // // // // GET_PATTERN_EDITOR()->Paste(m_ClipData, m_iPasteMode, m_iPastePos); // // // GET_PATTERN_EDITOR()->DragPaste(m_ClipData, m_dragTarget, m_bDragMix); }
void EditTextTask::OnKeyDown(wxKeyEvent &event) { if ( m_done ) return; int code = event.GetKeyCode(); event.Skip(true); if ( code == WXK_ESCAPE ) { CloseTask(); event.Skip(false); } if ( code == WXK_DELETE || code == WXK_NUMPAD_DELETE || code == WXK_BACK ) { if ( HasSelection() ) DeleteSelection(); else if ( code == WXK_BACK ) DeleteBack(); else Delete(); event.Skip(false); } if ( code == WXK_RETURN || code == WXK_NUMPAD_ENTER ) { InsertText(_T("\n")); event.Skip(false); } if ( code == WXK_TAB ) { InsertText(_T("\t")); event.Skip(false); } }
int HoldKeyPressing(TextEdition *te, SDL_Event event) { char c, done=1; if (event.type != SDL_KEYDOWN || !te->focus || HasReadOnlyStyle(te->style)) return 0; switch(event.key.keysym.sym) { case SDLK_DELETE: if (te->selection.begin == te->selection.end) DeleteChar(te->text, te->cursorPos); else DeleteSelection(te); TE_UpdateTextEdition(te, 0); break; case SDLK_BACKSPACE: if (te->selection.begin == te->selection.end) { if (te->cursorPos > 0) DeleteChar(te->text, -- te->cursorPos); } else DeleteSelection(te); TE_UpdateTextEdition(te, 0); break; case SDLK_RETURN: case SDLK_KP_ENTER: event.key.keysym.unicode = '\n'; default: if (event.key.keysym.unicode) { if (event.key.keysym.unicode<256) c = event.key.keysym.unicode; else c = '?'; if (te->selection.begin != te->selection.end) DeleteSelection(te); InsertChar(te->text, te->cursorPos, c, te->textLength); TE_UpdateTextEdition(te, 0); te->cursorPos++; } else done = 0; break; } return done; }
//-------------------------------------------------------------------// // Cut() // //-------------------------------------------------------------------// void OleListCtrl::Cut() { Copy(); // Now delete the current selection. DeleteSelection( false ); }
void CPActionInsertAtSel::Redo(CMainFrame &MainFrm) { CPatternEditor *pPatternEditor = GET_PATTERN_EDITOR(); CSelection Sel(m_pUndoState->Selection); Sel.m_cpEnd.Ypos.Row = pPatternEditor->GetCurrentPatternLength(Sel.m_cpEnd.Ypos.Frame) - 1; DeleteSelection(*GET_SONG_VIEW(), Sel); if (m_UndoHead.ContainsData()) pPatternEditor->PasteRaw(m_UndoHead, m_cpHeadPos); }
void CPActionDeleteAtSel::Redo(CMainFrame &MainFrm) { CPatternEditor *pPatternEditor = GET_PATTERN_EDITOR(); CSelection Sel(m_pUndoState->Selection); Sel.m_cpEnd.Ypos.Row = pPatternEditor->GetCurrentPatternLength(Sel.m_cpEnd.Ypos.Frame) - 1; DeleteSelection(*GET_SONG_VIEW(), Sel); if (m_UndoTail.ContainsData()) pPatternEditor->PasteRaw(m_UndoTail, m_pUndoState->Selection.m_cpStart); pPatternEditor->CancelSelection(); }
void DisplayDirector::SetSelection(Selection* newSelection) { StartRefreshCycle(); if (selection) { RefreshDocRect(selection->Bounds()); DeleteSelection(selection); } selection = newSelection; if (newSelection) RefreshDocRect(newSelection->Bounds()); FinishRefreshCycle(); }
void CPlainTextEditor::Cut(CChars* pszDest) { if (IsSelected()) { Copy(pszDest); miEditPos = DeleteSelection(); ResetUpDown(); } else { CutLine(pszDest); } }
void CPlainTextEditor::Delete(void) { if (!IsSelected()) { if (CanGoRight(miEditPos)) { mszText.RemoveCharacter(miEditPos); ResetUpDown(); } } else { miEditPos = DeleteSelection(); ResetUpDown(); } }
void CPlainTextEditor::Backspace(void) { if (!IsSelected()) { if (CanGoLeft(miEditPos)) { mszText.RemoveCharacter(miEditPos-1); Left(); } } else { miEditPos = DeleteSelection(); ResetUpDown(); } }
void CPaneHierarchy::OnEmptyCommandRange( UINT ID) { switch (ID) { case ID_HRC_REFRESH: RefreshHierarchy(); return; case ID_HRC_DELETE: DeleteSelection(); return; case ID_HRC_FOCUS: FocusOnSelection(); return; } }
void CEdit::Replace() { if ( m_Buffer.GetLineCount() && !m_Selection.IsEmpty() ) { if ( g_FindReplaceData.m_pszFindText ) { if ( g_FindReplaceData.m_pszReplaceText ) { FindReplaceSelection(); } else { DeleteSelection( FALSE, FALSE ); } } } FindText( TRUE ); }
void CEdit::DoDragDrop() { int nStartCol, nStartRow, nEndCol, nEndRow; ASSERT( !m_Selection.IsEmpty() ); // Drag and drop does not currently support column selection. Convert // the column selection to a paragraph selection as a fallback. if ( m_Selection.IsColumnSel() ) { m_Selection.EnableColumnSel( FALSE ); DamageSelection( TRUE ); } m_Selection.GetNormalizedBufferSelection( nStartCol, nStartRow, nEndCol, nEndRow ); HGLOBAL hGlobal; if ( m_Buffer.GetText( nStartRow, nStartCol, nEndRow, nEndCol, hGlobal, FALSE ) ) { CDataObject DataObj( hGlobal ); CDropSource DropSource; VERIFY( SUCCEEDED( CoLockObjectExternal( ( LPUNKNOWN ) ( LPVOID ) &DataObj, TRUE, FALSE ) ) ); VERIFY( SUCCEEDED( CoLockObjectExternal( ( LPUNKNOWN ) &DropSource, TRUE, FALSE ) ) ); DWORD dwEffect; m_bDroppedHere = FALSE; if ( ::DoDragDrop( &DataObj, &DropSource, DROPEFFECT_COPY | ( m_Buffer.IsReadOnly() ? 0 : DROPEFFECT_MOVE ), &dwEffect ) == DRAGDROP_S_DROP ) { // text was dropped successfully -- The OnDrop() method of the drop target freed the memory // because CDataObject::GetData() set pUnkForRelease = NULL. // if moved text to another window, delete the selection here if ( !m_bDroppedHere && HAS_FLAG( dwEffect, DROPEFFECT_MOVE ) ) { DeleteSelection( FALSE, FALSE ); } } else { // cleanup clip data since target window didn't drop the text GlobalFree( hGlobal ); } VERIFY( SUCCEEDED( CoLockObjectExternal( ( LPUNKNOWN ) &DropSource, FALSE, TRUE ) ) ); VERIFY( SUCCEEDED( CoLockObjectExternal( ( LPUNKNOWN ) ( LPVOID ) &DataObj, FALSE, TRUE ) ) ); DataObj.Release(); } SetMode( eIdle ); }
void EditBox::OnKeyDown(int key){ switch(key){ case VK_DELETE: if(mSelectStart != mSelectEnd){ DeleteSelection(); }else{ int len = strlen(mString) - 1; if(len < 0 || mCaret > len) return; memcpy_s(mString, 256, mString, mCaret); memcpy_s(mString + mCaret, 256, mString + mCaret + 1, len - mCaret); mString[len] = 0; UpdateText(); } break; case VK_HOME: mCaret = 0; break; case VK_END: mCaret = strlen(mString); break; case VK_LEFT: if(mSelectStart != mSelectEnd){ mCaret = mSelectStart; mSelectStart = mSelectEnd = 0; }else if(mCaret > 0) --mCaret; break; case VK_RIGHT: { int len = strlen(mString); if(mSelectStart != mSelectEnd){ mCaret = mSelectEnd; mSelectStart = mSelectEnd = 0; }else if(mCaret < len) ++mCaret; } break; } }
void EditBox::OnChar(int key){ if(key >= 32 && key <= 126){ if(mSelectStart != mSelectEnd){ int left, right, dc; left = mSelectStart; right = mSelectEnd; dc = right - left; int len = strlen(mString) + 1 - dc; memcpy_s(mString, 256, mString, left); mString[left] = char(key); memcpy_s(mString + right - dc + 1, 256, mString + right, len - right + dc); mString[len] = 0; UpdateText(); mCaret = left + 1; mSelectStart = mSelectEnd = 0; }else{ int len = strlen(mString) + 1; memcpy_s(mString, 256, mString, mCaret); memcpy_s(mString + mCaret + 1, 256, mString + mCaret, len - mCaret); mString[mCaret] = char(key); mString[len] = 0; UpdateText(); mCaret++; } }else if(key == VK_BACK){ if(mSelectStart != mSelectEnd){ DeleteSelection(); }else if(mCaret > 0){ int len = strlen(mString); memcpy_s(mString, 256, mString, mCaret - 1); memcpy_s(mString + (mCaret - 1), 256, mString + mCaret, len - mCaret); mString[len - 1] = 0; --mCaret; UpdateText(); } } }
void JXExprEditor::HandleEditMenu ( const JIndex item ) { CmdIndex cmd; if (!EditMenuIndexToCmd(item, &cmd)) { return; } if (cmd == kUndoCmd) { Undo(); } else if (cmd == kCutCmd) { Cut(); } else if (cmd == kCopyCmd) { Copy(); } else if (cmd == kPasteCmd) { Paste(); } else if (cmd == kDeleteSelCmd) { DeleteSelection(); } else if (cmd == kSelectAllCmd) { SelectAll(); } }
BOOL CEdit::OnDrop( LPDATAOBJECT pIDataSource, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect ) { CEditView *pView; int nBuffCol, nRow; *pdwEffect = GetDropEffect( pIDataSource, grfKeyState, pt, pView, nBuffCol, nRow ); m_bDroppedHere = TRUE; BOOL bDropped = FALSE; if ( *pdwEffect != DROPEFFECT_NONE ) { FORMATETC fe = { CLIP_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; STGMEDIUM stgm; if ( !SUCCEEDED( pIDataSource->GetData( &fe, &stgm ) ) ) { // data could not be retrieved m_Selection.SetEmptySelection( nBuffCol, nRow ); m_Selection.ShowCaret(); return FALSE; } HGLOBAL hMem = stgm.hGlobal; ASSERT( hMem ); LPCTSTR pszText = ( LPCTSTR ) GlobalLock( hMem ); m_Buffer.BeginEdit( m_Selection.GetEndRow(), m_Selection.GetEndCol() ); if ( pszText && IsDragAndDropping() ) { // we are dragging and dropping from within this control -- be careful how // the *current* selection is handled POINT ptClient = { pt.x, pt.y }; ScreenToClient( m_hWnd, &ptClient ); if ( PtInSelection( ptClient.x, ptClient.y, FALSE ) ) { m_Selection.SetEmptySelection( nBuffCol, nRow ); } else { BOOL bMove = HAS_FLAG( *pdwEffect, DROPEFFECT_MOVE ); int nStartRow, nStartCol, nEndRow, nEndCol; m_Selection.GetNormalizedBufferSelection( nStartCol, nStartRow, nEndCol, nEndRow ); if (nRow == nStartRow && nBuffCol == nStartCol) { // nothing really to do -- the source and destination are identical. // We do however need to erase the drag insertion caret. DamageSelection(FALSE); } else if ( ( nRow < nStartRow ) || ( nRow == nStartRow && nBuffCol < nStartCol ) ) { // dragging before the selection -- delete the selection first (if move) if ( bMove ) DeleteSelection( FALSE, FALSE ); m_Selection.SetEmptySelection( nBuffCol, nRow ); ReplaceSelection( pszText, FALSE, TRUE, TRUE ); } else { // dragging after the selection -- insert the new text first m_Selection.SetEmptySelection( nBuffCol, nRow ); ReplaceSelection( pszText, FALSE, TRUE, TRUE ); int nStartRowNew, nStartColNew, nEndRowNew, nEndColNew; m_Selection.GetNormalizedBufferSelection( nStartColNew, nStartRowNew, nEndColNew, nEndRowNew ); if ( bMove ) { m_Selection.SetExtendedSelection( nStartCol, nStartRow, nEndCol, nEndRow ); DeleteSelection( FALSE, FALSE ); } // we want to select the dropped text, but we must first factor in the // shift caused by the text that was just deleted. if ( nStartRowNew == nEndRow ) { ASSERT( nStartColNew >= nEndCol ); if ( nStartRow == nEndRow ) nStartColNew -= nEndCol - nStartCol; else if ( nStartRowNew == nEndRow ) nStartColNew = nStartCol + nStartColNew - nEndCol; else nStartColNew -= nEndCol; } nStartRowNew -= nEndRow - nStartRow; if ( nEndRowNew == nEndRow ) { ASSERT( nEndColNew > nEndCol ); if ( nStartRow == nEndRow ) nEndColNew -= nEndCol - nStartCol; else nEndColNew -= nEndCol; } nEndRowNew -= nEndRow - nStartRow; // select the dropped text m_Selection.SetExtendedSelection( nStartColNew, nStartRowNew, nEndColNew, nEndRowNew ); } } } else { // data came from another window -- just insert it as usual -- the other window // will remove the text if a move m_Selection.SetEmptySelection( nBuffCol, nRow ); ReplaceSelection( pszText, FALSE, TRUE, TRUE ); } if ( m_pActiveView != pView ) { SetActiveView( pView ); } m_Buffer.EndEdit( m_Selection.GetEndRow(), m_Selection.GetEndCol() ); GlobalUnlock( hMem ); if ( !stgm.pUnkForRelease ) { // provider of data decided that we should release the data ReleaseStgMedium( &stgm ); } bDropped = TRUE; } m_Selection.ShowCaret(); return bDropped; }
void DataModelListCtrlAdaptor::OnRemove() { DeleteSelection(true); }
void EditTextTask::InsertText(const wxString &str) /// { if ( !m_textgraph ) return; if ( HasSelection() ) DeleteSelection(); /// /////////////////////////////////////////////// // generate the new string: wxString text; wxString s( *( m_textgraph->m_brick->GetTextByNumber(m_textgraph->m_nmbr) ) ); wxString insstr = str; insstr.Replace(_T("\t"), _T(" ")); insstr.Replace(_T("\r"), _T("\n")); wxInt32 pos; wxUint32 line = 0; do{ pos = s.Find('\n'); wxString te = s; if ( pos != -1 ) { te = s.SubString(0, pos); s = s.SubString(pos+1, s.Length() ); } if ( line == m_posa.line ) { text += te.SubString(0, m_posa.column-1); text += insstr; text += te.SubString( m_posa.column, te.Length() ); } else text += te; ++line; } while ( pos != -1); // update the position // cals size of inserted text (lines and columns) line = 0; s = insstr; do { pos = s.Find('\n'); if ( pos != -1 ) { line++; s = s.SubString( pos+1, s.Length() ); } } while ( pos != -1); // update local position variable if ( line ) { m_posa.line += line; m_posa.column = s.Length(); } else m_posa.column += s.Length(); m_posb = m_posa; m_nfc->GetCommandProcessor()->Submit( new NassiEditTextCommand( m_nfc, m_textgraph->m_brick, text, m_textgraph->m_nmbr )); }
void DataListCtrl::OnDelete(wxCommandEvent &event) { DeleteSelection(); }
LRESULT GraphicsWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: // Should be created before the first WM_PAINT message if (FAILED(D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &pFactory))) { return -1; // Fail CreateWindowEx. } DPIScale::Initialize(pFactory); SetTimer(m_hwnd, m_nTimerID, 1000, NULL); return 0; case WM_DESTROY: KillTimer(m_hwnd, m_nTimerID); DiscardGraphicsResources(); SafeRelease(&pFactory); break; case WM_TIMER: InvalidateRect(m_hwnd, NULL, FALSE); // allow the clock faces to cycle the second hand break; case WM_PAINT: OnPaint(); return 0; case WM_LBUTTONDOWN: OnLButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), (DWORD)wParam); return 0; case WM_LBUTTONUP: OnLButtonUp(); return 0; case WM_MOUSEMOVE: OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), (DWORD)wParam); return 0; case WM_SIZE: Resize(); return 0; case WM_COMMAND: // We've received an accelerator command switch (LOWORD(wParam)) { case ID_DRAW_MODE: SetMode(DrawMode); break; case ID_SELECT_MODE: SetMode(SelectMode); break; case ID_TOGGLE_MODE: if (mode == DrawMode) { SetMode(SelectMode); } else { SetMode(DrawMode); } break; case ID_MOVE_UP: MoveSelectionUp(); break; case ID_MOVE_DOWN: MoveSelectionDown(); break; case ID_DELETE: DeleteSelection(); break; } return 0; case WM_SETCURSOR: // The mouse is back on our window, maintain the cursor display we had before if (LOWORD(lParam) == HTCLIENT) { SetCursor(hCursor); return TRUE; } break; } return DefWindowProc(m_hwnd, uMsg, wParam, lParam); }
void CPlainTextEditor::OverwriteSelection(char* szText) { miEditPos = DeleteSelection(); Paste(szText); }
void TextManip::DeleteLine () { Select(_text->BeginningOfLine(_mark), _text->BeginningOfNextLine(_mark)); DeleteSelection(); }
void EditTextTask::Delete() { m_posb = m_posa; IncrementPosition(m_posb); if(HasSelection())DeleteSelection(); }
void TextManip::InsertCharacter (char c) { DeleteSelection(); InsertText(&c, 1); }
void CEdit::ReplaceAllInSelection() { CHourGlass wait( this ); CDelayRepaint delay( this ); if ( m_Buffer.GetLineCount() && g_FindReplaceData.m_pszFindText && *g_FindReplaceData.m_pszFindText ) { int nStartCol, nStartRow, nEndCol, nEndRow; m_Selection.GetNormalizedBufferSelection( nStartCol, nStartRow, nEndCol, nEndRow ); m_Buffer.BeginEdit( nStartRow, nStartCol ); BOOL bFoundText = FALSE; int nFirstRow = 0, nFirstCol = 0; int nCol = nStartCol; int nRow = nStartRow; int cbFindText = _tcslen( g_FindReplaceData.m_pszFindText ); int cbReplaceText = _tcslen( g_FindReplaceData.m_pszReplaceText ); for ( ;; ) { BOOL bWrapped; int cbMatched; if ( m_Buffer.FindText( g_FindReplaceData.m_pszFindText, cbFindText, TRUE, g_FindReplaceData.m_bCaseSensitiveSearch, g_FindReplaceData.m_bWholeWordOnly, g_FindReplaceData.m_bRegExp, nRow, nCol, bWrapped, cbMatched ) ) { if ( !bFoundText ) { bFoundText = TRUE; nFirstRow = nRow; nFirstCol = nCol; } else { BOOL bOutsideSel = ( nRow < nStartRow ) || ( nRow == nStartRow && nCol < nStartCol ) || ( nRow > nEndRow ) || ( nRow == nEndRow && nCol >= nEndCol ); if ( bOutsideSel || ( bWrapped && ( nRow >= nFirstRow ) && ( nCol >= nFirstCol ) ) ) { // no longer in selection, or wrapped around to the start -- done! break; } } m_Selection.SetExtendedSelection( nCol, nRow, nCol + cbMatched, nRow ); if ( g_FindReplaceData.m_pszReplaceText ) { FindReplaceSelection(); nCol += cbReplaceText; } else { DeleteSelection( FALSE, FALSE ); nCol += cbMatched; } } else { break; } } if ( bFoundText && !m_pActiveView->LineIsVisible( nFirstRow ) ) { // found occurrences of the find text. Go to the location of the first bookmark GoToLine( nFirstRow, TRUE ); } Repaint( FALSE ); m_Buffer.EndEdit( nStartRow, nStartCol ); } }