2015-05-07 17:05:27 -04:00
|
|
|
/**
|
|
|
|
* The editor widget
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "widget.h"
|
2015-04-02 18:00:50 -04:00
|
|
|
|
|
|
|
EditPane::EditPane(
|
2015-04-24 16:55:10 -04:00
|
|
|
wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size
|
|
|
|
) : wxStyledTextCtrl (parent, id, pos, size, wxBORDER_NONE)
|
2015-04-21 14:07:04 -04:00
|
|
|
{
|
2015-04-29 17:03:15 -04:00
|
|
|
lang_config = new LangConfig();
|
2015-05-07 14:06:12 -04:00
|
|
|
theme_config = new ThemeConfig();
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-21 17:06:21 -04:00
|
|
|
// Map language types to their lexers
|
2015-04-16 11:23:08 -04:00
|
|
|
lexerMap["batch"] = wxSTC_LEX_BATCH;
|
|
|
|
lexerMap["caml"] = wxSTC_LEX_CAML;
|
|
|
|
lexerMap["cmake"] = wxSTC_LEX_CMAKE;
|
2015-04-21 14:07:04 -04:00
|
|
|
lexerMap["coffeescript"] = wxSTC_LEX_COFFEESCRIPT;
|
2015-04-16 11:23:08 -04:00
|
|
|
lexerMap["cpp"] = wxSTC_LEX_CPP;
|
|
|
|
lexerMap["css"] = wxSTC_LEX_CSS;
|
2015-04-21 14:07:04 -04:00
|
|
|
lexerMap["fortran"] = wxSTC_LEX_FORTRAN;
|
|
|
|
lexerMap["haskell"] = wxSTC_LEX_HASKELL;
|
2015-04-16 11:23:08 -04:00
|
|
|
lexerMap["html"] = wxSTC_LEX_HTML;
|
2015-04-21 14:07:04 -04:00
|
|
|
lexerMap["java"] = wxSTC_LEX_CPP;
|
|
|
|
lexerMap["js"] = wxSTC_LEX_CPP;
|
|
|
|
lexerMap["lisp"] = wxSTC_LEX_LISP;
|
|
|
|
lexerMap["lua"] = wxSTC_LEX_LUA;
|
2015-04-16 11:23:08 -04:00
|
|
|
lexerMap["makefile"] = wxSTC_LEX_MAKEFILE;
|
2015-04-21 14:07:04 -04:00
|
|
|
lexerMap["markdown"] = wxSTC_LEX_MARKDOWN;
|
2015-04-28 16:59:19 -04:00
|
|
|
lexerMap["php"] = wxSTC_LEX_HTML;
|
2015-04-16 11:23:08 -04:00
|
|
|
lexerMap["perl"] = wxSTC_LEX_PERL;
|
|
|
|
lexerMap["python"] = wxSTC_LEX_PYTHON;
|
2015-04-21 14:07:04 -04:00
|
|
|
lexerMap["ruby"] = wxSTC_LEX_RUBY;
|
2015-04-22 16:57:10 -04:00
|
|
|
lexerMap["rust"] = wxSTC_LEX_CPP;
|
2015-04-16 11:23:08 -04:00
|
|
|
lexerMap["shell"] = wxSTC_LEX_BASH;
|
2015-04-21 14:07:04 -04:00
|
|
|
lexerMap["sql"] = wxSTC_LEX_SQL;
|
|
|
|
lexerMap["xml"] = wxSTC_LEX_XML;
|
|
|
|
lexerMap["yaml"] = wxSTC_LEX_YAML;
|
|
|
|
|
2015-04-16 17:03:27 -04:00
|
|
|
this->BindEvents();
|
2015-05-04 16:27:21 -04:00
|
|
|
|
|
|
|
// Some basic properties to set
|
|
|
|
this->SetStyleBits(8);
|
|
|
|
this->SetScrollWidthTracking(true);// Set scroll width by longest line
|
|
|
|
this->SetProperty("technology", "2");
|
|
|
|
this->SetProperty("error.inline", "0");
|
|
|
|
this->SetProperty("styling.within.preprocessor", "1");
|
|
|
|
this->SetProperty("lexer.cpp.track.preprocessor", "1");
|
|
|
|
this->SetProperty("font.quality", "3"); // LCD Optimized
|
|
|
|
|
|
|
|
// Set up Code folding
|
|
|
|
this->SetProperty("fold", "1");
|
|
|
|
this->SetProperty("fold.comment", "1");
|
|
|
|
this->SetProperty("fold.compact", "1");
|
|
|
|
this->SetProperty("fold.html", "1");
|
|
|
|
this->SetFoldFlags(wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED);
|
|
|
|
this->SetMarginType(MARGIN_FOLD, wxSTC_MARGIN_SYMBOL);
|
|
|
|
this->SetMarginWidth(MARGIN_FOLD, 16);
|
|
|
|
this->SetMarginSensitive(MARGIN_FOLD, true);
|
|
|
|
this->SetMarginMask(MARGIN_FOLD, wxSTC_MASK_FOLDERS);
|
|
|
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUSCONNECTED, "WHITE", "BLACK");
|
|
|
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUSCONNECTED, "WHITE", "BLACK");
|
|
|
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "BLACK", "BLACK");
|
|
|
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_CIRCLEPLUSCONNECTED, "WHITE", "BLACK");
|
|
|
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_CIRCLEMINUSCONNECTED, "WHITE", "BLACK");
|
|
|
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "BLACK", "BLACK");
|
|
|
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "BLACK", "BLACK");
|
|
|
|
|
|
|
|
this->SetLayoutCache (wxSTC_CACHE_DOCUMENT);
|
|
|
|
|
|
|
|
// set spaces and indention
|
|
|
|
this->SetTabWidth(4);
|
|
|
|
|
|
|
|
// Blank highlight
|
|
|
|
this->Highlight("");
|
2015-04-02 18:00:50 -04:00
|
|
|
}
|
|
|
|
|
2015-04-21 14:07:04 -04:00
|
|
|
EditPane::~EditPane()
|
2015-04-14 15:58:43 -04:00
|
|
|
{
|
2015-05-08 16:01:36 -04:00
|
|
|
wxLogDebug("Called EditPane Destructor");
|
2015-04-21 09:55:28 -04:00
|
|
|
delete lang_config;
|
|
|
|
delete theme_config;
|
2015-04-14 15:58:43 -04:00
|
|
|
}
|
2015-04-10 15:11:15 -04:00
|
|
|
|
|
|
|
/**
|
2015-04-17 16:55:48 -04:00
|
|
|
* Handle the highlighting config for the
|
|
|
|
* selected file
|
2015-04-21 14:07:04 -04:00
|
|
|
*
|
2015-04-10 15:11:15 -04:00
|
|
|
* @param wxString filePath
|
2015-04-17 16:55:48 -04:00
|
|
|
* @return void
|
2015-04-10 15:11:15 -04:00
|
|
|
*/
|
2015-04-17 16:55:48 -04:00
|
|
|
void EditPane::Highlight(wxString filePath)
|
2015-04-10 15:11:15 -04:00
|
|
|
{
|
2015-04-17 16:55:48 -04:00
|
|
|
this->fileName.Assign(filePath);
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
// Get the configuration name for the selected language
|
2015-04-29 17:03:15 -04:00
|
|
|
string lang = lang_config->GetLangByFile(this->fileName);
|
2015-04-17 16:55:48 -04:00
|
|
|
|
2015-04-14 15:58:43 -04:00
|
|
|
this->StyleClearAll();
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-16 11:23:08 -04:00
|
|
|
if (lexerMap.count(lang) > 0)
|
|
|
|
{
|
|
|
|
this->SetLexer(lexerMap[lang]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->SetLexer(wxSTC_LEX_NULL);
|
|
|
|
}
|
2015-04-21 14:07:04 -04:00
|
|
|
|
|
|
|
// Apply the theme
|
|
|
|
this->ApplyTheme(lang);
|
|
|
|
|
|
|
|
bool use_tabs = (lang != "yaml");
|
|
|
|
|
2015-04-23 11:03:50 -04:00
|
|
|
this->SetUseTabs(use_tabs);
|
|
|
|
this->SetTabIndents(true);
|
|
|
|
this->SetBackSpaceUnIndents(true);
|
2015-04-21 14:07:04 -04:00
|
|
|
}
|
|
|
|
|
2015-04-21 17:06:21 -04:00
|
|
|
/**
|
|
|
|
* Set the current theme for the current language
|
|
|
|
*
|
|
|
|
* @param string lang
|
|
|
|
* @param string theme
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-04-21 14:07:04 -04:00
|
|
|
void EditPane::ApplyTheme(string lang, string theme)
|
2015-05-07 17:05:27 -04:00
|
|
|
{
|
|
|
|
if (theme != "")
|
|
|
|
{
|
|
|
|
theme_config->SetTheme(theme);
|
|
|
|
}
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-29 17:03:15 -04:00
|
|
|
// Get the keywords and mapping for the selected language
|
|
|
|
JsonValue lexer_map = lang_config->GetLexerMap(lang);
|
|
|
|
JsonValue keywords_array = lang_config->GetKeywordList(lang);
|
|
|
|
|
2015-04-15 09:47:20 -04:00
|
|
|
if (keywords_array.isArray())
|
|
|
|
{
|
2015-04-22 21:06:35 -04:00
|
|
|
for(unsigned int i = 0; i < keywords_array.size(); i++)
|
2015-04-15 12:17:25 -04:00
|
|
|
{
|
|
|
|
this->SetKeyWords(i, keywords_array[i].asString());
|
|
|
|
}
|
2015-04-15 09:47:20 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-08 16:01:36 -04:00
|
|
|
if (lang != "")
|
|
|
|
{
|
|
|
|
string typeMap[] = {"null", "int", "unsigned int", "double", "string", "boolean", "array", "object"};
|
|
|
|
stringstream output;
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-05-08 16:01:36 -04:00
|
|
|
output << "current lang is:" << lang << endl;
|
|
|
|
output << "keywords array is not an array" << endl;
|
|
|
|
output << "keyword array is a " << typeMap[keywords_array.type()] << endl;
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-05-08 16:01:36 -04:00
|
|
|
wxLogDebug(output.str().c_str());
|
|
|
|
}
|
2015-04-15 09:47:20 -04:00
|
|
|
}
|
2015-04-21 14:07:04 -04:00
|
|
|
|
|
|
|
// Do the appropriate mappings to load the selected theme
|
2015-04-29 17:03:15 -04:00
|
|
|
this->_ApplyTheme(lexer_map);
|
2015-04-17 16:55:48 -04:00
|
|
|
}
|
2015-04-10 15:11:15 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
/**
|
|
|
|
* Check file path and open the selected file
|
|
|
|
*
|
|
|
|
* @param wxString filePath
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
bool EditPane::Load(wxString filePath)
|
|
|
|
{
|
|
|
|
this->fileName.Assign(filePath);
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
if (this->FileReadable())
|
2015-04-21 14:07:04 -04:00
|
|
|
{
|
2015-04-17 16:55:48 -04:00
|
|
|
this->Highlight(filePath);
|
|
|
|
bool didLoad = this->LoadFile(filePath);
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
// @TODO Toggle controls based on write permission
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
return didLoad;
|
|
|
|
}
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
return false;
|
2015-04-10 15:11:15 -04:00
|
|
|
}
|
2015-04-16 17:03:27 -04:00
|
|
|
|
|
|
|
bool EditPane::SaveFile()
|
|
|
|
{
|
2015-04-17 16:55:48 -04:00
|
|
|
wxString fname;
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
if ( ! this->fileName.IsOk())
|
2015-04-16 17:03:27 -04:00
|
|
|
{
|
|
|
|
wxFileDialog dlg (
|
2015-04-21 14:07:04 -04:00
|
|
|
this,
|
|
|
|
_T("Save file"),
|
|
|
|
wxEmptyString,
|
2015-04-16 17:03:27 -04:00
|
|
|
wxEmptyString,
|
|
|
|
TYRO_FILE_SAVE_WILDCARDS,
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
|
|
|
);
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-16 17:03:27 -04:00
|
|
|
if (dlg.ShowModal() != wxID_OK) return false;
|
2015-04-17 16:55:48 -04:00
|
|
|
fname = dlg.GetPath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fname = this->fileName.GetFullPath();
|
2015-04-16 17:03:27 -04:00
|
|
|
}
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
const wxString cfname(fname);
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
return this->SaveFile(cfname);
|
2015-04-16 17:03:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool EditPane::SaveFile(const wxString &filename)
|
|
|
|
{
|
|
|
|
if ( ! this->IsModified()) return true;
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
this->fileName.Assign(filename);
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
// Check file permissions
|
|
|
|
if (this->FileWritable())
|
|
|
|
{
|
|
|
|
this->SetSavePoint();
|
|
|
|
return wxStyledTextCtrl::SaveFile(filename);
|
|
|
|
}
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
return false;
|
2015-04-16 17:03:27 -04:00
|
|
|
}
|
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
/**
|
|
|
|
* Check that the current file can be opened
|
2015-04-21 14:07:04 -04:00
|
|
|
*
|
|
|
|
* @return bool
|
2015-04-17 16:55:48 -04:00
|
|
|
*/
|
|
|
|
bool EditPane::FileReadable()
|
2015-04-21 14:07:04 -04:00
|
|
|
{
|
2015-04-17 16:55:48 -04:00
|
|
|
if (
|
|
|
|
this->fileName.IsOk() &&
|
|
|
|
this->fileName.Exists() &&
|
|
|
|
this->fileName.IsFileReadable()
|
|
|
|
) return true;
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
// Hmm...well, let's give an error
|
|
|
|
wxMessageDialog errDlg(
|
2015-04-21 14:07:04 -04:00
|
|
|
this,
|
|
|
|
TYRO_OPEN_ERROR,
|
2015-04-17 16:55:48 -04:00
|
|
|
TYRO_OPEN_ERROR_CAPTION,
|
|
|
|
wxOK | wxICON_ERROR | wxCENTER
|
|
|
|
);
|
|
|
|
errDlg.ShowModal();
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check that the current file can be saved
|
2015-04-21 14:07:04 -04:00
|
|
|
*
|
|
|
|
* @return bool
|
2015-04-17 16:55:48 -04:00
|
|
|
*/
|
|
|
|
bool EditPane::FileWritable()
|
|
|
|
{
|
|
|
|
// Lets see...can we write somewhere?
|
|
|
|
if (
|
|
|
|
this->fileName.IsOk() &&
|
|
|
|
((this->fileName.Exists() && this->fileName.IsFileWritable()) ||
|
|
|
|
(( ! this->fileName.Exists()) && this->fileName.IsDirWritable()))
|
|
|
|
) return true;
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-04-17 16:55:48 -04:00
|
|
|
// Hmm...well, let's give an error
|
|
|
|
wxMessageDialog errDlg(
|
2015-04-21 14:07:04 -04:00
|
|
|
this,
|
|
|
|
TYRO_SAVE_ERROR,
|
2015-04-17 16:55:48 -04:00
|
|
|
TYRO_SAVE_ERROR_CAPTION,
|
|
|
|
wxOK | wxICON_ERROR | wxCENTER
|
|
|
|
);
|
|
|
|
errDlg.ShowModal();
|
|
|
|
|
|
|
|
return false;
|
2015-04-16 17:03:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditPane::BindEvents()
|
|
|
|
{
|
|
|
|
Bind(wxEVT_STC_MARGINCLICK, &EditPane::OnMarginClick, this, wxID_ANY);
|
2015-04-28 14:58:52 -04:00
|
|
|
Bind(wxEVT_STC_CHARADDED, &EditPane::OnCharAdded, this, wxID_ANY);
|
2015-04-16 17:03:27 -04:00
|
|
|
}
|
|
|
|
|
2015-04-21 17:06:21 -04:00
|
|
|
/**
|
|
|
|
* Code folding event handler
|
|
|
|
*
|
|
|
|
* @param wxStyledTextEvent& event
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-04-16 17:03:27 -04:00
|
|
|
void EditPane::OnMarginClick(wxStyledTextEvent& event)
|
|
|
|
{
|
|
|
|
if (event.GetMargin() == MARGIN_FOLD) {
|
2015-04-23 11:03:50 -04:00
|
|
|
int lineClick = this->LineFromPosition (event.GetPosition());
|
|
|
|
int levelClick = this->GetFoldLevel (lineClick);
|
|
|
|
if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0) {
|
|
|
|
this->ToggleFold (lineClick);
|
|
|
|
}
|
|
|
|
}
|
2015-04-16 17:03:27 -04:00
|
|
|
}
|
2015-04-21 09:55:28 -04:00
|
|
|
|
2015-04-28 14:58:52 -04:00
|
|
|
/**
|
|
|
|
* Look at characters added to help with indentation
|
|
|
|
*
|
|
|
|
* @param wxStyledTextEvent& event
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
void EditPane::OnCharAdded(wxStyledTextEvent& event)
|
|
|
|
{
|
|
|
|
char chr = (char) event.GetKey();
|
|
|
|
int currentLine = this->GetCurrentLine();
|
|
|
|
|
|
|
|
if (chr == '\n')
|
|
|
|
{
|
|
|
|
int lineInd = 0;
|
|
|
|
if (currentLine > 0)
|
|
|
|
{
|
|
|
|
lineInd = this->GetLineIndentation(currentLine - 1);
|
|
|
|
}
|
|
|
|
if (lineInd == 0) return;
|
|
|
|
|
|
|
|
this->SetLineIndentation(currentLine, lineInd);
|
|
|
|
this->GotoPos(this->PositionFromLine(currentLine) + (lineInd / 4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-21 14:07:04 -04:00
|
|
|
/**
|
|
|
|
* Iterate through the theme settings and apply them
|
|
|
|
*
|
|
|
|
* @param JsonValue lexer_map - Maps token types to theme colors
|
2015-04-22 16:57:10 -04:00
|
|
|
* @param int addtoi - Offset for some languages
|
2015-04-21 14:07:04 -04:00
|
|
|
* @return void
|
|
|
|
*/
|
2015-04-29 17:03:15 -04:00
|
|
|
void EditPane::_ApplyTheme(JsonValue &lexer_map)
|
2015-04-21 14:07:04 -04:00
|
|
|
{
|
|
|
|
// Font setup
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
wxFont *defaultFont = wxFont::New(
|
|
|
|
14,
|
|
|
|
wxFONTFAMILY_MODERN,
|
|
|
|
wxFONTFLAG_ANTIALIASED
|
|
|
|
);
|
|
|
|
#else
|
|
|
|
wxFont *defaultFont = wxFont::New(
|
2015-04-21 21:09:08 -04:00
|
|
|
10,
|
2015-04-21 14:07:04 -04:00
|
|
|
wxFONTFAMILY_MODERN,
|
|
|
|
wxFONTFLAG_ANTIALIASED
|
|
|
|
);
|
|
|
|
#endif
|
|
|
|
|
2015-05-07 14:06:12 -04:00
|
|
|
static const wxColor default_background = theme_config->GetThemeColor("background", "default");
|
|
|
|
static const wxColor default_foreground = theme_config->GetThemeColor("foreground", "default");
|
|
|
|
wxColor line_number_background = ( ! theme_config->GetThemeValue("line_numbers", "background").isNull())
|
|
|
|
? (theme_config->GetThemeColor("line_numbers", "background"))
|
2015-04-21 17:06:21 -04:00
|
|
|
: default_background;
|
2015-04-21 14:07:04 -04:00
|
|
|
|
2015-05-07 14:06:12 -04:00
|
|
|
wxColor line_number_foreground = ( ! theme_config->GetThemeValue("line_numbers", "foreground").isNull())
|
|
|
|
? (theme_config->GetThemeColor("line_numbers", "foreground"))
|
2015-04-21 17:06:21 -04:00
|
|
|
: default_foreground;
|
2015-04-21 14:07:04 -04:00
|
|
|
|
|
|
|
// Set default colors/ fonts
|
|
|
|
for(int i = 0; i <= wxSTC_STYLE_MAX; i++)
|
|
|
|
{
|
|
|
|
this->StyleSetBackground(i, default_background);
|
2015-04-21 17:06:21 -04:00
|
|
|
this->StyleSetForeground(i, default_foreground);
|
2015-04-21 14:07:04 -04:00
|
|
|
this->StyleSetFont(i, *defaultFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->StyleSetForeground (wxSTC_STYLE_DEFAULT, default_foreground);
|
|
|
|
this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161));
|
|
|
|
|
2015-05-04 16:27:21 -04:00
|
|
|
this->SetMarginWidth (MARGIN_LINE_NUMBERS, TextWidth(wxSTC_STYLE_LINENUMBER, "_999"));
|
2015-04-21 14:07:04 -04:00
|
|
|
this->StyleSetForeground (wxSTC_STYLE_LINENUMBER, line_number_foreground);
|
|
|
|
this->StyleSetBackground (wxSTC_STYLE_LINENUMBER, line_number_background);
|
|
|
|
this->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);
|
|
|
|
|
2015-04-29 17:03:15 -04:00
|
|
|
int max = lexer_map.size();
|
2015-04-22 16:57:10 -04:00
|
|
|
|
2015-04-29 17:03:15 -04:00
|
|
|
for (int i = 0; i < max; i++)
|
2015-04-21 14:07:04 -04:00
|
|
|
{
|
2015-04-29 17:03:15 -04:00
|
|
|
string key = lexer_map[i].asString();
|
2015-04-22 16:57:10 -04:00
|
|
|
|
|
|
|
//wxLogDebug("Token type: %s", key);
|
|
|
|
//wxLogDebug("Lexer constant: %i", i);
|
2015-04-21 14:07:04 -04:00
|
|
|
|
|
|
|
// Set the foreground color, if it exists
|
2015-05-07 14:06:12 -04:00
|
|
|
if ( ! theme_config->GetThemeValue("foreground", key).isNull())
|
2015-04-21 14:07:04 -04:00
|
|
|
{
|
2015-05-07 14:06:12 -04:00
|
|
|
this->StyleSetForeground(i, theme_config->GetThemeColor("foreground", key));
|
2015-04-21 14:07:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the background color, if it exists
|
2015-05-07 14:06:12 -04:00
|
|
|
if ( ! theme_config->GetThemeValue("background", key).isNull())
|
2015-04-21 14:07:04 -04:00
|
|
|
{
|
2015-05-07 14:06:12 -04:00
|
|
|
this->StyleSetBackground(i, theme_config->GetThemeColor("background", key));
|
2015-04-21 14:07:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set bold, if it applies
|
2015-05-07 14:06:12 -04:00
|
|
|
if (theme_config->GetThemeValue("bold", key).isBool())
|
2015-04-21 14:07:04 -04:00
|
|
|
{
|
2015-05-07 14:06:12 -04:00
|
|
|
this->StyleSetBold(i, theme_config->GetThemeValue("bold", key).asBool());
|
2015-04-21 14:07:04 -04:00
|
|
|
}
|
2015-04-21 17:06:21 -04:00
|
|
|
|
|
|
|
// Italic
|
2015-05-07 14:06:12 -04:00
|
|
|
if (theme_config->GetThemeValue("italic", key).isBool())
|
2015-04-21 17:06:21 -04:00
|
|
|
{
|
2015-05-07 14:06:12 -04:00
|
|
|
this->StyleSetItalic(i, theme_config->GetThemeValue("italic", key).asBool());
|
2015-04-21 17:06:21 -04:00
|
|
|
}
|
2015-04-29 10:18:44 -04:00
|
|
|
|
|
|
|
// Underline
|
2015-05-07 14:06:12 -04:00
|
|
|
if (theme_config->GetThemeValue("underline", key).isBool())
|
2015-04-29 10:18:44 -04:00
|
|
|
{
|
2015-05-07 14:06:12 -04:00
|
|
|
this->StyleSetUnderline(i, theme_config->GetThemeValue("underline", key).asBool());
|
2015-04-29 10:18:44 -04:00
|
|
|
}
|
2015-04-21 14:07:04 -04:00
|
|
|
}
|
|
|
|
}
|