diff --git a/apps/Makefile b/apps/Makefile index 2edbb9ea6..ec371132a 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -9,6 +9,7 @@ include apps/sequence/Makefile include apps/settings/Makefile include apps/shared/Makefile include apps/statistics/Makefile +include apps/code/Makefile #include apps/picview/Makefile app_objs += $(addprefix apps/,\ diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 504b4aac1..a6abcdd22 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -58,6 +58,7 @@ App::Snapshot * AppsContainer::appSnapshotAtIndex(int index) { &m_statisticsSnapshot, &m_probabilitySnapshot, &m_regressionSnapshot, + &m_codeSnapshot }; assert(sizeof(snapshots)/sizeof(snapshots[0]) == k_numberOfCommonApps); assert(index >= 0 && index < k_numberOfCommonApps); diff --git a/apps/apps_container.h b/apps/apps_container.h index 0481f273e..f19b2f0db 100644 --- a/apps/apps_container.h +++ b/apps/apps_container.h @@ -11,6 +11,7 @@ #include "statistics/app.h" #include "on_boarding/app.h" #include "hardware_test/app.h" +#include "code/app.h" #include "on_boarding/update_controller.h" #include "apps_window.h" #include "empty_battery_window.h" @@ -55,7 +56,7 @@ private: int numberOfContainerTimers() override; Timer * containerTimerAtIndex(int i) override; bool processEvent(Ion::Events::Event event); - static constexpr int k_numberOfCommonApps = 8; + static constexpr int k_numberOfCommonApps = 9; static constexpr int k_totalNumberOfApps = 2+k_numberOfCommonApps; AppsWindow m_window; EmptyBatteryWindow m_emptyBatteryWindow; @@ -82,6 +83,7 @@ private: Statistics::App::Snapshot m_statisticsSnapshot; Probability::App::Snapshot m_probabilitySnapshot; Regression::App::Snapshot m_regressionSnapshot; + Code::App::Snapshot m_codeSnapshot; }; #endif diff --git a/apps/code/Makefile b/apps/code/Makefile new file mode 100644 index 000000000..f80595606 --- /dev/null +++ b/apps/code/Makefile @@ -0,0 +1,4 @@ +app_objs += $(addprefix apps/code/,\ + app.o\ + editor_controller.o\ +) diff --git a/apps/code/app.cpp b/apps/code/app.cpp new file mode 100644 index 000000000..eb3abbd6f --- /dev/null +++ b/apps/code/app.cpp @@ -0,0 +1,30 @@ +#include "app.h" +#include "../apps_container.h" +#include + +namespace Code { + +I18n::Message App::Descriptor::name() { + return I18n::Message::Matrices; +} + +I18n::Message App::Descriptor::upperName() { + return I18n::Message::Matrices; +} + +App * App::Snapshot::unpack(Container * container) { + return new App(container, this); +} + +App::Descriptor * App::Snapshot::descriptor() { + static Descriptor descriptor; + return &descriptor; +} + +App::App(Container * container, Snapshot * snapshot) : + ::App(container, snapshot, &m_editorController), + m_editorController(this) +{ +} + +} diff --git a/apps/code/app.h b/apps/code/app.h new file mode 100644 index 000000000..070a922f8 --- /dev/null +++ b/apps/code/app.h @@ -0,0 +1,33 @@ +#ifndef CODE_APP_H +#define CODE_APP_H + +#include +#include "editor_controller.h" + +namespace Code { + +class App : public ::App { +public: + class Descriptor : public ::App::Descriptor { + public: + I18n::Message name() override; + I18n::Message upperName() override; + //const Image * icon() override; + }; + class Snapshot : public ::App::Snapshot { + public: + App * unpack(Container * container) override; + Descriptor * descriptor() override; + }; + //int numberOfTimers() override; + //Timer * timerAtIndex(int i) override; + //bool processEvent(Ion::Events::Event) override; + //void didBecomeActive(Window * window) override; +private: + App(Container * container, Snapshot * snapshot); + EditorController m_editorController; +}; + +} + +#endif diff --git a/apps/code/editor_controller.cpp b/apps/code/editor_controller.cpp new file mode 100644 index 000000000..4c14f07c9 --- /dev/null +++ b/apps/code/editor_controller.cpp @@ -0,0 +1,25 @@ +#include "editor_controller.h" + +EditorController::EditorController(Responder * parentResponder) : + ViewController(parentResponder), + m_view(this, buffer, 256) +{ + memcpy(buffer, "Hello\nWorld\nOhOhOh\nThis\nLooks\nlike\nso\nmuch\nfun\nI\nwonder\nhow\nmany very very very very very very very long\nlines\nI\ncan\ndisplay", 256); +} + +void EditorController::didBecomeFirstResponder() { + app()->setFirstResponder(&m_view); +} + + +View * EditorController::view() { + return &m_view; +} + +/* + +const char * PicViewController::title() { + return "PicView"; +} +*/ + diff --git a/apps/code/editor_controller.h b/apps/code/editor_controller.h new file mode 100644 index 000000000..346220634 --- /dev/null +++ b/apps/code/editor_controller.h @@ -0,0 +1,17 @@ +#ifndef CODE_EDITOR_CONTROLLER_H +#define CODE_EDITOR_CONTROLLER_H + +#include + +class EditorController : public ViewController { +public: + EditorController(Responder * parentResponder); + View * view() override; + void didBecomeFirstResponder() override; +private: + char buffer[256]; + TextArea m_view; +}; + +#endif +