|
|
|
|
@ -234,9 +234,9 @@ parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) {
|
|
|
|
|
}, 1000); |
|
|
|
|
type_tooltips.hide(); |
|
|
|
|
diagnostic_tooltips.hide(); |
|
|
|
|
if(last_similar_token_marked!="") { |
|
|
|
|
if(last_similar_tokens_tagged!="") { |
|
|
|
|
get_buffer()->remove_tag(similar_tokens_tag, get_buffer()->begin(), get_buffer()->end()); |
|
|
|
|
last_similar_token_marked=""; |
|
|
|
|
last_similar_tokens_tagged=""; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
@ -442,22 +442,22 @@ void Source::ClangView::on_mark_set(const Gtk::TextBuffer::iterator& iterator, c
|
|
|
|
|
if(range_data.path==file_path && insert_offset>=range_data.start_offset && insert_offset<=range_data.end_offset) { |
|
|
|
|
found=true; |
|
|
|
|
auto referenced_usr_and_token_spelling=token.get_cursor().get_referenced_usr()+token.get_token_spelling(); |
|
|
|
|
if(last_similar_token_marked!=referenced_usr_and_token_spelling) { |
|
|
|
|
if(last_similar_tokens_tagged!=referenced_usr_and_token_spelling) { |
|
|
|
|
get_buffer()->remove_tag(similar_tokens_tag, get_buffer()->begin(), get_buffer()->end()); |
|
|
|
|
auto offsets=clang_tokens->get_similar_token_offsets(token); |
|
|
|
|
for(auto &offset: offsets) { |
|
|
|
|
get_buffer()->apply_tag(similar_tokens_tag, get_buffer()->get_iter_at_offset(offset.first), get_buffer()->get_iter_at_offset(offset.second)); |
|
|
|
|
} |
|
|
|
|
last_similar_token_marked=referenced_usr_and_token_spelling; |
|
|
|
|
last_similar_tokens_tagged=referenced_usr_and_token_spelling; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(!found && last_similar_token_marked!="") { |
|
|
|
|
if(!found && last_similar_tokens_tagged!="") { |
|
|
|
|
get_buffer()->remove_tag(similar_tokens_tag, get_buffer()->begin(), get_buffer()->end()); |
|
|
|
|
last_similar_token_marked=""; |
|
|
|
|
last_similar_tokens_tagged=""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -569,43 +569,13 @@ bool Source::ClangView::on_key_press_event(GdkEventKey* key) {
|
|
|
|
|
Source::ClangViewAutocomplete::ClangViewAutocomplete(const std::string& file_path, const std::string& project_path, Terminal::Controller& terminal): |
|
|
|
|
Source::ClangView(file_path, project_path, terminal), selection_dialog(*this), autocomplete_cancel_starting(false) { |
|
|
|
|
selection_dialog.on_hide=[this](){ |
|
|
|
|
|
|
|
|
|
//TODO: start parsing again?
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
get_buffer()->signal_changed().connect([this](){ |
|
|
|
|
if(selection_dialog.shown) |
|
|
|
|
delayed_reparse_connection.disconnect(); |
|
|
|
|
const std::regex autocomplete_keys("[a-zA-Z0-9_>\\.:]"); |
|
|
|
|
std::smatch sm; |
|
|
|
|
if(!std::regex_match(std::string()+(char)last_keyval, sm, autocomplete_keys)) |
|
|
|
|
return; |
|
|
|
|
std::string line=" "+get_line_before_insert(); |
|
|
|
|
if((std::count(line.begin(), line.end(), '\"')%2)!=1 && line.find("//")==std::string::npos) { |
|
|
|
|
const std::regex in_specified_namespace("^(.*[a-zA-Z0-9_\\)])(->|\\.|::)([a-zA-Z0-9_]*)$"); |
|
|
|
|
const std::regex within_namespace("^(.*)([^a-zA-Z0-9_]+)([a-zA-Z0-9_]{3,})$"); |
|
|
|
|
if(std::regex_match(line, sm, in_specified_namespace)) { |
|
|
|
|
prefix_mutex.lock(); |
|
|
|
|
prefix=sm[3].str(); |
|
|
|
|
prefix_mutex.unlock(); |
|
|
|
|
if((prefix.size()==0 || prefix[0]<'0' || prefix[0]>'9') && !autocomplete_starting && !selection_dialog.shown) { |
|
|
|
|
autocomplete(); |
|
|
|
|
} |
|
|
|
|
else if(last_keyval=='.' && autocomplete_starting) |
|
|
|
|
autocomplete_cancel_starting=true; |
|
|
|
|
} |
|
|
|
|
else if(std::regex_match(line, sm, within_namespace)) { |
|
|
|
|
prefix_mutex.lock(); |
|
|
|
|
prefix=sm[3].str(); |
|
|
|
|
prefix_mutex.unlock(); |
|
|
|
|
if((prefix.size()==0 || prefix[0]<'0' || prefix[0]>'9') && !autocomplete_starting && !selection_dialog.shown) { |
|
|
|
|
autocomplete(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
autocomplete_cancel_starting=true; |
|
|
|
|
if(autocomplete_starting || selection_dialog.shown) |
|
|
|
|
delayed_reparse_connection.disconnect(); |
|
|
|
|
} |
|
|
|
|
start_autocomplete(); |
|
|
|
|
}); |
|
|
|
|
get_buffer()->signal_mark_set().connect([this](const Gtk::TextBuffer::iterator& iterator, const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark){ |
|
|
|
|
if(mark->get_name()=="insert") { |
|
|
|
|
@ -647,6 +617,42 @@ bool Source::ClangViewAutocomplete::on_focus_out_event(GdkEventFocus* event) {
|
|
|
|
|
return Source::ClangView::on_focus_out_event(event); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Source::ClangViewAutocomplete::start_autocomplete() { |
|
|
|
|
const std::regex autocomplete_keys("[a-zA-Z0-9_>\\.:]"); |
|
|
|
|
std::smatch sm; |
|
|
|
|
if(!std::regex_match(std::string()+(char)last_keyval, sm, autocomplete_keys)) { |
|
|
|
|
autocomplete_cancel_starting=true; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
std::string line=" "+get_line_before_insert(); |
|
|
|
|
if((std::count(line.begin(), line.end(), '\"')%2)!=1 && line.find("//")==std::string::npos) { |
|
|
|
|
const std::regex in_specified_namespace("^(.*[a-zA-Z0-9_\\)])(->|\\.|::)([a-zA-Z0-9_]*)$"); |
|
|
|
|
const std::regex within_namespace("^(.*)([^a-zA-Z0-9_]+)([a-zA-Z0-9_]{3,})$"); |
|
|
|
|
if(std::regex_match(line, sm, in_specified_namespace)) { |
|
|
|
|
prefix_mutex.lock(); |
|
|
|
|
prefix=sm[3].str(); |
|
|
|
|
prefix_mutex.unlock(); |
|
|
|
|
if((prefix.size()==0 || prefix[0]<'0' || prefix[0]>'9') && !autocomplete_starting && !selection_dialog.shown) { |
|
|
|
|
autocomplete(); |
|
|
|
|
} |
|
|
|
|
else if(last_keyval=='.' && autocomplete_starting) |
|
|
|
|
autocomplete_cancel_starting=true; |
|
|
|
|
} |
|
|
|
|
else if(std::regex_match(line, sm, within_namespace)) { |
|
|
|
|
prefix_mutex.lock(); |
|
|
|
|
prefix=sm[3].str(); |
|
|
|
|
prefix_mutex.unlock(); |
|
|
|
|
if((prefix.size()==0 || prefix[0]<'0' || prefix[0]>'9') && !autocomplete_starting && !selection_dialog.shown) { |
|
|
|
|
autocomplete(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
autocomplete_cancel_starting=true; |
|
|
|
|
if(autocomplete_starting || selection_dialog.shown) |
|
|
|
|
delayed_reparse_connection.disconnect(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Source::ClangViewAutocomplete::autocomplete() { |
|
|
|
|
if(!autocomplete_starting) { |
|
|
|
|
autocomplete_starting=true; |
|
|
|
|
@ -655,6 +661,7 @@ void Source::ClangViewAutocomplete::autocomplete() {
|
|
|
|
|
std::shared_ptr<std::vector<Source::AutoCompleteData> > ac_data=std::make_shared<std::vector<Source::AutoCompleteData> >(); |
|
|
|
|
autocomplete_done_connection.disconnect(); |
|
|
|
|
autocomplete_done_connection=autocomplete_done.connect([this, ac_data](){ |
|
|
|
|
autocomplete_starting=false; |
|
|
|
|
if(!autocomplete_cancel_starting) { |
|
|
|
|
if(selection_dialog.start_mark) |
|
|
|
|
get_buffer()->delete_mark(selection_dialog.start_mark); |
|
|
|
|
@ -688,7 +695,8 @@ void Source::ClangViewAutocomplete::autocomplete() {
|
|
|
|
|
selection_dialog.rows=std::move(rows); |
|
|
|
|
selection_dialog.show(); |
|
|
|
|
} |
|
|
|
|
autocomplete_starting=false; |
|
|
|
|
else |
|
|
|
|
start_autocomplete(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
std::shared_ptr<std::map<std::string, std::string> > buffer_map=std::make_shared<std::map<std::string, std::string> >(); |
|
|
|
|
|