| 578 | } |
| 579 | |
| 580 | bool ZepMode::GetCommand(CommandContext& context) { |
| 581 | auto bufferCursor = GetCurrentWindow()->GetBufferCursor(); |
| 582 | auto& buffer = GetCurrentWindow()->GetBuffer(); |
| 583 | |
| 584 | if (m_currentMode == EditorMode::Ex) { |
| 585 | // TODO: Is it possible extend our key mapping to better process ex commands? Or are these |
| 586 | // too specialized? |
| 587 | if (HandleExCommand(context.fullCommand)) { |
| 588 | // buffer.GetMode()->Begin(GetCurrentWindow()); |
| 589 | SwitchMode(DefaultMode()); |
| 590 | ResetCommand(); |
| 591 | return true; |
| 592 | } |
| 593 | GetEditor().SetCommandText(m_currentCommand); |
| 594 | |
| 595 | return false; |
| 596 | } |
| 597 | |
| 598 | // The keymapper is waiting for more input |
| 599 | if (context.keymap.needMoreChars) { |
| 600 | return false; |
| 601 | } |
| 602 | |
| 603 | // This flag is for non-modal editors which like to break insertions into undo groups. |
| 604 | // Vim, for example, doesn't do that; an insert mode operation is a single 'group' |
| 605 | bool shouldGroupInserts = ZTestFlags(m_modeFlags, ModeFlags::InsertModeGroupUndo); |
| 606 | |
| 607 | GlyphIterator cursorItr = bufferCursor; |
| 608 | |
| 609 | auto mappedCommand = context.keymap.foundMapping; |
| 610 | |
| 611 | // Using movement in insert mode vs normal mode is different; should be able to move the cursor beyond the end of the line in insert mode. |
| 612 | auto movementLineEndLocation = (context.currentMode == EditorMode::Insert ? LineLocation::LineCRBegin : LineLocation::LineLastNonCR); |
| 613 | |
| 614 | auto pEx = GetEditor().FindExCommand(mappedCommand); |
| 615 | if (pEx) { |
| 616 | pEx->Run(); |
| 617 | return true; |
| 618 | } |
| 619 | |
| 620 | // Inherited modes can handle extra commands this way |
| 621 | if (HandleSpecialCommand(context)) { |
| 622 | return true; |
| 623 | } |
| 624 | |
| 625 | if (mappedCommand == id_NormalMode) { |
| 626 | // TODO: I think this should be a 'command' which would get replayed with dot; |
| 627 | // instead of special casing it later, we could just insert it into the stream of commands |
| 628 | context.commandResult.modeSwitch = EditorMode::Normal; |
| 629 | return true; |
| 630 | } else if (mappedCommand == id_ExMode) { |
| 631 | context.commandResult.modeSwitch = EditorMode::Ex; |
| 632 | return true; |
| 633 | } |
| 634 | // Control |
| 635 | else if (mappedCommand == id_MotionNextMarker) { |
| 636 | auto pFound = buffer.FindNextMarker(GetCurrentWindow()->GetBufferCursor(), Direction::Forward, RangeMarkerType::Mark); |
| 637 | if (pFound) { |
nothing calls this directly
no test coverage detected