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/
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @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>
|
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"
|
|
|
|
#include "../dialog_search_replace.h"
|
|
|
|
#include "../include/aegisub/context.h"
|
|
|
|
#include "../subs_edit_ctrl.h"
|
|
|
|
#include "../subs_grid.h"
|
|
|
|
#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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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")
|
|
|
|
STR_MENU("Copy Lines")
|
|
|
|
STR_DISP("Copy Lines")
|
|
|
|
STR_HELP("Copy subtitles.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-09-15 07:17:07 +02:00
|
|
|
if (c->parent->FindFocus() == c->editBox) {
|
|
|
|
c->editBox->Copy();
|
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
|
|
|
return;
|
|
|
|
}
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->CopyLines(c->subsGrid->GetSelection());
|
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")
|
|
|
|
STR_MENU("Cut Lines")
|
|
|
|
STR_DISP("Cut Lines")
|
|
|
|
STR_HELP("Cut subtitles.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-09-15 07:17:07 +02:00
|
|
|
if (c->parent->FindFocus() == c->editBox) {
|
|
|
|
c->editBox->Cut();
|
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
|
|
|
return;
|
|
|
|
}
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->CutLines(c->subsGrid->GetSelection());
|
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")
|
|
|
|
STR_MENU("Delete Lines")
|
|
|
|
STR_DISP("Delete Lines")
|
|
|
|
STR_HELP("Delete currently selected lines.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->DeleteLines(c->subsGrid->GetSelection());
|
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")
|
|
|
|
STR_HELP("Duplicate the selected lines.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
wxArrayInt sels = c->subsGrid->GetSelection();
|
|
|
|
c->subsGrid->DuplicateLines(sels.front(), sels.back(), 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")
|
|
|
|
STR_MENU("&Duplicate and Shift by 1 Frame")
|
|
|
|
STR_DISP("Duplicate and Shift by 1 Frame")
|
|
|
|
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) {
|
2011-01-16 08:16:54 +01:00
|
|
|
wxArrayInt sels = c->subsGrid->GetSelection();
|
|
|
|
c->subsGrid->DuplicateLines(sels.front(), sels.back(), 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) {
|
|
|
|
SelectionController<AssDialogue>::Selection sel = c->selectionController->GetSelectedSet();
|
|
|
|
|
|
|
|
AssDialogue *first = 0;
|
|
|
|
entryIter out = c->ass->Line.begin();
|
|
|
|
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
|
|
|
AssDialogue *diag = dynamic_cast<AssDialogue*>(*it);
|
|
|
|
if (!diag || !sel.count(diag)) {
|
|
|
|
*out++ = *it;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!first) {
|
|
|
|
first = diag;
|
|
|
|
*out++ = *it;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
combiner(first, diag);
|
|
|
|
|
|
|
|
first->End.SetMS(diag->End.GetMS());
|
|
|
|
delete diag;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->ass->Line.erase(out, c->ass->Line.end());
|
|
|
|
sel.clear();
|
|
|
|
sel.insert(first);
|
|
|
|
c->selectionController->SetActiveLine(first);
|
|
|
|
c->selectionController->SetSelectedSet(sel);
|
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) {
|
|
|
|
first->Text += wxString::Format("{\\k%d}%s", (second->Start.GetMS() - first->End.GetMS()) / 10, second->Text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void combine_concat(AssDialogue *first, AssDialogue *second) {
|
2011-09-28 21:43:11 +02:00
|
|
|
first->Text += "\\N" + 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")
|
|
|
|
STR_HELP("Joins selected lines in a single one, as karaoke.")
|
|
|
|
|
|
|
|
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")
|
|
|
|
STR_HELP("Joins selected lines in a single one, concatenating text together.")
|
|
|
|
|
|
|
|
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")
|
|
|
|
STR_HELP("Joins selected lines in a single one, keeping text of first and discarding remaining.")
|
|
|
|
|
|
|
|
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")
|
|
|
|
STR_MENU("Paste Lines")
|
|
|
|
STR_DISP("Paste Lines")
|
|
|
|
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-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
if (wxTheClipboard->Open()) {
|
|
|
|
bool can_paste = wxTheClipboard->IsSupported(wxDF_TEXT);
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
return can_paste;
|
|
|
|
}
|
|
|
|
return 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
|
|
|
void operator()(agi::Context *c) {
|
2011-09-15 07:17:07 +02:00
|
|
|
if (c->parent->FindFocus() == c->editBox) {
|
|
|
|
c->editBox->Paste();
|
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
|
|
|
return;
|
|
|
|
}
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->PasteLines(c->subsGrid->GetFirstSelRow());
|
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")
|
|
|
|
STR_MENU("Paste Lines Over..")
|
|
|
|
STR_DISP("Paste Lines Over")
|
|
|
|
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) {
|
|
|
|
if (wxTheClipboard->Open()) {
|
|
|
|
bool can_paste = wxTheClipboard->IsSupported(wxDF_TEXT);
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
return can_paste && c->selectionController->GetSelectedSet().size();
|
|
|
|
}
|
|
|
|
return 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
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->PasteLines(c->subsGrid->GetFirstSelRow(),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")
|
|
|
|
STR_MENU("Recombine Lines")
|
|
|
|
STR_DISP("Recombine Lines")
|
|
|
|
STR_HELP("Recombine subtitles when they have been split and merged.")
|
|
|
|
|
|
|
|
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)")
|
|
|
|
STR_HELP("Uses karaoke timing to split line into multiple smaller lines.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->BeginBatch();
|
|
|
|
wxArrayInt sels = c->subsGrid->GetSelection();
|
2011-01-16 08:15:24 +01:00
|
|
|
bool didSplit = false;
|
|
|
|
for (int i = sels.size() - 1; i >= 0; --i) {
|
2011-01-16 08:16:54 +01:00
|
|
|
didSplit |= c->subsGrid->SplitLineByKaraoke(sels[i]);
|
2011-01-16 08:15:24 +01:00
|
|
|
}
|
|
|
|
if (didSplit) {
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("splitting"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
|
2011-01-16 08:15:24 +01:00
|
|
|
}
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->EndBatch();
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Swaps the two selected lines.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct edit_line_swap : 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/swap")
|
|
|
|
STR_MENU("Swap Lines")
|
|
|
|
STR_DISP("Swap Lines")
|
|
|
|
STR_HELP("Swaps the two selected lines.")
|
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().size() == 2;
|
|
|
|
}
|
|
|
|
|
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-18 06:13:26 +01:00
|
|
|
SelectionController<AssDialogue>::Selection sel = c->selectionController->GetSelectedSet();
|
|
|
|
if (sel.size() == 2) {
|
2011-01-18 07:01:29 +01:00
|
|
|
entryIter a = find(c->ass->Line.begin(), c->ass->Line.end(), *sel.begin());
|
|
|
|
entryIter b = find(c->ass->Line.begin(), c->ass->Line.end(), *sel.rbegin());
|
|
|
|
|
2011-01-18 06:13:26 +01:00
|
|
|
using std::swap;
|
2011-01-18 07:01:29 +01:00
|
|
|
swap(*a, *b);
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("swap lines"), AssFile::COMMIT_ORDER);
|
2011-01-18 06:13:26 +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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// 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")
|
|
|
|
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 {
|
|
|
|
return wxString::Format(_("&Redo %s"), c->ass->GetRedoDescription());
|
|
|
|
}
|
|
|
|
wxString StrDisplay(const agi::Context *c) const {
|
|
|
|
return wxString::Format(_("Redo %s"), c->ass->GetRedoDescription());
|
|
|
|
}
|
|
|
|
|
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) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->videoController->Stop();
|
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
|
|
|
c->ass->Redo();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Find and replace words in subtitles.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct edit_search_replace : 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/search_replace")
|
|
|
|
STR_MENU("Search and &Replace..")
|
|
|
|
STR_DISP("Search and Replace")
|
|
|
|
STR_HELP("Find and replace words in subtitles.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->videoController->Stop();
|
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
|
|
|
Search.OpenDialog(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// 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")
|
|
|
|
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 {
|
|
|
|
return wxString::Format(_("&Undo %s"), c->ass->GetUndoDescription());
|
|
|
|
}
|
|
|
|
wxString StrDisplay(const agi::Context *c) const {
|
|
|
|
return wxString::Format(_("Undo %s"), c->ass->GetUndoDescription());
|
|
|
|
}
|
|
|
|
|
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) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->videoController->Stop();
|
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
|
|
|
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() {
|
|
|
|
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);
|
|
|
|
reg(new edit_line_swap);
|
|
|
|
reg(new edit_redo);
|
|
|
|
reg(new edit_search_replace);
|
|
|
|
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
|
|
|
}
|