Add message dialog asking to save on quit
This commit is contained in:
@@ -408,6 +408,30 @@ void OnCommand(Event event) {
|
||||
String16 string16 = ToString16(scratch, event.text);
|
||||
Replace(active.view, string16);
|
||||
}
|
||||
|
||||
if (event.kind == EVENT_QUIT) {
|
||||
Scratch scratch;
|
||||
bool do_quit = true;
|
||||
For (Buffers) {
|
||||
if (it->garbage || it->dont_warn_on_save) {
|
||||
continue;
|
||||
}
|
||||
if (it->dirty) {
|
||||
String message = Format(scratch, "Do you really want to quit? Unsaved buffer: %S", it->name);
|
||||
int save = SaveMessageBox("There are unsaved changes, do you really want to quit!", message.data);
|
||||
if (save == 0) {
|
||||
break;
|
||||
}
|
||||
if (save == 2) {
|
||||
SaveBuffer(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (do_quit) {
|
||||
AppIsRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GarbageCollect() {
|
||||
@@ -556,10 +580,6 @@ void MainLoop() {
|
||||
if (it.kind != 1) {
|
||||
if (!Testing) Serialize(&ser, &it);
|
||||
}
|
||||
if (it.kind == EVENT_QUIT) {
|
||||
AppIsRunning = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (it.xwindow == 0 || it.ywindow == 0) {
|
||||
int xwindow, ywindow;
|
||||
|
||||
Reference in New Issue
Block a user