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

Method AddCommand

external/zep/src/mode.cpp:456–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454 }
455
456 void ZepMode::AddCommand(std::shared_ptr<ZepCommand> spCmd) {
457 if (m_pCurrentWindow == nullptr) {
458 return;
459 }
460
461 if (GetCurrentWindow()->GetBuffer().HasFileFlags(FileFlags::Locked)) {
462 // Ignore commands on buffers because we are view only,
463 // and all commands currently modify the buffer!
464 return;
465 }
466
467 auto& undoStack = m_pCurrentWindow->GetBuffer().GetUndoStack();
468 auto& redoStack = m_pCurrentWindow->GetBuffer().GetRedoStack();
469
470 spCmd->Redo();
471 undoStack.push(spCmd);
472
473 // Can't redo anything beyond this point
474 std::stack<std::shared_ptr<ZepCommand>> empty;
475 redoStack.swap(empty);
476
477 if (spCmd->GetCursorAfter().Valid()) {
478 GetCurrentWindow()->SetBufferCursor(spCmd->GetCursorAfter());
479 }
480 }
481
482 void ZepMode::Redo() {
483 if (m_pCurrentWindow == nullptr) {

Callers 2

pasteFromClipboardMethod · 0.80

Calls 7

HasFileFlagsMethod · 0.80
ValidMethod · 0.80
GetCursorAfterMethod · 0.80
SetBufferCursorMethod · 0.80
RedoMethod · 0.45
pushMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected