Skip to content

Commit

Permalink
allow text selection with search/replace dialog open (#2426)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuspen committed Jan 21, 2024
1 parent e333c67 commit bce4002
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 176 deletions.
33 changes: 14 additions & 19 deletions src/ct/ct_actions_find.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ void CtActions::find_in_selected_node()
if (not _is_there_selected_node_or_error()) return;
Glib::RefPtr<Gtk::TextBuffer> curr_buffer = _pCtMainWin->get_text_view().get_buffer();

std::string pattern;
if (not _s_state.from_find_iterated) {
_s_state.latest_node_offset = -1;
auto iter_insert = curr_buffer->get_iter_at_mark(curr_buffer->get_insert());
Expand All @@ -55,17 +54,18 @@ void CtActions::find_in_selected_node()
if (entry_predefined_text.length()) {
_s_options.str_find = entry_predefined_text;
}
std::string title = _s_state.replace_active ? _("Replace in Current Node") : _("Search in Current Node");
pattern = CtDialogs::dialog_search(_pCtMainWin, title, _s_options, _s_state.replace_active, false/*multiple_nodes*/);
Glib::ustring title = _s_state.replace_active ? _("Replace in Current Node") : _("Search in Current Node");
CtDialogs::dialog_search(_pCtMainWin, title, _s_options, _s_state, false/*multiple_nodes*/);
#if 0 /* TODO check if still needed */
if (entry_predefined_text.length()) {
curr_buffer->move_mark(curr_buffer->get_insert(), iter_insert);
curr_buffer->move_mark(curr_buffer->get_selection_bound(), iter_bound);
}
if (pattern.empty()) return;
_s_state.curr_find_pattern = pattern;
_s_state.curr_find_type = CtCurrFindType::SingleNode;
#endif
}
else {
find_in_selected_node_ok_clicked();
}
find_in_selected_node_ok_clicked();
}

void CtActions::find_in_selected_node_ok_clicked()
Expand Down Expand Up @@ -132,8 +132,6 @@ void CtActions::find_in_multiple_nodes()
CtTextView& ctTextView = _pCtMainWin->get_text_view();
Glib::RefPtr<Gtk::TextBuffer> curr_buffer = ctTextView.get_buffer();

Glib::ustring title;
Glib::ustring pattern;
if (not _s_state.from_find_iterated) {
_s_state.latest_node_offset = -1;
Gtk::TextIter iter_insert = curr_buffer->get_insert()->get_iter();
Expand All @@ -142,21 +140,18 @@ void CtActions::find_in_multiple_nodes()
if (not entry_predefined_text.empty()) {
_s_options.str_find = entry_predefined_text;
}
title = _s_state.replace_active ? _("Replace in Multiple Nodes...") : _("Find in Multiple Nodes...");
pattern = CtDialogs::dialog_search(_pCtMainWin, title, _s_options, _s_state.replace_active, true/*multiple_nodes*/);
Glib::ustring title = _s_state.replace_active ? _("Replace in Multiple Nodes...") : _("Find in Multiple Nodes...");
CtDialogs::dialog_search(_pCtMainWin, title, _s_options, _s_state, true/*multiple_nodes*/);
#if 0 /* TODO check if still needed */
if (not entry_predefined_text.empty()) {
curr_buffer->move_mark(curr_buffer->get_insert(), iter_insert);
curr_buffer->move_mark(curr_buffer->get_selection_bound(), iter_bound);
}
if (not pattern.empty()) {
_s_state.curr_find_pattern = pattern;
_s_state.curr_find_type = CtCurrFindType::MultipleNodes;
}
else {
return;
}
#endif
}
else {
find_in_multiple_nodes_ok_clicked();
}
find_in_multiple_nodes_ok_clicked();
}

void CtActions::find_in_multiple_nodes_ok_clicked()
Expand Down
10 changes: 5 additions & 5 deletions src/ct/ct_dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ void match_dialog(const std::string& str_find,
void iterated_find_dialog(CtMainWin* pCtMainWin,
CtSearchState& s_state);

std::string dialog_search(CtMainWin* pCtMainWin,
const std::string& title,
CtSearchOptions& s_options,
bool replace_on,
bool multiple_nodes);
void dialog_search(CtMainWin* pCtMainWin,
const Glib::ustring& title,
CtSearchOptions& s_options,
CtSearchState& s_state,
bool multiple_nodes);

// Insert/Edit Anchor Name
Glib::ustring img_n_entry_dialog(Gtk::Window& parent,
Expand Down
Loading

0 comments on commit bce4002

Please sign in to comment.