diff --git a/juci/notebook.cc b/juci/notebook.cc index 36c3c79..e0fd548 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -236,13 +236,13 @@ bool Notebook::Controller::GeneratePopup(int key_id) { for (auto &data : acdata) { std::stringstream ss; std::string return_value; - for (auto &chunk : data.chunks_) { - switch (chunk.kind()) { + for (auto &chunk : data.chunks) { + switch (chunk.kind) { case clang::CompletionChunk_ResultType: - return_value = chunk.chunk(); + return_value = chunk.chunk; break; case clang::CompletionChunk_Informative: break; - default: ss << chunk.chunk(); break; + default: ss << chunk.chunk; break; } } if (ss.str().length() > 0) { // if length is 0 the result is empty diff --git a/juci/source.cc b/juci/source.cc index 97f04dc..68d8e6d 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -260,20 +260,11 @@ Source::Controller::~Controller() { parse_thread.join(); } -void Source::Controller::OnNewEmptyFile() { - string filename("/tmp/juci_t"); - sourcefile s(filename); - parser.file_path=filename; - parser.project_path=filename; - s.save(""); -} - -void Source::View::OnUpdateSyntax(const std::vector &ranges, - const Source::Config &config) { +void Source::Controller::update_syntax(const std::vector &ranges) { if (ranges.empty() || ranges.size() == 0) { return; } - Glib::RefPtr buffer = get_buffer(); + auto buffer = view.get_buffer(); buffer->remove_all_tags(buffer->begin(), buffer->end()); for (auto &range : ranges) { std::string type = std::to_string(range.kind()); @@ -298,6 +289,14 @@ void Source::View::OnUpdateSyntax(const std::vector &ranges, } } +void Source::Controller::OnNewEmptyFile() { + string filename("/tmp/juci_t"); + sourcefile s(filename); + parser.file_path=filename; + parser.project_path=filename; + s.save(""); +} + void Source::Controller::OnOpenFile(const string &filepath) { parser.file_path=filepath; sourcefile s(filepath); @@ -315,7 +314,7 @@ void Source::Controller::OnOpenFile(const string &filepath) { start_offset, end_offset, &Parser::clang_index); - view.OnUpdateSyntax(parser.ExtractTokens(start_offset, end_offset), config); + update_syntax(parser.ExtractTokens(start_offset, end_offset)); //GTK-calls must happen in main thread, so the parse_thread //sends signals to the main thread that it is to call the following functions: @@ -331,8 +330,7 @@ void Source::Controller::OnOpenFile(const string &filepath) { parse_done.connect([this](){ if(parse_thread_mapped) { INFO("Updating syntax"); - view. - OnUpdateSyntax(parser.ExtractTokens(0, buffer()->get_text().size()), config); + update_syntax(parser.ExtractTokens(0, buffer()->get_text().size())); INFO("Syntax updated"); } else { diff --git a/juci/source.h b/juci/source.h index be372d6..6c5e614 100644 --- a/juci/source.h +++ b/juci/source.h @@ -66,28 +66,23 @@ namespace Source { public: View(); virtual ~View() { } - void OnUpdateSyntax(const std::vector &locations, - const Config &config); std::string GetLine(size_t line_number); std::string GetLineBeforeInsert(); }; // class View class AutoCompleteChunk { public: - explicit AutoCompleteChunk(const clang::CompletionChunk &chunk) : - chunk_(chunk.chunk()), kind_(chunk.kind()) { } - const std::string& chunk() const { return chunk_; } - const clang::CompletionChunkKind& kind() const { return kind_; } - private: - std::string chunk_; - enum clang::CompletionChunkKind kind_; + explicit AutoCompleteChunk(const clang::CompletionChunk &clang_chunk) : + chunk(clang_chunk.chunk()), kind(clang_chunk.kind()) { } + std::string chunk; + enum clang::CompletionChunkKind kind; }; class AutoCompleteData { public: explicit AutoCompleteData(const std::vector &chunks) : - chunks_(chunks) { } - std::vector chunks_; + chunks(chunks) { } + std::vector chunks; }; class Controller; @@ -131,6 +126,7 @@ namespace Source { Controller(const Source::Config &config, const std::vector > &controllers); ~Controller(); + void update_syntax(const std::vector &locations); void OnNewEmptyFile(); void OnOpenFile(const std::string &filename); Glib::RefPtr buffer();