forked from mia/Aegisub
Add option to sort subtitles by text
This commit is contained in:
parent
732c5c7654
commit
c8d4df1355
|
@ -200,6 +200,12 @@ bool AssFile::CompEffect(AssDialogue const& lft, AssDialogue const& rgt) {
|
||||||
bool AssFile::CompLayer(AssDialogue const& lft, AssDialogue const& rgt) {
|
bool AssFile::CompLayer(AssDialogue const& lft, AssDialogue const& rgt) {
|
||||||
return lft.Layer < rgt.Layer;
|
return lft.Layer < rgt.Layer;
|
||||||
}
|
}
|
||||||
|
bool AssFile::CompText(AssDialogue const& lft, AssDialogue const& rgt) {
|
||||||
|
return lft.Text < rgt.Text;
|
||||||
|
}
|
||||||
|
bool AssFile::CompTextStripped(AssDialogue const& lft, AssDialogue const& rgt) {
|
||||||
|
return lft.GetStrippedText() < rgt.GetStrippedText();
|
||||||
|
}
|
||||||
|
|
||||||
void AssFile::Sort(CompFunc comp, std::set<AssDialogue*> const& limit) {
|
void AssFile::Sort(CompFunc comp, std::set<AssDialogue*> const& limit) {
|
||||||
Sort(Events, comp, limit);
|
Sort(Events, comp, limit);
|
||||||
|
|
|
@ -194,6 +194,10 @@ public:
|
||||||
static bool CompEffect(AssDialogue const& lft, AssDialogue const& rgt);
|
static bool CompEffect(AssDialogue const& lft, AssDialogue const& rgt);
|
||||||
/// Compare based on layer
|
/// Compare based on layer
|
||||||
static bool CompLayer(AssDialogue const& lft, AssDialogue const& rgt);
|
static bool CompLayer(AssDialogue const& lft, AssDialogue const& rgt);
|
||||||
|
/// Compare based on text
|
||||||
|
static bool CompText(AssDialogue const& lft, AssDialogue const& rgt);
|
||||||
|
/// Compare based on stripped text
|
||||||
|
static bool CompTextStripped(AssDialogue const& lft, AssDialogue const& rgt);
|
||||||
|
|
||||||
/// @brief Sort the dialogue lines in this file
|
/// @brief Sort the dialogue lines in this file
|
||||||
/// @param comp Comparison function to use. Defaults to sorting by start time.
|
/// @param comp Comparison function to use. Defaults to sorting by start time.
|
||||||
|
|
|
@ -248,6 +248,54 @@ struct grid_sort_style_selected final : public validate_sel_multiple {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct grid_sort_text final : public Command {
|
||||||
|
CMD_NAME("grid/sort/text")
|
||||||
|
STR_MENU("Te&xt")
|
||||||
|
STR_DISP("Text")
|
||||||
|
STR_HELP("Sort all subtitles by their text, including styling tags")
|
||||||
|
|
||||||
|
void operator()(agi::Context *c) override {
|
||||||
|
c->ass->Sort(AssFile::CompText);
|
||||||
|
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct grid_sort_text_selected final : public validate_sel_multiple {
|
||||||
|
CMD_NAME("grid/sort/text/selected")
|
||||||
|
STR_MENU("Te&xt")
|
||||||
|
STR_DISP("Text")
|
||||||
|
STR_HELP("Sort selected subtitles by their text, including styling tags")
|
||||||
|
|
||||||
|
void operator()(agi::Context *c) override {
|
||||||
|
c->ass->Sort(AssFile::CompText, c->selectionController->GetSelectedSet());
|
||||||
|
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct grid_sort_text_stripped final : public Command {
|
||||||
|
CMD_NAME("grid/sort/text_stripped")
|
||||||
|
STR_MENU("Stri&pped Text")
|
||||||
|
STR_DISP("Stripped Text")
|
||||||
|
STR_HELP("Sort all subtitles by their stripped text")
|
||||||
|
|
||||||
|
void operator()(agi::Context *c) override {
|
||||||
|
c->ass->Sort(AssFile::CompTextStripped);
|
||||||
|
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct grid_sort_text_stripped_selected final : public validate_sel_multiple {
|
||||||
|
CMD_NAME("grid/sort/text_stripped/selected")
|
||||||
|
STR_MENU("Stri&pped Text")
|
||||||
|
STR_DISP("Stripped Text")
|
||||||
|
STR_HELP("Sort selected subtitles by their stripped text")
|
||||||
|
|
||||||
|
void operator()(agi::Context *c) override {
|
||||||
|
c->ass->Sort(AssFile::CompTextStripped, c->selectionController->GetSelectedSet());
|
||||||
|
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct grid_tag_cycle_hiding final : public Command {
|
struct grid_tag_cycle_hiding final : public Command {
|
||||||
CMD_NAME("grid/tag/cycle_hiding")
|
CMD_NAME("grid/tag/cycle_hiding")
|
||||||
CMD_ICON(toggle_tag_hiding)
|
CMD_ICON(toggle_tag_hiding)
|
||||||
|
@ -411,12 +459,16 @@ namespace cmd {
|
||||||
reg(agi::make_unique<grid_sort_layer>());
|
reg(agi::make_unique<grid_sort_layer>());
|
||||||
reg(agi::make_unique<grid_sort_start>());
|
reg(agi::make_unique<grid_sort_start>());
|
||||||
reg(agi::make_unique<grid_sort_style>());
|
reg(agi::make_unique<grid_sort_style>());
|
||||||
|
reg(agi::make_unique<grid_sort_text>());
|
||||||
|
reg(agi::make_unique<grid_sort_text_stripped>());
|
||||||
reg(agi::make_unique<grid_sort_actor_selected>());
|
reg(agi::make_unique<grid_sort_actor_selected>());
|
||||||
reg(agi::make_unique<grid_sort_effect_selected>());
|
reg(agi::make_unique<grid_sort_effect_selected>());
|
||||||
reg(agi::make_unique<grid_sort_end_selected>());
|
reg(agi::make_unique<grid_sort_end_selected>());
|
||||||
reg(agi::make_unique<grid_sort_layer_selected>());
|
reg(agi::make_unique<grid_sort_layer_selected>());
|
||||||
reg(agi::make_unique<grid_sort_start_selected>());
|
reg(agi::make_unique<grid_sort_start_selected>());
|
||||||
reg(agi::make_unique<grid_sort_style_selected>());
|
reg(agi::make_unique<grid_sort_style_selected>());
|
||||||
|
reg(agi::make_unique<grid_sort_text_selected>());
|
||||||
|
reg(agi::make_unique<grid_sort_text_stripped_selected>());
|
||||||
reg(agi::make_unique<grid_move_down>());
|
reg(agi::make_unique<grid_move_down>());
|
||||||
reg(agi::make_unique<grid_move_up>());
|
reg(agi::make_unique<grid_move_up>());
|
||||||
reg(agi::make_unique<grid_swap>());
|
reg(agi::make_unique<grid_swap>());
|
||||||
|
|
|
@ -109,6 +109,8 @@
|
||||||
{ "command" : "grid/sort/style" },
|
{ "command" : "grid/sort/style" },
|
||||||
{ "command" : "grid/sort/actor" },
|
{ "command" : "grid/sort/actor" },
|
||||||
{ "command" : "grid/sort/effect" },
|
{ "command" : "grid/sort/effect" },
|
||||||
|
{ "command" : "grid/sort/text" },
|
||||||
|
{ "command" : "grid/sort/text_stripped" },
|
||||||
{ "command" : "grid/sort/layer" }
|
{ "command" : "grid/sort/layer" }
|
||||||
],
|
],
|
||||||
"main/subtitle/sort selected lines" : [
|
"main/subtitle/sort selected lines" : [
|
||||||
|
@ -117,6 +119,8 @@
|
||||||
{ "command" : "grid/sort/style/selected" },
|
{ "command" : "grid/sort/style/selected" },
|
||||||
{ "command" : "grid/sort/actor/selected" },
|
{ "command" : "grid/sort/actor/selected" },
|
||||||
{ "command" : "grid/sort/effect/selected" },
|
{ "command" : "grid/sort/effect/selected" },
|
||||||
|
{ "command" : "grid/sort/text/selected" },
|
||||||
|
{ "command" : "grid/sort/text_stripped/selected" },
|
||||||
{ "command" : "grid/sort/layer/selected" }
|
{ "command" : "grid/sort/layer/selected" }
|
||||||
],
|
],
|
||||||
"main/timing" : [
|
"main/timing" : [
|
||||||
|
|
|
@ -111,6 +111,8 @@
|
||||||
{ "command" : "grid/sort/style" },
|
{ "command" : "grid/sort/style" },
|
||||||
{ "command" : "grid/sort/actor" },
|
{ "command" : "grid/sort/actor" },
|
||||||
{ "command" : "grid/sort/effect" },
|
{ "command" : "grid/sort/effect" },
|
||||||
|
{ "command" : "grid/sort/text" },
|
||||||
|
{ "command" : "grid/sort/text_stripped" },
|
||||||
{ "command" : "grid/sort/layer" }
|
{ "command" : "grid/sort/layer" }
|
||||||
],
|
],
|
||||||
"main/subtitle/sort selected lines" : [
|
"main/subtitle/sort selected lines" : [
|
||||||
|
@ -119,6 +121,8 @@
|
||||||
{ "command" : "grid/sort/style/selected" },
|
{ "command" : "grid/sort/style/selected" },
|
||||||
{ "command" : "grid/sort/actor/selected" },
|
{ "command" : "grid/sort/actor/selected" },
|
||||||
{ "command" : "grid/sort/effect/selected" },
|
{ "command" : "grid/sort/effect/selected" },
|
||||||
|
{ "command" : "grid/sort/text/selected" },
|
||||||
|
{ "command" : "grid/sort/text_stripped/selected" },
|
||||||
{ "command" : "grid/sort/layer/selected" }
|
{ "command" : "grid/sort/layer/selected" }
|
||||||
],
|
],
|
||||||
"main/timing" : [
|
"main/timing" : [
|
||||||
|
|
Loading…
Reference in New Issue