diff --git a/juci/config.cc b/juci/config.cc index 6024824..9fa2a69 100644 --- a/juci/config.cc +++ b/juci/config.cc @@ -25,16 +25,19 @@ void MainConfig::GenerateSource() { if (i.first == "background") { source_cfg->background = i.second.get_value(); } - if (i.first == "background_tooltips") { + else if (i.first == "background_selected") { + source_cfg->background_selected = i.second.get_value(); + } + else if (i.first == "background_tooltips") { source_cfg->background_tooltips = i.second.get_value(); } - if (i.first == "show_line_numbers") { + else if (i.first == "show_line_numbers") { source_cfg->show_line_numbers = i.second.get_value() == "1" ? true : false; } - if (i.first == "highlight_current_line") { + else if (i.first == "highlight_current_line") { source_cfg->highlight_current_line = i.second.get_value() == "1" ? true : false; } - if (i.first == "font") { + else if (i.first == "font") { source_cfg->font = i.second.get_value(); } } diff --git a/juci/config.json b/juci/config.json index a831e64..42effbb 100644 --- a/juci/config.json +++ b/juci/config.json @@ -34,6 +34,7 @@ ], "visual": { "background": "white", + "background_selected": "blue", "background_tooltips": "yellow", "font": "Monospace", "show_line_numbers": 1, diff --git a/juci/selectiondialog.cc b/juci/selectiondialog.cc index d812b20..00ca3f6 100644 --- a/juci/selectiondialog.cc +++ b/juci/selectiondialog.cc @@ -1,4 +1,5 @@ #include "selectiondialog.h" +#include #include using namespace std; @@ -66,13 +67,28 @@ void SelectionDialog::hide() { void SelectionDialog::select(bool hide_window) { auto selected=list_view_text->get_selected(); + std::string select; if(selected.size()>0) { - std::string select = rows.at(list_view_text->get_text(selected[0])); + select = rows.at(list_view_text->get_text(selected[0])); text_view.get_buffer()->erase(start_mark->get_iter(), text_view.get_buffer()->get_insert()->get_iter()); text_view.get_buffer()->insert(start_mark->get_iter(), select); } if(hide_window) { hide(); + char find_char=select.back(); + if(find_char==')' || find_char=='>') { + if(find_char==')') + find_char='('; + else + find_char='<'; + size_t pos=select.find(find_char); + if(pos!=std::string::npos) { + auto start_offset=start_mark->get_iter().get_offset()+pos+1; + auto end_offset=start_mark->get_iter().get_offset()+select.size()-1; + if(start_offset!=end_offset) + text_view.get_buffer()->select_range(text_view.get_buffer()->get_iter_at_offset(start_offset), text_view.get_buffer()->get_iter_at_offset(end_offset)); + } + } } } diff --git a/juci/source.cc b/juci/source.cc index f0009de..10d637f 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -38,7 +38,9 @@ file_path(file_path), project_path(project_path) { search_start = search_end = this->get_buffer()->end(); override_font(Pango::FontDescription(Singletons::Config::source()->font)); + override_background_color(Gdk::RGBA(Singletons::Config::source()->background)); + override_background_color(Gdk::RGBA(Singletons::Config::source()->background_selected), Gtk::StateFlags::STATE_FLAG_SELECTED); for (auto &item : Singletons::Config::source()->tags) { get_source_buffer()->create_tag(item.first)->property_foreground() = item.second; } @@ -441,6 +443,9 @@ bool Source::ClangView::clangview_on_motion_notify_event(GdkEventMotion* event) } void Source::ClangView::clangview_on_mark_set(const Gtk::TextBuffer::iterator& iterator, const Glib::RefPtr& mark) { + if(get_buffer()->get_has_selection() && mark->get_name()=="selection_bound") + on_mark_set_timeout_connection.disconnect(); + if(mark->get_name()=="insert") { if(selection_dialog.shown) { selection_dialog.hide(); diff --git a/juci/source.h b/juci/source.h index f06d23b..bd4cb62 100644 --- a/juci/source.h +++ b/juci/source.h @@ -20,7 +20,7 @@ namespace Source { bool legal_extension(std::string e) const ; unsigned tab_size; bool show_line_numbers, highlight_current_line; - std::string tab, background, background_tooltips, font; + std::string tab, background, background_selected, background_tooltips, font; char tab_char=' '; std::vector extensions; std::unordered_map tags, types;