MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / Process

Method Process

src/dialog_selection.cpp:185–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185void DialogSelection::Process(wxCommandEvent& event) {
186 std::set<AssDialogue*> matches;
187
188 try {
189 matches = process(
190 from_wx(match_text->GetValue()), case_sensitive->IsChecked(),
191 static_cast<Mode>(match_mode->GetSelection()), select_unmatching_lines->GetValue(),
192 apply_to_comments->IsChecked(), apply_to_dialogue->IsChecked(),
193 dialogue_field->GetSelection(), con->ass.get());
194 }
195 catch (agi::Exception const&) {
196 if (event.GetId() == wxID_OK) Close();
197 return;
198 }
199
200 auto action = static_cast<Action>(selection_change_type->GetSelection());
201
202 Selection old_sel, new_sel;
203 if (action != Action::SET)
204 old_sel = con->selectionController->GetSelectedSet();
205
206 wxString message;
207 size_t count = 0;
208 switch (action) {
209 case Action::SET:
210 new_sel = std::move(matches);
211 message = (count = new_sel.size())
212 ? fmt_plural(count, "Selection was set to one line", "Selection was set to %u lines", count)
213 : _("Selection was set to no lines");
214 break;
215
216 case Action::ADD:
217 boost::set_union(old_sel, matches, inserter(new_sel, new_sel.begin()));
218 message = (count = new_sel.size() - old_sel.size())
219 ? fmt_plural(count, "One line was added to selection", "%u lines were added to selection", count)
220 : _("No lines were added to selection");
221 break;
222
223 case Action::SUB:
224 boost::set_difference(old_sel, matches, inserter(new_sel, new_sel.begin()));
225 goto sub_message;
226
227 case Action::INTERSECT:
228 boost::set_intersection(old_sel, matches, inserter(new_sel, new_sel.begin()));
229 sub_message:
230 message = (count = old_sel.size() - new_sel.size())
231 ? fmt_plural(count, "One line was removed from selection", "%u lines were removed from selection", count)
232 : _("No lines were removed from selection");
233 break;
234 }
235
236 if (count == 0)
237 wxMessageBox(message, _("Selection"), wxOK | wxCENTER, this);
238 else
239 con->frame->StatusTimeout(message);
240
241 AssDialogue *new_active = con->selectionController->GetActiveLine();
242 if (new_sel.size() && !new_sel.count(new_active))

Callers

nothing calls this directly

Calls 9

processFunction · 0.85
from_wxFunction · 0.85
StatusTimeoutMethod · 0.80
GetActiveLineMethod · 0.80
SetSelectionAndActiveMethod · 0.80
GetValueMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected