Browse Source

merge conflict

master
oyvang 11 years ago
parent
commit
3590d6154f
  1. 20
      juci/notebook.cc
  2. 33
      juci/source.cc
  3. 7
      juci/source.h

20
juci/notebook.cc

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

7
juci/source.h

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

Loading…
Cancel
Save