Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
// Copyright (c) 2005-2010, Niels Martin Hansen
|
|
|
|
// Copyright (c) 2005-2010, Rodrigo Braz Monteiro
|
|
|
|
// Copyright (c) 2010, Amar Takhar
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file edit.cpp
|
|
|
|
/// @brief edit/ commands.
|
|
|
|
/// @ingroup command
|
|
|
|
///
|
|
|
|
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../config.h"
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
#ifndef AGI_PRE
|
2011-01-18 07:01:29 +01:00
|
|
|
#include <algorithm>
|
2011-07-16 08:42:55 +02:00
|
|
|
|
|
|
|
#include <wx/clipbrd.h>
|
2012-10-15 06:37:14 +02:00
|
|
|
#include <wx/fontdlg.h>
|
|
|
|
#include <wx/tokenzr.h>
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
|
2011-01-18 07:01:29 +01:00
|
|
|
#include "../ass_dialogue.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../ass_file.h"
|
2011-09-28 21:44:07 +02:00
|
|
|
#include "../ass_karaoke.h"
|
2012-10-09 04:07:54 +02:00
|
|
|
#include "../ass_override.h"
|
|
|
|
#include "../ass_style.h"
|
|
|
|
#include "../dialog_colorpicker.h"
|
2012-10-14 06:21:43 +02:00
|
|
|
#include "../dialog_paste_over.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../dialog_search_replace.h"
|
2012-10-14 06:21:43 +02:00
|
|
|
#include "../main.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../include/aegisub/context.h"
|
|
|
|
#include "../subs_edit_ctrl.h"
|
|
|
|
#include "../subs_grid.h"
|
2012-10-09 04:07:54 +02:00
|
|
|
#include "../text_selection_controller.h"
|
2012-10-25 17:13:13 +02:00
|
|
|
#include "../utils.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../video_context.h"
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2012-11-05 17:20:58 +01:00
|
|
|
#include <boost/range/adaptor/reversed.hpp>
|
|
|
|
|
|
|
|
#include <libaegisub/of_type_adaptor.h>
|
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
namespace {
|
|
|
|
using cmd::Command;
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
/// @defgroup cmd-edit Editing commands.
|
|
|
|
/// @{
|
|
|
|
|
2011-07-15 06:05:22 +02:00
|
|
|
struct validate_sel_nonempty : public Command {
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return c->selectionController->GetSelectedSet().size() > 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct validate_sel_multiple : public Command {
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return c->selectionController->GetSelectedSet().size() > 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-14 06:21:43 +02:00
|
|
|
void paste_lines(agi::Context *c, bool paste_over) {
|
2012-10-25 17:13:13 +02:00
|
|
|
wxString data = GetClipboard();
|
2012-10-14 06:21:43 +02:00
|
|
|
if (!data) return;
|
|
|
|
|
|
|
|
AssDialogue *rel_line = c->selectionController->GetActiveLine();
|
2012-10-12 19:16:39 +02:00
|
|
|
entryIter pos = c->ass->Line.iterator_to(*rel_line);
|
2012-10-14 06:21:43 +02:00
|
|
|
|
|
|
|
AssDialogue *first = 0;
|
|
|
|
SubtitleSelection newsel;
|
|
|
|
|
|
|
|
std::vector<bool> pasteOverOptions;
|
|
|
|
wxStringTokenizer token (data,"\r\n",wxTOKEN_STRTOK);
|
|
|
|
while (token.HasMoreTokens()) {
|
|
|
|
// Convert data into an AssDialogue
|
|
|
|
wxString curdata = token.GetNextToken();
|
|
|
|
curdata.Trim(true);
|
|
|
|
curdata.Trim(false);
|
|
|
|
AssDialogue *curdiag;
|
|
|
|
try {
|
|
|
|
// Try to interpret the line as an ASS line
|
|
|
|
curdiag = new AssDialogue(curdata);
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
// Line didn't parse correctly, assume it's plain text that
|
|
|
|
// should be pasted in the Text field only
|
|
|
|
curdiag = new AssDialogue();
|
|
|
|
curdiag->Text = curdata;
|
|
|
|
// Make sure pasted plain-text lines always are blank-timed
|
|
|
|
curdiag->Start = 0;
|
|
|
|
curdiag->End = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!first)
|
|
|
|
first = curdiag;
|
|
|
|
|
|
|
|
if (!paste_over) {
|
|
|
|
newsel.insert(curdiag);
|
2012-10-12 19:16:39 +02:00
|
|
|
c->ass->Line.insert(pos, *curdiag);
|
2012-10-14 06:21:43 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Get list of options to paste over, if not asked yet
|
|
|
|
if (pasteOverOptions.empty()) {
|
|
|
|
DialogPasteOver diag(c->parent);
|
|
|
|
if (diag.ShowModal()) {
|
|
|
|
delete curdiag;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pasteOverOptions = OPT_GET("Tool/Paste Lines Over/Fields")->GetListBool();
|
|
|
|
}
|
|
|
|
|
2012-10-12 19:16:39 +02:00
|
|
|
AssDialogue *line = static_cast<AssDialogue *>(&*pos);
|
2012-10-14 06:21:43 +02:00
|
|
|
if (pasteOverOptions[0]) line->Layer = curdiag->Layer;
|
|
|
|
if (pasteOverOptions[1]) line->Start = curdiag->Start;
|
|
|
|
if (pasteOverOptions[2]) line->End = curdiag->End;
|
|
|
|
if (pasteOverOptions[3]) line->Style = curdiag->Style;
|
|
|
|
if (pasteOverOptions[4]) line->Actor = curdiag->Actor;
|
|
|
|
if (pasteOverOptions[5]) line->Margin[0] = curdiag->Margin[0];
|
|
|
|
if (pasteOverOptions[6]) line->Margin[1] = curdiag->Margin[1];
|
|
|
|
if (pasteOverOptions[7]) line->Margin[2] = curdiag->Margin[2];
|
|
|
|
if (pasteOverOptions[8]) line->Effect = curdiag->Effect;
|
|
|
|
if (pasteOverOptions[9]) line->Text = curdiag->Text;
|
|
|
|
|
|
|
|
delete curdiag;
|
|
|
|
|
|
|
|
do {
|
|
|
|
++pos;
|
2012-10-12 19:16:39 +02:00
|
|
|
} while (pos != c->ass->Line.end() && !dynamic_cast<AssDialogue*>(&*pos));
|
2012-10-14 06:21:43 +02:00
|
|
|
if (pos == c->ass->Line.end())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (first) {
|
|
|
|
c->ass->Commit(_("paste"), paste_over ? AssFile::COMMIT_DIAG_FULL : AssFile::COMMIT_DIAG_ADDREM);
|
|
|
|
|
|
|
|
if (!paste_over)
|
|
|
|
c->selectionController->SetSelectionAndActive(newsel, first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-09 04:07:54 +02:00
|
|
|
template<class T>
|
2012-11-20 23:28:24 +01:00
|
|
|
T get_value(AssDialogue const& line, int blockn, T initial, wxString const& tag_name, wxString alt = wxString()) {
|
2012-11-05 17:20:58 +01:00
|
|
|
for (auto ovr : line.Blocks | boost::adaptors::reversed | agi::of_type<AssDialogueBlockOverride>()) {
|
|
|
|
for (auto tag : ovr->Tags | boost::adaptors::reversed) {
|
2012-11-20 23:28:24 +01:00
|
|
|
if (tag->Name == tag_name || tag->Name == alt)
|
2012-11-05 17:20:58 +01:00
|
|
|
return tag->Params[0]->Get<T>(initial);
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return initial;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the block index in the text of the position
|
|
|
|
int block_at_pos(wxString const& text, int pos) {
|
|
|
|
int n = 0;
|
|
|
|
int max = text.size() - 1;
|
|
|
|
for (int i = 0; i <= pos && i <= max; ++i) {
|
|
|
|
if (i > 0 && text[i] == '{')
|
|
|
|
n++;
|
|
|
|
if (text[i] == '}' && i != max && i != pos && i != pos -1 && (i+1 == max || text[i+1] != '{'))
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-10-15 05:35:08 +02:00
|
|
|
void set_tag(const agi::Context *c, wxString const& tag, wxString const& value, int &sel_start, int &sel_end, bool at_end = false) {
|
2012-10-09 04:07:54 +02:00
|
|
|
AssDialogue * const line = c->selectionController->GetActiveLine();
|
|
|
|
if (line->Blocks.empty())
|
2012-10-12 03:52:36 +02:00
|
|
|
line->ParseAssTags();
|
2012-10-09 04:07:54 +02:00
|
|
|
|
|
|
|
int start = at_end ? sel_end : sel_start;
|
|
|
|
int blockn = block_at_pos(line->Text, start);
|
|
|
|
|
|
|
|
AssDialogueBlockPlain *plain = 0;
|
|
|
|
AssDialogueBlockOverride *ovr = 0;
|
|
|
|
while (blockn >= 0) {
|
|
|
|
AssDialogueBlock *block = line->Blocks[blockn];
|
|
|
|
if (dynamic_cast<AssDialogueBlockDrawing*>(block))
|
|
|
|
--blockn;
|
|
|
|
else if ((plain = dynamic_cast<AssDialogueBlockPlain*>(block))) {
|
|
|
|
// Cursor is in a comment block, so try the previous block instead
|
|
|
|
if (plain->GetText().StartsWith("{")) {
|
|
|
|
--blockn;
|
|
|
|
start = line->Text.rfind('{', start);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ovr = dynamic_cast<AssDialogueBlockOverride*>(block);
|
|
|
|
assert(ovr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we didn't hit a suitable block for inserting the override just put
|
|
|
|
// it at the beginning of the line
|
|
|
|
if (blockn < 0)
|
|
|
|
start = 0;
|
|
|
|
|
|
|
|
wxString insert = tag + value;
|
|
|
|
int shift = insert.size();
|
|
|
|
if (plain || blockn < 0) {
|
|
|
|
line->Text = line->Text.Left(start) + "{" + insert + "}" + line->Text.Mid(start);
|
|
|
|
shift += 2;
|
2012-10-12 03:52:36 +02:00
|
|
|
line->ParseAssTags();
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
else if(ovr) {
|
|
|
|
wxString alt;
|
|
|
|
if (tag == "\\c") alt = "\\1c";
|
|
|
|
// Remove old of same
|
|
|
|
bool found = false;
|
|
|
|
for (size_t i = 0; i < ovr->Tags.size(); i++) {
|
|
|
|
wxString name = ovr->Tags[i]->Name;
|
|
|
|
if (tag == name || alt == name) {
|
|
|
|
shift -= ((wxString)*ovr->Tags[i]).size();
|
|
|
|
if (found) {
|
|
|
|
delete ovr->Tags[i];
|
|
|
|
ovr->Tags.erase(ovr->Tags.begin() + i);
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ovr->Tags[i]->Params[0]->Set(value);
|
|
|
|
ovr->Tags[i]->Params[0]->omitted = false;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
ovr->AddTag(insert);
|
|
|
|
|
|
|
|
line->UpdateText();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
assert(false);
|
|
|
|
|
2012-10-15 05:35:08 +02:00
|
|
|
if (!at_end) {
|
|
|
|
sel_start += shift;
|
|
|
|
sel_end += shift;
|
|
|
|
}
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void set_text(AssDialogue *line, wxString const& value) {
|
|
|
|
line->Text = value;
|
|
|
|
}
|
|
|
|
|
2012-10-15 05:35:08 +02:00
|
|
|
void commit_text(agi::Context const * const c, wxString const& desc, int sel_start = -1, int sel_end = -1, int *commit_id = 0) {
|
2012-10-09 04:07:54 +02:00
|
|
|
SubtitleSelection const& sel = c->selectionController->GetSelectedSet();
|
|
|
|
for_each(sel.begin(), sel.end(),
|
2012-09-25 01:35:27 +02:00
|
|
|
std::bind(set_text, std::placeholders::_1, c->selectionController->GetActiveLine()->Text));
|
2012-10-09 04:07:54 +02:00
|
|
|
int new_commit_id = c->ass->Commit(desc, AssFile::COMMIT_DIAG_TEXT, commit_id ? *commit_id : -1, sel.size() == 1 ? *sel.begin() : 0);
|
|
|
|
if (commit_id)
|
|
|
|
*commit_id = new_commit_id;
|
2012-10-15 05:35:08 +02:00
|
|
|
if (sel_start >= 0 && sel_end >= 0)
|
|
|
|
c->textSelectionController->SetSelection(sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void toggle_override_tag(const agi::Context *c, bool (AssStyle::*field), const char *tag, wxString const& undo_msg) {
|
|
|
|
AssDialogue *const line = c->selectionController->GetActiveLine();
|
|
|
|
AssStyle const* const style = c->ass->GetStyle(line->Style);
|
|
|
|
bool state = style ? style->*field : AssStyle().*field;
|
|
|
|
|
2012-10-12 03:52:36 +02:00
|
|
|
line->ParseAssTags();
|
2012-10-09 04:07:54 +02:00
|
|
|
int sel_start = c->textSelectionController->GetSelectionStart();
|
|
|
|
int sel_end = c->textSelectionController->GetSelectionEnd();
|
|
|
|
int blockn = block_at_pos(line->Text, sel_start);
|
|
|
|
|
|
|
|
state = get_value(*line, blockn, state, tag);
|
|
|
|
|
2012-10-15 05:35:08 +02:00
|
|
|
set_tag(c, tag, state ? "0" : "1", sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
if (sel_start != sel_end)
|
2012-10-15 05:35:08 +02:00
|
|
|
set_tag(c, tag, state ? "1" : "0", sel_start, sel_end, true);
|
2012-10-09 04:07:54 +02:00
|
|
|
|
|
|
|
line->ClearBlocks();
|
2012-10-15 05:35:08 +02:00
|
|
|
commit_text(c, undo_msg, sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
|
2012-10-26 16:09:14 +02:00
|
|
|
void got_color(const agi::Context *c, const char *tag, int *commit_id, agi::Color new_color) {
|
|
|
|
int sel_start = c->textSelectionController->GetSelectionStart();
|
|
|
|
int sel_end = c->textSelectionController->GetSelectionEnd();
|
|
|
|
set_tag(c, tag, new_color.GetAssOverrideFormatted(), sel_start, sel_end);
|
|
|
|
commit_text(c, _("set color"), sel_start, sel_end, commit_id);
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
|
2012-10-26 16:09:14 +02:00
|
|
|
void show_color_picker(const agi::Context *c, agi::Color (AssStyle::*field), const char *tag, const char *alt) {
|
2012-10-09 04:07:54 +02:00
|
|
|
AssDialogue *const line = c->selectionController->GetActiveLine();
|
|
|
|
AssStyle const* const style = c->ass->GetStyle(line->Style);
|
2012-10-26 16:09:14 +02:00
|
|
|
agi::Color color = (style ? style->*field : AssStyle().*field);
|
2012-10-09 04:07:54 +02:00
|
|
|
|
2012-10-12 03:52:36 +02:00
|
|
|
line->ParseAssTags();
|
2012-10-09 04:07:54 +02:00
|
|
|
|
|
|
|
int sel_start = c->textSelectionController->GetSelectionStart();
|
|
|
|
int sel_end = c->textSelectionController->GetSelectionEnd();
|
|
|
|
int blockn = block_at_pos(line->Text, sel_start);
|
|
|
|
|
|
|
|
color = get_value(*line, blockn, color, tag, alt);
|
|
|
|
int commit_id = -1;
|
2012-09-25 01:35:27 +02:00
|
|
|
bool ok = GetColorFromUser(c->parent, color, std::bind(got_color, c, tag, &commit_id, std::placeholders::_1));
|
2012-10-09 04:07:54 +02:00
|
|
|
line->ClearBlocks();
|
2012-10-15 05:35:08 +02:00
|
|
|
commit_text(c, _("set color"), -1, -1, &commit_id);
|
2012-10-09 04:07:54 +02:00
|
|
|
|
2012-10-26 16:09:14 +02:00
|
|
|
if (!ok) {
|
2012-10-09 04:07:54 +02:00
|
|
|
c->ass->Undo();
|
|
|
|
c->textSelectionController->SetSelection(sel_start, sel_end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct edit_color_primary : public Command {
|
|
|
|
CMD_NAME("edit/color/primary")
|
|
|
|
STR_MENU("Primary Color...")
|
|
|
|
STR_DISP("Primary Color")
|
|
|
|
STR_HELP("Primary Color")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
show_color_picker(c, &AssStyle::primary, "\\c", "\\1c");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_color_secondary : public Command {
|
|
|
|
CMD_NAME("edit/color/secondary")
|
|
|
|
STR_MENU("Secondary Color...")
|
|
|
|
STR_DISP("Secondary Color")
|
|
|
|
STR_HELP("Secondary Color")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2012-10-10 16:18:54 +02:00
|
|
|
show_color_picker(c, &AssStyle::secondary, "\\2c", "");
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_color_outline : public Command {
|
|
|
|
CMD_NAME("edit/color/outline")
|
|
|
|
STR_MENU("Outline Color...")
|
|
|
|
STR_DISP("Outline Color")
|
|
|
|
STR_HELP("Outline Color")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2012-10-10 16:18:54 +02:00
|
|
|
show_color_picker(c, &AssStyle::outline, "\\3c", "");
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_color_shadow : public Command {
|
|
|
|
CMD_NAME("edit/color/shadow")
|
|
|
|
STR_MENU("Shadow Color...")
|
|
|
|
STR_DISP("Shadow Color")
|
|
|
|
STR_HELP("Shadow Color")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2012-10-10 16:18:54 +02:00
|
|
|
show_color_picker(c, &AssStyle::shadow, "\\4c", "");
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_style_bold : public Command {
|
|
|
|
CMD_NAME("edit/style/bold")
|
|
|
|
STR_MENU("Bold")
|
|
|
|
STR_DISP("Bold")
|
|
|
|
STR_HELP("Bold")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle_override_tag(c, &AssStyle::bold, "\\b", _("toggle bold"));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_style_italic : public Command {
|
|
|
|
CMD_NAME("edit/style/italic")
|
|
|
|
STR_MENU("Italics")
|
|
|
|
STR_DISP("Italics")
|
|
|
|
STR_HELP("Italics")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle_override_tag(c, &AssStyle::italic, "\\i", _("toggle italic"));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_style_underline : public Command {
|
|
|
|
CMD_NAME("edit/style/underline")
|
|
|
|
STR_MENU("Underline")
|
|
|
|
STR_DISP("Underline")
|
|
|
|
STR_HELP("Underline")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle_override_tag(c, &AssStyle::underline, "\\u", _("toggle underline"));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_style_strikeout : public Command {
|
|
|
|
CMD_NAME("edit/style/strikeout")
|
|
|
|
STR_MENU("Strikeout")
|
|
|
|
STR_DISP("Strikeout")
|
|
|
|
STR_HELP("Strikeout")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle_override_tag(c, &AssStyle::strikeout, "\\s", _("toggle strikeout"));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_font : public Command {
|
|
|
|
CMD_NAME("edit/font")
|
|
|
|
STR_MENU("Font Face...")
|
|
|
|
STR_DISP("Font Face")
|
|
|
|
STR_HELP("Font Face")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
AssDialogue *const line = c->selectionController->GetActiveLine();
|
2012-10-12 03:52:36 +02:00
|
|
|
line->ParseAssTags();
|
2012-10-09 04:07:54 +02:00
|
|
|
const int blockn = block_at_pos(line->Text, c->textSelectionController->GetInsertionPoint());
|
|
|
|
|
|
|
|
const AssStyle *style = c->ass->GetStyle(line->Style);
|
|
|
|
const AssStyle default_style;
|
|
|
|
if (!style)
|
|
|
|
style = &default_style;
|
|
|
|
|
2012-10-15 05:35:08 +02:00
|
|
|
int sel_start = c->textSelectionController->GetSelectionStart();
|
|
|
|
int sel_end = c->textSelectionController->GetSelectionEnd();
|
|
|
|
|
2012-10-09 04:07:54 +02:00
|
|
|
const wxFont startfont(
|
|
|
|
get_value(*line, blockn, (int)style->fontsize, "\\fs"),
|
|
|
|
wxFONTFAMILY_DEFAULT,
|
|
|
|
get_value(*line, blockn, style->italic, "\\i") ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL,
|
|
|
|
get_value(*line, blockn, style->bold, "\\b") ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL,
|
|
|
|
get_value(*line, blockn, style->underline, "\\u"),
|
|
|
|
get_value(*line, blockn, style->font, "\\fn"));
|
|
|
|
|
|
|
|
const wxFont font = wxGetFontFromUser(c->parent, startfont);
|
|
|
|
if (!font.Ok() || font == startfont) {
|
|
|
|
line->ClearBlocks();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (font.GetFaceName() != startfont.GetFaceName())
|
2012-10-15 05:35:08 +02:00
|
|
|
set_tag(c, "\\fn", font.GetFaceName(), sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
if (font.GetPointSize() != startfont.GetPointSize())
|
2012-10-15 05:35:08 +02:00
|
|
|
set_tag(c, "\\fs", wxString::Format("%d", font.GetPointSize()), sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
if (font.GetWeight() != startfont.GetWeight())
|
2012-10-15 05:35:08 +02:00
|
|
|
set_tag(c, "\\b", wxString::Format("%d", font.GetWeight() == wxFONTWEIGHT_BOLD), sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
if (font.GetStyle() != startfont.GetStyle())
|
2012-10-15 05:35:08 +02:00
|
|
|
set_tag(c, "\\i", wxString::Format("%d", font.GetStyle() == wxFONTSTYLE_ITALIC), sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
if (font.GetUnderlined() != startfont.GetUnderlined())
|
2012-10-15 05:35:08 +02:00
|
|
|
set_tag(c, "\\i", wxString::Format("%d", font.GetUnderlined()), sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
|
|
|
|
line->ClearBlocks();
|
2012-10-15 05:35:08 +02:00
|
|
|
commit_text(c, _("set font"), sel_start, sel_end);
|
2012-10-09 04:07:54 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-10-01 01:51:41 +02:00
|
|
|
/// Find and replace words in subtitles.
|
|
|
|
struct edit_find_replace : public Command {
|
|
|
|
CMD_NAME("edit/find_replace")
|
2012-10-09 04:07:54 +02:00
|
|
|
STR_MENU("Find and R&eplace...")
|
|
|
|
STR_DISP("Find and Replace")
|
|
|
|
STR_HELP("Find and replace words in subtitles")
|
2011-10-01 01:51:41 +02:00
|
|
|
|
2012-10-09 04:07:54 +02:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->videoController->Stop();
|
|
|
|
Search.OpenDialog(true);
|
2011-10-01 01:51:41 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-15 03:57:57 +02:00
|
|
|
static void copy_lines(agi::Context *c) {
|
|
|
|
wxString data;
|
|
|
|
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
2012-11-05 17:20:58 +01:00
|
|
|
for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) {
|
|
|
|
if (sel.count(diag)) {
|
2012-10-15 03:57:57 +02:00
|
|
|
if (!data.empty())
|
|
|
|
data += "\r\n";
|
|
|
|
data += diag->GetEntryData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 17:13:13 +02:00
|
|
|
SetClipboard(data);
|
2012-10-15 03:57:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
|
|
|
AssDialogue *active = c->selectionController->GetActiveLine();
|
|
|
|
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
|
|
|
|
|
|
|
// Find a line near the active line not being deleted to make the new active line
|
|
|
|
AssDialogue *new_active = 0;
|
|
|
|
bool hit_active = false;
|
|
|
|
|
2012-11-05 17:20:58 +01:00
|
|
|
for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) {
|
2012-10-15 03:57:57 +02:00
|
|
|
if (diag == active) {
|
|
|
|
hit_active = true;
|
|
|
|
if (new_active) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sel.count(diag)) {
|
|
|
|
new_active = diag;
|
|
|
|
if (hit_active) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete selected lines
|
|
|
|
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ) {
|
2012-10-12 19:16:39 +02:00
|
|
|
if (sel.count(static_cast<AssDialogue*>(&*it)))
|
|
|
|
delete &*it++;
|
2012-10-15 03:57:57 +02:00
|
|
|
else
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we didn't get a new active line then we just deleted all the dialogue
|
|
|
|
// lines, so make a new one
|
|
|
|
if (!new_active) {
|
|
|
|
new_active = new AssDialogue;
|
|
|
|
c->ass->InsertDialogue(new_active);
|
|
|
|
}
|
|
|
|
|
|
|
|
c->ass->Commit(commit_message, AssFile::COMMIT_DIAG_ADDREM);
|
|
|
|
|
|
|
|
sel.clear();
|
|
|
|
sel.insert(new_active);
|
|
|
|
c->selectionController->SetSelectionAndActive(sel, new_active);
|
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
/// Copy subtitles.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_copy : public validate_sel_nonempty {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/copy")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("&Copy Lines")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Copy Lines")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Copy subtitles")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2012-03-13 00:34:25 +01:00
|
|
|
// Ideally we'd let the control's keydown handler run and only deal
|
|
|
|
// with the events not processed by it, but that doesn't seem to be
|
|
|
|
// possible with how wx implements key event handling - the native
|
|
|
|
// platform processing is evoked only if the wx event is unprocessed,
|
|
|
|
// and there's no way to do something if the native platform code leaves
|
|
|
|
// it unprocessed
|
|
|
|
|
|
|
|
if (wxTextEntryBase *ctrl = dynamic_cast<wxTextEntryBase*>(c->parent->FindFocus()))
|
|
|
|
ctrl->Copy();
|
2012-10-15 03:57:57 +02:00
|
|
|
else {
|
|
|
|
copy_lines(c);
|
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Cut subtitles.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_cut: public validate_sel_nonempty {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/cut")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("Cu&t Lines")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Cut Lines")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Cut subtitles")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2012-03-13 00:34:25 +01:00
|
|
|
if (wxTextEntryBase *ctrl = dynamic_cast<wxTextEntryBase*>(c->parent->FindFocus()))
|
|
|
|
ctrl->Cut();
|
2012-10-15 03:57:57 +02:00
|
|
|
else {
|
|
|
|
copy_lines(c);
|
|
|
|
delete_lines(c, _("cut lines"));
|
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Delete currently selected lines.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_delete : public validate_sel_nonempty {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/delete")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("De&lete Lines")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Delete Lines")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Delete currently selected lines")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2012-10-15 03:57:57 +02:00
|
|
|
delete_lines(c, _("delete lines"));
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-12 19:16:39 +02:00
|
|
|
struct in_selection : public std::unary_function<AssEntry, bool> {
|
2012-02-15 23:14:10 +01:00
|
|
|
SubtitleSelectionController::Selection const& sel;
|
|
|
|
in_selection(SubtitleSelectionController::Selection const& sel) : sel(sel) { }
|
2012-10-12 19:16:39 +02:00
|
|
|
bool operator()(AssEntry const& e) const {
|
|
|
|
const AssDialogue *d = dynamic_cast<const AssDialogue*>(&e);
|
|
|
|
return d && sel.count(const_cast<AssDialogue *>(d));
|
2012-02-15 23:14:10 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void duplicate_lines(agi::Context *c, bool shift) {
|
|
|
|
in_selection sel(c->selectionController->GetSelectedSet());
|
|
|
|
SubtitleSelectionController::Selection new_sel;
|
|
|
|
AssDialogue *new_active = 0;
|
|
|
|
|
2012-10-12 19:16:39 +02:00
|
|
|
entryIter start = c->ass->Line.begin();
|
|
|
|
entryIter end = c->ass->Line.end();
|
2012-02-15 23:14:10 +01:00
|
|
|
while (start != end) {
|
|
|
|
// Find the first line in the selection
|
|
|
|
start = find_if(start, end, sel);
|
|
|
|
if (start == end) break;
|
|
|
|
|
|
|
|
// And the last line in this contiguous selection
|
2012-11-13 14:52:24 +01:00
|
|
|
entryIter insert_pos = find_if_not(start, end, sel);
|
2012-10-12 19:16:39 +02:00
|
|
|
entryIter last = insert_pos;
|
2012-02-15 23:14:10 +01:00
|
|
|
--last;
|
|
|
|
|
|
|
|
// Duplicate each of the selected lines, inserting them in a block
|
|
|
|
// after the selected block
|
|
|
|
do {
|
2012-10-12 19:16:39 +02:00
|
|
|
AssDialogue *new_diag = static_cast<AssDialogue*>(start->Clone());
|
2012-02-15 23:14:10 +01:00
|
|
|
|
2012-10-12 19:16:39 +02:00
|
|
|
c->ass->Line.insert(insert_pos, *new_diag);
|
2012-02-15 23:14:10 +01:00
|
|
|
new_sel.insert(new_diag);
|
|
|
|
if (!new_active)
|
|
|
|
new_active = new_diag;
|
|
|
|
|
|
|
|
if (shift) {
|
|
|
|
int pos = c->videoController->FrameAtTime(new_diag->End, agi::vfr::END) + 1;
|
|
|
|
new_diag->Start = c->videoController->TimeAtFrame(pos, agi::vfr::START);
|
|
|
|
new_diag->End = c->videoController->TimeAtFrame(pos, agi::vfr::END);
|
|
|
|
}
|
|
|
|
} while (start++ != last);
|
|
|
|
|
|
|
|
// Skip over the lines we just made
|
|
|
|
start = insert_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_sel.empty()) return;
|
|
|
|
|
|
|
|
c->ass->Commit(_("duplicate lines"), AssFile::COMMIT_DIAG_ADDREM);
|
|
|
|
|
2012-05-05 04:11:09 +02:00
|
|
|
c->selectionController->SetSelectionAndActive(new_sel, new_active);
|
2012-02-15 23:14:10 +01:00
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
/// Duplicate the selected lines.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_duplicate : public validate_sel_nonempty {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/duplicate")
|
|
|
|
STR_MENU("&Duplicate Lines")
|
|
|
|
STR_DISP("Duplicate Lines")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Duplicate the selected lines")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2012-02-15 23:14:10 +01:00
|
|
|
duplicate_lines(c, false);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Duplicate lines and shift by one frame.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct edit_line_duplicate_shift : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/duplicate/shift")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("D&uplicate and Shift by 1 Frame")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Duplicate and Shift by 1 Frame")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Duplicate lines and shift by one frame")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return !c->selectionController->GetSelectedSet().empty() && c->videoController->IsLoaded();
|
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2012-02-15 23:14:10 +01:00
|
|
|
duplicate_lines(c, true);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-07-15 06:04:48 +02:00
|
|
|
static void combine_lines(agi::Context *c, void (*combiner)(AssDialogue *, AssDialogue *), wxString const& message) {
|
2012-10-05 05:22:54 +02:00
|
|
|
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
2011-07-15 06:04:48 +02:00
|
|
|
|
|
|
|
AssDialogue *first = 0;
|
2012-10-12 19:16:39 +02:00
|
|
|
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ) {
|
|
|
|
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it++);
|
|
|
|
if (!diag || !sel.count(diag))
|
2011-07-15 06:04:48 +02:00
|
|
|
continue;
|
|
|
|
if (!first) {
|
|
|
|
first = diag;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
combiner(first, diag);
|
2012-05-01 04:49:53 +02:00
|
|
|
first->End = std::max(first->End, diag->End);
|
2011-07-15 06:04:48 +02:00
|
|
|
delete diag;
|
|
|
|
}
|
|
|
|
|
|
|
|
sel.clear();
|
|
|
|
sel.insert(first);
|
2012-05-05 04:11:09 +02:00
|
|
|
c->selectionController->SetSelectionAndActive(sel, first);
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(message, AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
|
2011-07-15 06:04:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void combine_karaoke(AssDialogue *first, AssDialogue *second) {
|
2011-12-22 22:28:51 +01:00
|
|
|
first->Text += wxString::Format("{\\k%d}%s", (second->Start - first->End) / 10, second->Text);
|
2011-07-15 06:04:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void combine_concat(AssDialogue *first, AssDialogue *second) {
|
2012-05-01 04:49:48 +02:00
|
|
|
first->Text += " " + second->Text;
|
2011-07-15 06:04:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void combine_drop(AssDialogue *, AssDialogue *) { }
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
/// Joins selected lines in a single one, as karaoke.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_join_as_karaoke : public validate_sel_multiple {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/join/as_karaoke")
|
|
|
|
STR_MENU("As &Karaoke")
|
|
|
|
STR_DISP("As Karaoke")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Joins selected lines in a single one, as karaoke")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-07-15 06:04:48 +02:00
|
|
|
combine_lines(c, combine_karaoke, _("join as karaoke"));
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Joins selected lines in a single one, concatenating text together.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_join_concatenate : public validate_sel_multiple {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/join/concatenate")
|
|
|
|
STR_MENU("&Concatenate")
|
|
|
|
STR_DISP("Concatenate")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Joins selected lines in a single one, concatenating text together")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-07-15 06:04:48 +02:00
|
|
|
combine_lines(c, combine_concat, _("join lines"));
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Joins selected lines in a single one, keeping text of first and discarding remaining.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_join_keep_first : public validate_sel_multiple {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/join/keep_first")
|
|
|
|
STR_MENU("Keep &First")
|
|
|
|
STR_DISP("Keep First")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Joins selected lines in a single one, keeping text of first and discarding remaining")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-07-15 06:04:48 +02:00
|
|
|
combine_lines(c, combine_drop, _("join lines"));
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Paste subtitles.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct edit_line_paste : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/paste")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("&Paste Lines")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Paste Lines")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Paste subtitles")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
bool Validate(const agi::Context *) {
|
2012-10-25 17:13:13 +02:00
|
|
|
bool can_paste = false;
|
2011-07-15 06:05:22 +02:00
|
|
|
if (wxTheClipboard->Open()) {
|
2012-10-25 17:13:13 +02:00
|
|
|
can_paste = wxTheClipboard->IsSupported(wxDF_TEXT);
|
2011-07-15 06:05:22 +02:00
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
2012-10-25 17:13:13 +02:00
|
|
|
return can_paste;
|
2011-07-15 06:05:22 +02:00
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2012-03-13 00:34:25 +01:00
|
|
|
if (wxTextEntryBase *ctrl = dynamic_cast<wxTextEntryBase*>(c->parent->FindFocus()))
|
|
|
|
ctrl->Paste();
|
|
|
|
else
|
2012-10-14 06:21:43 +02:00
|
|
|
paste_lines(c, false);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Paste subtitles over others.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct edit_line_paste_over : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/paste/over")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("Paste Lines &Over...")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Paste Lines Over")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Paste subtitles over others")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
2012-10-25 17:13:13 +02:00
|
|
|
bool can_paste = !c->selectionController->GetSelectedSet().empty();
|
|
|
|
if (can_paste && wxTheClipboard->Open()) {
|
|
|
|
can_paste = wxTheClipboard->IsSupported(wxDF_TEXT);
|
2011-07-15 06:05:22 +02:00
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
2012-10-25 17:13:13 +02:00
|
|
|
return can_paste;
|
2011-07-15 06:05:22 +02:00
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2012-10-14 06:21:43 +02:00
|
|
|
paste_lines(c, true);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Recombine subtitles when they have been split and merged.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_recombine : public validate_sel_multiple {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/recombine")
|
2012-01-27 20:22:57 +01:00
|
|
|
STR_MENU("Recom&bine Lines")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Recombine Lines")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Recombine subtitles when they have been split and merged")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:17:46 +01:00
|
|
|
c->subsGrid->RecombineLines();
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Uses karaoke timing to split line into multiple smaller lines.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct edit_line_split_by_karaoke : public validate_sel_nonempty {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/line/split/by_karaoke")
|
|
|
|
STR_MENU("Split Lines (by karaoke)")
|
|
|
|
STR_DISP("Split Lines (by karaoke)")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Uses karaoke timing to split line into multiple smaller lines")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-09-28 21:44:07 +02:00
|
|
|
AssKaraoke::SplitLines(c->selectionController->GetSelectedSet(), c);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-30 20:32:47 +01:00
|
|
|
void split_lines(agi::Context *c, bool estimate) {
|
|
|
|
int pos = c->textSelectionController->GetSelectionStart();
|
|
|
|
|
|
|
|
AssDialogue *n1 = c->selectionController->GetActiveLine();
|
|
|
|
AssDialogue *n2 = new AssDialogue(*n1);
|
|
|
|
c->ass->Line.insert(++c->ass->Line.iterator_to(*n1), *n2);
|
|
|
|
|
|
|
|
wxString orig = n1->Text;
|
|
|
|
n1->Text = orig.Left(pos).Trim(true); // Trim off trailing whitespace
|
|
|
|
n2->Text = orig.Mid(pos).Trim(false); // Trim off leading whitespace
|
|
|
|
|
|
|
|
if (estimate && orig.size()) {
|
|
|
|
double splitPos = double(pos) / orig.size();
|
|
|
|
n2->Start = n1->End = (int)((n1->End - n1->Start) * splitPos) + n1->Start;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->ass->Commit(_("split"), AssFile::COMMIT_DIAG_ADDREM | (estimate ? AssFile::COMMIT_DIAG_FULL : AssFile::COMMIT_DIAG_TEXT));
|
|
|
|
}
|
|
|
|
|
|
|
|
struct edit_line_split_estimate : public validate_sel_nonempty {
|
|
|
|
CMD_NAME("edit/line/split/estimate")
|
|
|
|
STR_MENU("Split at cursor (estimate times)")
|
|
|
|
STR_DISP("Split at cursor (estimate times)")
|
|
|
|
STR_HELP("Split the current line at the cursor, dividing the original line's duration between the new ones")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
split_lines(c, true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct edit_line_split_preserve : public validate_sel_nonempty {
|
|
|
|
CMD_NAME("edit/line/split/preserve")
|
|
|
|
STR_MENU("Split at cursor (preserve times)")
|
|
|
|
STR_DISP("Split at cursor (preserve times)")
|
|
|
|
STR_HELP("Split the current line at the cursor, setting both lines to the original line's times")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
split_lines(c, false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
/// Redoes last action.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct edit_redo : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/redo")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Redoes last action")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE | COMMAND_DYNAMIC_NAME)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-08-27 08:29:36 +02:00
|
|
|
wxString StrMenu(const agi::Context *c) const {
|
2011-11-17 03:19:10 +01:00
|
|
|
return c->ass->IsRedoStackEmpty() ?
|
|
|
|
_("Nothing to &redo") :
|
|
|
|
wxString::Format(_("&Redo %s"), c->ass->GetRedoDescription());
|
2011-08-27 08:29:36 +02:00
|
|
|
}
|
|
|
|
wxString StrDisplay(const agi::Context *c) const {
|
2011-11-17 03:19:10 +01:00
|
|
|
return c->ass->IsRedoStackEmpty() ?
|
|
|
|
_("Nothing to redo") :
|
|
|
|
wxString::Format(_("Redo %s"), c->ass->GetRedoDescription());
|
2011-08-27 08:29:36 +02:00
|
|
|
}
|
|
|
|
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return !c->ass->IsRedoStackEmpty();
|
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->ass->Redo();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Undoes last action.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct edit_undo : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("edit/undo")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Undoes last action")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE | COMMAND_DYNAMIC_NAME)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-08-27 08:29:36 +02:00
|
|
|
wxString StrMenu(const agi::Context *c) const {
|
2011-11-17 03:19:10 +01:00
|
|
|
return c->ass->IsUndoStackEmpty() ?
|
|
|
|
_("Nothing to &undo") :
|
|
|
|
wxString::Format(_("&Undo %s"), c->ass->GetUndoDescription());
|
2011-08-27 08:29:36 +02:00
|
|
|
}
|
|
|
|
wxString StrDisplay(const agi::Context *c) const {
|
2011-11-17 03:19:10 +01:00
|
|
|
return c->ass->IsUndoStackEmpty() ?
|
|
|
|
_("Nothing to undo") :
|
|
|
|
wxString::Format(_("Undo %s"), c->ass->GetUndoDescription());
|
2011-08-27 08:29:36 +02:00
|
|
|
}
|
|
|
|
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return !c->ass->IsUndoStackEmpty();
|
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->ass->Undo();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
/// @}
|
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
namespace cmd {
|
|
|
|
void init_edit() {
|
2012-10-09 04:07:54 +02:00
|
|
|
reg(new edit_color_primary);
|
|
|
|
reg(new edit_color_secondary);
|
|
|
|
reg(new edit_color_outline);
|
|
|
|
reg(new edit_color_shadow);
|
|
|
|
reg(new edit_font);
|
2011-10-01 01:51:41 +02:00
|
|
|
reg(new edit_find_replace);
|
2011-07-15 06:05:01 +02:00
|
|
|
reg(new edit_line_copy);
|
|
|
|
reg(new edit_line_cut);
|
|
|
|
reg(new edit_line_delete);
|
|
|
|
reg(new edit_line_duplicate);
|
|
|
|
reg(new edit_line_duplicate_shift);
|
|
|
|
reg(new edit_line_join_as_karaoke);
|
|
|
|
reg(new edit_line_join_concatenate);
|
|
|
|
reg(new edit_line_join_keep_first);
|
|
|
|
reg(new edit_line_paste);
|
|
|
|
reg(new edit_line_paste_over);
|
|
|
|
reg(new edit_line_recombine);
|
|
|
|
reg(new edit_line_split_by_karaoke);
|
2012-10-30 20:32:47 +01:00
|
|
|
reg(new edit_line_split_estimate);
|
|
|
|
reg(new edit_line_split_preserve);
|
2012-10-09 04:07:54 +02:00
|
|
|
reg(new edit_style_bold);
|
|
|
|
reg(new edit_style_italic);
|
|
|
|
reg(new edit_style_underline);
|
|
|
|
reg(new edit_style_strikeout);
|
2011-07-15 06:05:01 +02:00
|
|
|
reg(new edit_redo);
|
|
|
|
reg(new edit_undo);
|
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|