From 422213754939f43f570aeef391392de24dab4bcd Mon Sep 17 00:00:00 2001 From: Laury Date: Sat, 27 Nov 2021 13:42:47 +0100 Subject: [PATCH] [apps/code] Improve code style in syntax highlighting setting --- apps/code/python_text_area.cpp | 4 ++-- apps/settings/sub_menu/code_options_controller.cpp | 13 ++++++------- apps/settings/sub_menu/code_options_controller.h | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/apps/code/python_text_area.cpp b/apps/code/python_text_area.cpp index 0cef1875a..70b9aef5a 100644 --- a/apps/code/python_text_area.cpp +++ b/apps/code/python_text_area.cpp @@ -25,7 +25,7 @@ constexpr KDColor HighlightColor = Palette::CodeBackgroundSelected; constexpr KDColor AutocompleteColor = KDColor::RGB24(0xC6C6C6); // TODO Palette change static inline KDColor TokenColor(mp_token_kind_t tokenKind) { - if(!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()) { + if (!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()) { return Palette::CodeText; } if (tokenKind == MP_TOKEN_STRING) { @@ -309,7 +309,7 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char tokenFrom += tokenLength; KDColor color = CommentColor; - if(!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()) { + if (!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()) { color = Palette::CodeText; } // Even if the token is being autocompleted, use CommentColor diff --git a/apps/settings/sub_menu/code_options_controller.cpp b/apps/settings/sub_menu/code_options_controller.cpp index 824419dba..8f8ecdbf8 100644 --- a/apps/settings/sub_menu/code_options_controller.cpp +++ b/apps/settings/sub_menu/code_options_controller.cpp @@ -10,9 +10,9 @@ CodeOptionsController::CodeOptionsController(Responder * parentResponder) : GenericSubController(parentResponder), m_preferencesController(this) { - m_chevronCell.setMessageFont(KDFont::LargeFont); - m_switchCell.setMessageFont(KDFont::LargeFont); - m_switchCell_syntax_highlighting.setMessageFont(KDFont::LargeFont); + m_chevronCellFontSize.setMessageFont(KDFont::LargeFont); + m_switchCellAutoCompletion.setMessageFont(KDFont::LargeFont); + m_switchCellSyntaxHighlighting.setMessageFont(KDFont::LargeFont); } bool CodeOptionsController::handleEvent(Ion::Events::Event event) { @@ -26,7 +26,6 @@ bool CodeOptionsController::handleEvent(Ion::Events::Event event) { GlobalPreferences::sharedGlobalPreferences()->setSyntaxhighlighting(!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()); m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()); break; - default: GenericSubController * subController = nullptr; subController = &m_preferencesController; @@ -46,12 +45,12 @@ HighlightCell * CodeOptionsController::reusableCell(int index, int type) { assert(type == 0); assert(index >= 0 && index < k_totalNumberOfCell); if (index == 0) { - return &m_chevronCell; + return &m_chevronCellFontSize; } else if (index == 1) { - return &m_switchCell; + return &m_switchCellAutoCompletion; } - return &m_switchCell_syntax_highlighting; + return &m_switchCellSyntaxHighlighting; } int CodeOptionsController::reusableCellCount(int type) { diff --git a/apps/settings/sub_menu/code_options_controller.h b/apps/settings/sub_menu/code_options_controller.h index d7c089b57..650ea6da5 100644 --- a/apps/settings/sub_menu/code_options_controller.h +++ b/apps/settings/sub_menu/code_options_controller.h @@ -16,9 +16,9 @@ public: private: constexpr static int k_totalNumberOfCell = 3; PreferencesController m_preferencesController; - MessageTableCellWithChevronAndMessage m_chevronCell; - MessageTableCellWithSwitch m_switchCell; - MessageTableCellWithSwitch m_switchCell_syntax_highlighting; + MessageTableCellWithChevronAndMessage m_chevronCellFontSize; + MessageTableCellWithSwitch m_switchCellAutoCompletion; + MessageTableCellWithSwitch m_switchCellSyntaxHighlighting; }; }