mirror of https://github.com/odrling/Aegisub
Use boost::join in a handful of places
This commit is contained in:
parent
0ac8df140c
commit
28705000bb
|
@ -48,6 +48,8 @@
|
||||||
|
|
||||||
#include <libaegisub/of_type_adaptor.h>
|
#include <libaegisub/of_type_adaptor.h>
|
||||||
|
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
std::size_t hash_value(wxString const& s) {
|
std::size_t hash_value(wxString const& s) {
|
||||||
return wxStringHash()(s);
|
return wxStringHash()(s);
|
||||||
}
|
}
|
||||||
|
@ -290,7 +292,7 @@ void AssDialogue::StripTag(wxString const& tag_name) {
|
||||||
static wxString get_text(AssDialogueBlock &d) { return d.GetText(); }
|
static wxString get_text(AssDialogueBlock &d) { return d.GetText(); }
|
||||||
void AssDialogue::UpdateText(boost::ptr_vector<AssDialogueBlock>& blocks) {
|
void AssDialogue::UpdateText(boost::ptr_vector<AssDialogueBlock>& blocks) {
|
||||||
if (blocks.empty()) return;
|
if (blocks.empty()) return;
|
||||||
Text = join(blocks | boost::adaptors::transformed(get_text), wxS(""));
|
Text = join(blocks | transformed(get_text), wxS(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssDialogue::SetMarginString(wxString const& origvalue, int which) {
|
void AssDialogue::SetMarginString(wxString const& origvalue, int which) {
|
||||||
|
@ -323,12 +325,11 @@ bool AssDialogue::CollidesWith(const AssDialogue *target) const {
|
||||||
return ((Start < target->Start) ? (target->Start < End) : (Start < target->End));
|
return ((Start < target->Start) ? (target->Start < End) : (Start < target->End));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static wxString get_text_p(AssDialogueBlock *d) { return d->GetText(); }
|
||||||
wxString AssDialogue::GetStrippedText() const {
|
wxString AssDialogue::GetStrippedText() const {
|
||||||
wxString ret;
|
wxString ret;
|
||||||
boost::ptr_vector<AssDialogueBlock> blocks(ParseTags());
|
boost::ptr_vector<AssDialogueBlock> blocks(ParseTags());
|
||||||
for (auto block : blocks | agi::of_type<AssDialogueBlockPlain>())
|
return join(blocks | agi::of_type<AssDialogueBlockPlain>() | transformed(get_text_p), wxS(""));
|
||||||
ret += block->GetText();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AssEntry *AssDialogue::Clone() const {
|
AssEntry *AssDialogue::Clone() const {
|
||||||
|
|
|
@ -35,15 +35,21 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <wx/log.h>
|
|
||||||
#include <wx/tokenzr.h>
|
|
||||||
|
|
||||||
#include <libaegisub/log.h>
|
#include <libaegisub/log.h>
|
||||||
|
|
||||||
#include "ass_dialogue.h"
|
#include "ass_dialogue.h"
|
||||||
#include "ass_override.h"
|
#include "ass_override.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <boost/algorithm/string/join.hpp>
|
||||||
|
#include <boost/range/adaptor/filtered.hpp>
|
||||||
|
#include <boost/range/adaptor/transformed.hpp>
|
||||||
|
#include <functional>
|
||||||
|
#include <wx/log.h>
|
||||||
|
#include <wx/tokenzr.h>
|
||||||
|
|
||||||
|
using namespace boost::adaptors;
|
||||||
|
|
||||||
AssOverrideParameter::AssOverrideParameter()
|
AssOverrideParameter::AssOverrideParameter()
|
||||||
: classification(PARCLASS_NORMAL)
|
: classification(PARCLASS_NORMAL)
|
||||||
, omitted(false)
|
, omitted(false)
|
||||||
|
@ -91,11 +97,9 @@ void AssDialogueBlockOverride::AddTag(wxString const& tag) {
|
||||||
Tags.push_back(new AssOverrideTag(tag));
|
Tags.push_back(new AssOverrideTag(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static wxString tag_str(AssOverrideTag *t) { return *t; }
|
||||||
wxString AssDialogueBlockOverride::GetText() {
|
wxString AssDialogueBlockOverride::GetText() {
|
||||||
text = "{";
|
text = "{" + join(Tags | transformed(tag_str), wxString()) + "}";
|
||||||
for (auto tag : Tags)
|
|
||||||
text += *tag;
|
|
||||||
text += "}";
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,6 +428,7 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static wxString param_str(AssOverrideParameter *p) { return p->Get<wxString>(); }
|
||||||
AssOverrideTag::operator wxString() const {
|
AssOverrideTag::operator wxString() const {
|
||||||
wxString result = Name;
|
wxString result = Name;
|
||||||
|
|
||||||
|
@ -432,15 +437,10 @@ AssOverrideTag::operator wxString() const {
|
||||||
if (parentheses) result += "(";
|
if (parentheses) result += "(";
|
||||||
|
|
||||||
// Add parameters
|
// Add parameters
|
||||||
bool any = false;
|
result += join(Params
|
||||||
for (auto param : Params) {
|
| filtered([](AssOverrideParameter *p) { return p->GetType() != VARDATA_NONE && !p->omitted; })
|
||||||
if (param->GetType() != VARDATA_NONE && !param->omitted) {
|
| transformed(param_str),
|
||||||
result += param->Get<wxString>();
|
wxS(","));
|
||||||
result += ",";
|
|
||||||
any = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (any) result.resize(result.size() - 1);
|
|
||||||
|
|
||||||
if (parentheses) result += ")";
|
if (parentheses) result += ")";
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
#include "../utils.h"
|
#include "../utils.h"
|
||||||
#include "../video_context.h"
|
#include "../video_context.h"
|
||||||
|
|
||||||
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <boost/range/adaptor/reversed.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <boost/range/adaptor/sliced.hpp>
|
#include <boost/range/adaptor/sliced.hpp>
|
||||||
|
|
||||||
|
@ -468,18 +469,14 @@ struct edit_find_replace : public Command {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static wxString get_entry_data(AssDialogue *d) { return d->GetEntryData(); }
|
||||||
static void copy_lines(agi::Context *c) {
|
static void copy_lines(agi::Context *c) {
|
||||||
wxString data;
|
|
||||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||||
for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) {
|
SetClipboard(join(c->ass->Line
|
||||||
if (sel.count(diag)) {
|
| agi::of_type<AssDialogue>()
|
||||||
if (!data.empty())
|
| filtered([&](AssDialogue *d) { return sel.count(d); })
|
||||||
data += "\r\n";
|
| transformed(get_entry_data),
|
||||||
data += diag->GetEntryData();
|
wxS("")));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetClipboard(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
||||||
|
|
|
@ -26,23 +26,23 @@
|
||||||
#include "libresrc/libresrc.h"
|
#include "libresrc/libresrc.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
#include <libaegisub/hotkey.h>
|
||||||
|
#include <libaegisub/json.h>
|
||||||
|
#include <libaegisub/log.h>
|
||||||
|
#include <libaegisub/signal.h>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
#include <wx/toolbar.h>
|
#include <wx/toolbar.h>
|
||||||
|
|
||||||
#include <libaegisub/hotkey.h>
|
|
||||||
#include <libaegisub/json.h>
|
|
||||||
#include <libaegisub/log.h>
|
|
||||||
#include <libaegisub/signal.h>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
json::Object const& get_root() {
|
json::Object const& get_root() {
|
||||||
static json::Object root;
|
static json::Object root;
|
||||||
if (root.empty()) {
|
if (root.empty())
|
||||||
root = agi::json_util::parse(new std::istringstream(GET_DEFAULT_CONFIG(default_toolbar)));
|
root = agi::json_util::parse(new std::istringstream(GET_DEFAULT_CONFIG(default_toolbar)));
|
||||||
}
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,14 +70,12 @@ namespace {
|
||||||
/// Enable/disable the toolbar buttons
|
/// Enable/disable the toolbar buttons
|
||||||
void OnIdle(wxIdleEvent &) {
|
void OnIdle(wxIdleEvent &) {
|
||||||
for (size_t i = 0; i < commands.size(); ++i) {
|
for (size_t i = 0; i < commands.size(); ++i) {
|
||||||
if (commands[i]->Type() & cmd::COMMAND_VALIDATE) {
|
if (commands[i]->Type() & cmd::COMMAND_VALIDATE)
|
||||||
EnableTool(TOOL_ID_BASE + i, commands[i]->Validate(context));
|
EnableTool(TOOL_ID_BASE + i, commands[i]->Validate(context));
|
||||||
}
|
if (commands[i]->Type() & cmd::COMMAND_TOGGLE || commands[i]->Type() & cmd::COMMAND_RADIO)
|
||||||
if (commands[i]->Type() & cmd::COMMAND_TOGGLE || commands[i]->Type() & cmd::COMMAND_RADIO) {
|
|
||||||
ToggleTool(TOOL_ID_BASE + i, commands[i]->IsActive(context));
|
ToggleTool(TOOL_ID_BASE + i, commands[i]->IsActive(context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Toolbar button click handler
|
/// Toolbar button click handler
|
||||||
void OnClick(wxCommandEvent &evt) {
|
void OnClick(wxCommandEvent &evt) {
|
||||||
|
@ -157,14 +155,8 @@ namespace {
|
||||||
wxString ret = command->StrHelp();
|
wxString ret = command->StrHelp();
|
||||||
|
|
||||||
std::vector<std::string> hotkeys = hotkey::get_hotkey_strs(ht_context, command->name());
|
std::vector<std::string> hotkeys = hotkey::get_hotkey_strs(ht_context, command->name());
|
||||||
for (size_t i = 0; i < hotkeys.size(); ++i) {
|
if (!hotkeys.empty())
|
||||||
if (i == 0)
|
ret += " (" + boost::join(hotkeys, "/") + ")";
|
||||||
ret += " (";
|
|
||||||
else
|
|
||||||
ret += "/";
|
|
||||||
ret += hotkeys[i];
|
|
||||||
}
|
|
||||||
if (hotkeys.size()) ret += ")";
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue