MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / GetCommand

Method GetCommand

external/zep/src/mode.cpp:580–1495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 15

ZTestFlagsFunction · 0.85
GlyphIteratorClass · 0.85
string_tolowerFunction · 0.85
ZSetFlagsFunction · 0.85
GetBufferCursorMethod · 0.80
SetCommandTextMethod · 0.80
FindExCommandMethod · 0.80
FindNextMarkerMethod · 0.80
SetBufferCursorMethod · 0.80
GetFilePathMethod · 0.80
ExistsMethod · 0.80
ScanDirectoryMethod · 0.80

Tested by

no test coverage detected