Browse Source

Create new nodes

merge-requests/365/head
Jørgen Lien Sellæg 11 years ago
parent
commit
a3e7a560d1
  1. 16
      juci/CMakeLists.txt
  2. 48
      juci/source.cc
  3. 31
      juci/source.h

16
juci/CMakeLists.txt

@ -4,11 +4,19 @@ set(module juci_to_python_api)
project (${project_name}) project (${project_name})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
INCLUDE(FindPkgConfig) INCLUDE(FindPkgConfig)
#libclang_LIBRARIES
#libclang_INCLUDE_DIR
find_package(Libclang)
message("Libclang libraries ${Libclang_LIBRARIES}")
message("Libclang libraries ${Libclang_LIBRARY}")
message("Libclang include dirs ${Libclang_INCLUDE_DIR}")
#### Finding boost, the variables below is set ##### #### Finding boost, the variables below is set #####
#PYTHONLIBS_FOUND - True if headers and requested libraries were found #PYTHONLIBS_FOUND - True if headers and requested libraries were found
#PYTHON_INCLUDE_DIRS - Boost include directories #PYTHON_INCLUDE_DIRS - Boost include directories
@ -85,11 +93,11 @@ add_library(${module} SHARED
) )
# dependencies # dependencies
include_directories(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS} "/home/zalox/bachelor/libclang++/")
link_directories(${GTKMM_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${PYTHON_INCLUDE_DIRS}) link_directories(${GTKMM_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${PYTHON_INCLUDE_DIRS} "/home/zalox/bachelor/libclang++/")
#module: #module:
set_target_properties(${module} PROPERTIES PREFIX "") set_target_properties(${module} PROPERTIES PREFIX "")
target_link_libraries(${module} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(${module} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
#executable: #executable:
target_link_libraries(${project_name} ${GTKMM_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) target_link_libraries(${project_name} ${GTKMM_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} "/home/zalox/bachelor/libclang++/")

48
juci/source.cc

@ -7,10 +7,41 @@
Source::View::View() { Source::View::View() {
std::cout << "View constructor run" << std::endl; std::cout << "View constructor run" << std::endl;
} }
// Source::View::UpdateLine
// returns the new line
string Source::View::UpdateLine() {
Gtk::TextIter line(get_buffer()->get_insert()->get_iter());
// for each word --> check what it is --> apply appropriate tag
void Source::View::UpdateLine(Glib::RefPtr<Gtk::TextBuffer::Mark> mark) { // retUrn "";
std::cout << "Update line called. linum: "; }
std::cout << mark->get_iter().get_line() << std::endl;
String Source::View::Getline(const Gtk::TextIter &begin) {
Gtk::TextIter end(begin);
while (!end.ends_line())
end++;
return begin.get_text(end);
}
// Source::View::ApplyTheme()
// Applies theme in textview
void Source::View::ApplyTheme(const Source::Theme &theme) {
for (auto &item : theme.tagtable()) {
get_buffer()->create_tag(item.first)->property_foreground() = item.second;
}
}
// Source::View::Theme::tagtable()
// returns a const refrence to the tagtable
const std::unordered_map<string, string>& Source::Theme::tagtable() const {
return tagtable_;
}
// Source::View::Theme::SetTagTable()
// sets the tagtable for the view
void Source::Theme::SetTagTable(
const std::unordered_map<string, string> &tagtable) {
tagtable_ = tagtable;
} }
/////////////// ///////////////
@ -20,6 +51,10 @@ Source::Model::Model() {
std::cout << "Model constructor run" << std::endl; std::cout << "Model constructor run" << std::endl;
} }
const string Source::Model::filepath() {
return filepath_;
}
//////////////////// ////////////////////
//// Controller //// //// Controller ////
//////////////////// ////////////////////
@ -28,6 +63,9 @@ Source::Model::Model() {
// Constructor for Controller // Constructor for Controller
Source::Controller::Controller() { Source::Controller::Controller() {
std::cout << "Controller constructor run" << std::endl; std::cout << "Controller constructor run" << std::endl;
view().get_buffer()->signal_changed().connect([this](){
this->OnLineEdit();
});
} }
// Source::Controller::view() // Source::Controller::view()
// return shared_ptr to the view // return shared_ptr to the view
@ -41,4 +79,6 @@ Source::Model& Source::Controller::model() {
} }
// Source::Controller::OnLineEdit() // Source::Controller::OnLineEdit()
// fired when a line in the buffer is edited // fired when a line in the buffer is edited
void Source::Controller::OnLineEdit(Glib::RefPtr<Gtk::TextBuffer::Mark> mark) {} void Source::Controller::OnLineEdit() {
view().UpdateLine();
}

31
juci/source.h

@ -1,21 +1,40 @@
#ifndef JUCI_SOURCE_H_ #ifndef JUCI_SOURCE_H_
#define JUCI_SOURCE_H_ #define JUCI_SOURCE_H_
#include <iostream> #include <unordered_map>
#include <vector>
#include <string>
#include "gtkmm.h" #include "gtkmm.h"
using std::string;
namespace Source { namespace Source {
class Theme {
public:
const std::unordered_map<string, string>& tagtable() const;
void SetTagTable(const std::unordered_map<string, string> &tagtable);
private:
std::unordered_map<string, string> tagtable_;
string background_;
}; // class Theme
class View : public Gtk::TextView { class View : public Gtk::TextView {
public: public:
View(); View();
void UpdateLine(Glib::RefPtr<Gtk::TextBuffer::Mark> mark); string UpdateLine();
void ApplyTheme(const Theme &theme);
private: private:
void UpdateSyntaxHighlighting(int line_number); string GetLine(const Gtk::TextIter &begin);
}; }; // class View
class Model{ class Model{
public: public:
Model(); Model();
Theme theme();
const string filepath();
private:
Theme theme_;
string filepath_;
}; };
class Controller { class Controller {
@ -25,7 +44,9 @@ namespace Source {
Model& model(); Model& model();
private: private:
void OnLineEdit(Glib::RefPtr<Gtk::TextBuffer::Mark> mark); void OnLineEdit();
void OnOpenFile();
void OnSaveFile();
protected: protected:
View view_; View view_;

Loading…
Cancel
Save