Browse Source

Parameters are now marked as selected after using autocomplete.

merge-requests/365/head
eidheim 11 years ago
parent
commit
11468432fa
  1. 11
      juci/config.cc
  2. 1
      juci/config.json
  3. 18
      juci/selectiondialog.cc
  4. 5
      juci/source.cc
  5. 2
      juci/source.h

11
juci/config.cc

@ -25,16 +25,19 @@ void MainConfig::GenerateSource() {
if (i.first == "background") {
source_cfg->background = i.second.get_value<std::string>();
}
if (i.first == "background_tooltips") {
else if (i.first == "background_selected") {
source_cfg->background_selected = i.second.get_value<std::string>();
}
else if (i.first == "background_tooltips") {
source_cfg->background_tooltips = i.second.get_value<std::string>();
}
if (i.first == "show_line_numbers") {
else if (i.first == "show_line_numbers") {
source_cfg->show_line_numbers = i.second.get_value<std::string>() == "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<std::string>() == "1" ? true : false;
}
if (i.first == "font") {
else if (i.first == "font") {
source_cfg->font = i.second.get_value<std::string>();
}
}

1
juci/config.json

@ -34,6 +34,7 @@
],
"visual": {
"background": "white",
"background_selected": "blue",
"background_tooltips": "yellow",
"font": "Monospace",
"show_line_numbers": 1,

18
juci/selectiondialog.cc

@ -1,4 +1,5 @@
#include "selectiondialog.h"
#include <regex>
#include <iostream>
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));
}
}
}
}

5
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<Gtk::TextBuffer::Mark>& 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();

2
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<std::string> extensions;
std::unordered_map<std::string, std::string> tags, types;

Loading…
Cancel
Save