From ee7efc87c2dd461acc21a81f7a771ddf75fda60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hallgeir=20L=C3=B8kken?= Date: Thu, 9 Feb 2017 13:58:20 +0100 Subject: [PATCH] Added possibility to disable interactive completion by setting completion keybinding instead --- CMakeLists.txt | 2 +- src/files.h | 2 ++ src/source.cc | 9 +++++++++ src/source.h | 3 +++ src/source_clang.cc | 15 ++++++++++++--- src/window.cc | 9 +++++++++ 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd7dfc7..92b3def 100644 --- a/CMakeLists.txt +++ b/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 ") diff --git a/src/files.h b/src/files.h index 1cf4075..2432ad3 100644 --- a/src/files.h +++ b/src/files.h @@ -111,6 +111,8 @@ R"RAW( "source_center_cursor": "l", "source_cursor_history_back": "Left", "source_cursor_history_forward": "Right", + "source_show_completion_comment" : "Add completion keybinding to disable interactive autocompletion", + "source_show_completion" : "", "source_find_symbol_ctags": "f", "source_comments_toggle": "slash", "source_comments_add_documentation": "slash", diff --git a/src/source.cc b/src/source.cc index dd0cf45..b5a8951 100644 --- a/src/source.cc +++ b/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() { diff --git a/src/source.h b/src/source.h index e5787e5..574afee 100644 --- a/src/source.h +++ b/src/source.h @@ -65,6 +65,7 @@ namespace Source { Glib::RefPtr language; + std::function non_interactive_completion; std::function format_style; std::function get_declaration_location; std::function(const std::vector &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(); diff --git a/src/source_clang.cc b/src/source_clang.cc index 32c6e5f..7159f77 100644 --- a/src/source_clang.cc +++ b/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 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(); + } } } }); diff --git a/src/window.cc b/src/window.cc index ca2d8fe..0699d04 100644 --- a/src/window.cc +++ b/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();