mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Code: use the FileSystem to store the scripts instead of an
accordion
This commit is contained in:
committed by
EmilieNumworks
parent
c37696133d
commit
19ca0f0640
@@ -1,7 +1,6 @@
|
||||
#ifndef CODE_SCRIPT_STORE_H
|
||||
#define CODE_SCRIPT_STORE_H
|
||||
|
||||
#include "accordion.h"
|
||||
#include "script.h"
|
||||
#include "script_template.h"
|
||||
#include <python/port/port.h>
|
||||
@@ -13,24 +12,15 @@ namespace Code {
|
||||
|
||||
class ScriptStore : public MicroPython::ScriptProvider {
|
||||
public:
|
||||
enum class EditableZone {
|
||||
None,
|
||||
Name,
|
||||
Content
|
||||
};
|
||||
|
||||
static constexpr char k_scriptExtension[] = ".py";
|
||||
static constexpr char k_defaultScriptName[] = "script.py";
|
||||
static constexpr int k_maxNumberOfScripts = 8;
|
||||
|
||||
ScriptStore();
|
||||
const Script scriptAtIndex(int index, EditableZone zone = EditableZone::None);
|
||||
const Script scriptNamed(const char * name);
|
||||
Script scriptAtIndex(int index);
|
||||
Script scriptNamed(const char * name);
|
||||
int numberOfScripts();
|
||||
bool addNewScript();
|
||||
bool renameScriptAtIndex(int index, const char * newName);
|
||||
void switchAutoImportAtIndex(int index);
|
||||
void deleteScriptAtIndex(int index);
|
||||
void deleteAllScripts();
|
||||
bool isFull();
|
||||
|
||||
@@ -43,21 +33,13 @@ public:
|
||||
|
||||
bool addScriptFromTemplate(const ScriptTemplate * scriptTemplate);
|
||||
private:
|
||||
static constexpr int k_fullFreeSpaceSizeLimit = 50;
|
||||
// If m_accordion's free space has a size smaller than
|
||||
// If the system file free space has a size smaller than
|
||||
// k_fullFreeSpaceSizeLimit, we consider the script store as full.
|
||||
static constexpr size_t k_scriptDataSize = 4096;
|
||||
static constexpr int k_fullFreeSpaceSizeLimit = File::k_sizeSize+File::k_nameSize+File::k_typeSize+10;
|
||||
static constexpr size_t k_fileInput2ParseNodeStructKind = 1;
|
||||
static constexpr size_t k_functionDefinitionParseNodeStructKind = 3;
|
||||
static constexpr size_t k_expressionStatementParseNodeStructKind = 5;
|
||||
bool copyStaticScriptOnFreeSpace(const ScriptTemplate * scriptTemplate);
|
||||
int accordionIndexOfScriptAtIndex(int index) const;
|
||||
int accordionIndexOfMarkersOfScriptAtIndex(int index) const;
|
||||
int accordionIndexOfNameOfScriptAtIndex(int index) const;
|
||||
int accordionIndexOfContentOfScriptAtIndex(int index) const;
|
||||
const char * structID(mp_parse_node_struct_t *structNode);
|
||||
char m_scriptData[k_scriptDataSize];
|
||||
Accordion m_accordion;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user