Browse Source

Add mark of current search result, needs more work

merge-requests/365/head
Jørgen Lien Sellæg 11 years ago
parent
commit
bca64014af
  1. 1
      juci/config.json
  2. 13
      juci/notebook.cc

1
juci/config.json

@ -2,6 +2,7 @@
"source": { "source": {
"colors": { "colors": {
"text_color": "black", "text_color": "black",
"search": "orange",
"string": "#CC0000", "string": "#CC0000",
"namespace_ref": "#990099", "namespace_ref": "#990099",
"type": "#0066FF", "type": "#0066FF",

13
juci/notebook.cc

@ -416,20 +416,25 @@ void Notebook::Controller::OnEditSearch() {
void Notebook::Controller::Search(bool forward) { void Notebook::Controller::Search(bool forward) {
INFO("Notebook search"); INFO("Notebook search");
// fetch buffer and greate settings
auto buffer = CurrentTextView().get_source_buffer(); auto buffer = CurrentTextView().get_source_buffer();
auto settings = gtk_source_search_settings_new(); auto settings = gtk_source_search_settings_new();
// get search text from entry
gtk_source_search_settings_set_search_text(settings, entry_.text().c_str()); gtk_source_search_settings_set_search_text(settings, entry_.text().c_str());
gtk_source_search_settings_set_wrap_around(settings, TRUE);
// make sure the search continues
gtk_source_search_settings_set_wrap_around(settings, true);
auto context = gtk_source_search_context_new(buffer->gobj(), settings); auto context = gtk_source_search_context_new(buffer->gobj(), settings);
gtk_source_search_context_set_highlight(context, forward); gtk_source_search_context_set_highlight(context, forward);
auto itr = buffer->get_insert()->get_iter().gobj(); auto itr = buffer->get_insert()->get_iter().gobj();
gtk_source_search_context_forward(context, gtk_source_search_context_forward(context,
end ? end.gobj() : itr, end ? end.gobj() : itr,
start.gobj(), start.gobj(),
end.gobj()); end.gobj());
buffer->apply_tag_by_name("search", start, end);
CurrentTextView().scroll_to(end); CurrentTextView().scroll_to(end);
} }

Loading…
Cancel
Save