13
0

Sort Lua scripts case-insensitive and expose sort-struct

This commit is contained in:
Robin Gareus 2019-07-18 15:49:48 +02:00
parent 8d98dfe8fc
commit 9748656a90
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 16 additions and 12 deletions

View File

@ -123,6 +123,10 @@ public:
static std::string get_factory_bytecode (const std::string&, const std::string& ffn = "factory", const std::string& fp = "f"); static std::string get_factory_bytecode (const std::string&, const std::string& ffn = "factory", const std::string& fp = "f");
static std::string user_script_dir (); static std::string user_script_dir ();
struct Sorter {
bool operator() (LuaScriptInfoPtr const a, LuaScriptInfoPtr const b) const;
};
private: private:
static LuaScripting* _instance; // singleton static LuaScripting* _instance; // singleton
LuaScripting (); LuaScripting ();

View File

@ -28,6 +28,7 @@
#include "ardour/luascripting.h" #include "ardour/luascripting.h"
#include "ardour/lua_script_params.h" #include "ardour/lua_script_params.h"
#include "ardour/search_paths.h" #include "ardour/search_paths.h"
#include "ardour/utils.h"
#include "lua/luastate.h" #include "lua/luastate.h"
#include "LuaBridge/LuaBridge.h" #include "LuaBridge/LuaBridge.h"
@ -104,11 +105,10 @@ LuaScripting::refresh (bool run_scan)
} }
} }
struct ScriptSorter { bool
bool operator () (LuaScriptInfoPtr a, LuaScriptInfoPtr b) { LuaScripting::Sorter::operator() (LuaScriptInfoPtr const a, LuaScriptInfoPtr const b) const {
return a->name < b->name; return ARDOUR::cmp_nocase_utf8 (a->name, b->name) < 0;
} }
};
LuaScriptInfoPtr LuaScriptInfoPtr
LuaScripting::script_info (const std::string &script) { LuaScripting::script_info (const std::string &script) {
@ -166,13 +166,13 @@ LuaScripting::scan ()
} }
} }
std::sort (_sl_dsp->begin(), _sl_dsp->end(), ScriptSorter()); std::sort (_sl_dsp->begin(), _sl_dsp->end(), Sorter());
std::sort (_sl_session->begin(), _sl_session->end(), ScriptSorter()); std::sort (_sl_session->begin(), _sl_session->end(), Sorter());
std::sort (_sl_hook->begin(), _sl_hook->end(), ScriptSorter()); std::sort (_sl_hook->begin(), _sl_hook->end(), Sorter());
std::sort (_sl_action->begin(), _sl_action->end(), ScriptSorter()); std::sort (_sl_action->begin(), _sl_action->end(), Sorter());
std::sort (_sl_snippet->begin(), _sl_snippet->end(), ScriptSorter()); std::sort (_sl_snippet->begin(), _sl_snippet->end(), Sorter());
std::sort (_sl_setup->begin(), _sl_setup->end(), ScriptSorter()); std::sort (_sl_setup->begin(), _sl_setup->end(), Sorter());
std::sort (_sl_tracks->begin(), _sl_tracks->end(), ScriptSorter()); std::sort (_sl_tracks->begin(), _sl_tracks->end(), Sorter());
scripts_changed (); /* EMIT SIGNAL */ scripts_changed (); /* EMIT SIGNAL */
} }