1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 00:29:41 +02:00

CommandManager interacts with journal; simple journals can play...

... such as one whose only line is "CM,Exit", which can also be recorded.

But no commands that pop up modal dialogs, or mouse interactions, can yet play
back.
This commit is contained in:
Paul Licameli 2019-01-29 16:02:34 -05:00
parent 82d88b99e1
commit 03f8efc0ab

View File

@ -92,6 +92,7 @@ CommandManager. It holds the callback for one command.
#include <wx/menu.h>
#include <wx/tokenzr.h>
#include "../Journal.h"
#include "../Menus.h"
#include "../Project.h"
@ -1183,6 +1184,33 @@ bool CommandManager::FilterKeyEvent(AudacityProject *project, const wxKeyEvent &
return false;
}
namespace {
constexpr auto JournalCode = wxT("CM"); // for CommandManager
// Register a callback for the journal
Journal::RegisteredCommand sCommand{ JournalCode,
[]( const wxArrayString &fields )
{
// Expect JournalCode and the command name.
// To do, perhaps, is to include some parameters.
bool handled = false;
if ( fields.size() == 2 ) {
auto project = GetActiveProject();
if (project) {
auto pManager = &CommandManager::Get( *project );
auto flags = MenuManager::Get( *project ).GetUpdateFlags();
const CommandContext context( *project );
auto &command = fields[1];
handled =
pManager->HandleTextualCommand( command, context, flags, false );
}
}
return handled;
}
};
}
/// HandleCommandEntry() takes a CommandListEntry and executes it
/// returning true iff successful. If you pass any flags,
@ -1217,6 +1245,8 @@ bool CommandManager::HandleCommandEntry(AudacityProject &project,
mNiceName = {};
}
Journal::Output({ JournalCode, entry->name.GET() });
const CommandContext context{ project, evt, entry->index, entry->parameter };
auto &handler = entry->finder(project);
(handler.*(entry->callback))(context);