Browse Source

clang autocomplete: moved stream manipulator replacements to map

merge-requests/365/head
eidheim 10 years ago
parent
commit
d4b9498269
  1. 25
      src/source_clang.cc
  2. 1
      src/source_clang.h

25
src/source_clang.cc

@ -555,15 +555,10 @@ void Source::ClangViewAutocomplete::autocomplete_dialog_setup() {
} }
} }
//Fixes for the most commonly used stream manipulators //Fixes for the most commonly used stream manipulators
//TODO: feel free to add more static auto manipulators_map=autocomplete_manipulators_map();
if(row=="endl(basic_ostream<_CharT, _Traits> &__os)") auto it=manipulators_map.find(row);
row="endl"; if(it!=manipulators_map.end())
else if(row=="flush(basic_ostream<_CharT, _Traits> &__os)") row=it->second;
row="flush";
else if(row=="hex(std::ios_base &__str)" || row=="hex(std::ios_base &__base)")
row="hex";
else if(row=="dec(std::ios_base &__str)" || row=="dec(std::ios_base &__base)")
row="dec";
get_buffer()->insert(autocomplete_dialog->start_mark->get_iter(), row); get_buffer()->insert(autocomplete_dialog->start_mark->get_iter(), row);
//if selection is finalized, select text inside template arguments or function parameters //if selection is finalized, select text inside template arguments or function parameters
if(hide_window) { if(hide_window) {
@ -787,6 +782,18 @@ std::vector<Source::ClangViewAutocomplete::AutoCompleteData> Source::ClangViewAu
return suggestions; return suggestions;
} }
std::unordered_map<std::string, std::string> Source::ClangViewAutocomplete::autocomplete_manipulators_map() {
std::unordered_map<std::string, std::string> map;
//TODO: feel free to add more
map["endl(basic_ostream<_CharT, _Traits> &__os)"]="endl";
map["flush(basic_ostream<_CharT, _Traits> &__os)"]="flush";
map["hex(std::ios_base &__str)"]="hex"; //clang++ headers
map["hex(std::ios_base &__base)"]="hex"; //g++ headers
map["dec(std::ios_base &__str)"]="dec";
map["dec(std::ios_base &__base)"]="dec";
return map;
}
void Source::ClangViewAutocomplete::async_delete() { void Source::ClangViewAutocomplete::async_delete() {
parsing_in_progress->cancel("canceled, freeing resources in the background"); parsing_in_progress->cancel("canceled, freeing resources in the background");
parse_state=ParseState::STOP; parse_state=ParseState::STOP;

1
src/source_clang.h

@ -89,6 +89,7 @@ namespace Source {
Tooltips autocomplete_tooltips; Tooltips autocomplete_tooltips;
std::string prefix; std::string prefix;
std::mutex prefix_mutex; std::mutex prefix_mutex;
static std::unordered_map<std::string, std::string> autocomplete_manipulators_map();
Glib::Dispatcher do_delete_object; Glib::Dispatcher do_delete_object;
std::thread delete_thread; std::thread delete_thread;

Loading…
Cancel
Save