Revert "[storage] Possibility to store metadata with records (cursor in scripts)"

This commit is contained in:
Laury
2022-05-09 18:39:02 +02:00
parent 5220dda095
commit 36fa4a4152
7 changed files with 9 additions and 195 deletions

View File

@@ -65,19 +65,13 @@ void EditorController::viewWillAppear() {
ViewController::viewWillAppear();
m_editorView.loadSyntaxHighlighter();
if(GlobalPreferences::sharedGlobalPreferences()->cursorSaving()) {
int offset = m_script.cursorOffset();
if (offset != -1) {
m_editorView.setCursorLocation(m_editorView.text() + offset);
} else {
m_editorView.setCursorLocation(m_editorView.text() + strlen(m_editorView.text()));
}
m_editorView.setCursorLocation(m_editorView.text() + strlen(m_editorView.text()));
} else {
m_editorView.setCursorLocation(m_editorView.text() + strlen(m_editorView.text()));
}
}
void EditorController::viewDidDisappear() {
m_script.setCursorOffset(m_editorView.cursorLocation() - m_script.content());
m_editorView.resetSelection();
m_menuController->scriptContentEditionDidFinish();
}

View File

@@ -65,21 +65,6 @@ bool Script::nameCompliant(const char * name) {
return false;
}
uint16_t Script::cursorOffset() {
assert(!isNull());
Ion::Storage::MetadataRowHeader * metadataForRecord = Ion::Storage::sharedStorage()->metadataForRecord(*this);
if (metadataForRecord != nullptr) {
assert(metadataForRecord->metadataSize == 2);
return *((uint16_t*) metadataForRecord->data());
}
return -1;
}
void Script::setCursorOffset(uint16_t position) {
assert(!isNull());
Ion::Storage::sharedStorage()->setMetadataForRecord(*this, sizeof(uint16_t), &position);
}
uint8_t * StatusFromData(Script::Data d) {
return const_cast<uint8_t *>(static_cast<const uint8_t *>(d.buffer));
}

View File

@@ -50,8 +50,6 @@ public:
void toggleAutoimportationStatus();
const char * content() const;
size_t contentSize() { return value().size - k_statusSize; }
void setCursorOffset(uint16_t position); // -1 if no metadata
uint16_t cursorOffset();
/* Fetched status */
bool fetchedFromConsole() const;