From bca64014af20d42cbbd3d7f1bb35b86d581b93f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 17 Jun 2015 16:02:45 +0200 Subject: [PATCH] Add mark of current search result, needs more work --- juci/config.json | 1 + juci/notebook.cc | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/juci/config.json b/juci/config.json index 7c0b9d1..1a73d5c 100644 --- a/juci/config.json +++ b/juci/config.json @@ -2,6 +2,7 @@ "source": { "colors": { "text_color": "black", + "search": "orange", "string": "#CC0000", "namespace_ref": "#990099", "type": "#0066FF", diff --git a/juci/notebook.cc b/juci/notebook.cc index c8fae34..39cbaab 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -416,20 +416,25 @@ void Notebook::Controller::OnEditSearch() { void Notebook::Controller::Search(bool forward) { INFO("Notebook search"); + + // fetch buffer and greate settings auto buffer = CurrentTextView().get_source_buffer(); 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_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); gtk_source_search_context_set_highlight(context, forward); - - - auto itr = buffer->get_insert()->get_iter().gobj(); gtk_source_search_context_forward(context, end ? end.gobj() : itr, start.gobj(), end.gobj()); + + buffer->apply_tag_by_name("search", start, end); CurrentTextView().scroll_to(end); }