[apps/code] Add a setting for syntax highlighting (#85)

This commit is contained in:
Yaya-Cout
2021-11-27 12:34:09 +01:00
committed by GitHub
parent fb4b2ffdfa
commit 806b11b589
14 changed files with 38 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ CodeOptionsController::CodeOptionsController(Responder * parentResponder) :
{
m_chevronCell.setMessageFont(KDFont::LargeFont);
m_switchCell.setMessageFont(KDFont::LargeFont);
m_switchCell_syntax_highlighting.setMessageFont(KDFont::LargeFont);
}
bool CodeOptionsController::handleEvent(Ion::Events::Event event) {
@@ -20,6 +21,10 @@ bool CodeOptionsController::handleEvent(Ion::Events::Event event) {
case 1:
GlobalPreferences::sharedGlobalPreferences()->setAutocomplete(!GlobalPreferences::sharedGlobalPreferences()->autocomplete());
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
break;
case 2:
GlobalPreferences::sharedGlobalPreferences()->setSyntaxhighlighting(!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting());
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
break;
default:
@@ -43,7 +48,10 @@ HighlightCell * CodeOptionsController::reusableCell(int index, int type) {
if (index == 0) {
return &m_chevronCell;
}
return &m_switchCell;
else if (index == 1) {
return &m_switchCell;
}
return &m_switchCell_syntax_highlighting;
}
int CodeOptionsController::reusableCellCount(int type) {
@@ -68,6 +76,11 @@ void CodeOptionsController::willDisplayCellForIndex(HighlightCell * cell, int in
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
mySwitch->setState(GlobalPreferences::sharedGlobalPreferences()->autocomplete());
}
else if (thisLabel == I18n::Message::SyntaxHighlighting) {
MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell;
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
mySwitch->setState(GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting());
}
#endif
}