Tyro/src/widgets/EditPane.cpp

72 lines
3.2 KiB
C++
Raw Normal View History

#include "EditPane.h"
EditPane::EditPane(
wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style
) : wxStyledTextCtrl (parent, id, pos, size, style)
{
2015-04-10 15:11:15 -04:00
}
2015-04-06 15:42:05 -04:00
EditPane::~EditPane() {}
2015-04-10 15:11:15 -04:00
/**
* Encapsulate lexer selection when opening a file
*
* @param wxString filePath
* @return bool
*/
bool EditPane::LoadAndHighlight(wxString filePath)
{
fileName = filePath;
2015-04-10 15:11:15 -04:00
wxFileName file(filePath);
wxString ext = file.GetExt();
2015-04-13 13:01:25 -04:00
2015-04-14 08:09:11 -04:00
this->SetLexer(wxSTC_LEX_CPP);
2015-04-13 13:01:25 -04:00
this->StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColor(101, 123, 131));
this->StyleSetBackground (wxSTC_STYLE_DEFAULT, wxColor(253, 246, 227));
2015-04-14 08:09:11 -04:00
this->StyleSetBackground (wxSTC_STYLE_MAX, wxColor(253, 246, 227));
this->StyleSetBackground (wxSTC_STYLE_CONTROLCHAR, wxColor(253, 246, 227));
2015-04-13 13:01:25 -04:00
this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161));
this->SetMarginWidth (MARGIN_LINE_NUMBERS, 50);
this->StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColor(147, 161, 161));
this->StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColor(238, 232, 213));
this->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);
this->SetProperty (wxT("fold"), wxT("1") );
this->SetProperty (wxT("fold.comment"), wxT("1") );
this->SetProperty (wxT("fold.compact"), wxT("1") );
this->StyleSetForeground (wxSTC_C_STRING, wxColour(150,0,0));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_STRING, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_PREPROCESSOR, wxColour(165,105,0));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_PREPROCESSOR, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_IDENTIFIER, wxColour(40,0,60));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_IDENTIFIER, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_NUMBER, wxColour(0,150,0));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_NUMBER, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_CHARACTER, wxColour(150,0,0));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_CHARACTER, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_WORD, wxColour(0,0,150));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_WORD, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_WORD2, wxColour(0,150,0));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_WORD2, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_COMMENT, wxColor(147, 161, 161));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_COMMENT, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_COMMENTLINE, wxColor(147, 161, 161));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_COMMENTLINE, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_COMMENTDOC, wxColor(147, 161, 161));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_COMMENTDOC, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_COMMENTDOCKEYWORD, wxColour(0,0,200));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_COMMENTDOCKEYWORD, wxColor(253, 246, 227));
this->StyleSetForeground (wxSTC_C_COMMENTDOCKEYWORDERROR, wxColour(0,0,200));
2015-04-13 13:01:25 -04:00
this->StyleSetBackground (wxSTC_C_COMMENTDOCKEYWORDERROR, wxColor(253, 246, 227));
this->StyleSetBold(wxSTC_C_WORD, true);
2015-04-13 13:01:25 -04:00
this->StyleSetBold(wxSTC_C_WORD2, true);
this->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true);
2015-04-10 15:11:15 -04:00
return this->LoadFile(filePath);
}