mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
A Script object now contains its AutoImport marker, its name and its content. The ScripStore methods have better names and the optimization is cleaner. Change-Id: I1b21af2d23f1c9a34f984309512b0c01b2f1c320
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
#ifndef CODE_SCRIPT_STORE_H
|
|
#define CODE_SCRIPT_STORE_H
|
|
|
|
#include "script.h"
|
|
#include <escher/accordion.h>
|
|
#include <python/port/port.h>
|
|
|
|
namespace Code {
|
|
|
|
class ScriptStore : public MicroPython::ScriptProvider {
|
|
public:
|
|
enum class EditableZone {
|
|
None,
|
|
Name,
|
|
Content
|
|
};
|
|
|
|
enum class DefaultScript {
|
|
Empty,
|
|
Mandelbrot,
|
|
Factorial
|
|
};
|
|
|
|
ScriptStore();
|
|
const Script scriptAtIndex(int index, EditableZone zone = EditableZone::None);
|
|
const Script scriptNamed(const char * name);
|
|
int numberOfScripts();
|
|
bool addNewScript(DefaultScript defaultScript = DefaultScript::Empty);
|
|
bool renameScriptAtIndex(int index, const char * newName);
|
|
void deleteScriptAtIndex(int index);
|
|
void deleteAllScripts();
|
|
|
|
/* MicroPython::ScriptProvider */
|
|
const char * contentOfScript(const char * name) override;
|
|
|
|
private:
|
|
static constexpr char k_defaultScriptName[] = ".py";
|
|
static constexpr size_t k_scriptDataSize = 1024;
|
|
int accordionIndexOfScriptAtIndex(int index) const;
|
|
int accordionIndexOfMarkersOfScriptAtIndex(int index) const;
|
|
int accordionIndexOfNameOfScriptAtIndex(int index) const;
|
|
int accordionIndexOfContentOfScriptAtIndex(int index) const;
|
|
bool copyMandelbrotScriptOnFreeSpace();
|
|
bool copyFactorialScriptOnFreeSpace();
|
|
bool copyEmptyScriptOnFreeSpace();
|
|
char m_scriptData[k_scriptDataSize];
|
|
Accordion m_accordion;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|