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. 11
      src/source_clang.cc
  6. 9
      src/window.cc

2
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.8) cmake_minimum_required (VERSION 2.8.8)
project(juci) project(juci)
set(JUCI_VERSION "1.2.3") set(JUCI_VERSION "1.2.3.1")
set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>") 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_center_cursor": "<primary>l",
"source_cursor_history_back": "<alt>Left", "source_cursor_history_back": "<alt>Left",
"source_cursor_history_forward": "<alt>Right", "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_find_symbol_ctags": "<primary><shift>f",
"source_comments_toggle": "<primary>slash", "source_comments_toggle": "<primary>slash",
"source_comments_add_documentation": "<primary><alt>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()) { if(style->property_foreground_set()) {
note_tag->property_foreground()=style->property_foreground(); 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() { void Source::View::set_tooltip_and_dialog_events() {

3
src/source.h

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

11
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::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::Language> language):
Source::ClangViewParse(file_path, language), autocomplete_state(AutocompleteState::IDLE) { 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](){ get_buffer()->signal_changed().connect([this](){
if(CompletionDialog::get() && CompletionDialog::get()->is_visible()) if(CompletionDialog::get() && CompletionDialog::get()->is_visible())
delayed_reparse_connection.disconnect(); delayed_reparse_connection.disconnect();
@ -577,6 +583,7 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa
if((last_keyval>='0' && last_keyval<='9') || if((last_keyval>='0' && last_keyval<='9') ||
(last_keyval>='a' && last_keyval<='z') || (last_keyval>='A' && last_keyval<='Z') || (last_keyval>='a' && last_keyval<='z') || (last_keyval>='A' && last_keyval<='Z') ||
last_keyval=='_') { last_keyval=='_') {
if(interactive_completion || autocomplete_state!=AutocompleteState::IDLE)
autocomplete_check(); autocomplete_check();
} }
else { else {
@ -584,10 +591,12 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa
autocomplete_state=AutocompleteState::CANCELED; autocomplete_state=AutocompleteState::CANCELED;
auto iter=get_buffer()->get_insert()->get_iter(); auto iter=get_buffer()->get_insert()->get_iter();
iter.backward_chars(2); iter.backward_chars(2);
if(last_keyval=='.' || (last_keyval==':' && *iter==':') || (last_keyval=='>' && *iter=='-')) if(last_keyval=='.' || (last_keyval==':' && *iter==':') || (last_keyval=='>' && *iter=='-')) {
if(interactive_completion)
autocomplete_check(); autocomplete_check();
} }
} }
}
}); });
get_buffer()->signal_mark_set().connect([this](const Gtk::TextBuffer::iterator& iterator, const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark){ get_buffer()->signal_mark_set().connect([this](const Gtk::TextBuffer::iterator& iterator, const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark){
if(mark->get_name()=="insert") { if(mark->get_name()=="insert") {

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); 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]() { menu.add_action("source_find_symbol_ctags", [this]() {
auto view=Notebook::get().get_current_view(); auto view=Notebook::get().get_current_view();

Loading…
Cancel
Save