From 7e557c1dad5ed9944e7deb71167ea069fe04b3e0 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 13 Jan 2012 20:18:57 +0000 Subject: [PATCH] Rename edit/line/swap to grid/swap and grid/swap/* to grid/move/* Continue moving all the reordering commands to grid (why were they in three different categories?), and change swap to move to better reflect what they do. Originally committed to SVN as r6287. --- aegisub/src/command/edit.cpp | 28 -------------- aegisub/src/command/grid.cpp | 47 +++++++++++++++++++----- aegisub/src/libresrc/default_hotkey.json | 4 +- aegisub/src/libresrc/default_menu.json | 4 +- 4 files changed, 41 insertions(+), 42 deletions(-) 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" } ],