diff --git a/apps/code/editor_controller.cpp b/apps/code/editor_controller.cpp index 4cb3e5a98..bb02d1ff6 100644 --- a/apps/code/editor_controller.cpp +++ b/apps/code/editor_controller.cpp @@ -4,6 +4,7 @@ #include "app.h" #include #include +#include "../global_preferences.h" using namespace Shared; @@ -63,7 +64,11 @@ void EditorController::didBecomeFirstResponder() { void EditorController::viewWillAppear() { ViewController::viewWillAppear(); m_editorView.loadSyntaxHighlighter(); - m_editorView.setCursorLocation(m_script.content() + *m_script.CursorPosition()); + if(GlobalPreferences::sharedGlobalPreferences()->cursorSaving()) { + m_editorView.setCursorLocation(m_script.content() + *m_script.CursorPosition()); + } else { + m_editorView.setCursorLocation(m_editorView.text() + strlen(m_editorView.text())); + } } void EditorController::viewDidDisappear() { diff --git a/apps/global_preferences.h b/apps/global_preferences.h index a54a5d8a6..bcfa324ea 100644 --- a/apps/global_preferences.h +++ b/apps/global_preferences.h @@ -38,6 +38,8 @@ public: void setAutocomplete(bool autocomple) { m_autoComplete = autocomple; } bool syntaxhighlighting() const { return m_syntaxhighlighting; } void setSyntaxhighlighting(bool syntaxhighlight) { m_syntaxhighlighting = syntaxhighlight; } + bool cursorSaving() const { return m_cursorSaving; } + void setCursorSaving(bool cursorsave) { m_cursorSaving = cursorsave; } int brightnessLevel() const { return m_brightnessLevel; } void setBrightnessLevel(int brightnessLevel); const KDFont * font() const { return m_font; } @@ -56,6 +58,7 @@ private: m_dfuLevel(0), m_autoComplete(true), m_syntaxhighlighting(true), + m_cursorSaving(true), m_brightnessLevel(Ion::Backlight::MaxBrightness), m_font(KDFont::LargeFont) {} I18n::Language m_language; @@ -69,6 +72,7 @@ private: uint8_t m_dfuLevel; bool m_autoComplete; bool m_syntaxhighlighting; + bool m_cursorSaving; int m_brightnessLevel; const KDFont * m_font; }; diff --git a/apps/settings/base.de.i18n b/apps/settings/base.de.i18n index 5675747fa..2f38be2bb 100644 --- a/apps/settings/base.de.i18n +++ b/apps/settings/base.de.i18n @@ -71,6 +71,7 @@ Time = "Uhrzeit" RTCWarning1 = "Das Aktivieren der Uhr verkürzt die" RTCWarning2 = "Akkulaufzeit im Bereitschaftsmodus." SyntaxHighlighting = "Syntaxhervorhebung" +CursorSaving = "Cursor speichern" USBExplanation1 = "USB-Schutz schützt Ihren" USBExplanation2 = "Taschenrechner vor" USBExplanation3 = "unbeabsichtigter Verriegelung" diff --git a/apps/settings/base.en.i18n b/apps/settings/base.en.i18n index ddc854c0e..ebdc55abe 100644 --- a/apps/settings/base.en.i18n +++ b/apps/settings/base.en.i18n @@ -71,6 +71,7 @@ Time = "Time" RTCWarning1 = "Enabling the clock drains the battery faster" RTCWarning2 = "when the calculator is powered off." SyntaxHighlighting = "Syntax Highlighting" +CursorSaving = "Cursor saving" USBExplanation1 = "The USB protection protects" USBExplanation2 = "the calculator from" USBExplanation3 = "unintentional locking" diff --git a/apps/settings/base.es.i18n b/apps/settings/base.es.i18n index 1e59a1d16..b3b8ec6e6 100644 --- a/apps/settings/base.es.i18n +++ b/apps/settings/base.es.i18n @@ -71,6 +71,7 @@ Time = "Hora" RTCWarning1 = "Activar el reloj gasta la batería más rápido" RTCWarning2 = "cuando la calculadora está apagada." SyntaxHighlighting = "Resaltado de sintaxis" +CursorSaving = "Ahorro de cursor" USBExplanation1 = "La protección USB protege" USBExplanation2 = "su calculadora del" USBExplanation3 = "bloqueo involuntario" diff --git a/apps/settings/base.fr.i18n b/apps/settings/base.fr.i18n index 758cb2087..3204ba621 100644 --- a/apps/settings/base.fr.i18n +++ b/apps/settings/base.fr.i18n @@ -71,6 +71,7 @@ Time = "Heure" RTCWarning1 = "Activer l'horloge décharge la batterie plus" RTCWarning2 = "vite quand la calculatrice est éteinte." SyntaxHighlighting = "Coloration syntaxique" +CursorSaving = "Sauvegarde du curseur" USBExplanation1 = "La protection USB protège votre" USBExplanation2 = "calculatrice contre un verrouillage" USBExplanation3 = "non-intentionnel" diff --git a/apps/settings/base.hu.i18n b/apps/settings/base.hu.i18n index 1518f3982..080b7b5da 100644 --- a/apps/settings/base.hu.i18n +++ b/apps/settings/base.hu.i18n @@ -71,6 +71,7 @@ Time = "Óra" RTCWarning1 = "Amikor a számológép alvómódban van, az óra" RTCWarning2 = "használása az elemet gyorsabban meríti ki." SyntaxHighlighting = "Szintaxis kiemelés" +CursorSaving = "Kurzor mentése" USBExplanation1 = "Az USB-védelem megvédi" USBExplanation2 = "a számológépet a nem" USBExplanation3 = "szándékos reteszeléstől" diff --git a/apps/settings/base.it.i18n b/apps/settings/base.it.i18n index fb253c161..ae64c22dd 100644 --- a/apps/settings/base.it.i18n +++ b/apps/settings/base.it.i18n @@ -71,6 +71,7 @@ Time = "Time" RTCWarning1 = "Enabling the clock drains the battery faster" RTCWarning2 = "when the calculator is powered off." SyntaxHighlighting = "Evidenziazione della sintassi" +CursorSaving = "Salvataggio cursore" USBExplanation1 = "La protezione USB protegge" USBExplanation2 = "la calcolatrice dal" USBExplanation3 = "blocco involontario" diff --git a/apps/settings/base.nl.i18n b/apps/settings/base.nl.i18n index 88e42f70c..6d72e3402 100644 --- a/apps/settings/base.nl.i18n +++ b/apps/settings/base.nl.i18n @@ -71,6 +71,7 @@ Time = "Time" RTCWarning1 = "Enabling the clock drains the battery faster" RTCWarning2 = "when the calculator is powered off." SyntaxHighlighting = "Syntax Highlighting" +CursorSaving = "Cursor opslaan" USBExplanation1 = "USB-beveiliging beschermt uw" USBExplanation2 = "rekenmachine tegen" USBExplanation3 = "onbedoelde vergrendeling" diff --git a/apps/settings/base.pt.i18n b/apps/settings/base.pt.i18n index 7cc14a15f..d1f42789c 100644 --- a/apps/settings/base.pt.i18n +++ b/apps/settings/base.pt.i18n @@ -71,6 +71,7 @@ Time = "Time" RTCWarning1 = "Enabling the clock drains the battery faster" RTCWarning2 = "when the calculator is powered off." SyntaxHighlighting = "Destaque da sintaxe" +CursorSaving = "Economia de cursor" USBExplanation1 = "A proteção USB protege" USBExplanation2 = "sua calculadora contra" USBExplanation3 = "bloqueios não intencionais" diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index 6ee5ff5b1..df4880990 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -24,7 +24,7 @@ constexpr SettingsMessageTree s_contributorsChildren[23] = {SettingsMessageTree( // Code Settings #ifdef HAS_CODE -constexpr SettingsMessageTree s_codeChildren[3] = {SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren), SettingsMessageTree(I18n::Message::Autocomplete), SettingsMessageTree(I18n::Message::SyntaxHighlighting)}; +constexpr SettingsMessageTree s_codeChildren[4] = {SettingsMessageTree(I18n::Message::FontSizes, s_modelFontChildren), SettingsMessageTree(I18n::Message::Autocomplete), SettingsMessageTree(I18n::Message::SyntaxHighlighting), SettingsMessageTree(I18n::Message::CursorSaving)}; #endif constexpr SettingsMessageTree s_modelFontChildren[2] = {SettingsMessageTree(I18n::Message::LargeFont), SettingsMessageTree(I18n::Message::SmallFont)}; diff --git a/apps/settings/main_controller.h b/apps/settings/main_controller.h index ffcc2cfe6..cb3aae2f9 100644 --- a/apps/settings/main_controller.h +++ b/apps/settings/main_controller.h @@ -24,7 +24,7 @@ extern const Shared::SettingsMessageTree s_symbolChildren[4]; extern const Shared::SettingsMessageTree s_symbolFunctionChildren[3]; extern const Shared::SettingsMessageTree s_modelMathOptionsChildren[6]; extern const Shared::SettingsMessageTree s_modelFontChildren[2]; -extern const Shared::SettingsMessageTree s_codeChildren[3]; +extern const Shared::SettingsMessageTree s_codeChildren[4]; extern const Shared::SettingsMessageTree s_modelDateTimeChildren[3]; extern const Shared::SettingsMessageTree s_accessibilityChildren[6]; extern const Shared::SettingsMessageTree s_contributorsChildren[23]; diff --git a/apps/settings/sub_menu/code_options_controller.cpp b/apps/settings/sub_menu/code_options_controller.cpp index 8f8ecdbf8..f3c17b2fc 100644 --- a/apps/settings/sub_menu/code_options_controller.cpp +++ b/apps/settings/sub_menu/code_options_controller.cpp @@ -13,6 +13,7 @@ CodeOptionsController::CodeOptionsController(Responder * parentResponder) : m_chevronCellFontSize.setMessageFont(KDFont::LargeFont); m_switchCellAutoCompletion.setMessageFont(KDFont::LargeFont); m_switchCellSyntaxHighlighting.setMessageFont(KDFont::LargeFont); + m_switchCellCursorSaving.setMessageFont(KDFont::LargeFont); } bool CodeOptionsController::handleEvent(Ion::Events::Event event) { @@ -21,11 +22,15 @@ 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; + break; case 2: GlobalPreferences::sharedGlobalPreferences()->setSyntaxhighlighting(!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()); m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()); break; + case 3: + GlobalPreferences::sharedGlobalPreferences()->setCursorSaving(!GlobalPreferences::sharedGlobalPreferences()->cursorSaving()); + m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()); + break; default: GenericSubController * subController = nullptr; subController = &m_preferencesController; @@ -34,7 +39,6 @@ bool CodeOptionsController::handleEvent(Ion::Events::Event event) { m_lastSelect = selectedRow(); stack->push(subController); break; - } return true; } @@ -50,6 +54,9 @@ HighlightCell * CodeOptionsController::reusableCell(int index, int type) { else if (index == 1) { return &m_switchCellAutoCompletion; } + else if (index == 2) { + return &m_switchCellCursorSaving; + } return &m_switchCellSyntaxHighlighting; } @@ -66,9 +73,9 @@ void CodeOptionsController::willDisplayCellForIndex(HighlightCell * cell, int in MessageTableCellWithChevronAndMessage * myTextCell = (MessageTableCellWithChevronAndMessage *)cell; myTextCell->setMessage(thisLabel); GlobalPreferences::sharedGlobalPreferences()->font() == KDFont::LargeFont - ? myTextCell->setSubtitle(I18n::Message::LargeFont) + ? myTextCell->setSubtitle(I18n::Message::LargeFont) : myTextCell->setSubtitle(I18n::Message::SmallFont); - } + } #ifdef HAS_CODE else if (thisLabel == I18n::Message::Autocomplete) { MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell; @@ -80,6 +87,11 @@ void CodeOptionsController::willDisplayCellForIndex(HighlightCell * cell, int in SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); mySwitch->setState(GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting()); } + else if (thisLabel == I18n::Message::CursorSaving) { + MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell; + SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); + mySwitch->setState(GlobalPreferences::sharedGlobalPreferences()->cursorSaving()); + } #endif } diff --git a/apps/settings/sub_menu/code_options_controller.h b/apps/settings/sub_menu/code_options_controller.h index 650ea6da5..854de5e8e 100644 --- a/apps/settings/sub_menu/code_options_controller.h +++ b/apps/settings/sub_menu/code_options_controller.h @@ -14,11 +14,12 @@ public: int reusableCellCount(int type) override; void willDisplayCellForIndex(HighlightCell * cell, int index) override; private: - constexpr static int k_totalNumberOfCell = 3; + constexpr static int k_totalNumberOfCell = 4; PreferencesController m_preferencesController; MessageTableCellWithChevronAndMessage m_chevronCellFontSize; MessageTableCellWithSwitch m_switchCellAutoCompletion; MessageTableCellWithSwitch m_switchCellSyntaxHighlighting; + MessageTableCellWithSwitch m_switchCellCursorSaving; }; }