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
@@ -5,64 +5,22 @@
|
||||
|
||||
namespace Code {
|
||||
|
||||
class Script {
|
||||
/* File : | Total Size | Type | Name | Body |
|
||||
* Script: | AutoImportationStatus | Content |*/
|
||||
|
||||
class Script : public File {
|
||||
friend class ScriptStore;
|
||||
public:
|
||||
Script(const char * marker = nullptr, const char * name = nullptr, size_t nameBufferSize = 0, const char * content = nullptr, size_t contentBufferSize = 0);
|
||||
bool isNull() const;
|
||||
bool autoImport() const;
|
||||
Script(File f);
|
||||
|
||||
const char * name() const {
|
||||
assert(!isNull());
|
||||
assert(m_name != nullptr);
|
||||
return m_name;
|
||||
}
|
||||
bool importationStatus() const;
|
||||
void toggleImportationStatus();
|
||||
|
||||
char * editableName() {
|
||||
assert(!isNull());
|
||||
assert(m_name != nullptr);
|
||||
return const_cast<char *>(m_name);
|
||||
}
|
||||
const char * readContent() const;
|
||||
ErrorStatus writeContent(const char * data, size_t size);
|
||||
|
||||
/* nameBufferSize() might not be equal to strlen(name()): There might be free
|
||||
* space (chars equal to ScriptStore::FreeSpaceMarker), that is used to edit
|
||||
* the script name. */
|
||||
size_t nameBufferSize() const {
|
||||
assert(!isNull());
|
||||
return m_nameBufferSize;
|
||||
}
|
||||
|
||||
const char * content() const {
|
||||
assert(!isNull());
|
||||
assert(m_content != nullptr);
|
||||
return m_content;
|
||||
}
|
||||
|
||||
char * editableContent() {
|
||||
assert(!isNull());
|
||||
assert(m_content != nullptr);
|
||||
return const_cast<char *>(m_content);
|
||||
}
|
||||
|
||||
/* contentBufferSize() might not be equal to strlen(name()): There might be
|
||||
* free space (chars equal to ScriptStore::FreeSpaceMarker), that is used to
|
||||
* edit the script content. */
|
||||
size_t contentBufferSize() const {
|
||||
assert(!isNull());
|
||||
return m_contentBufferSize;
|
||||
}
|
||||
|
||||
static constexpr int NumberOfStringsPerScript = 3;
|
||||
static constexpr char AutoImportationMarker = 2;
|
||||
static constexpr char NoAutoImportationMarker = 3;
|
||||
static constexpr char DefaultAutoImportationMarker = AutoImportationMarker;
|
||||
/* We made sure that these chars are not used in ion/include/ion/charset.h,
|
||||
* nor used in the ScriptStore. */
|
||||
private:
|
||||
const char * m_marker;
|
||||
const char * m_name;
|
||||
size_t m_nameBufferSize;
|
||||
const char * m_content;
|
||||
size_t m_contentBufferSize;
|
||||
constexpr static size_t k_importationStatusSize = 1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user