Skip to content

Commit

Permalink
Up to 1.8.2
Browse files Browse the repository at this point in the history
* Improve autocomplete
* Ctrl + Mouse wheel to change font size
* Duplicate table data
* Up SQLite to 3.44.0
* Minor changes (inc. issue #148)
  • Loading branch information
little-brother committed Nov 6, 2023
1 parent dd5259f commit da59247
Show file tree
Hide file tree
Showing 14 changed files with 4,847 additions and 2,636 deletions.
26 changes: 0 additions & 26 deletions extensions/ora.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
Returns a row number starting from a passed argument
select *, rownum(0) from mytable
concat(str1, str2, ...)
Concatenates strings. Equals to str1 || str2 || ...
select concat(1, 'a', 2.5) --> 1a2.5
decode(expr, key1, value1, ke2, value2, ..., defValue)
Compares expr to each key one by one. If expr is equal to a key, then returns the corresponding value.
If no match is found, then returns defValue. If defValue is omitted, then returns null.
Expand Down Expand Up @@ -80,27 +76,6 @@ static void rownum(sqlite3_context *ctx, int argc, sqlite3_value **argv){
sqlite3_result_int(ctx, *pCounter);
}

static void concat (sqlite3_context *ctx, int argc, sqlite3_value **argv) {
if (argc == 0)
return sqlite3_result_null(ctx);

for(int i = 0; i < argc; i++) {
if(sqlite3_value_type(argv[i]) == SQLITE_NULL)
return sqlite3_result_null(ctx);
}

size_t len = 0;
for(int i = 0; i < argc; i++)
len += strlen(sqlite3_value_text(argv[i]));

char* all = (char*)calloc(sizeof(char), len + 1);
for(int i = 0; i < argc; i++)
strcat(all, sqlite3_value_text(argv[i]));

sqlite3_result_text(ctx, all, -1, SQLITE_TRANSIENT);
free(all);
}

static void decode (sqlite3_context *ctx, int argc, sqlite3_value **argv) {
if (argc < 2)
return sqlite3_result_error(ctx, "Not enough values", -1);
Expand Down Expand Up @@ -729,7 +704,6 @@ int sqlite3_ora_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *p
(void)pzErrMsg; /* Unused parameter */
return SQLITE_OK == sqlite3_create_function(db, "rownum", 0, SQLITE_UTF8, 0, rownum, 0, 0) &&
SQLITE_OK == sqlite3_create_function(db, "rownum", 1, SQLITE_UTF8, 0, rownum, 0, 0) &&
SQLITE_OK == sqlite3_create_function(db, "concat", -1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, concat, 0, 0) &&
SQLITE_OK == sqlite3_create_function(db, "decode", -1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, decode, 0, 0) &&
SQLITE_OK == sqlite3_create_function(db, "crc32", 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, crc32, 0, 0) &&
SQLITE_OK == sqlite3_create_function(db, "md5", 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, md5, 0, 0) &&
Expand Down
6,485 changes: 4,144 additions & 2,341 deletions include/sqlite3.c

Large diffs are not rendered by default.

199 changes: 168 additions & 31 deletions include/sqlite3.h

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions include/sqlite3ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ struct sqlite3_api_routines {
int (*is_interrupted)(sqlite3*);
/* Version 3.43.0 and later */
int (*stmt_explain)(sqlite3_stmt*,int);
/* Version 3.44.0 and later */
void *(*get_clientdata)(sqlite3*,const char*);
int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
};

/*
Expand Down Expand Up @@ -693,6 +696,9 @@ typedef int (*sqlite3_loadext_entry)(
#define sqlite3_is_interrupted sqlite3_api->is_interrupted
/* Version 3.43.0 and later */
#define sqlite3_stmt_explain sqlite3_api->stmt_explain
/* Version 3.44.0 and later */
#define sqlite3_get_clientdata sqlite3_api->get_clientdata
#define sqlite3_set_clientdata sqlite3_api->set_clientdata
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */

#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
Expand Down
53 changes: 27 additions & 26 deletions resources/help.sql

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions sqlite-gui.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
<Option compiler="mingw64_x32" />
<Compiler>
<Add option="-std=c++11" />
<Add option="-g" />
<Add option="-U__STRICT_ANSI__" />
<Add option="-g" />
<Add directory="include" />
</Compiler>
<Linker>
<Add option="-static-libstdc++" />
<Add option="-static" />
<Add option="-m32" />
<Add library="lib/x32/libsqlite3.a" />
</Linker>
</Target>
Expand All @@ -33,10 +36,10 @@
<Add directory="include" />
</Compiler>
<Linker>
<Add option="-s" />
<Add option="-static-libstdc++" />
<Add option="-static" />
<Add option="-m32" />
<Add option="-s" />
<Add library="lib/x32/libsqlite3.a" />
</Linker>
</Target>
Expand Down
68 changes: 43 additions & 25 deletions src/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4744,38 +4744,49 @@ namespace dialogs {
EnumChildWindows(hWnd, (WNDENUMPROC)cbEnumChildrenReparent, (LPARAM)hTabWnd);
cbOldTabSettings = (WNDPROC)SetWindowLongPtr(hTabWnd, GWLP_WNDPROC, (LONG_PTR)cbNewTabSettings);

HWND hFontSize = GetDlgItem(hTabWnd, IDC_DLG_FONT_SIZE);
// There is a some issue for edit after the combobox reparenting
// So just recreate it. Use for font family and size
auto recreateDropDown = [hTabWnd](int idc) {
HWND hWnd = GetDlgItem(hTabWnd, idc);

RECT rc;
GetWindowRect(hWnd, &rc);
POINT pos{rc.left, rc.top}, dims {rc.right - rc.left, rc.bottom - rc.top};
ScreenToClient(hTabWnd, &pos);
DestroyWindow(hWnd);

hWnd = CreateWindow(WC_COMBOBOX, NULL, CBS_DROPDOWN | CBS_HASSTRINGS | WS_VISIBLE | WS_CHILD | WS_TABSTOP,
pos.x, pos.y, dims.x, 200, hTabWnd, (HMENU)(LONG_PTR)idc, GetModuleHandle(0), NULL);
SendMessage(hWnd, WM_SETFONT, (LPARAM)hDefFont, TRUE);

return hWnd;
};

HWND hFontSize = recreateDropDown(IDC_DLG_FONT_SIZE);
int fontSize = prefs::get("font-size");
int sizes[] = {8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24};
int idx = 0;
int idx = -1;
for (int i = 0; i < 11; i++) {
idx = fontSize == sizes[i] ? i : idx;
TCHAR buf[4];
_sntprintf(buf, 3, TEXT("%i"), sizes[i]);
ComboBox_AddString(hFontSize, buf);
}
ComboBox_SetCurSel(hFontSize, idx);
if (idx != -1) {
ComboBox_SetCurSel(hFontSize, idx);
} else {
TCHAR fs[10];
_sntprintf(fs, 9, TEXT("%i"), fontSize);
ComboBox_SetText(hFontSize, fs);
}

HWND hExitByEscape = GetDlgItem(hTabWnd, IDC_DLG_EXIT_BY_ESCAPE);
ComboBox_AddString(hExitByEscape, TEXT("Do nothing"));
ComboBox_AddString(hExitByEscape, TEXT("Close application"));
ComboBox_AddString(hExitByEscape, TEXT("Ask before closing the app"));
ComboBox_SetCurSel(hExitByEscape, prefs::get("exit-by-escape"));

HWND hFontFamily = GetDlgItem(hTabWnd, IDC_DLG_FONT_FAMILY);

// There is a some issue for edit after the combobox reparenting
// So just recreate it
RECT rc;
GetWindowRect(hFontFamily, &rc);
POINT pos{rc.left, rc.top}, dims {rc.right - rc.left, rc.bottom - rc.top};
ScreenToClient(hTabWnd, &pos);
DestroyWindow(hFontFamily);

hFontFamily = CreateWindow(WC_COMBOBOX, NULL, CBS_DROPDOWN | CBS_HASSTRINGS | WS_VISIBLE | WS_CHILD | WS_TABSTOP,
pos.x, pos.y, dims.x, 200, hTabWnd, (HMENU)IDC_DLG_FONT_FAMILY, GetModuleHandle(0), NULL);
SendMessage(hFontFamily, WM_SETFONT, (LPARAM)hDefFont, TRUE);

HWND hFontFamily = recreateDropDown(IDC_DLG_FONT_FAMILY);
HDC hDC = GetDC(hMainWnd);
LOGFONT lf = {0};
lf.lfFaceName[0] = TEXT('\0');
Expand All @@ -4796,8 +4807,11 @@ namespace dialogs {
Button_SetCheck(GetDlgItem(hTabWnd, IDC_DLG_HTTP_SERVER), prefs::get("http-server") ? BST_CHECKED : BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hTabWnd, IDC_DLG_CHECK_UPDATES), prefs::get("check-update") ? BST_CHECKED : BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hTabWnd, IDC_DLG_TAB_AUTOCOMPLETE), prefs::get("autocomplete-by-tab") ? BST_CHECKED : BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hTabWnd, IDC_DLG_DISABLE_HELP), prefs::get("disable-autocomplete-help") ? BST_CHECKED : BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hTabWnd, IDC_DLG_SYNC_OFF), prefs::get("synchronous-off") ? BST_CHECKED : BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hTabWnd, IDC_DLG_RETAIN_PASSPHRASE), prefs::get("retain-passphrase") ? BST_CHECKED : BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hTabWnd, IDC_DLG_FOREIGN_KEYS), prefs::get("use-foreign-keys") ? BST_CHECKED : BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hTabWnd, IDC_DLG_LEGACY_RENAME), prefs::get("use-legacy-rename") ? BST_CHECKED : BST_UNCHECKED);

