int EList::ExecCommand(int Command, ExState &State) { int W = 1; int H = 1; if (View && View->MView && View->MView->Win) { View->MView->ConQuerySize(&W, &H); H--; } FixPos(); switch (Command) { case ExMoveLeft: return MoveLeft(); case ExMoveRight: return MoveRight(); case ExMoveUp: return MoveUp(); case ExMoveDown: return MoveDown(); case ExMovePageUp: return MovePageUp(); case ExMovePageDown: return MovePageDown(); case ExScrollLeft: return ScrollLeft(8); case ExScrollRight: return ScrollRight(8); case ExMovePageStart: return MovePageStart(); case ExMovePageEnd: return MovePageEnd(); case ExMoveFileStart: return MoveFileStart(); case ExMoveFileEnd: return MoveFileEnd(); case ExMoveLineStart: return MoveLineStart(); case ExMoveLineEnd: return MoveLineEnd(); case ExRescan: RescanList(); return ErOK; case ExActivate: return Activate(); case ExListMark: return Mark(); case ExListUnmark: return Unmark(); case ExListToggleMark: return ToggleMark(); case ExListMarkAll: return MarkAll(); case ExListUnmarkAll: return UnmarkAll(); case ExListToggleMarkAll: return ToggleMarkAll(); } return EModel::ExecCommand(Command, State); }
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; }
/* * HandleMouseEvent - handle main editor mouse events */ vi_rc HandleMouseEvent( void ) { windim win_x, win_y; window_id wid; info *cinfo; window *w; int i; bool diff_word; vi_rc rc; wid = GetMousePosInfo( &win_x, &win_y ); if( BAD_ID( wid ) ) { return( ERR_NO_ERR ); } w = WINDOW_FROM_ID( wid ); if( !w->has_border ) { win_x += 1; win_y += 1; } if( dragThumb ) { if( LastMouseEvent == MOUSE_RELEASE ) { dragThumb = false; } if( wid != current_window_id ) { return( ERR_NO_ERR ); } if( win_x == w->width - 1 ) { return( PositionToNewThumbPosition( w, win_y ) ); } return( ERR_NO_ERR ); } if( EditFlags.Dragging ) { if( LastMouseEvent == MOUSE_DRAG || LastMouseEvent == MOUSE_REPEAT ) { UpdateDrag( wid, win_x, win_y ); } else { if( LastMouseEvent == MOUSE_PRESS_R || LastMouseEvent == MOUSE_PRESS ) { EditFlags.Dragging = false; if( LastMouseEvent == MOUSE_PRESS_R ) { LastMouseEvent = MOUSE_RELEASE_R; } } } } if( LastMouseEvent == MOUSE_RELEASE_R || LastMouseEvent == MOUSE_DCLICK ) { if( wid == current_window_id && InsideWindow( wid, win_x, win_y ) ) { diff_word = (LastMouseEvent == MOUSE_DCLICK); if( GoToLineRelCurs( LeftTopPos.line + win_y - 1 ) ) { return( ERR_NO_ERR ); } win_x += LeftTopPos.column; win_x = RealColumnOnCurrentLine( win_x ); GoToColumnOnCurrentLine( win_x ); if( diff_word ) { InitWordSearch( EditVars.WordAltDefn ); } rc = DoSelectSelection( true ); if( diff_word ) { InitWordSearch( EditVars.WordDefn ); } return( rc ); } } /* * all kinds of stuff to do if the button was pressed */ if( LastMouseEvent == MOUSE_PRESS || LastMouseEvent == MOUSE_PRESS_R ) { if( wid != current_window_id ) { /* * swap to another window */ for( cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) { if( wid == cinfo->current_window_id ) { BringUpFile( cinfo, true ); break; } } } if( wid == current_window_id ) { if( !ShiftDown() ) { UnselectRegion(); } if( w->has_border && LastMouseEvent == MOUSE_PRESS ) { /* * clicked on menu for window */ if( win_x == 0 && win_y == 0 ) { return( DoWindowGadgetMenu() ); } /* * check for resize request */ if( win_x == w->width - 1 && win_y == w->height - 1 ) { return( ResizeCurrentWindowWithMouse() ); } /* * check for move request */ if( win_y == 0 ) { return( MoveCurrentWindowWithMouse() ); } } /* * check for locate cursor */ if( InsideWindow( wid, win_x, win_y ) ) { if( ShiftDown() ) { EditFlags.Dragging = true; } if( GoToLineRelCurs( LeftTopPos.line + win_y - 1 ) ) { return( ERR_NO_ERR ); } win_x += LeftTopPos.column; win_x = RealColumnOnCurrentLine( win_x ); GoToColumnOnCurrentLine( win_x ); if( ShiftDown() ) { EditFlags.Dragging = false; } else { InitSelectedRegion(); } return( ERR_NO_ERR ); } } if( EditFlags.Menus && wid == menu_window_id ) { i = GetMenuIdFromCoord( win_x - 1 ); if( i >= 0 ) { return( SetToMenuId( i ) ); } } } /* * allow double click to close window */ if( wid == current_window_id && LastMouseEvent == MOUSE_DCLICK ) { if( win_y == 0 && win_x == 0 ) { return( NextFile() ); } } /* * try to scroll screen */ if( (LastMouseEvent == MOUSE_REPEAT || LastMouseEvent == MOUSE_DCLICK || LastMouseEvent == MOUSE_PRESS) && w->has_border && wid == current_window_id && win_x == w->width - 1 ) { if( win_y == w->height - 2 ) { return( MoveScreenDown() ); } if( win_y == 1 ) { return( MoveScreenUp() ); } /* * if we have gadgets, then scroll based on position of scroll * thumb. furthermore, if the thumb is selected, then begin * thumb dragging mode */ if( w->has_gadgets ) { if( win_y == w->vert_scroll_pos ) { dragThumb = true; return( ERR_NO_ERR ); } else if( win_y < w->vert_scroll_pos ) { return( MovePageUp() ); } else { return( MovePageDown() ); } } else { if( win_y < w->height / 2 ) { return( MovePageUp() ); } else { return( MovePageDown() ); } } } /* * start dragging */ if( wid == current_window_id && (LastMouseEvent == MOUSE_DRAG || LastMouseEvent == MOUSE_DRAG_R ) && InsideWindow( wid, win_x, win_y ) ) { EditFlags.Dragging = true; UpdateDrag( wid, win_x, win_y ); } return( ERR_NO_ERR ); } /* HandleMouseEvent */
// // 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; }