From a40b76ea59e67e462574d16d037e1b45fcb84f8f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sun, 14 Oct 2012 08:21:41 -0700 Subject: [PATCH] Insert new lines before/after the active line rather than the first selected line --- aegisub/src/command/subtitle.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/aegisub/src/command/subtitle.cpp b/aegisub/src/command/subtitle.cpp index 644fc5eb4..4c81ab04d 100644 --- a/aegisub/src/command/subtitle.cpp +++ b/aegisub/src/command/subtitle.cpp @@ -124,21 +124,21 @@ struct subtitle_find_next : public Command { }; static void insert_subtitle_at_video(agi::Context *c, bool after) { - int n = c->subsGrid->GetFirstSelRow(); - - // Create line to add AssDialogue *def = new AssDialogue; int video_ms = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START); def->Start = video_ms; def->End = video_ms + OPT_GET("Timing/Default Duration")->GetInt(); - def->Style = c->subsGrid->GetDialogue(n)->Style; + def->Style = c->selectionController->GetActiveLine()->Style; - // Insert it - c->subsGrid->BeginBatch(); - c->subsGrid->InsertLine(def, n, after); - c->subsGrid->SelectRow(n + (int)after); - c->subsGrid->SetActiveLine(def); - c->subsGrid->EndBatch(); + entryIter pos = find(c->ass->Line.begin(), c->ass->Line.end(), c->selectionController->GetActiveLine()); + if (after) ++pos; + + c->ass->Line.insert(pos, def); + c->ass->Commit(_("line insertion"), AssFile::COMMIT_DIAG_ADDREM); + + SubtitleSelection sel; + sel.insert(def); + c->selectionController->SetSelectionAndActive(sel, def); } /// Inserts a line after current.