Skip to content

Commit

Permalink
this featurs #285
Browse files Browse the repository at this point in the history
  • Loading branch information
cartoone222 committed Jun 10, 2024
1 parent 1206511 commit 15225a0
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 9 deletions.
4 changes: 4 additions & 0 deletions apps/global_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class GlobalPreferences {
void setAutocomplete(bool autocomple) { m_autoComplete = autocomple; }
bool syntaxhighlighting() const { return m_syntaxhighlighting; }
void setSyntaxhighlighting(bool syntaxhighlight) { m_syntaxhighlighting = syntaxhighlight; }
bool clearalphalockshift() const { return m_clearalphalockshift; }
void setclearalphalockshift(bool clearalphalockshift) { m_clearalphalockshift = clearalphalockshift; }
int brightnessLevel() const { return m_brightnessLevel; }
void setBrightnessLevel(int brightnessLevel);
const KDFont * font() const { return m_font; }
Expand Down Expand Up @@ -63,6 +65,7 @@ class GlobalPreferences {
m_dfuUnlocked(false),
m_autoComplete(true),
m_syntaxhighlighting(true),
m_clearalphalockshift(true),
m_brightnessLevel(Ion::Backlight::MaxBrightness),
m_idleBeforeSuspendSeconds(55),
m_idleBeforeDimmingSeconds(45),
Expand All @@ -80,6 +83,7 @@ class GlobalPreferences {
bool m_dfuUnlocked;
bool m_autoComplete;
bool m_syntaxhighlighting;
bool m_clearalphalockshift;
int m_brightnessLevel;
int m_idleBeforeSuspendSeconds;
int m_idleBeforeDimmingSeconds;
Expand Down
1 change: 1 addition & 0 deletions apps/settings/base.de.i18n
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ ExtAppWriteExplanation1 = "Standardmäßig externe Anwendungen"
ExtAppWriteExplanation2 = "kann nicht in den Speicher schreiben"
ExtAppWriteExplanation3 = "Flash (dauerhaft) Ihres Rechners."
ExtAppEnabled = "Aufstecken"
Clearshiftlock = "Tastenkombination Umschalt + Löschen"
1 change: 1 addition & 0 deletions apps/settings/base.en.i18n
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ ExtAppWriteExplanation1 = "By default, external applications"
ExtAppWriteExplanation2 = "cannot write to memory"
ExtAppWriteExplanation3 = "flash (persistent) of your calculator."
ExtAppEnabled = "Pin up"
Clearshiftlock = "shortcut shift + clear"
1 change: 1 addition & 0 deletions apps/settings/base.es.i18n
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ ExtAppWriteExplanation1 = "Por defecto, las aplicaciones externas"
ExtAppWriteExplanation2 = "no se puede escribir en la memoria"
ExtAppWriteExplanation3 = "flash (persistente) de su calculadora."
ExtAppEnabled = "Fijar"
Clearshiftlock = "atajo mayús + borrar"
1 change: 1 addition & 0 deletions apps/settings/base.fr.i18n
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Time = "Heure"
RTCWarning1 = "Activer l'horloge décharge la batterie plus"
RTCWarning2 = "vite quand la calculatrice est éteinte."
SyntaxHighlighting = "Coloration syntaxique"
Clearshiftlock = "raccourci shift + clear"
Normal = "Normale"
IdleTimeBeforeDimming = "Assombrir après (s)"
IdleTimeBeforeSuspend = "Éteindre après (s)"
Expand Down
1 change: 1 addition & 0 deletions apps/settings/base.hu.i18n
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ ExtAppWriteExplanation1 = "Alapértelmezés szerint külső alkalmazások"
ExtAppWriteExplanation2 = "nem tud a memóriába írni"
ExtAppWriteExplanation3 = "villog (tartósan) a számológép."
ExtAppEnabled = "Feltűz"
Clearshiftlock = "gyorsbillentyű shift + törlés"
1 change: 1 addition & 0 deletions apps/settings/base.it.i18n
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ ExtAppWriteExplanation1 = "Per impostazione predefinita, le app esterne"
ExtAppWriteExplanation2 = "non possono scrivere in memoria flash"
ExtAppWriteExplanation3 = "(persistente) della calcolatrice."
ExtAppEnabled = "Affiggere"
Clearshiftlock = "scorciatoia Maiusc + Cancella"
1 change: 1 addition & 0 deletions apps/settings/base.nl.i18n
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ ExtAppWriteExplanation1 = "Standaard zijn externe toepassingen"
ExtAppWriteExplanation2 = "kan niet naar het geheugen schrijven"
ExtAppWriteExplanation3 = "flash (aanhoudend) van uw rekenmachine."
ExtAppEnabled = "Vastpinnen"
Clearshiftlock = "sneltoets shift + wissen"
1 change: 1 addition & 0 deletions apps/settings/base.pt.i18n
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ ExtAppWriteExplanation1 = "Por padrão, aplicativos externos"
ExtAppWriteExplanation2 = "não pode gravar na memória"
ExtAppWriteExplanation3 = "flash (persistente) de sua calculadora."
ExtAppEnabled = "Pôster"
Clearshiftlock = "atalho shift + limpar"
2 changes: 1 addition & 1 deletion apps/settings/main_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ constexpr SettingsMessageTree s_contributorsChildren[18] = {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::Clearshiftlock)};
#endif
constexpr SettingsMessageTree s_modelFontChildren[2] = {SettingsMessageTree(I18n::Message::LargeFont), SettingsMessageTree(I18n::Message::SmallFont)};

Expand Down
2 changes: 1 addition & 1 deletion apps/settings/main_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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[18];
Expand Down
14 changes: 13 additions & 1 deletion apps/settings/sub_menu/code_options_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CodeOptionsController::CodeOptionsController(Responder * parentResponder) :
m_chevronCellFontSize.setMessageFont(KDFont::LargeFont);
m_switchCellAutoCompletion.setMessageFont(KDFont::LargeFont);
m_switchCellSyntaxHighlighting.setMessageFont(KDFont::LargeFont);
m_switchCellClearshiftlock.setMessageFont(KDFont::LargeFont);
}

bool CodeOptionsController::handleEvent(Ion::Events::Event event) {
Expand All @@ -26,6 +27,10 @@ bool CodeOptionsController::handleEvent(Ion::Events::Event event) {
GlobalPreferences::sharedGlobalPreferences()->setSyntaxhighlighting(!GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting());
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
break;
case 3:
GlobalPreferences::sharedGlobalPreferences()->setclearalphalockshift(!GlobalPreferences::sharedGlobalPreferences()->clearalphalockshift());
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow());
break;
default:
GenericSubController * subController = nullptr;
subController = &m_preferencesController;
Expand All @@ -48,8 +53,10 @@ HighlightCell * CodeOptionsController::reusableCell(int index, int type) {
}
else if (index == 1) {
return &m_switchCellAutoCompletion;
}else if (index == 2){
return &m_switchCellSyntaxHighlighting;
}
return &m_switchCellSyntaxHighlighting;
return &m_switchCellClearshiftlock;
}

int CodeOptionsController::reusableCellCount(int type) {
Expand Down Expand Up @@ -79,6 +86,11 @@ void CodeOptionsController::willDisplayCellForIndex(HighlightCell * cell, int in
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
mySwitch->setState(GlobalPreferences::sharedGlobalPreferences()->syntaxhighlighting());
}
else if (thisLabel == I18n::Message::Clearshiftlock) {
MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell;
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
mySwitch->setState(GlobalPreferences::sharedGlobalPreferences()->clearalphalockshift());
}
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion apps/settings/sub_menu/code_options_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ class CodeOptionsController : public GenericSubController {
int reusableCellCount(int type) override;
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
private:
constexpr static int k_totalNumberOfCell = 4;
constexpr static int k_totalNumberOfCell = 5;
PreferencesController m_preferencesController;
MessageTableCellWithChevronAndMessage m_chevronCellFontSize;
MessageTableCellWithSwitch m_switchCellAutoCompletion;
MessageTableCellWithSwitch m_switchCellSyntaxHighlighting;
MessageTableCellWithSwitch m_switchCellClearshiftlock;
};

}
Expand Down
13 changes: 8 additions & 5 deletions escher/src/text_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <ion/unicode/utf8_decoder.h>
#include <ion/unicode/utf8_helper.h>
#include <poincare/serialization_helper.h>
#include <../../apps/global_preferences.h>

#include <stddef.h>
#include <assert.h>
Expand Down Expand Up @@ -249,11 +250,13 @@ bool TextArea::handleEvent(Ion::Events::Event event) {
contentView()->resetSelection();
contentView()->moveCursorGeo(0, event == Ion::Events::Up ? -step : step);
} else if (event == Ion::Events::Clear) {
if (!contentView()->selectionIsEmpty()) {
deleteSelection();
return true;
} else if (!contentView()->removeEndOfLine()) {
contentView()->removeStartOfLine();
if (GlobalPreferences::sharedGlobalPreferences()->clearalphalockshift()){
if (!contentView()->selectionIsEmpty()) {
deleteSelection();
return true;
} else if (!contentView()->removeEndOfLine()) {
contentView()->removeStartOfLine();
}
}
} else if (event == Ion::Events::Paste) {
return handleEventWithText(Clipboard::sharedClipboard()->storedText());
Expand Down

0 comments on commit 15225a0

Please sign in to comment.