TCHAR buf[256];
_sntprintf(buf, 255, TEXT("%i"), prefs::get("row-limit"));
Expand Down Expand Up @@ -4861,7 +4875,7 @@ namespace dialogs {
delete [] fontFamily8;

GetDlgItemText(hTabWnd, IDC_DLG_FONT_SIZE, buf, 255);
prefs::set("font-size", _tcstol(buf, NULL, 10));
prefs::set("font-size", MAX(8, _tcstol(buf, NULL, 10)));
prefs::set("autoload-extensions", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_AUTOLOAD)));
prefs::set("restore-db", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_RESTORE_DB)));
prefs::set("restore-editor", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_RESTORE_EDITOR)));
Expand All @@ -4870,10 +4884,13 @@ namespace dialogs {
prefs::set("http-server", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_HTTP_SERVER)));
prefs::set("check-update", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_CHECK_UPDATES)));
prefs::set("autocomplete-by-tab", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_TAB_AUTOCOMPLETE)));
prefs::set("disable-autocomplete-help", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_DISABLE_HELP)));
prefs::set("retain-passphrase", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_RETAIN_PASSPHRASE)));
prefs::set("exit-by-escape", ComboBox_GetCurSel(GetDlgItem(hTabWnd, IDC_DLG_EXIT_BY_ESCAPE)));
prefs::set("synchronous-off", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_SYNC_OFF)));
prefs::set("editor-indent", ComboBox_GetCurSel(GetDlgItem(hTabWnd, IDC_DLG_INDENT)));
prefs::set("use-foreign-keys", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_FOREIGN_KEYS)));
prefs::set("use-legacy-rename", Button_GetCheck(GetDlgItem(hTabWnd, IDC_DLG_LEGACY_RENAME)));

