Browse Source

Added possibility to disable interactive completion by setting completion keybinding instead

merge-requests/365/head
Hallgeir Løkken 9 years ago committed by eidheim
parent
commit
ee7efc87c2
  1. 2
      CMakeLists.txt
  2. 2
      src/files.h
  3. 9
      src/source.cc
  4. 3
      src/source.h
  5. 15
      src/source_clang.cc
  6. 9
      src/window.cc

2
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.8)
project(juci)
set(JUCI_VERSION "1.2.3")
set(JUCI_VERSION "1.2.3.1")
set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")

2
src/files.h

@ -111,6 +111,8 @@ R"RAW(
"source_center_cursor": "<primary>l",
"source_cursor_history_back": "<alt>Left",
"source_cursor_history_forward": "<alt>Right",
"source_show_completion_comment" : "Add completion keybinding to disable interactive autocompletion",
"source_show_completion" : "",
"source_find_symbol_ctags": "<primary><shift>f",
"source_comments_toggle": "<primary>slash",
"source_comments_add_documentation": "<primary><alt>slash",

9
src/source.cc

@ -654,6 +654,15 @@ void Source::View::configure() {
if(style->property_foreground_set()) {
note_tag->property_foreground()=style->property_foreground();
}
if(Config::get().menu.keys["source_show_completion"].empty()) {
get_completion()->unblock_interactive();
interactive_completion=true;
}
else {
get_completion()->block_interactive();
interactive_completion=false;
}
}
void Source::View::set_tooltip_and_dialog_events() {

3
src/source.h

@ -65,6 +65,7 @@ namespace Source {
Glib::RefPtr<Gsv::Language> language;
std::function<void()> non_interactive_completion;
std::function<void()> format_style;
std::function<Offset()> get_declaration_location;
std::function<std::vector<Offset>(const std::vector<Source::View*> &views)> get_implementation_locations;
@ -155,6 +156,8 @@ namespace Source {
char tab_char;
std::string tab;
bool interactive_completion=true;
guint previous_non_modifier_keyval=0;
private:
void cleanup_whitespace_characters();

15
src/source_clang.cc

@ -568,6 +568,12 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle)
Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language):
Source::ClangViewParse(file_path, language), autocomplete_state(AutocompleteState::IDLE) {
non_interactive_completion=[this] {
if(CompletionDialog::get() && CompletionDialog::get()->is_visible())
return;
autocomplete_check();
};
get_buffer()->signal_changed().connect([this](){
if(CompletionDialog::get() && CompletionDialog::get()->is_visible())
delayed_reparse_connection.disconnect();
@ -577,15 +583,18 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa
if((last_keyval>='0' && last_keyval<='9') ||
(last_keyval>='a' && last_keyval<='z') || (last_keyval>='A' && last_keyval<='Z') ||
last_keyval=='_') {
autocomplete_check();
if(interactive_completion || autocomplete_state!=AutocompleteState::IDLE)
autocomplete_check();
}
else {
if(autocomplete_state==AutocompleteState::STARTING || autocomplete_state==AutocompleteState::RESTARTING)
autocomplete_state=AutocompleteState::CANCELED;
auto iter=get_buffer()->get_insert()->get_iter();
iter.backward_chars(2);
if(last_keyval=='.' || (last_keyval==':' && *iter==':') || (last_keyval=='>' && *iter=='-'))
autocomplete_check();
if(last_keyval=='.' || (last_keyval==':' && *iter==':') || (last_keyval=='>' && *iter=='-')) {
if(interactive_completion)
autocomplete_check();
}
}
}
});

9
src/window.cc

@ -584,6 +584,15 @@ void Window::set_menu_actions() {
cursor_location.view->scroll_to_cursor_delayed(cursor_location.view, true, false);
});
menu.add_action("source_show_completion", [this] {
if(auto view=Notebook::get().get_current_view()) {
if(view->non_interactive_completion)
view->non_interactive_completion();
else
g_signal_emit_by_name(view->gobj(), "show-completion");
}
});
menu.add_action("source_find_symbol_ctags", [this]() {
auto view=Notebook::get().get_current_view();

Loading…
Cancel
Save