Skip to content

Commit dc3d95e

Browse files
author
Taylor Holberton
committed
Implemented document close
1 parent 934b8e7 commit dc3d95e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

editor/App.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ class AppImpl final : public App,
312312
{
313313
switch (event) {
314314
case MenuBar::Event::ClickedClose:
315+
closeDocument();
315316
break;
316317
case MenuBar::Event::ClickedDiscardChanges:
317318
discardChanges();
@@ -382,6 +383,17 @@ class AppImpl final : public App,
382383
pushAppState(BrowseDocumentsState::init(this));
383384
}
384385
}
386+
/// Closes the document by clearing out the application
387+
/// state and restarting program.
388+
void closeDocument()
389+
{
390+
// TODO : There's probably a cleaner way to do this.
391+
stateStack.clear();
392+
history = History();
393+
zoom = 1;
394+
documentID = -1;
395+
AppStorage::init(this);
396+
}
385397
/// Saves the document to the application storage.
386398
void saveDocumentToAppStorage()
387399
{

0 commit comments

Comments
 (0)