GetDlgItemText(hTabWnd, IDC_DLG_ROW_LIMIT, buf, 255);
prefs::set("row-limit", (int)_tcstod(buf, NULL));
Expand All @@ -4887,8 +4904,6 @@ namespace dialogs {
GetDlgItemText(hTabWnd, IDC_DLG_HTTP_SERVER_PORT, buf, 255);
prefs::set("http-server-port", (int)_tcstod(buf, NULL));

sqlite3_exec(db, prefs::get("use-legacy-rename") ? "pragma legacy_alter_table = 1" : "pragma legacy_alter_table = 0", 0, 0, 0);

TCHAR startup16[MAX_TEXT_LENGTH]{0};
GetDlgItemText(hTabWnd, IDC_DLG_STARTUP, startup16, MAX_TEXT_LENGTH - 1);
char* startup8 = utils::utf16to8(startup16);
Expand Down Expand Up @@ -4940,8 +4955,8 @@ namespace dialogs {
int idcs[3][30] = {
{
IDC_DLG_AUTOLOAD, IDC_DLG_RESTORE_DB, IDC_DLG_RESTORE_EDITOR, IDC_DLG_WORD_WRAP, IDC_DLG_TAB_AUTOCOMPLETE,
IDC_DLG_ASK_DELETE, IDC_DLG_SYNC_OFF, IDC_DLG_RETAIN_PASSPHRASE, IDC_DLG_HTTP_SERVER, IDC_DLG_HTTP_SERVER_PORT,
IDC_DLG_CHECK_UPDATES
IDC_DLG_DISABLE_HELP, IDC_DLG_ASK_DELETE, IDC_DLG_SYNC_OFF, IDC_DLG_RETAIN_PASSPHRASE, IDC_DLG_HTTP_SERVER,
IDC_DLG_HTTP_SERVER_PORT, IDC_DLG_CHECK_UPDATES
},
{
IDC_DLG_FONT_LABEL, IDC_DLG_FONT_FAMILY, IDC_DLG_FONT_SIZE, IDC_DLG_EDITOR_LABEL, IDC_DLG_COLOR, IDC_DLG_GRID_LABEL,
Expand All @@ -4951,7 +4966,10 @@ namespace dialogs {
IDC_DLG_ROW_LIMIT_LABEL, IDC_DLG_ROW_LIMIT, IDC_DLG_CLI_ROW_LIMIT_LABEL, IDC_DLG_CLI_ROW_LIMIT,
IDC_DLG_BEEP_LABEL, IDC_DLG_BEEP_ON_QUERY_END
},
{IDC_DLG_STARTUP_LABEL, IDC_DLG_STARTUP, IDC_DLG_GOOGLE_KEY_LABEL, IDC_DLG_GOOGLE_KEY}
{
IDC_DLG_STARTUP_LABEL, IDC_DLG_STARTUP, IDC_DLG_FOREIGN_KEYS, IDC_DLG_LEGACY_RENAME, IDC_DLG_GOOGLE_KEY_LABEL,
IDC_DLG_GOOGLE_KEY
}
};

HWND hTabWnd = GetDlgItem(hWnd, IDC_DLG_SETTING_TAB);
Expand Down Expand Up @@ -5679,8 +5697,8 @@ namespace dialogs {

case WM_PAINT: {
cbOldHeaderEdit(hWnd, msg, wParam, lParam);
if (GetDlgCtrlID(hWnd) == IDC_DLG_FILTER)
return TRUE;
if (GetDlgCtrlID(hWnd) == IDC_DLG_FILTER)
return TRUE;

RECT rc;
GetClientRect(hWnd, &rc);
Expand Down
1 change: 1 addition & 0 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define ACTION_RESIZETAB 4
#define ACTION_UPDATETAB 5
#define ACTION_REDRAW 6
#define ACTION_SET_THEME 7

#define ROW_VIEW 0
#define ROW_EDIT 1
Expand Down
Loading

0 comments on commit da59247

Please sign in to comment.