Browse Source

merge conflict

merge-requests/365/head
oyvang 11 years ago
parent
commit
3590d6154f
  1. 20
      juci/notebook.cc
  2. 33
      juci/source.cc
  3. 9
      juci/source.h

20
juci/notebook.cc

@ -1,6 +1,6 @@
#include "notebook.h"
#include <fstream>
#include "clangmm.h"
Notebook::Model::Model() {
cc_extension_ = ".cc";
@ -21,9 +21,9 @@ Notebook::Controller::Controller(Keybindings::Controller& keybindings,
OnNewPage("juCi++");
refClipboard_ = Gtk::Clipboard::get();
ispopup = false;
view().pack1(directories_.widget(),true,true);
view().pack1(directories_.widget(), true, true);
CreateKeybindings(keybindings);
}// Constructor
} // Constructor
void Notebook::Controller::CreateKeybindings(Keybindings::Controller
@ -141,16 +141,10 @@ bool Notebook::Controller:: OnMouseRelease(GdkEventButton* button){
bool Notebook::Controller::GeneratePopup(Gtk::Window* window){
// Get function to fill popup with suggests item vector under is for testing
std::vector<std::string> items;
items.push_back("toString(std::string& string) -> void");
items.push_back("toLower(std::string& string) -> void");
items.push_back("toUpper(std::string& string) -> void");
items.push_back("fuckOFF(const std::string string) -> bool");
items.push_back("fuckOFF(const std::string string) -> bool");
items.push_back("toString(std::string& string) -> void");
items.push_back("toLower(std::string& string) -> void");
items.push_back("toUpper(std::string& string) -> void");
items.push_back("fuckOFF(const std::string string) -> bool");
items.push_back("fuckOFF(const std::string string) -> bool");
Gtk::TextIter start = CurrentTextView().get_buffer()->get_insert()->get_iter();
text_vec_.at(CurrentPage())->GetAutoCompleteSuggestions(start.get_line()+1,
start.get_line_offset()+2,
&items);
// Replace over with get suggestions from zalox! OVER IS JUST FOR TESTING

33
juci/source.cc

@ -132,6 +132,39 @@ ReParse(const std::string &buffer) {
// fired when a line in the buffer is edited
void Source::Controller::OnLineEdit() { }
void Source::Controller::
GetAutoCompleteSuggestions(int line_number,
int column,
std::vector<std::string> *suggestions) {
parsing.lock();
model().GetAutoCompleteSuggestions(view().get_buffer()
->get_text().raw(),
line_number,
column,
suggestions);
parsing.unlock();
}
void Source::Model::
GetAutoCompleteSuggestions(const std::string& buffer,
int line_number,
int column,
std::vector<std::string> *suggestions) {
clang::CodeCompleteResults results(&tu_,
file_path(),
buffer,
line_number,
column);
for (int i = 0; i < results.size(); i++) {
std::stringstream ss;
const vector<clang::CompletionChunk> c = results.get(i).get_chunks();
for (auto &stringchunk : c) {
ss << stringchunk.chunk();
}
suggestions->emplace_back(ss.str());
}
}
// sets the filepath for this mvc
void Source::Model::
set_file_path(const std::string &file_path) {

9
juci/source.h

@ -95,7 +95,11 @@ namespace Source {
const string& project_path() const;
// gets the config member
const Config& config() const;
~Model() { }
void GetAutoCompleteSuggestions(const std::string& buffer,
int line_number,
int column,
std::vector<std::string> *suggestions);
~Model() { }
int ReParse(const std::string &buffer);
std::vector<Range> ExtractTokens(int, int);
@ -121,6 +125,9 @@ namespace Source {
Model& model();
void OnNewEmptyFile();
void OnOpenFile(const string &filename);
void GetAutoCompleteSuggestions(int line_number,
int column,
std::vector<std::string> *suggestions);
Glib::RefPtr<Gtk::TextBuffer> buffer();
private:

Loading…
Cancel
Save