Revert "[storage] New attempt to save cursor position"

This reverts commit c826e556a1.
This commit is contained in:
Laury
2022-06-17 12:06:56 +02:00
parent 1319ad2f42
commit d983797ac8
9 changed files with 2 additions and 91 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::Metadata metadata = Ion::Storage::sharedStorage()->metadataForRecord(*this);
if (metadata.buffer != nullptr) {
assert(metadata.size == 2);
return *((uint16_t*) metadata.buffer);
}
return -1;
}
void Script::setCursorOffset(uint16_t position) {
assert(!isNull());
Ion::Storage::sharedStorage()->setMetadataForRecord(*this, { &position, sizeof(uint16_t) });
}
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;