More settings class stuff

This commit is contained in:
Timothy Warren 2015-04-14 08:09:11 -04:00
parent 1adde169ec
commit d6212be16d
6 changed files with 19 additions and 30 deletions

View File

@ -1,6 +1,6 @@
CXX = $(shell wx-config --cxx) CXX = $(shell wx-config --cxx)
SOURCES = $(wildcard include/**/*.cpp include/*.cpp) SOURCES = $(wildcard include/**/*.cpp src/settings/*.cpp include/*.cpp)
OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES)) OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES))
TARGET = build/Tyro.a TARGET = build/Tyro.a
@ -8,7 +8,7 @@ PROGRAM_SRC = $(wildcard src/*.cpp src/widgets/*.cpp)
PROGRAM = build/Tyro PROGRAM = build/Tyro
PROGRAM_OBJECTS = $(patsubst %.cpp,%.o, $(PROGRAM_SRC)) PROGRAM_OBJECTS = $(patsubst %.cpp,%.o, $(PROGRAM_SRC))
BASE_FLAGS = -DSCI_LEXER -std=c++11 BASE_FLAGS = -DSCI_LEXER
LDLIBS = $(TARGET) $(shell wx-config --libs base core aui stc adv) LDLIBS = $(TARGET) $(shell wx-config --libs base core aui stc adv)
WX_CXXFLAGS = $(shell wx-config --cxxflags) $(BASE_FLAGS) WX_CXXFLAGS = $(shell wx-config --cxxflags) $(BASE_FLAGS)

View File

@ -6,6 +6,7 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <fstream>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -6,10 +6,16 @@
TyroSettings::TyroSettings() TyroSettings::TyroSettings()
{ {
ifstream file("../../config/scintilla.json");
reader.parse(file, default_root);
} }
TyroSettings::~TyroSettings() TyroSettings::~TyroSettings()
{ {
}
Json::Value TyroSettings::GetRoot()
{
return default_root;
} }

View File

@ -13,9 +13,12 @@
class TyroSettings { class TyroSettings {
public: public:
TyroSettings(); TyroSettings();
~TyroSettings(); ~TyroSettings();
Json::Value GetRoot();
private: private:
Json::Value default_root;
Json::Reader reader;
}; };

View File

@ -5,30 +5,11 @@ EditPane::EditPane(
const wxSize &size, long style const wxSize &size, long style
) : wxStyledTextCtrl (parent, id, pos, size, style) ) : wxStyledTextCtrl (parent, id, pos, size, style)
{ {
StringConstMapData map_data[] = {
{"c", wxSTC_LEX_CPP},
{"h", wxSTC_LEX_CPP},
{"cpp", wxSTC_LEX_CPP},
{"cxx", wxSTC_LEX_CPP},
{"py", wxSTC_LEX_PYTHON},
{"php", wxSTC_LEX_PHPSCRIPT},
{"js", wxSTC_LEX_ESCRIPT},
{"json", wxSTC_LEX_ESCRIPT}
};
lexer_map = StringConstMap(
map_data,
map_data + sizeof map_data / sizeof map_data[0]
);
} }
EditPane::~EditPane() {} EditPane::~EditPane() {}
/*void EditPane::OnSize(wxSizeEvent &event)
{
}*/
/** /**
* Encapsulate lexer selection when opening a file * Encapsulate lexer selection when opening a file
* *
@ -41,8 +22,12 @@ bool EditPane::LoadAndHighlight(wxString filePath)
wxFileName file(filePath); wxFileName file(filePath);
wxString ext = file.GetExt(); wxString ext = file.GetExt();
this->SetLexer(wxSTC_LEX_CPP);
this->StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColor(101, 123, 131)); this->StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColor(101, 123, 131));
this->StyleSetBackground (wxSTC_STYLE_DEFAULT, wxColor(253, 246, 227)); this->StyleSetBackground (wxSTC_STYLE_DEFAULT, wxColor(253, 246, 227));
this->StyleSetBackground (wxSTC_STYLE_MAX, wxColor(253, 246, 227));
this->StyleSetBackground (wxSTC_STYLE_CONTROLCHAR, wxColor(253, 246, 227));
this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161)); this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161));
this->SetMarginWidth (MARGIN_LINE_NUMBERS, 50); this->SetMarginWidth (MARGIN_LINE_NUMBERS, 50);
@ -82,8 +67,5 @@ bool EditPane::LoadAndHighlight(wxString filePath)
this->StyleSetBold(wxSTC_C_WORD2, true); this->StyleSetBold(wxSTC_C_WORD2, true);
this->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true); this->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true);
lexer_map_it = lexer_map.find((string) ext);
this->SetLexer(lexer_map_it->second);
return this->LoadFile(filePath); return this->LoadFile(filePath);
} }

View File

@ -22,7 +22,6 @@ public:
); );
~EditPane(); ~EditPane();
wxString fileName; wxString fileName;
void OnSize(wxSizeEvent &event);
bool LoadAndHighlight(wxString filePath); bool LoadAndHighlight(wxString filePath);
private: private:
enum enum
@ -30,8 +29,6 @@ private:
MARGIN_LINE_NUMBERS, MARGIN_LINE_NUMBERS,
MARGIN_FOLD MARGIN_FOLD
}; };
StringConstMap lexer_map;
StringConstMap::iterator lexer_map_it;
}; };
#endif // TYRODOC_FRAME_H #endif // TYRODOC_FRAME_H