From e9f26db92c6f71c5287142bf6436d3fb9788c610 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 10 Oct 2015 09:51:22 +0200 Subject: [PATCH] Find Documentation now works on OS X. --- README.md | 1 + src/entrybox.cc | 6 +++--- src/entrybox.h | 2 +- src/files.h | 2 +- src/source.cc | 32 ++++++++++++++++++++------------ 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ab867fc..ed0e918 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ towards libclang with speed and ease of use in mind. * Tooltips showing type information and doxygen documentation * Refactoring across files * Highlighting of similar types +* Documentation search * Spell checking depending on file context * Run shell commands within JuCi++, even on Windows * Regex search and replace diff --git a/src/entrybox.cc b/src/entrybox.cc index a8bbb85..08a3a5e 100644 --- a/src/entrybox.cc +++ b/src/entrybox.cc @@ -16,8 +16,9 @@ namespace sigc { std::unordered_map > EntryBox::entry_histories; -EntryBox::Entry::Entry(const std::string& content, std::function on_activate, unsigned length) : Gtk::Entry(), on_activate(on_activate) { - set_max_length(length); +EntryBox::Entry::Entry(const std::string& content, std::function on_activate, unsigned width_chars) : Gtk::Entry(), on_activate(on_activate) { + set_max_length(0); + set_width_chars(width_chars); set_text(content); selected_history=0; signal_activate().connect([this](){ @@ -92,7 +93,6 @@ void EntryBox::clear() { void EntryBox::show() { std::vector focus_chain; for(auto& entry: entries) { - entry.set_max_length(0); lower_box.pack_start(entry, Gtk::PACK_SHRINK); focus_chain.emplace_back(&entry); } diff --git a/src/entrybox.h b/src/entrybox.h index e7bdebd..6f8cecf 100644 --- a/src/entrybox.h +++ b/src/entrybox.h @@ -12,7 +12,7 @@ class EntryBox : public Gtk::Box { public: class Entry : public Gtk::Entry { public: - Entry(const std::string& content="", std::function on_activate=nullptr, unsigned length=50); + Entry(const std::string& content="", std::function on_activate=nullptr, unsigned width_chars=-1); std::function on_activate; private: size_t selected_history; diff --git a/src/files.h b/src/files.h index 9fcb4d7..8912d95 100644 --- a/src/files.h +++ b/src/files.h @@ -97,7 +97,7 @@ const std::string configjson = " \"clang\": {\n" " \"separator\": \"::\",\n" " \"queries\": {\n" -" \"@empty\": \"https://www.google.com/search?btnI&q=site:http://www.cplusplus.com/reference/+\",\n" +" \"@empty\": \"https://www.google.com/search?btnI&q=c%2B%2B+\",\n" " \"std\": \"https://www.google.com/search?btnI&q=site:http://www.cplusplus.com/reference/+\",\n" " \"boost\": \"https://www.google.com/search?btnI&q=site:http://www.boost.org/doc/libs/1_59_0/+\",\n" " \"Gtk\": \"https://www.google.com/search?btnI&q=site:https://developer.gnome.org/gtkmm/stable/+\",\n" diff --git a/src/source.cc b/src/source.cc index d914241..02a49a6 100644 --- a/src/source.cc +++ b/src/source.cc @@ -2369,27 +2369,35 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { auto referenced=cursor.get_referenced(); if(referenced) { auto usr=referenced.get_usr(); + boost::filesystem::path referenced_path=referenced.get_source_location().get_path(); + + //Return empty if referenced is within project + if(referenced_path.generic_string().substr(0, this->project_path.generic_string().size()+1)==this->project_path.generic_string()+'/') + return data; + data.emplace_back("clang"); //namespace - not working - size_t pos1=usr.find("@N@"); - size_t pos2; - std::string first_namespace; - while(pos1!=std::string::npos) { + size_t pos1=0, pos2; + while((pos1=usr.find('@', pos1))!=std::string::npos && pos1+1