/* virtual methods from class ActionListener */ void OnAction(int id) override { switch (id) { case COPY: OnCopy(); break; case PASTE: OnPaste(); break; } }
void EditorBase::InitActions() { mNewAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); mNewAct->setShortcut(tr("Ctrl+N")); mNewAct->setStatusTip(tr("Create a new file")); connect(mNewAct, SIGNAL(triggered()), this, SLOT(OnNew())); mOpenAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); mOpenAct->setShortcut(tr("Ctrl+O")); mOpenAct->setStatusTip(tr("Open an existing file")); connect(mOpenAct, SIGNAL(triggered()), this, SLOT(OnOpen())); mSaveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); mSaveAct->setShortcut(tr("Ctrl+S")); mSaveAct->setStatusTip(tr("Save the document to disk")); connect(mSaveAct, SIGNAL(triggered()), this, SLOT(OnSave())); mSaveAsAct = new QAction(tr("Save &As..."), this); mSaveAsAct->setStatusTip(tr("Save the document under a new name")); connect(mSaveAsAct, SIGNAL(triggered()), this, SLOT(OnSaveAs())); mExitAct = new QAction(tr("E&xit"), this); mExitAct->setShortcut(tr("Ctrl+Q")); mExitAct->setStatusTip(tr("Exit the application")); connect(mExitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); mCutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this); mCutAct->setShortcut(tr("Ctrl+X")); mCutAct->setStatusTip(tr("Cut the current selection's contents to the clipboard")); connect(mCutAct, SIGNAL(triggered()), this, SLOT(OnCut())); mCopyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this); mCopyAct->setShortcut(tr("Ctrl+C")); mCopyAct->setStatusTip(tr("Copy the current selection's contents to the clipboard")); connect(mCopyAct, SIGNAL(triggered()), this, SLOT(OnCopy())); mPasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this); mPasteAct->setShortcut(tr("Ctrl+V")); mPasteAct->setStatusTip(tr("Paste the clipboard's contents into the current selection")); connect(mPasteAct, SIGNAL(triggered()), this, SLOT(OnPaste())); mSeparatorAct = new QAction(this); mSeparatorAct->setSeparator(true); mAboutAct = new QAction(tr("&About"), this); mAboutAct->setStatusTip(tr("Show the application's About box")); connect(mAboutAct, SIGNAL(triggered()), this, SLOT(OnAbout())); mAboutQtAct = new QAction(tr("About &Qt"), this); mAboutQtAct->setStatusTip(tr("Show the Qt library's About box")); connect(mAboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); }
// ----------------------------------------------------------------------------------- bool cgUILineEdit::OnMessage( UINT uMsg, unsigned wparam, unsigned lparam ) { switch (uMsg) { case WM_LBUTTONDOWN: { OnLButtonDown(wparam, lparam); }break; case WM_MOUSEMOVE: { OnMouseMove(wparam, lparam); }break; case WM_CHAR: { return OnChar(wparam, lparam); }break; case WM_KEYDOWN: { if ( OnKeyDown(wparam, lparam)) return true; }break; case WM_LBUTTONDBLCLK: { SetSelBegin(0); SetCursorPos(m_strText.length()); }break; case cgUIMsg_Copy: { return OnCopy(); }break; case cgUIMsg_Cut: { return OnCut(); }break; case cgUIMsg_Paste: { return OnPaste(); }break; case cgUIMsg_MouseOut: { OnMouseMove(wparam, lparam); }break; case cgUIMsg_MouseIn: { } default: break; } return cgUIWidget::OnMessage(uMsg, wparam, lparam); }
static bool OnKeyDown(WndForm &sender, unsigned key_code) { DataFieldEnum *dfe; /* map the Altair hardware buttons */ switch (key_code){ case VK_UP: dfe = (DataFieldEnum *)edit_select->GetDataField(); dfe->Dec(); edit_select->RefreshDisplay(); return true; case VK_DOWN: dfe = (DataFieldEnum *)edit_select->GetDataField(); dfe->Inc(); edit_select->RefreshDisplay(); return true; case VK_LEFT: dfe = (DataFieldEnum *)edit_content->GetDataField(); dfe->Dec(); edit_content->RefreshDisplay(); return true; case VK_RIGHT: dfe = (DataFieldEnum *)edit_content->GetDataField(); dfe->Inc(); edit_content->RefreshDisplay(); return true; case VK_APP1: OnNameAccess(*buttonPaste); return true; case '6': sender.SetModalResult(mrOK); return true; case '7': OnCopy(*buttonPaste); return true; case '8': OnPaste(*buttonPaste); return true; default: return false; } }
static bool OnKeyDown(unsigned key_code) { DataFieldEnum *dfe; /* map the Altair hardware buttons */ switch (key_code){ case KEY_UP: dfe = (DataFieldEnum *)edit_select->GetDataField(); dfe->Dec(); edit_select->RefreshDisplay(); return true; case KEY_DOWN: dfe = (DataFieldEnum *)edit_select->GetDataField(); dfe->Inc(); edit_select->RefreshDisplay(); return true; case KEY_LEFT: dfe = (DataFieldEnum *)edit_content->GetDataField(); dfe->Dec(); edit_content->RefreshDisplay(); return true; case KEY_RIGHT: dfe = (DataFieldEnum *)edit_content->GetDataField(); dfe->Inc(); edit_content->RefreshDisplay(); return true; case KEY_APP1: edit_name->BeginEditing(); return true; case '6': wf->SetModalResult(mrOK); return true; case '7': OnCopy(); return true; case '8': OnPaste(); return true; default: return false; } }
bool InfoBoxesConfigWidget::KeyPress(unsigned key_code) { /* map the Altair hardware buttons */ switch (key_code){ case KEY_UP: ((DataFieldEnum &)GetDataField(INFOBOX)).Dec(); GetControl(INFOBOX).RefreshDisplay(); return true; case KEY_DOWN: ((DataFieldEnum &)GetDataField(INFOBOX)).Inc(); GetControl(INFOBOX).RefreshDisplay(); return true; case KEY_LEFT: ((DataFieldEnum &)GetDataField(CONTENT)).Dec(); GetControl(CONTENT).RefreshDisplay(); return true; case KEY_RIGHT: ((DataFieldEnum &)GetDataField(CONTENT)).Inc(); GetControl(CONTENT).RefreshDisplay(); return true; case KEY_APP1: GetControl(NAME).BeginEditing(); return true; case '6': dialog.OnAction(mrOK); return true; case '7': OnCopy(); return true; case '8': OnPaste(); return true; default: return false; } }
bool OnCommand(HWND hwnd, WORD commandID) { HRESULT hr = S_OK; switch (commandID) { case IDM_EXIT: DestroyWindow(hwnd); break; case ID_EDIT_COPY: OnCopy(hwnd); break; case ID_EDIT_PASTE: OnPaste(hwnd); break; case ID_EDIT_FONT: hr = OnChooseFont(hwnd); break; case ID_EDIT_INCREASETEXTSIZE: hr = IncreaseFontSize(hwnd); break; case ID_EDIT_DECREASETEXTSIZE: hr = DecreaseFontSize(hwnd); break; case ID_VIEW_ROTATELEFT: if ((g_degrees -= 3) < 0) g_degrees += 360; SetTransform(hwnd); InvalidateRect(hwnd, NULL, TRUE); break; case ID_VIEW_ROTATERIGHT: if ((g_degrees += 3) >= 360) g_degrees -= 360; SetTransform(hwnd); InvalidateRect(hwnd, NULL, TRUE); break; case ID_VIEW_NUDGELEFT: g_animationStartCount = GetTickCount(); g_animationDuration = 0.1f; g_animationStartX = g_animationCurrentX; g_animationEndX = g_animationCurrentX - 10.0f; InvalidateRect(hwnd, NULL, TRUE); break; case ID_VIEW_NUDGERIGHT: g_animationStartCount = GetTickCount(); g_animationDuration = 0.1f; g_animationStartX = g_animationCurrentX; g_animationEndX = g_animationCurrentX + 10.0f; InvalidateRect(hwnd, NULL, TRUE); break; case ID_VIEW_SHOWMAGNIFIER: g_magnifier.visible = !g_magnifier.visible; if (g_renderer != NULL) { g_renderer->SetMagnifier(g_magnifier); InvalidateRect(hwnd, NULL, TRUE); } break; case ID_MAGNIFIERTYPE_VECTOR: SetMagnifierType(hwnd, MagnifierInfo::Vector); break; case ID_MAGNIFIERTYPE_PIXELS: SetMagnifierType(hwnd, MagnifierInfo::Pixel); break; case ID_MAGNIFIERTYPE_SUBPIXELS: SetMagnifierType(hwnd, MagnifierInfo::Subpixel); break; case ID_MAGNIFIERSCALE_3X: SetMagnifierScale(hwnd, 3); break; case ID_MAGNIFIERSCALE_6X: SetMagnifierScale(hwnd, 6); break; case ID_OPTIONS_NATURALMODE: SetMeasuringMode(hwnd, DWRITE_MEASURING_MODE_NATURAL); break; case ID_OPTIONS_GDICLASSICMODE: SetMeasuringMode(hwnd, DWRITE_MEASURING_MODE_GDI_CLASSIC); break; case ID_OPTIONS_GDINATURALMODE: SetMeasuringMode(hwnd, DWRITE_MEASURING_MODE_GDI_NATURAL); break; case ID_OPTIONS_USEDIRECT2D: SetRenderer(hwnd, RendererD2D); break; case ID_OPTIONS_USEDIRECTWRITE: SetRenderer(hwnd, RendererDWrite); break; default: return false; } if (FAILED(hr)) PostQuitMessage(hr); return true; }
// // Process keyboard-navigation keys // LONG TextViewBase::OnKeyDown(UINT nKeyCode, UINT nFlags) { bool fCtrlDown = IsKeyPressed(VK_CONTROL); bool fShiftDown = IsKeyPressed(VK_SHIFT); BOOL fAdvancing = FALSE; long oldCursorOffset = m_nSelectionEnd; // // Process the key-press. Cursor movement is different depending // on if <ctrl> is held down or not, so act accordingly // switch(nKeyCode) { case VK_SHIFT: case VK_CONTROL: return 0; case 'a': case 'A': { if(fCtrlDown) SelectAll(); } return 0; // CTRL+Z undo case 'z': case 'Z': if(fCtrlDown && Undo()) /*NotifyParent(TVN_CHANGED);*/ return 0; // CTRL+Y redo case 'y': case 'Y': if(fCtrlDown && Redo()) //NotifyParent(TVN_CHANGED); return 0; // CTRL+C copy case 'c': case 'C': { //if(fCtrlDown && Redo()) // NotifyParent(TVN_CHANGED); if(fCtrlDown) return OnCopy(); else break; } case 'x': case 'X': { if(fCtrlDown) return OnCut(); else break; } case 'v': case 'V': { if(fCtrlDown) return OnPaste(); else break; } // Change insert mode / clipboard copy&paste case VK_INSERT: if(fCtrlDown) { OnCopy(); NotifyParent(TVN_CHANGED); } else if(fShiftDown) { OnPaste(); NotifyParent(TVN_CHANGED); } else { if(m_nEditMode == MODE_INSERT) m_nEditMode = MODE_OVERWRITE; else if(m_nEditMode == MODE_OVERWRITE) m_nEditMode = MODE_INSERT; NotifyParent(TVN_EDITMODE_CHANGE); } return 0; case VK_DELETE: if(m_nEditMode != MODE_READONLY) { if(fShiftDown) OnCut(); else ForwardDelete(); NotifyParent(TVN_CHANGED); } return 0; case VK_BACK: if(m_nEditMode != MODE_READONLY) { BackDelete(); fAdvancing = FALSE; NotifyParent(TVN_CHANGED); } return 0; case VK_LEFT: if(fCtrlDown) MoveWordPrev(); else MoveCharPrev(); fAdvancing = FALSE; break; case VK_RIGHT: if(fCtrlDown) MoveWordNext(); else MoveCharNext(); fAdvancing = TRUE; break; case VK_UP: if(fCtrlDown) Scroll(0, -1); else MoveLineUp(1); break; case VK_DOWN: if(fCtrlDown) Scroll(0, 1); else MoveLineDown(1); break; case VK_PRIOR: if(!fCtrlDown) MovePageUp(); break; case VK_NEXT: if(!fCtrlDown) MovePageDown(); break; case VK_HOME: if(fCtrlDown) MoveFileStart(); else MoveLineStart(m_nCurrentLine); break; case VK_END: if(fCtrlDown) MoveFileEnd(); else MoveLineEnd(m_nCurrentLine); break; default: return 0; } // Extend selection if <shift> is down if(fShiftDown) { InvalidateRange(m_nSelectionEnd, oldCursorOffset); //m_nSelectionEnd = m_nCursorOffset; } // Otherwise clear the selection else { if(m_nSelectionStart != m_nSelectionEnd) InvalidateRange(m_nSelectionStart, m_nSelectionEnd); //m_nSelectionEnd = m_nCursorOffset; m_nSelectionStart = m_nSelectionEnd; } // update caret-location (xpos, line#) from the offset //UpdateCaretOffset(m_nCursorOffset, fAdvancing, &m_nCaretPosX, &m_nCurrentLine); CHAR_POS cp; FilePosToCharPos(m_nSelectionEnd, &cp); m_nCurrentLine_D = cp.logLine; // maintain the caret 'anchor' position *except* for up/down actions if(nKeyCode != VK_UP && nKeyCode != VK_DOWN) { //m_nAnchorPosX = m_nCaretPosX; // scroll as necessary to keep caret within viewport //ScrollToPosition(m_nCaretPosX, m_nCurrentLine); } else { // scroll as necessary to keep caret within viewport if(!fCtrlDown); //ScrollToPosition(m_nCaretPosX, m_nCurrentLine); } NotifyParent(TVN_CURSOR_CHANGE); return 0; }
bool TextViewBase::HandleWndProc(UINT msg, WPARAM wParam, LPARAM lParam, LONG *pResult) { HIMC hIMC = NULL; switch (msg) { // Draw contents of TextView whenever window needs updating case WM_ERASEBKGND: *pResult = 1; return true; // Need to custom-draw the border for XP/Vista themes case WM_NCPAINT: *pResult = OnNcPaint((HRGN)wParam); return true; case WM_PAINT: *pResult = OnPaint(); return true; // Set a new font case WM_SETFONT: *pResult = OnSetFont((HFONT)wParam); return true; case WM_SIZE: *pResult = OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); return true; case WM_VSCROLL: *pResult = OnVScroll(LOWORD(wParam), HIWORD(wParam)); return true; case WM_HSCROLL: *pResult = OnHScroll(LOWORD(wParam), HIWORD(wParam)); return true; case WM_MOUSEACTIVATE: *pResult = OnMouseActivate((HWND)wParam, LOWORD(lParam), HIWORD(lParam)); return true; //case WM_CONTEXTMENU: // return OnContextMenu((HWND)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); case WM_MOUSEWHEEL: if (IsKeyPressed(VK_CONTROL)) return false; else *pResult = OnMouseWheel((short)HIWORD(wParam)); return true; case WM_SETFOCUS: *pResult = OnSetFocus((HWND)wParam); return true; case WM_KILLFOCUS: *pResult = OnKillFocus((HWND)wParam); return true; // make sure we get arrow-keys, enter, tab, etc when hosted inside a dialog case WM_GETDLGCODE: *pResult = DLGC_WANTALLKEYS;//DLGC_WANTMESSAGE;//DLGC_WANTARROWS; return true; case WM_LBUTTONDOWN: *pResult = OnLButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_LBUTTONUP: *pResult = OnLButtonUp(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_LBUTTONDBLCLK: *pResult = OnLButtonDblClick(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_RBUTTONDOWN: *pResult = OnRButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_MOUSEMOVE: *pResult = OnMouseMove(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_KEYDOWN: *pResult = OnKeyDown(wParam, lParam); return true; case WM_UNDO: case TXM_UNDO: case EM_UNDO: *pResult = Undo(); return true; case TXM_REDO : case EM_REDO: *pResult = Redo(); return true; case TXM_CANUNDO: case EM_CANUNDO: *pResult = CanUndo(); return true; case TXM_CANREDO: case EM_CANREDO: *pResult = CanRedo(); return true; case WM_CHAR: OutputDebugString(L"WM_CHAR\n"); *pResult = OnChar(wParam, lParam); return true; case WM_SETCURSOR: if (LOWORD(lParam) == HTCLIENT) { *pResult = TRUE; return true; } else return false; case WM_COPY: *pResult = OnCopy(); return true; case WM_CUT: *pResult = OnCut(); return true; case WM_PASTE: *pResult = OnPaste(); return true; case WM_CLEAR: *pResult = OnClear(); return true; case WM_GETTEXT: *pResult = GetText((WCHAR*)lParam, 0, (ULONG)wParam); return true; case WM_SETTEXT: *pResult = OnSetText((WCHAR*)lParam, lstrlen((WCHAR*)lParam)); return true; //case TXM_SETTEXT: // { // ClearFile(); // EnterText((WCHAR*)lParam, (LONG)wParam); // return 0; // } case WM_TIMER: *pResult = OnTimer(wParam); return true; case WM_IME_STARTCOMPOSITION: OutputDebugString(L"WM_IME_STARTCOMPOSITION\n"); *pResult = OnStartComposition(wParam, lParam); return true; //return DefWindowProc(m_hWnd, WM_IME_STARTCOMPOSITION, wParam, lParam); case WM_IME_COMPOSITION: OutputDebugString(L"WM_IME_COMPOSITION\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_COMPOSITION, wParam, lParam); return true; //return OnComposition(wParam, lParam); case WM_IME_ENDCOMPOSITION: OutputDebugString(L"WM_IME_ENDCOMPOSITION\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_ENDCOMPOSITION, wParam, lParam); return true; //return OnEndComposition(wParam, lParam); case WM_IME_CHAR: OutputDebugString(L"WM_IME_CHAR\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_CHAR, wParam, lParam); return true; case WM_IME_CONTROL: OutputDebugString(L"WM_IME_CONTROL\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_CONTROL, wParam, lParam); return true; case WM_IME_NOTIFY: OutputDebugString(L"WM_IME_NOTIFY\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_NOTIFY, wParam, lParam); return true; //return HandleImeNotify(wParam, lParam); case WM_IME_REQUEST: OutputDebugString(L"WM_IME_REQUEST\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_REQUEST, wParam, lParam); return true; case WM_INPUTLANGCHANGE: *pResult = OnInputLanChange(wParam, lParam); return true; case TXM_PRINT: *pResult = OnPrint((HDC)wParam, (int)lParam); return true; // case TXM_OPENFILE: *pResult = OpenFile((TCHAR *)lParam); return true; case TXM_SAVEFILE: *pResult = SaveFile((TCHAR *)lParam); return true; case TXM_IMPORTFILE: *pResult = ImportFile((TCHAR *)lParam, (int)wParam); return true; case TXM_EXPORTFILE: { int convertype = LOWORD(wParam); int utf_type = HIWORD(wParam); *pResult = ExportFile((TCHAR *)lParam, convertype, utf_type); return true; } case TXM_CLEAR: *pResult = ClearFile(); return true; case TXM_GETFORMAT: *pResult = m_pTextDoc->getformat(); return true; case TXM_SETFORMAT: *pResult = m_pTextDoc->setformat((int)wParam); return true; case TXM_GETSELSIZE: *pResult = SelectionSize(); return true; case TXM_SETSELALL: *pResult = SelectAll(); return true; case TXM_GETCURPOS: *pResult = m_CurrentCharPos.get(); return true; case TXM_GETCURLINE_D: *pResult = m_nCurrentLine_D; return true; case TXM_GETCURLINE_V: *pResult = OnGetCurLineV(); return true; case TXM_GETCURCOL: *pResult = OnGetCurCol(); return true; case TXM_GETEDITMODE: *pResult = m_nEditMode; return true; case TXM_SETEDITMODE: lParam = m_nEditMode; m_nEditMode = wParam; *pResult = lParam; return true; case TXM_FIND_INIT: FindInitial((WCHAR*)lParam); *pResult = 0; return true; case TXM_FIND: { BOOL m = (BOOL)LOWORD(wParam); BOOL b = (BOOL)HIWORD(wParam); //FindText() if (b) *pResult = FindBackward(m, NULL); else *pResult = FindForward(m, NULL); return true; } case TXM_FIND_TEXT: { FIND_OPTION* fp = (FIND_OPTION*)(lParam); *pResult = Find_Text(fp->text, lstrlen(fp->text), fp->fBackward, fp->fMachCase, fp->fWarp); return true; } case TXM_REPLACE_TEXT: { *pResult = Replace_Text((REPLACE_OPTION*)(lParam)); return true; } case TXM_SETRESMODULE: { *pResult = OnSetResModule((HMODULE)lParam); return true; } case WM_GETTEXTLENGTH: case TXM_GETTEXTLEN: { *pResult = OnGetTextLen(); return true; } case TXM_REPLACE: { BOOL ra = (BOOL)LOWORD(wParam); WORD mb = (WORD)HIWORD(wParam); BOOL m = (BOOL)LOBYTE(mb); BOOL b = (BOOL)HIBYTE(mb); if (b) *pResult = FindBackward(m, (WCHAR*)lParam, ra); else *pResult = FindForward(m, (WCHAR*)lParam, ra); return true; } case TXM_FIND_GETTEXTLENGTH: *pResult = m_pFndIterator->find_text_length(); return true; case TXM_GETSELSTART: *pResult = m_nSelectionStart; return true; case TXM_GETSELEND: *pResult = m_nSelectionEnd; return true; case TXM_GETSELTEXT: *pResult = OnGetSelText((WCHAR*)wParam, ULONG(lParam)); return true; case TXM_SETTESTERMODE: OnTesterMode((bool)wParam); *pResult = 0; return true; case TXM_SETCONTEXTMENU: m_hUserMenu = (HMENU)wParam; *pResult = 0; return true; case TXM_STATISTIC: *pResult = OnDoStatistic((STATISTIC*)(lParam)); return true; case TXM_GETCONVERTTYPES: *pResult = OnGetConvertTypes((convert_type*)(lParam)); return true; case EM_GETSEL: *pResult = OnMsg_EM_GETSEL((ULONG*)wParam, (ULONG*)lParam); return true; case EM_SETSEL: *pResult = OnMsg_EM_SETSEL((LONG)wParam, (LONG)lParam); return true; default: return false; } }
LRESULT HexView::OnKeyDown(UINT nVirtualKey, UINT nRepeatCount, UINT nFlags) { BOOL fForceUpdate = FALSE; bool fCtrlDown = IsKeyDown(VK_CONTROL); bool fShiftDown = IsKeyDown(VK_SHIFT); size_w oldoffset = m_nCursorOffset; fForceUpdate = !IsKeyDown(VK_SHIFT); if(nVirtualKey == VK_CONTROL || nVirtualKey == VK_SHIFT || nVirtualKey == VK_MENU) return 0; switch(nVirtualKey) { case VK_ESCAPE: fForceUpdate = TRUE; break; case VK_INSERT: if(fCtrlDown) { OnCopy(); } else if(fShiftDown) { OnPaste(); } else { if(m_nEditMode == HVMODE_INSERT) m_nEditMode = HVMODE_OVERWRITE; else if(m_nEditMode == HVMODE_OVERWRITE) m_nEditMode = HVMODE_INSERT; NotifyParent(HVN_EDITMODE_CHANGE); } return 0; case 'z': case 'Z': m_nSubItem = 0; if(fCtrlDown) Undo(); return 0; // CTRL+Y redo case 'y': case 'Y': m_nSubItem = 0; if(fCtrlDown) Redo(); return 0; case VK_DELETE: // can only erase when in Insert mode if(m_nEditMode == HVMODE_INSERT || CheckStyle(HVS_ALWAYSDELETE) && (m_nEditMode == HVMODE_INSERT || m_nEditMode == HVMODE_OVERWRITE) && SelectionSize() == 0) { ForwardDelete(); } else if(m_nEditMode != HVMODE_READONLY) { BYTE b[] = { 0 }; FillData(b, 1, SelectionSize()); } return 0; case VK_BACK: // can only erase when in Insert mode if(m_nEditMode == HVMODE_INSERT || CheckStyle(HVS_ALWAYSDELETE) && (m_nEditMode == HVMODE_INSERT || m_nEditMode == HVMODE_OVERWRITE)) { BackDelete(); } else { //PostMessage(m_hWnd, WM_KEYDOWN, INPUT inp = { INPUT_KEYBOARD }; inp.ki.wVk = VK_LEFT; SendInput(1, &inp, sizeof(inp)); } return 0; case VK_LEFT: //if ctrl held down, then scroll the viewport around! if(IsKeyDown(VK_CONTROL)) { PostMessage(m_hWnd, WM_HSCROLL, SB_LINEUP, 0L); return 0; } if(m_nCursorOffset > 0) m_nCursorOffset--; m_fCursorAdjustment = FALSE; break; case VK_RIGHT: //if ctrl held down, then scroll the viewport around! if(IsKeyDown(VK_CONTROL)) { PostMessage(m_hWnd, WM_HSCROLL, SB_LINEDOWN, 0L); return 0; } if(m_nCursorOffset < m_pDataSeq->size()) { m_nCursorOffset++; if(m_nCursorOffset == m_pDataSeq->size() && m_pDataSeq->size() % m_nBytesPerLine == 0) m_fCursorAdjustment = TRUE; else m_fCursorAdjustment = FALSE; } break; case VK_UP: //if ctrl held down, then scroll the viewport around! if(IsKeyDown(VK_CONTROL)) { PostMessage(m_hWnd, WM_VSCROLL, SB_LINEUP, 0L); return 0; } if(m_nCursorOffset > (unsigned)m_nBytesPerLine) m_nCursorOffset -= m_nBytesPerLine; break; case VK_DOWN: //if ctrl held down, then scroll the viewport around! if(IsKeyDown(VK_CONTROL)) { PostMessage(m_hWnd, WM_VSCROLL, SB_LINEDOWN, 0L); return 0; } m_nCursorOffset += min((size_w)m_nBytesPerLine, m_pDataSeq->size() - m_nCursorOffset); // if in the last partial line, don't go to end of file, rather // stay at "bottom" of file/window if(m_nCursorOffset >= m_pDataSeq->size() && !m_fCursorAdjustment) { // test if in a partial line if( oldoffset % m_nBytesPerLine < m_pDataSeq->size() % m_nBytesPerLine || m_pDataSeq->size() % m_nBytesPerLine == 0) { m_nCursorOffset = oldoffset; fForceUpdate = TRUE; } } break; case VK_HOME: //if ctrl held down, then scroll the viewport around! if(fCtrlDown) { m_nCursorOffset = 0; PostMessage(m_hWnd, WM_VSCROLL, SB_TOP, 0L); } else { if(m_fCursorAdjustment && m_nCursorOffset > 0) m_nCursorOffset--; m_nCursorOffset -= m_nCursorOffset % m_nBytesPerLine; } m_fCursorAdjustment = FALSE; break; case VK_END: if(IsKeyDown(VK_CONTROL)) { m_nCursorOffset = m_pDataSeq->size(); if(m_nCursorOffset % m_nBytesPerLine == 0) m_fCursorAdjustment = TRUE; PostMessage(m_hWnd, WM_VSCROLL, SB_BOTTOM, 0L); } else { // if not already at very end of line if(m_fCursorAdjustment == FALSE) { if(m_pDataSeq->size() - m_nBytesPerLine >= m_nCursorOffset && m_pDataSeq->size() >= m_nBytesPerLine) { m_nCursorOffset += m_nBytesPerLine - (m_nCursorOffset % m_nBytesPerLine); m_fCursorAdjustment = TRUE; } else { m_nCursorOffset += m_pDataSeq->size()-m_nCursorOffset; } } if(m_nCursorOffset >= m_pDataSeq->size() && m_pDataSeq->size() % m_nBytesPerLine == 0) m_fCursorAdjustment = TRUE; } break; case VK_PRIOR: // pageup m_nCursorOffset -= min(m_nCursorOffset, (size_w)m_nBytesPerLine * m_nWindowLines); break; case VK_NEXT: // pagedown m_nCursorOffset += min(m_pDataSeq->size() - m_nCursorOffset, (size_w)m_nBytesPerLine * m_nWindowLines); if(m_nCursorOffset >= m_pDataSeq->size() && m_pDataSeq->size() % m_nBytesPerLine == 0) { m_fCursorAdjustment = TRUE; } break; case VK_TAB: m_nWhichPane ^= 1; fForceUpdate = TRUE; if(m_ColourList[HVC_SELECTION] != m_ColourList[HVC_SELECTION2]) { InvalidateRange(m_nSelectionStart, m_nSelectionEnd); } break; default: // don't know what this key is, so exit return 0; } m_nSubItem = 0; if(m_nCursorOffset != oldoffset || fForceUpdate) { // SHIFT key being held down? if(IsKeyDown(VK_SHIFT)) { // extend the selection m_nSelectionEnd = m_nCursorOffset; InvalidateRange(oldoffset, m_nSelectionEnd); } else if(nVirtualKey != VK_TAB) { // clear any selection if(m_nSelectionEnd != m_nSelectionStart) InvalidateRange(m_nSelectionEnd, m_nSelectionStart); m_nSelectionEnd = m_nCursorOffset; m_nSelectionStart = m_nCursorOffset; } ScrollToCaret(); NotifyParent(HVN_CURSOR_CHANGE); if(nVirtualKey == VK_NEXT || nVirtualKey == VK_PRIOR) { RefreshWindow(); } } return 0; }