| 114 | |
| 115 | template<typename Paster> |
| 116 | void paste_lines(agi::Context *c, bool paste_over, Paster&& paste_line) { |
| 117 | std::string data = GetClipboard(); |
| 118 | if (data.empty()) return; |
| 119 | |
| 120 | AssDialogue *first = nullptr; |
| 121 | Selection newsel; |
| 122 | |
| 123 | boost::char_separator<char> sep("\r\n"); |
| 124 | for (auto curdata : boost::tokenizer<boost::char_separator<char>>(data, sep)) { |
| 125 | AssDialogue *inserted = paste_line(get_dialogue(curdata)); |
| 126 | if (!inserted) |
| 127 | break; |
| 128 | |
| 129 | newsel.insert(inserted); |
| 130 | if (!first) |
| 131 | first = inserted; |
| 132 | } |
| 133 | |
| 134 | if (first) { |
| 135 | c->ass->Commit(_("paste"), paste_over ? AssFile::COMMIT_DIAG_FULL : AssFile::COMMIT_DIAG_ADDREM); |
| 136 | |
| 137 | if (!paste_over) |
| 138 | c->selectionController->SetSelectionAndActive(std::move(newsel), first); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | bool paste_over(wxWindow *parent, std::vector<bool>& pasteOverOptions, AssDialogue &new_line, AssDialogue &old_line) { |
| 143 | if (pasteOverOptions.empty()) { |
no test coverage detected