commit 00bb998e4b557ed62e82a5ee39e8743f5851e4f2
parent 1a1ba963ccb9bbe8c7d3f18919afd2cf8eb9f4bc
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sat, 8 Apr 2017 17:27:21 -0400
add support for the MIDI Inline Editor section
Diffstat:
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/about.cpp b/src/about.cpp
@@ -566,6 +566,7 @@ void AboutPackageDelegate::updateList(const int index)
static const map<Source::Section, string> sectionMap{
{Source::MainSection, "Main"},
{Source::MIDIEditorSection, "MIDI Editor"},
+ {Source::MIDIInlineEditorSection, "MIDI Inline Editor"},
};
if(index < 0)
diff --git a/src/source.cpp b/src/source.cpp
@@ -30,6 +30,8 @@ auto Source::getSection(const char *name) -> Section
return MainSection;
else if(!strcmp(name, "midi_editor"))
return MIDIEditorSection;
+ else if(!strcmp(name, "midi_inline_editor"))
+ return MIDIInlineEditorSection;
else if(!strcmp(name, "true"))
return ImplicitSection;
else
@@ -45,6 +47,8 @@ auto Source::detectSection(const string &category) -> Section
if(topcategory == "midi editor")
return MIDIEditorSection;
+ else if(topcategory == "midi inline editor")
+ return MIDIInlineEditorSection;
else
return MainSection;
}
diff --git a/src/source.hpp b/src/source.hpp
@@ -28,11 +28,12 @@ class Version;
class Source {
public:
enum Section {
- UnknownSection = 0,
- MainSection = 1<<0,
- MIDIEditorSection = 1<<1,
+ UnknownSection = 0,
+ MainSection = 1<<0,
+ MIDIEditorSection = 1<<1,
+ MIDIInlineEditorSection = 1<<2,
- ImplicitSection = -1, // for compatibility with v1.0
+ ImplicitSection = -1, // for compatibility with v1.0
};
static Section getSection(const char *);
diff --git a/src/transaction.cpp b/src/transaction.cpp
@@ -336,6 +336,7 @@ void Transaction::registerScript(const HostTicket ®, const bool isLastCall)
static const map<Source::Section, int> sectionMap{
{Source::MainSection, 0},
{Source::MIDIEditorSection, 32060},
+ {Source::MIDIInlineEditorSection, 32062},
};
if(!AddRemoveReaScript || !reg.file.sections)
diff --git a/test/source.cpp b/test/source.cpp
@@ -58,6 +58,7 @@ TEST_CASE("parse file section", M) {
REQUIRE(0 == Source::getSection("hello"));
REQUIRE(Source::MainSection == Source::getSection("main"));
REQUIRE(Source::MIDIEditorSection == Source::getSection("midi_editor"));
+ REQUIRE(Source::MIDIInlineEditorSection == Source::getSection("midi_inline_editor"));
}
TEST_CASE("explicit source section", M) {
@@ -104,6 +105,16 @@ TEST_CASE("implicit source section") {
source.setSections(Source::ImplicitSection);
REQUIRE(source.sections() == Source::MIDIEditorSection);
}
+
+ SECTION("midi inline editor") {
+ Category cat("MIDI Inline Editor", &ri);
+ Package pack(Package::ScriptType, "package name", &cat);
+ Version ver("1.0", &pack);
+
+ Source source("filename", "url", &ver);
+ source.setSections(Source::ImplicitSection);
+ REQUIRE(source.sections() == Source::MIDIInlineEditorSection);
+ }
}
TEST_CASE("implicit section detection", M) {
@@ -113,6 +124,9 @@ TEST_CASE("implicit section detection", M) {
REQUIRE(Source::MIDIEditorSection == Source::detectSection("midi editor"));
REQUIRE(Source::MIDIEditorSection == Source::detectSection("midi editor/Hello"));
+
+ REQUIRE(Source::MIDIInlineEditorSection ==
+ Source::detectSection("midi inline editor"));
}
TEST_CASE("empty source url", M) {