forked from mia/Aegisub
Make the enter-key-in-edit-box logic a standard hotkeyed command
Originally committed to SVN as r6294.
This commit is contained in:
parent
d8cedf0eec
commit
40e4f887ba
3 changed files with 45 additions and 32 deletions
|
@ -43,9 +43,9 @@
|
||||||
#include "../ass_dialogue.h"
|
#include "../ass_dialogue.h"
|
||||||
#include "../ass_file.h"
|
#include "../ass_file.h"
|
||||||
#include "../include/aegisub/context.h"
|
#include "../include/aegisub/context.h"
|
||||||
#include "../subs_grid.h"
|
|
||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
#include "../frame_main.h"
|
#include "../frame_main.h"
|
||||||
|
#include "../selection_controller.h"
|
||||||
#include "../utils.h"
|
#include "../utils.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -61,10 +61,33 @@ struct grid_line_next : public Command {
|
||||||
STR_HELP("Move to the next subtitle line.")
|
STR_HELP("Move to the next subtitle line.")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
c->subsGrid->NextLine();
|
c->selectionController->NextLine();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Move to the next subtitle line, creating it if needed
|
||||||
|
struct grid_line_next_create : public Command {
|
||||||
|
CMD_NAME("grid/line/next/create")
|
||||||
|
STR_MENU("Next Line")
|
||||||
|
STR_DISP("Next Line")
|
||||||
|
STR_HELP("Move to the next subtitle line, creating a new one if needed.")
|
||||||
|
|
||||||
|
void operator()(agi::Context *c) {
|
||||||
|
AssDialogue *cur = c->selectionController->GetActiveLine();
|
||||||
|
c->selectionController->NextLine();
|
||||||
|
if (cur == c->selectionController->GetActiveLine()) {
|
||||||
|
AssDialogue *newline = new AssDialogue;
|
||||||
|
newline->Start = cur->End;
|
||||||
|
newline->End = cur->End + OPT_GET("Timing/Default Duration")->GetInt();
|
||||||
|
newline->Style = cur->Style;
|
||||||
|
|
||||||
|
entryIter pos = find(c->ass->Line.begin(), c->ass->Line.end(), cur);
|
||||||
|
c->ass->Line.insert(++pos, newline);
|
||||||
|
c->ass->Commit(_("line insertion"), AssFile::COMMIT_DIAG_ADDREM);
|
||||||
|
c->selectionController->NextLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// Move to the previous line.
|
/// Move to the previous line.
|
||||||
struct grid_line_prev : public Command {
|
struct grid_line_prev : public Command {
|
||||||
|
@ -74,7 +97,7 @@ struct grid_line_prev : public Command {
|
||||||
STR_HELP("Move to the previous line.")
|
STR_HELP("Move to the previous line.")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
c->subsGrid->PrevLine();
|
c->selectionController->PrevLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -284,6 +307,7 @@ struct grid_swap : public Command {
|
||||||
namespace cmd {
|
namespace cmd {
|
||||||
void init_grid() {
|
void init_grid() {
|
||||||
reg(new grid_line_next);
|
reg(new grid_line_next);
|
||||||
|
reg(new grid_line_next_create);
|
||||||
reg(new grid_line_prev);
|
reg(new grid_line_prev);
|
||||||
reg(new grid_sort_end);
|
reg(new grid_sort_end);
|
||||||
reg(new grid_sort_start);
|
reg(new grid_sort_start);
|
||||||
|
|
|
@ -545,6 +545,19 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"Subtitle Edit Box" : {
|
||||||
|
"grid/line/next/create" : [
|
||||||
|
{
|
||||||
|
"modifiers" : [],
|
||||||
|
"key" : "KP_Enter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"modifiers" : [],
|
||||||
|
"key" : "Enter"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
"Styling Assistant" : {
|
"Styling Assistant" : {
|
||||||
"audio/play/selection" : [
|
"audio/play/selection" : [
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,19 +54,19 @@
|
||||||
#include <wx/spinctrl.h>
|
#include <wx/spinctrl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "include/aegisub/hotkey.h"
|
#include "subs_edit_box.h"
|
||||||
|
|
||||||
#include "ass_dialogue.h"
|
#include "ass_dialogue.h"
|
||||||
#include "ass_file.h"
|
#include "ass_file.h"
|
||||||
#include "ass_override.h"
|
#include "ass_override.h"
|
||||||
#include "ass_style.h"
|
#include "ass_style.h"
|
||||||
#include "audio_controller.h"
|
#include "command/command.h"
|
||||||
#include "dialog_colorpicker.h"
|
#include "dialog_colorpicker.h"
|
||||||
#include "dialog_search_replace.h"
|
#include "dialog_search_replace.h"
|
||||||
#include "include/aegisub/context.h"
|
#include "include/aegisub/context.h"
|
||||||
|
#include "include/aegisub/hotkey.h"
|
||||||
#include "libresrc/libresrc.h"
|
#include "libresrc/libresrc.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "subs_edit_box.h"
|
|
||||||
#include "subs_edit_ctrl.h"
|
#include "subs_edit_ctrl.h"
|
||||||
#include "subs_grid.h"
|
#include "subs_grid.h"
|
||||||
#include "timeedit_ctrl.h"
|
#include "timeedit_ctrl.h"
|
||||||
|
@ -451,36 +451,12 @@ void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::OnKeyDown(wxKeyEvent &event) {
|
void SubsEditBox::OnKeyDown(wxKeyEvent &event) {
|
||||||
if (hotkey::check("Subtitle Edit Box", c, event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers()))
|
if (!hotkey::check("Subtitle Edit Box", c, event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers()))
|
||||||
return;
|
|
||||||
|
|
||||||
int key = event.GetKeyCode();
|
|
||||||
if (line && (key == WXK_RETURN || key == WXK_NUMPAD_ENTER)) {
|
|
||||||
NextLine();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void SubsEditBox::OnCommitButton(wxCommandEvent &) {
|
void SubsEditBox::OnCommitButton(wxCommandEvent &) {
|
||||||
if (line) NextLine();
|
cmd::call("grid/line/next/create", c);
|
||||||
}
|
|
||||||
|
|
||||||
void SubsEditBox::NextLine() {
|
|
||||||
AssDialogue *cur = line;
|
|
||||||
c->selectionController->NextLine();
|
|
||||||
if (line == cur) {
|
|
||||||
AssDialogue *newline = new AssDialogue;
|
|
||||||
newline->Start = cur->End;
|
|
||||||
newline->End = cur->End + OPT_GET("Timing/Default Duration")->GetInt();
|
|
||||||
newline->Style = cur->Style;
|
|
||||||
|
|
||||||
entryIter pos = find(c->ass->Line.begin(), c->ass->Line.end(), line);
|
|
||||||
c->ass->Line.insert(++pos, newline);
|
|
||||||
c->ass->Commit(_("line insertion"), AssFile::COMMIT_DIAG_ADDREM);
|
|
||||||
c->selectionController->NextLine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsEditBox::OnChange(wxStyledTextEvent &event) {
|
void SubsEditBox::OnChange(wxStyledTextEvent &event) {
|
||||||
|
|
Loading…
Reference in a new issue