Separate logic for setting editor properties from color scheme logic
This commit is contained in:
parent
8ea7ad4abc
commit
37faa83103
@ -25,7 +25,6 @@ EditorPane::EditorPane(
|
|||||||
this->BindEvents();
|
this->BindEvents();
|
||||||
|
|
||||||
// Some basic properties to set
|
// Some basic properties to set
|
||||||
this->SetStyleBits(8);
|
|
||||||
this->SetScrollWidthTracking(true);// Set scroll width by longest line
|
this->SetScrollWidthTracking(true);// Set scroll width by longest line
|
||||||
this->SetProperty("technology", "2");
|
this->SetProperty("technology", "2");
|
||||||
this->SetProperty("error.inline", "0");
|
this->SetProperty("error.inline", "0");
|
||||||
@ -34,6 +33,7 @@ EditorPane::EditorPane(
|
|||||||
this->SetProperty("font.quality", "3"); // LCD Optimized
|
this->SetProperty("font.quality", "3"); // LCD Optimized
|
||||||
|
|
||||||
// this->SetLayoutCache (wxSTC_CACHE_DOCUMENT);
|
// this->SetLayoutCache (wxSTC_CACHE_DOCUMENT);
|
||||||
|
this->SetUseAntiAliasing(true);
|
||||||
|
|
||||||
// set spaces and indention
|
// set spaces and indention
|
||||||
this->SetTabWidth(4);
|
this->SetTabWidth(4);
|
||||||
@ -126,6 +126,7 @@ void EditorPane::ApplyTheme(const string &lang, const string &theme)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do the appropriate mappings to load the selected theme
|
// Do the appropriate mappings to load the selected theme
|
||||||
|
this->_ApplyConfig();
|
||||||
this->_ApplyTheme(lexer_map);
|
this->_ApplyTheme(lexer_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,37 +317,21 @@ void EditorPane::BindEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate through the theme settings and apply them
|
* Set editor settings from config
|
||||||
*
|
*
|
||||||
* @param Json::Value lexer_map - Maps token types to theme colors
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void EditorPane::_ApplyTheme(Json::Value &lexer_map)
|
void EditorPane::_ApplyConfig()
|
||||||
{
|
{
|
||||||
// Make sure to have a default font, especially for Linux
|
|
||||||
wxFont globalFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
|
|
||||||
|
|
||||||
static const wxColor default_background = Glob_theme_config->GetThemeColor("background", "default");
|
static const wxColor default_background = Glob_theme_config->GetThemeColor("background", "default");
|
||||||
static const wxColor default_foreground = Glob_theme_config->GetThemeColor("foreground", "default");
|
static const wxColor default_foreground = Glob_theme_config->GetThemeColor("foreground", "default");
|
||||||
wxColor line_number_background = ( ! Glob_theme_config->GetThemeValue("line_numbers", "background").isNull())
|
wxColor line_number_background = ( ! Glob_theme_config->GetThemeValue("line_numbers", "background").isNull())
|
||||||
? (Glob_theme_config->GetThemeColor("line_numbers", "background"))
|
? (Glob_theme_config->GetThemeColor("line_numbers", "background"))
|
||||||
: default_background;
|
: default_background;
|
||||||
|
|
||||||
wxColor line_number_foreground = ( ! Glob_theme_config->GetThemeValue("line_numbers", "foreground").isNull())
|
wxColor line_number_foreground = ( ! Glob_theme_config->GetThemeValue("line_numbers", "foreground").isNull())
|
||||||
? (Glob_theme_config->GetThemeColor("line_numbers", "foreground"))
|
? (Glob_theme_config->GetThemeColor("line_numbers", "foreground"))
|
||||||
: default_foreground;
|
: default_foreground;
|
||||||
|
|
||||||
// Attempt to set the font according to config
|
|
||||||
Glob_config->Read("global_font", &globalFont);
|
|
||||||
|
|
||||||
// Set default colors/ fonts
|
|
||||||
for(int i = 0; i <= wxSTC_STYLE_MAX; i++)
|
|
||||||
{
|
|
||||||
this->StyleSetBackground(i, default_background);
|
|
||||||
this->StyleSetForeground(i, default_foreground);
|
|
||||||
|
|
||||||
this->StyleSetFont(i, globalFont);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up Code folding
|
// Set up Code folding
|
||||||
if (Glob_config->ReadBool("show_code_folding", false))
|
if (Glob_config->ReadBool("show_code_folding", false))
|
||||||
@ -403,6 +388,40 @@ void EditorPane::_ApplyTheme(Json::Value &lexer_map)
|
|||||||
{
|
{
|
||||||
this->SetMarginWidth (MARGIN_LINE_NUMBERS, 0);
|
this->SetMarginWidth (MARGIN_LINE_NUMBERS, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate through the theme colors and apply them
|
||||||
|
*
|
||||||
|
* @param Json::Value lexer_map - Maps token types to theme colors
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void EditorPane::_ApplyTheme(Json::Value &lexer_map)
|
||||||
|
{
|
||||||
|
// Make sure to have a default font, especially for Linux
|
||||||
|
wxFont globalFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
|
||||||
|
|
||||||
|
static const wxColor default_background = Glob_theme_config->GetThemeColor("background", "default");
|
||||||
|
static const wxColor default_foreground = Glob_theme_config->GetThemeColor("foreground", "default");
|
||||||
|
wxColor line_number_background = ( ! Glob_theme_config->GetThemeValue("line_numbers", "background").isNull())
|
||||||
|
? (Glob_theme_config->GetThemeColor("line_numbers", "background"))
|
||||||
|
: default_background;
|
||||||
|
|
||||||
|
wxColor line_number_foreground = ( ! Glob_theme_config->GetThemeValue("line_numbers", "foreground").isNull())
|
||||||
|
? (Glob_theme_config->GetThemeColor("line_numbers", "foreground"))
|
||||||
|
: default_foreground;
|
||||||
|
|
||||||
|
// Attempt to set the font according to config
|
||||||
|
Glob_config->Read("global_font", &globalFont);
|
||||||
|
|
||||||
|
// Set default colors/ fonts
|
||||||
|
for(int i = 0; i <= wxSTC_STYLE_MAX; i++)
|
||||||
|
{
|
||||||
|
this->StyleSetBackground(i, default_background);
|
||||||
|
this->StyleSetForeground(i, default_foreground);
|
||||||
|
|
||||||
|
this->StyleSetFont(i, globalFont);
|
||||||
|
}
|
||||||
|
|
||||||
int max = lexer_map.size();
|
int max = lexer_map.size();
|
||||||
for (int i = 0; i < max; i++)
|
for (int i = 0; i < max; i++)
|
||||||
|
@ -28,5 +28,6 @@ protected:
|
|||||||
bool FileReadable();
|
bool FileReadable();
|
||||||
bool FileWritable();
|
bool FileWritable();
|
||||||
void BindEvents();
|
void BindEvents();
|
||||||
|
void _ApplyConfig();
|
||||||
void _ApplyTheme(Json::Value &lexer_map);
|
void _ApplyTheme(Json::Value &lexer_map);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user