1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-04 14:39:08 +02:00

Scripting Help Command now supports JSON, LISP, Brief.

This commit is contained in:
James Crook 2020-02-10 15:55:39 +00:00
parent 7ff9f1b302
commit 371afa3ffa
3 changed files with 52 additions and 2 deletions

View File

@ -36,7 +36,6 @@ This class now lists
#include "../WaveTrack.h" #include "../WaveTrack.h"
#include "../LabelTrack.h" #include "../LabelTrack.h"
#include "../Envelope.h" #include "../Envelope.h"
#include "CommandContext.h"
#include "SelectCommand.h" #include "SelectCommand.h"
#include "../ShuttleGui.h" #include "../ShuttleGui.h"

View File

@ -20,6 +20,7 @@
#include "../Shuttle.h" #include "../Shuttle.h"
#include "LoadCommands.h" #include "LoadCommands.h"
#include "../ShuttleGui.h" #include "../ShuttleGui.h"
#include "CommandTargets.h"
#include "CommandContext.h" #include "CommandContext.h"
#include "../effects/EffectManager.h" #include "../effects/EffectManager.h"
@ -28,8 +29,28 @@ const ComponentInterfaceSymbol HelpCommand::Symbol
namespace{ BuiltinCommandsModule::Registration< HelpCommand > reg; } namespace{ BuiltinCommandsModule::Registration< HelpCommand > reg; }
enum {
kJson,
kLisp,
kBrief,
nFormats
};
static const EnumValueSymbol kFormats[nFormats] =
{
// These are acceptable dual purpose internal/visible names
/* i18n-hint JavaScript Object Notation */
{ XO("JSON") },
/* i18n-hint name of a computer programming language */
{ XO("LISP") },
{ XO("Brief") }
};
bool HelpCommand::DefineParams( ShuttleParams & S ){ bool HelpCommand::DefineParams( ShuttleParams & S ){
S.Define( mCommandName, wxT("Command"), "Help" ); S.Define( mCommandName, wxT("Command"), "Help" );
S.DefineEnum( mFormat, wxT("Format"), 0, kFormats, nFormats );
return true; return true;
} }
@ -40,11 +61,39 @@ void HelpCommand::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2, wxALIGN_CENTER); S.StartMultiColumn(2, wxALIGN_CENTER);
{ {
S.TieTextBox(XO("Command:"),mCommandName); S.TieTextBox(XO("Command:"),mCommandName);
S.TieChoice( XO("Format:"),
mFormat, Msgids( kFormats, nFormats ));
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
bool HelpCommand::Apply(const CommandContext & context){ bool HelpCommand::Apply(const CommandContext &context)
{
if( mFormat == kJson )
return ApplyInner( context );
if( mFormat == kLisp )
{
CommandContext LispyContext(
context.project,
std::make_unique<LispifiedCommandOutputTargets>( *context.pOutput.get() )
);
return ApplyInner( LispyContext );
}
if( mFormat == kBrief )
{
CommandContext BriefContext(
context.project,
std::make_unique<BriefCommandOutputTargets>( *context.pOutput.get() )
);
return ApplyInner( BriefContext );
}
return false;
}
bool HelpCommand::ApplyInner(const CommandContext & context){
EffectManager & em = EffectManager::Get(); EffectManager & em = EffectManager::Get();
PluginID ID = em.GetEffectByIdentifier( mCommandName ); PluginID ID = em.GetEffectByIdentifier( mCommandName );
if( ID.empty() ) if( ID.empty() )

View File

@ -27,6 +27,7 @@ class HelpCommand : public AudacityCommand
{ {
public: public:
static const ComponentInterfaceSymbol Symbol; static const ComponentInterfaceSymbol Symbol;
int mFormat;
// ComponentInterface overrides // ComponentInterface overrides
ComponentInterfaceSymbol GetSymbol() override {return Symbol;}; ComponentInterfaceSymbol GetSymbol() override {return Symbol;};
@ -34,6 +35,7 @@ public:
bool DefineParams( ShuttleParams & S ) override; bool DefineParams( ShuttleParams & S ) override;
void PopulateOrExchange(ShuttleGui & S) override; void PopulateOrExchange(ShuttleGui & S) override;
bool Apply(const CommandContext & context) override; bool Apply(const CommandContext & context) override;
bool ApplyInner(const CommandContext & context);
// AudacityCommand overrides // AudacityCommand overrides
wxString ManualPage() override {return wxT("Extra_Menu:_Scriptables_II#help");}; wxString ManualPage() override {return wxT("Extra_Menu:_Scriptables_II#help");};