diff --git a/aegisub/src/command/edit.cpp b/aegisub/src/command/edit.cpp index ba95a50bf..9fd999545 100644 --- a/aegisub/src/command/edit.cpp +++ b/aegisub/src/command/edit.cpp @@ -321,33 +321,6 @@ struct edit_line_split_by_karaoke : public validate_sel_nonempty { } }; - -/// Swaps the two selected lines. -struct edit_line_swap : public Command { - CMD_NAME("edit/line/swap") - STR_MENU("Swap Lines") - STR_DISP("Swap Lines") - STR_HELP("Swaps the two selected lines.") - CMD_TYPE(COMMAND_VALIDATE) - - bool Validate(const agi::Context *c) { - return c->selectionController->GetSelectedSet().size() == 2; - } - - void operator()(agi::Context *c) { - SelectionController::Selection sel = c->selectionController->GetSelectedSet(); - if (sel.size() == 2) { - 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()); - - using std::swap; - swap(*a, *b); - c->ass->Commit(_("swap lines"), AssFile::COMMIT_ORDER); - } - } -}; - - /// Redoes last action. struct edit_redo : public Command { CMD_NAME("edit/redo") @@ -420,7 +393,6 @@ namespace cmd { 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_undo); } diff --git a/aegisub/src/command/grid.cpp b/aegisub/src/command/grid.cpp index 7dbdd6ce8..a348b73fd 100644 --- a/aegisub/src/command/grid.cpp +++ b/aegisub/src/command/grid.cpp @@ -213,9 +213,9 @@ static bool move_one(T begin, T end, U value) { return false; } -/// Swap the active line with the dialogue line above it -struct grid_swap_up : public Command { - CMD_NAME("grid/swap/up") +/// Move the active line up one row +struct grid_move_up : public Command { + CMD_NAME("grid/move/up") STR_MENU("Move line up") STR_DISP("Move line up") STR_HELP("Move the selected line up one row") @@ -228,14 +228,14 @@ struct grid_swap_up : public Command { void operator()(agi::Context *c) { if (AssDialogue *line = c->selectionController->GetActiveLine()) { if (move_one(c->ass->Line.rbegin(), c->ass->Line.rend(), line)) - c->ass->Commit(_("swap lines"), AssFile::COMMIT_ORDER); + c->ass->Commit(_("move lines"), AssFile::COMMIT_ORDER); } } }; -/// Swap the active line with the dialogue line below it -struct grid_swap_down : public Command { - CMD_NAME("grid/swap/down") +/// Move the active line down one row +struct grid_move_down : public Command { + CMD_NAME("grid/move/down") STR_MENU("Move line down") STR_DISP("Move line down") STR_HELP("Move the selected line down one row") @@ -248,10 +248,36 @@ struct grid_swap_down : public Command { void operator()(agi::Context *c) { if (AssDialogue *line = c->selectionController->GetActiveLine()) { if (move_one(c->ass->Line.begin(), c->ass->Line.end(), line)) - c->ass->Commit(_("swap lines"), AssFile::COMMIT_ORDER); + c->ass->Commit(_("move lines"), AssFile::COMMIT_ORDER); } } }; + +/// Swaps the two selected lines. +struct grid_swap : public Command { + CMD_NAME("grid/swap") + STR_MENU("Swap Lines") + STR_DISP("Swap Lines") + STR_HELP("Swaps the two selected lines.") + CMD_TYPE(COMMAND_VALIDATE) + + bool Validate(const agi::Context *c) { + return c->selectionController->GetSelectedSet().size() == 2; + } + + void operator()(agi::Context *c) { + SelectionController::Selection sel = c->selectionController->GetSelectedSet(); + if (sel.size() == 2) { + 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()); + + using std::swap; + swap(*a, *b); + c->ass->Commit(_("swap lines"), AssFile::COMMIT_ORDER); + } + } +}; + } /// @} @@ -262,8 +288,9 @@ namespace cmd { reg(new grid_sort_end); reg(new grid_sort_start); reg(new grid_sort_style); - reg(new grid_swap_down); - reg(new grid_swap_up); + reg(new grid_move_down); + reg(new grid_move_up); + reg(new grid_swap); reg(new grid_tag_cycle_hiding); reg(new grid_tags_hide); reg(new grid_tags_show); diff --git a/aegisub/src/libresrc/default_hotkey.json b/aegisub/src/libresrc/default_hotkey.json index d86d7920e..b5f407018 100644 --- a/aegisub/src/libresrc/default_hotkey.json +++ b/aegisub/src/libresrc/default_hotkey.json @@ -148,13 +148,13 @@ "key" : "KP_8" } ], - "grid/swap/down" : [ + "grid/move/down" : [ { "modifiers" : [ "Alt" ], "key" : "Down" } ], - "grid/swap/up" : [ + "grid/move/up" : [ { "modifiers" : [ "Alt" ], "key" : "Up" diff --git a/aegisub/src/libresrc/default_menu.json b/aegisub/src/libresrc/default_menu.json index 569fb0b30..d3cec4b93 100644 --- a/aegisub/src/libresrc/default_menu.json +++ b/aegisub/src/libresrc/default_menu.json @@ -8,7 +8,7 @@ { "command" : "edit/line/duplicate" }, { "command" : "edit/line/duplicate/shift" }, {}, - { "command" : "edit/line/swap" }, + { "command" : "grid/swap" }, { "command" : "edit/line/join/concatenate", "text" : "&Join (concatenate)" }, { "command" : "edit/line/join/keep_first", "text" : "Join (keep first)" }, { "command" : "edit/line/join/as_karaoke", "text" : "Join (as Karaoke)" }, @@ -84,7 +84,7 @@ { "command" : "edit/line/split/by_karaoke" }, {}, { "submenu" : "main/subtitle/sort lines", "text" : "Sort Lines" }, - { "command" : "edit/line/swap" }, + { "command" : "grid/swap" }, { "command" : "tool/line/select" }, { "command" : "subtitle/select/all" } ],