Skip to content

Commit ae9c26a

Browse files
committed
Added prompt to save query on exit, changes to .gitignore for new Kiro steering workflow
1 parent c5c3982 commit ae9c26a

6 files changed

Lines changed: 22 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,4 +419,5 @@ FodyWeavers.xsd
419419

420420
# Project-specific exclusions
421421
docs/AGENTS/
422+
.kiro/*
422423
._*

src/sqlite-ce-edit/editor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ LRESULT CALLBACK LineNumProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
121121
LRESULT CALLBACK QueryEditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
122122
/* Alt+X - Exit (must handle here when edit has focus) */
123123
if (msg == WM_SYSKEYDOWN && (wParam == 'X' || wParam == 'x')) {
124-
DestroyWindow(g_hwndMain);
124+
SendMessage(g_hwndMain, WM_CLOSE, 0, 0);
125125
return 0;
126126
}
127127
/* Clear hint on focus */

src/sqlite-ce-edit/fileops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void DoOpenQuery(void) {
8383
SetWindowTextW(g_hwndQuery, wbuf);
8484
UpdateWindow(g_hwndQuery);
8585
lstrcpyW(g_szQueryPath, szFile);
86+
g_queryDirty = 0;
8687
UpdateTitle();
8788
UpdateLineNumbers();
8889
}
@@ -133,6 +134,7 @@ void DoSaveQuery(void) {
133134
if (hFile != INVALID_HANDLE_VALUE) {
134135
WriteFile(hFile, buf, dwLen, &dwWritten, NULL);
135136
CloseHandle(hFile);
137+
g_queryDirty = 0;
136138
}
137139
}
138140
if (wbuf) LocalFree(wbuf);

src/sqlite-ce-edit/globals.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ wchar_t g_lastResultStatus[64] = L"";
4545
wchar_t g_findText[128] = L"";
4646
int g_searchMode = 0;
4747
wchar_t g_szQueryPath[MAX_PATH] = L"";
48+
int g_queryDirty = 0;

src/sqlite-ce-edit/globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ extern wchar_t g_lastResultStatus[64];
146146
extern wchar_t g_findText[128];
147147
extern int g_searchMode;
148148
extern wchar_t g_szQueryPath[MAX_PATH];
149+
extern int g_queryDirty;
149150

150151
/*============================================================================
151152
** Function Declarations - Output (output.c)

src/sqlite-ce-edit/main.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
211211
case IDM_EXPORTDB: DoExportDb(); break;
212212
case IDM_IMPORTCSV: DoImportCSV(); break;
213213
case IDM_IMPORTCEDB: DoImportCEDB(); break;
214-
case IDM_EXIT: DestroyWindow(hwnd); break;
214+
case IDM_EXIT: SendMessage(hwnd, WM_CLOSE, 0, 0); break;
215215
case IDM_EXECUTE: ExecuteQuery(); break;
216216
case IDM_FIND: DoFind(); break;
217217
case IDM_FINDNEXT: DoFindNext(); break;
@@ -239,10 +239,12 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
239239
case IDM_FONTSIZE:
240240
CycleFontSize();
241241
break;
242-
case IDOK: DestroyWindow(hwnd); break;
242+
case IDOK: SendMessage(hwnd, WM_CLOSE, 0, 0); break;
243243
case 1001:
244-
if (HIWORD(wParam) == EN_CHANGE && g_viewMode == 0)
244+
if (HIWORD(wParam) == EN_CHANGE && g_viewMode == 0) {
245245
UpdateLineCount();
246+
if (!g_showingHint) g_queryDirty = 1;
247+
}
246248
break;
247249
}
248250
return 0;
@@ -257,7 +259,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
257259

258260
case WM_SYSKEYDOWN:
259261
if (wParam == 'X' && GetKeyState(VK_MENU) < 0) {
260-
DestroyWindow(hwnd);
262+
SendMessage(hwnd, WM_CLOSE, 0, 0);
261263
return 0;
262264
}
263265
break;
@@ -275,6 +277,16 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
275277
}
276278
break;
277279

280+
case WM_CLOSE:
281+
if (g_queryDirty) {
282+
int r = MessageBoxW(hwnd, L"Save changes to query?", L"SQLite/CE",
283+
MB_YESNOCANCEL | MB_ICONQUESTION);
284+
if (r == IDCANCEL) return 0;
285+
if (r == IDYES) DoSaveQuery();
286+
}
287+
DestroyWindow(hwnd);
288+
return 0;
289+
278290
case WM_DESTROY:
279291
CloseDatabase();
280292
if (g_hFontQuery) DeleteObject(g_hFontQuery);

0 commit comments

Comments
 (0)