diff --git a/conf/conf.d/snippets/cpp.snippets b/conf/conf.d/snippets/cpp.snippets index 248404c..f064bee 100644 --- a/conf/conf.d/snippets/cpp.snippets +++ b/conf/conf.d/snippets/cpp.snippets @@ -41,7 +41,7 @@ ${1:#pragma mark - $0 endsnippet -snippet main "main() (main)" +snippet main "main() (main)" b int main(int argc, char *argv[]) { $0 return 0; diff --git a/share/changelog b/share/changelog index ca2f285..fff65a1 100644 --- a/share/changelog +++ b/share/changelog @@ -1,3 +1,7 @@ +4.0.9 2023-12-07 adonais + * 变更: 文件管理器与标签栏平齐 + * 修复: Win11下, 暗色主题渲染问题 + 4.0.8 2023-12-01 adonais * 新增: 关于书签行的编辑菜单 * 新增: sumatrapdf解码文件到16进制的转换 diff --git a/src/eu_config.c b/src/eu_config.c index 0efe8a6..0e82d67 100644 --- a/src/eu_config.c +++ b/src/eu_config.c @@ -20,6 +20,12 @@ #define ascii_special_symbol(ch) \ ((ch > 0x20 && ch < 0x30)||(ch > 0x39 && ch < 0x41)||(ch > 0x5a && ch < 0x7f)) +typedef struct _skyver_data +{ + int ver; + int status; +} skyver_data; + static void on_config_setup_postion(const wchar_t **args, int arg_c, file_backup *pbak) { @@ -65,19 +71,16 @@ on_config_cvector_at(const file_backup *pbak, const TCHAR *pfile) return -1; } -static void +static bool on_config_open_args(file_backup **pbak) { - int arg_c = 0; + int arg_c = 0; + bool ret = false; LPWSTR *args = CommandLineToArgvW(GetCommandLineW(), &arg_c); - if (args == NULL || pbak == NULL) - { - return; - } - if (arg_c >= 2) + if (pbak && args && arg_c >= 2) { cvector_vector_type(file_backup) vpath = NULL; - if (eu_config_parser_path(args, arg_c, &vpath)) + if ((ret = eu_config_parser_path(args, arg_c, &vpath))) { for (size_t i = 0; i < cvector_size(vpath); ++i) { @@ -94,7 +97,11 @@ on_config_open_args(file_backup **pbak) } cvector_free(vpath); } - LocalFree(args); + if (args) + { + LocalFree(args); + } + return ret; } static int @@ -194,7 +201,10 @@ on_config_load_file(void *lp) { err = on_sql_do_session("SELECT * FROM skylar_ver;", NULL, NULL); } - on_config_open_args(&vbak); + if (on_config_open_args(&vbak)) + { + eu_logmsg("run with arguments\n"); + } if ((vec_size = cvector_size(vbak)) < 1) { file_backup bak = {0}; @@ -339,18 +349,89 @@ on_config_lua_execute(const wchar_t *file) return path; } +static int +on_config_edition(const char *str) +{ + int v = 0; + if (str) + { + int i = 0; + const char *p = str; + for (i = 100, v = atoi(p) * 10000; i && (p = strchr(p, '.')) != NULL; i /= 100) + { + v += (atoi(++p) * i); + } + } + return v; +} + static int on_config_skyver_callbak(void *data, int count, char **column, char **names) { - UNREFERENCED_PARAMETER(data); - UNREFERENCED_PARAMETER(count); - UNREFERENCED_PARAMETER(names); - int status = atoi(column[0]); - if (data) + skyver_data *pd = (skyver_data *)data; + for (int i = 0; i < count; ++i) + { + if (STRCMP(names[i], ==, "szVersion")) + { + pd->ver = on_config_edition(column[i]); + } + else if (STRCMP(names[i], ==, "szExtra")) + { + pd->status = atoi(column[i]); + } + } + return 0; +} + +static bool +on_config_create_cache(void) +{ + bool ret = false; + TCHAR cache_path[MAX_BUFFER] = {0}; + if (_sntprintf(cache_path, MAX_BUFFER, _T("%s\\cache"), eu_config_path) > 0) + { + if (!eu_exist_dir(cache_path)) + { + ret = eu_mk_dir(cache_path); + } + else + { + ret = true; + } + } + return ret; +} + +static bool +on_config_update_db(void) +{ + if (eu_hwnd_self() == share_envent_get_hwnd()) { - *(int *)data = status; + skyver_data v = {0}; + int err = on_sql_post("SELECT szVersion, szExtra FROM skylar_ver;", on_config_skyver_callbak, &v); + if (err != SKYLARK_SQL_END) + { + if (v.ver < 40009) + { + on_sql_post("UPDATE skylar_ver SET szVersion='4.0.9' WHERE szName='skylark.exe';", NULL, NULL); + on_sql_post("ALTER TABLE skylark_session ADD szView SMALLINT DEFAULT 0;", NULL, NULL); + } + if (v.status == VERSION_UPDATE_COMPLETED) + { + if (on_update_do()) + { + on_update_sql(); + eu_session_backup(SESSION_CONFIG); + return false; + } + else if (eu_get_config()->upgrade.flags != VERSION_LATEST) + { + on_update_sql(); + } + } + } } - return (int)(status == VERSION_UPDATE_COMPLETED); + return true; } void @@ -433,7 +514,7 @@ eu_config_parser_path(const wchar_t **args, int arg_c, file_backup **pbak) { for (int i = 1; i < arg_c; ++i) { - file_backup data = {-1, -1}; + file_backup data = {-1, -1, 0 , -1}; if (wcsncmp(ptr_arg[i], L"-restart", 8) == 0) { i += 2; @@ -490,10 +571,7 @@ eu_config_parser_path(const wchar_t **args, int arg_c, file_backup **pbak) { on_config_setup_postion(ptr_arg, arg_c, &data); cvector_push_back(*pbak, data); - } - if (!ret) - { - ret = true; + ret |= 0x1; } } } @@ -550,25 +628,6 @@ eu_config_load_docs(void) return ret; } -static bool -on_config_create_cache(void) -{ - bool ret = false; - TCHAR cache_path[MAX_BUFFER] = {0}; - if (_sntprintf(cache_path, MAX_BUFFER, _T("%s\\cache"), eu_config_path) > 0) - { - if (!eu_exist_dir(cache_path)) - { - ret = eu_mk_dir(cache_path); - } - else - { - ret = true; - } - } - return ret; -} - /************************************************************************************** * 调用euapi导出函数之前, 应该先初始化euapi路径变量, 可以写入dllmain * eu_module_path是主进程路径, eu_config_path是配置文件夹路径 @@ -645,25 +704,12 @@ eu_config_init_path(void) bool eu_config_load_files(void) { - if (eu_hwnd_self() == share_envent_get_hwnd()) + if (on_config_update_db()) { - int err = on_sql_post("SELECT szExtra FROM skylar_ver;", on_config_skyver_callbak, NULL); - if (err == SQLITE_ABORT) - { - if (on_update_do()) - { - on_update_sql(); - eu_session_backup(SESSION_CONFIG); - return false; - } - else if (eu_get_config()->upgrade.flags != VERSION_LATEST) - { - on_update_sql(); - } - } + CloseHandle((HANDLE) _beginthreadex(NULL, 0, on_favorite_up_config, NULL, 0, NULL)); + CloseHandle((HANDLE) _beginthreadex(NULL, 0, on_remote_load_config, NULL, 0, NULL)); + CloseHandle((HANDLE) _beginthreadex(NULL, 0, on_config_load_file, NULL, 0, NULL)); + return on_config_create_accel(); } - CloseHandle((HANDLE) _beginthreadex(NULL, 0, on_favorite_up_config, NULL, 0, NULL)); - CloseHandle((HANDLE) _beginthreadex(NULL, 0, on_remote_load_config, NULL, 0, NULL)); - CloseHandle((HANDLE) _beginthreadex(NULL, 0, on_config_load_file, NULL, 0, NULL)); - return on_config_create_accel(); + return false; } diff --git a/src/eu_hex.c b/src/eu_hex.c index f8ee037..1eddf42 100644 --- a/src/eu_hex.c +++ b/src/eu_hex.c @@ -1482,7 +1482,7 @@ hexview_proc(HWND hwnd, uint32_t message, WPARAM wParam, LPARAM lParam) } if (GetFocus() != hwnd) { // 可能被plugin窗口强占了键盘焦点 - eu_window_resize(NULL); + eu_window_resize(); } break; } diff --git a/src/eu_locale.c b/src/eu_locale.c index 420fa1b..d5efe05 100644 --- a/src/eu_locale.c +++ b/src/eu_locale.c @@ -379,7 +379,7 @@ eu_refresh_interface(HMODULE new_lang, const TCHAR *lang_path) } else { - on_statusbar_size(NULL); + on_statusbar_size(NULL, NULL); if (on_dark_enable()) { SendMessage(g_statusbar, WM_THEMECHANGED, 0, 0); @@ -459,7 +459,7 @@ i18n_switch_locale(HWND hwnd, int id) on_tabpage_newdoc_reload(); i18n_update_multi_lang(menu_env); i18n_update_menu(menu_env); - SendMessage(hwnd, WM_SIZE, 0, 0); + on_proc_redraw(NULL); } return 0; } diff --git a/src/eu_main.c b/src/eu_main.c index e8072ea..4d40438 100644 --- a/src/eu_main.c +++ b/src/eu_main.c @@ -275,7 +275,7 @@ _tmain(int argc, TCHAR *argv[]) eu_logmsg("eu_sci_register failed\n"); SKY_SAFE_EXIT(SKYLARK_SCI_FAILED); } - if (!eu_win11_or_later() && strcmp(eu_get_config()->window_theme, "black") == 0) + if (eu_win10_or_later() && strcmp(eu_get_config()->window_theme, "black") == 0) { if (eu_dark_theme_init(true, true)) { @@ -316,10 +316,6 @@ _tmain(int argc, TCHAR *argv[]) { SendMessage(eu_module_hwnd(), WM_THEMECHANGED, DARK_THEME_APPLY, 0); } - else if (eu_win11_or_later() && strcmp(eu_get_config()->window_theme, "black") == 0 && eu_dark_theme_init(true, true)) - { - SendMessage(eu_module_hwnd(), WM_THEMECHANGED, DARK_THEME_APPLY, 0); - } while (GetMessage(&msg, NULL, 0, 0) > 0) { if ((!eu_get_search_hwnd() || !IsDialogMessage(eu_get_search_hwnd(), &msg)) && diff --git a/src/eu_proc.c b/src/eu_proc.c index f133a10..7295a5c 100644 --- a/src/eu_proc.c +++ b/src/eu_proc.c @@ -225,13 +225,19 @@ on_proc_move_sidebar(eu_tabpage *pnode) * 主窗口缩放处理函数 ******************************************************************************/ static void -on_proc_msg_size(HWND hwnd, eu_tabpage *pnode) +on_proc_msg_size(const RECT *prc, eu_tabpage *pnode) { const bool redraw = pnode == NULL; if (pnode || (pnode = on_tabpage_focus_at())) { + RECT rc = {0}; RECT rc_tabbar = {0}; - on_tabpage_adjust_window(pnode, &rc_tabbar); + if (!prc) + { + GetClientRect(eu_hwnd_self(), &rc); + prc = &rc; + } + on_tabpage_adjust_window(prc, pnode, &rc_tabbar); if (pnode->hwnd_sc) { HDWP hdwp = NULL; @@ -308,16 +314,16 @@ on_proc_msg_size(HWND hwnd, eu_tabpage *pnode) UpdateWindow(g_splitter_tablebar); } } - on_statusbar_size(pnode); + on_statusbar_size(prc, pnode); // 从插件页面切换时获取鼠标焦点 on_proc_msg_active(pnode); } } static void -on_proc_tab_click(HWND hwnd, eu_tabpage *pnode) +on_proc_tab_click(eu_tabpage *pnode) { - on_proc_msg_size(hwnd, pnode); + on_proc_msg_size(NULL, pnode); if (pnode && pnode->nc_pos >= 0 && eu_get_config() && eu_get_config()->scroll_to_cursor) { if (TAB_HEX_MODE(pnode)) @@ -570,11 +576,8 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { if (wParam != SIZE_MINIMIZED) { - on_treebar_size(); - on_toolbar_size(); - on_tabpage_size(); - on_proc_msg_size(hwnd, NULL); - on_statusbar_size(NULL); + RECT rc = {0, 0, LOWORD(lParam), HIWORD(lParam)}; + on_proc_redraw(&rc); } break; } @@ -591,7 +594,7 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) GetClientRect(g_tabpages, &rect); if (PtInRect(&rect, pt) && (int)SendMessage(g_tabpages, WM_NCHITTEST, 0, lParam) == HTTRANSPARENT) { - PostMessage(g_tabpages, WM_TAB_NCCLICK, wParam, 0); + SendMessage(g_tabpages, WM_TAB_NCCLICK, wParam, 0); } } } @@ -599,7 +602,7 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } case WM_TAB_CLICK: { - on_proc_tab_click(hwnd, (void *)wParam); + on_proc_tab_click((void *)wParam); return 1; } case WM_UPCHECK_STATUS: @@ -752,28 +755,31 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { on_dark_allow_window(hwnd, true); on_dark_refresh_titlebar(hwnd); - if (eu_win11_or_later()) - { - on_toolbar_refresh(hwnd); - } - else + if (!eu_win11_or_later()) { // win10 dark模式启动时刷新标题栏 util_updateui_titlebar(hwnd); } - SendMessage(g_statusbar, WM_THEMECHANGED, 0, 0); + if (g_tabpages) + { + SendMessage(g_tabpages, WM_THEMECHANGED, 0, 0); + } + if (g_statusbar) + { + SendMessage(g_statusbar, WM_THEMECHANGED, 0, 0); + } } else { + HWND htool = NULL; HWND snippet = NULL; - HWND htool = on_toolbar_hwnd(); on_dark_allow_window(hwnd, on_dark_enable()); on_dark_refresh_titlebar(hwnd); if (g_tabpages) { - on_dark_tips_theme(g_tabpages, TCM_GETTOOLTIPS); on_tabpage_foreach(on_tabpage_theme_changed); + SendMessage(g_tabpages, WM_THEMECHANGED, 0, 0); } - if (htool) + if ((htool = on_toolbar_hwnd())) { on_dark_tips_theme(htool, TB_GETTOOLTIPS); SendMessage(htool, WM_THEMECHANGED, (WPARAM)hwnd, 0); @@ -812,7 +818,7 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { eu_logmsg("swiching light mode\n"); eu_dark_theme_release(false); - on_proc_msg_size(hwnd, NULL); + on_proc_msg_size(NULL, NULL); } } break; @@ -1590,7 +1596,7 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_VIEW_TABBAR_SPLIT: eu_get_config()->m_tab_split ^= true; - eu_window_resize(hwnd); + eu_window_resize(); break; case IDM_VIEW_SWITCH_TAB: on_tabpage_switch_next(hwnd); @@ -1737,9 +1743,9 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) on_toolbar_icon_set(wm_id); if (on_toolbar_refresh(hwnd)) { - on_toolbar_size(); - on_treebar_size(); - on_proc_msg_size(hwnd, NULL); + on_toolbar_size(NULL); + on_treebar_size(NULL); + on_proc_msg_size(NULL, NULL); } } break; @@ -1758,9 +1764,9 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } if (on_toolbar_refresh(hwnd)) { - on_toolbar_size(); - on_treebar_size(); - on_proc_msg_size(hwnd, NULL); + on_toolbar_size(NULL); + on_treebar_size(NULL); + on_proc_msg_size(NULL, NULL); } break; } @@ -1769,9 +1775,9 @@ on_proc_main_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (eu_get_config() && !(eu_get_config()->m_fullscreen)) { eu_get_config()->m_statusbar ^= true; - on_treebar_size(); - on_proc_msg_size(hwnd, NULL); - on_statusbar_size(NULL); + on_statusbar_size(NULL, NULL); + on_treebar_size(NULL); + on_proc_msg_size(NULL, NULL); } break; } @@ -2181,6 +2187,22 @@ on_proc_msg_active(eu_tabpage *pnode) } } +void +on_proc_redraw(const RECT *prc) +{ + RECT rc = {0}; + if (!prc) + { + GetClientRect(g_hwndmain, &rc); + prc = &rc; + } + on_statusbar_size(prc, NULL); + on_treebar_size(prc); + on_toolbar_size(prc); + on_tabpage_size(prc); + on_proc_msg_size(prc, NULL); +} + void on_proc_sync_wait(void) { // 销毁定时器 @@ -2287,9 +2309,9 @@ eu_create_fullscreen(HWND hwnd) } void -eu_window_resize(HWND hwnd) +eu_window_resize(void) { - on_proc_msg_size(hwnd ? hwnd : eu_module_hwnd(), NULL); + on_proc_msg_size(NULL, NULL); } int diff --git a/src/eu_proc.h b/src/eu_proc.h index e0b7201..f53c308 100644 --- a/src/eu_proc.h +++ b/src/eu_proc.h @@ -29,10 +29,11 @@ extern "C" { #endif +void on_proc_redraw(const RECT *prc); void on_proc_counter_stop(void); void on_proc_sync_wait(void); void on_proc_msg_active(eu_tabpage *pnode); -void eu_window_resize(HWND hwnd); +void eu_window_resize(void); void eu_window_layout_dpi(HWND hwnd, const RECT *pnew_rect, const uint32_t adpi); HWND eu_hwnd_self(void); int eu_dpi_scale_font(void); diff --git a/src/eu_resultctl.c b/src/eu_resultctl.c index 61a8fe2..1ae769b 100644 --- a/src/eu_resultctl.c +++ b/src/eu_resultctl.c @@ -245,7 +245,7 @@ on_result_edit_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) p->presult->hwnd_sc = NULL; p->result_show = false; eu_safe_free(p->presult); - eu_window_resize(NULL); + eu_window_resize(); } break; } diff --git a/src/eu_script.c b/src/eu_script.c index d89ca9d..8f2af01 100644 --- a/src/eu_script.c +++ b/src/eu_script.c @@ -946,7 +946,7 @@ do_byte_code(eu_tabpage *pnode) } allclean: pnode->presult->pwant = on_toolbar_no_highlight; - eu_window_resize(NULL); + eu_window_resize(); if (!status) { char u8_path[MAX_BUFFER] = {0}; diff --git a/src/eu_search.c b/src/eu_search.c index 6bedbd6..b51d7af 100644 --- a/src/eu_search.c +++ b/src/eu_search.c @@ -2514,7 +2514,7 @@ on_search_launch_result_dlg(eu_tabpage *pnode, LPCTSTR path, LPCTSTR key, int or pnode->result_show = true; // 关键字不高亮的回调函数 pnode->presult->pwant = NULL; - eu_window_resize(NULL); + eu_window_resize(); eu_sci_call(pnode->presult, SCI_SETREADONLY, 0, 0); eu_sci_call(pnode->presult, SCI_CLEARALL, 0, 0); sprintf(ptr_style, "%p", &pnode->ret_vec); diff --git a/src/eu_splitter.c b/src/eu_splitter.c index edd24a3..2ad2a02 100644 --- a/src/eu_splitter.c +++ b/src/eu_splitter.c @@ -44,7 +44,8 @@ on_splitter_rect_box(HWND hwnd, LPRECT r, const int offset) RECT rc_main = {0}; RECT rc_client = {0}; POINT client_top = {0}; - on_treebar_adjust_box(&rc_tree, &rc_client); + GetClientRect(hwnd, &rc_client); + on_treebar_adjust_box(&rc_client, &rc_tree); GetWindowRect(hwnd, &rc_main); ClientToScreen(hwnd, &client_top); int toolbar_height = on_toolbar_get_height(); @@ -107,7 +108,7 @@ on_splitter_callback_treebar(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { RECT rect_tree; HWND parent = GetParent(hwnd); - on_treebar_adjust_box(&rect_tree, NULL); + on_treebar_adjust_box(NULL, &rect_tree); x = rect_tree.right - rect_tree.left + on_splitter_tree_line(); HDC hdc = on_splitter_drawing_line(parent, &rect_tree, x, NULL); ReleaseDC(parent, hdc); @@ -126,8 +127,8 @@ on_splitter_callback_treebar(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { eu_get_config()->file_tree_width = FILETREEBAR_WIDTH_MIN; } - on_treebar_size(); - eu_window_resize(parent); + on_treebar_size(NULL); + eu_window_resize(); break; } case WM_MOUSEMOVE: @@ -241,7 +242,7 @@ on_splitter_callback_symbar(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) eu_get_config()->document_map_width = DOCUMENTMAP_WIDTH_MIN; } } - eu_window_resize(NULL); + eu_window_resize(); break; } case WM_MOUSEMOVE: @@ -341,7 +342,7 @@ on_splitter_callback_editbar(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { eu_get_config()->result_edit_height = SQLQUERYRESULT_LISTVIEW_HEIGHT_MIN; } - eu_window_resize(NULL); + eu_window_resize(); break; } case WM_MOUSEMOVE: @@ -421,7 +422,7 @@ on_splitter_callback_tablebar(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { eu_get_config()->result_list_height = m_height; } - eu_window_resize(NULL); + eu_window_resize(); break; } case WM_MOUSEMOVE: diff --git a/src/eu_sql.c b/src/eu_sql.c index 95a9a7d..56bb2cd 100644 --- a/src/eu_sql.c +++ b/src/eu_sql.c @@ -26,9 +26,9 @@ #define RECENT_INSERT(n1,n2) "insert or replace into "#n1 "(szName,szPos,szDate,szHex) select szName,szPos,szDate,szHex from "#n2";" #define SESSION_TABLE "create table skylark_session(szId INTEGER PRIMARY KEY,szTabId INTEGER,szRealPath char," \ "szBakPath char,szMark char,szFold char,szLine BIGINT,szCp INTEGER,szBakCp INTEGER,szEol SMALLINT," \ - "szBlank SMALLINT,szHex SMALLINT,szFocus SMALLINT,szZoom SMALLINT,szStatus SMALLINT,szSync SMALLINT,UNIQUE(szRealPath));" -#define SESSION_VAULE "(szTabId,szRealPath,szBakPath,szMark,szFold,szLine,szCp,szBakCp,szEol,szBlank,szHex,szFocus,szZoom,szStatus,szSync) " -#define SESSION_SELECT "select szTabId,szRealPath,szBakPath,szMark,szFold,szLine,szCp,szBakCp,szEol,szBlank,szHex,szFocus,szZoom,szStatus,szSync from " + "szBlank SMALLINT,szHex SMALLINT,szFocus SMALLINT,szZoom SMALLINT,szStatus SMALLINT,szSync SMALLINT,szView SMALLINT DEFAULT 0, UNIQUE(szRealPath));" +#define SESSION_VAULE "(szTabId,szRealPath,szBakPath,szMark,szFold,szLine,szCp,szBakCp,szEol,szBlank,szHex,szFocus,szZoom,szStatus,szSync, szView) " +#define SESSION_SELECT "select szTabId,szRealPath,szBakPath,szMark,szFold,szLine,szCp,szBakCp,szEol,szBlank,szHex,szFocus,szZoom,szStatus,szSync,szView from " #define SESSION_INSERT(n1,n2) "insert or replace into "#n1 SESSION_VAULE SESSION_SELECT#n2";" #define RECENT_FORMAT "create trigger delete_till_30 BEFORE INSERT ON file_recent WHEN (select count(*) from file_recent)>%d "\ "BEGIN "\ @@ -813,17 +813,20 @@ eu_update_backup_table(file_backup *pbak, DB_MODE mode) char *sql = (char *)calloc(1, MAX_BUFFER*5 + 1); if (sql) { - const char *fmt = "insert into skylark_session(szTabId,szRealPath,szBakPath,szMark,szFold,szLine,szCp,szBakCp,szEol,szBlank,szHex,szFocus,szZoom,szStatus,szSync) " - "values(%d, '%s', '%s', '%s', '%s', %zd, %d, %d, %d, %d, %d, %d, %d, %d, %d) on conflict (szRealPath) do update set " - "szTabId=%d,szBakPath='%s',szMark='%s',szFold='%s',szLine=%zd,szCp=%d,szBakCp=%d,szEol=%d,szBlank=%d,szHex=%d,szFocus=%d,szZoom=%d,szStatus=%d,szSync=%d;"; + const char *fmt = "insert into skylark_session(szTabId,szRealPath,szBakPath,szMark,szFold,szLine,szCp," + "szBakCp,szEol,szBlank,szHex,szFocus,szZoom,szStatus,szSync, szView) " + "values(%d, '%s', '%s', '%s', '%s', %zd, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d) on conflict (szRealPath) do update set " + "szTabId=%d,szBakPath='%s',szMark='%s',szFold='%s',szLine=%zd,szCp=%d,szBakCp=%d,szEol=%d,szBlank=%d,szHex=%d,szFocus=%d," + "szZoom=%d,szStatus=%d,szSync=%d,szView=%d;"; WideCharToMultiByte(CP_UTF8, 0, pbak->rel_path, -1, rel_path, MAX_BUFFER - 1, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, pbak->bak_path, -1, bak_path, MAX_BUFFER - 1, NULL, NULL); // 文件路径存在特殊符号时进行转义 eu_str_replace(rel_path, MAX_BUFFER - 1, "'", "''"); eu_str_replace(bak_path, MAX_BUFFER - 1, "'", "''"); _snprintf(sql, MAX_BUFFER*5, fmt, pbak->tab_id, rel_path, bak_path, pbak->mark_id, pbak->fold_id, pbak->postion, pbak->cp, pbak->bakcp, - pbak->eol, pbak->blank, pbak->hex, pbak->focus, pbak->zoom, pbak->status, pbak->sync, pbak->tab_id,bak_path,pbak->mark_id,pbak->fold_id,pbak->postion, - pbak->cp, pbak->bakcp,pbak->eol, pbak->blank, pbak->hex, pbak->focus, pbak->zoom, pbak->status, pbak->sync); + pbak->eol, pbak->blank, pbak->hex, pbak->focus, pbak->zoom, pbak->status, pbak->sync, pbak->view, + pbak->tab_id,bak_path,pbak->mark_id,pbak->fold_id,pbak->postion,pbak->cp, pbak->bakcp,pbak->eol, + pbak->blank, pbak->hex, pbak->focus, pbak->zoom, pbak->status, pbak->sync, pbak->view); switch (mode) { case DB_ALL: diff --git a/src/eu_statusbar.c b/src/eu_statusbar.c index fa115e4..430b779 100644 --- a/src/eu_statusbar.c +++ b/src/eu_statusbar.c @@ -172,7 +172,10 @@ on_statusbar_btn_rw(eu_tabpage *pnode, bool m_auto) } ret = 1; } - on_toolbar_update_button(); + if (eu_get_config()->m_toolbar != IDB_SIZE_0) + { + on_toolbar_update_button(); + } return ret; } @@ -186,17 +189,6 @@ on_statusbar_set_text(HWND hwnd, const uint8_t part, LPCTSTR lpsz) } } -int -on_statusbar_height(void) -{ - int status_height = 0; - if (g_statusbar && eu_get_config()->m_statusbar) - { - status_height = eu_dpi_scale_xy(0, STATUSBAR_DEFHIGHT); - } - return status_height; -} - static void on_statusbar_adjust_btn(int left, int right) { @@ -221,11 +213,38 @@ on_statusbar_adjust_btn(int left, int right) } } +int +on_statusbar_height(void) +{ + int status_height = 0; + if (g_statusbar && eu_get_config()->m_statusbar) + { + RECT rc_status = {0}; + if (GetWindowRect(g_statusbar, &rc_status) && (rc_status.top || rc_status.bottom)) + { + status_height = rc_status.bottom - rc_status.top; + } + else + { + status_height = eu_dpi_scale_xy(0, STATUSBAR_DEFHIGHT); + } + } + return status_height; +} + void -on_statusbar_size(eu_tabpage *pnode) +on_statusbar_size(const RECT *prc, eu_tabpage *pnode) { - if (g_statusbar) + HWND hwnd = eu_hwnd_self(); + if (hwnd && g_statusbar) { + int height = 0; + RECT rc = {0}; + if (!prc) + { + GetClientRect(hwnd, &rc); + prc = &rc; + } if (!eu_get_config()->m_statusbar) { on_statusbar_adjust_btn(0, 0); @@ -233,21 +252,20 @@ on_statusbar_size(eu_tabpage *pnode) } else if (pnode) { + height = on_statusbar_height(); on_statusbar_btn_rw(pnode, true); + eu_setpos_window(g_statusbar, HWND_TOP, 0, prc->bottom - height, prc->right - prc->left, height, SWP_FRAMECHANGED); } else { - RECT rc = {0}; - GetClientRect(eu_hwnd_self(), &rc); - const int height = on_statusbar_height(); - int cx = rc.right - rc.left; + int cx = prc->right - prc->left; int n_half = cx / 8; int btn_half = n_half*7+70; int parts[] = {n_half*2, n_half*3, n_half*4, n_half*5+20, n_half*6+20, btn_half, -1}; SendMessage(g_statusbar, SB_SETPARTS, STATUSBAR_PART, (LPARAM)&parts); on_statusbar_adjust_btn(btn_half, cx); - MoveWindow(g_statusbar, 0, rc.bottom - height, cx, height, TRUE); - ShowWindow(g_statusbar, SW_SHOW); + height = on_statusbar_height(); + eu_setpos_window(g_statusbar, HWND_TOP, 0, prc->bottom - height, cx, height, SWP_SHOWWINDOW); } } } @@ -402,7 +420,7 @@ on_statusbar_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, UINT_PT { if (on_dark_enable()) { - on_statusbar_size(NULL); + on_statusbar_size(NULL, NULL); on_dark_set_theme(g_statusbar, L"Explorer", NULL); } else @@ -951,15 +969,12 @@ on_statusbar_update(eu_tabpage *psrc) { if ((pnode || (pnode = on_tabpage_focus_at())) && pnode->hwnd_sc) { - SendMessage(g_statusbar, WM_SETREDRAW, FALSE, 0); on_statusbar_update_fileinfo(pnode, NULL); on_statusbar_update_line(pnode); on_statusbar_update_filesize(pnode); on_statusbar_update_eol(pnode, -1); on_statusbar_update_filetype_menu(pnode); on_statusbar_update_coding(pnode); - SendMessage(g_statusbar, WM_SETREDRAW, TRUE, 0); - RedrawWindow(g_statusbar, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); } } } @@ -992,13 +1007,8 @@ on_statusbar_create_dlg(HWND hwnd) { DestroyWindow(g_statusbar); } - g_statusbar = CreateWindowEx(WS_EX_COMPOSITED, STATUSCLASSNAME, NULL, style, 0, 0, 0, 0, hwnd, (HMENU)IDC_STATUSBAR, eu_module_handle(), 0); - do + while ((g_statusbar = CreateWindowEx(WS_EX_COMPOSITED, STATUSCLASSNAME, NULL, style, 0, 0, 0, 0, hwnd, (HMENU)IDC_STATUSBAR, eu_module_handle(), 0))) { - if (!g_statusbar) - { - break; - } if (!(SetWindowSubclass(g_statusbar, on_statusbar_proc, STATUSBAR_SUBID, 0))) { break; @@ -1022,6 +1032,7 @@ on_statusbar_create_dlg(HWND hwnd) break; } ret = 0; - } while(0); + break; + } return ret; } diff --git a/src/eu_statusbar.h b/src/eu_statusbar.h index f3ee3ed..61bab5a 100644 --- a/src/eu_statusbar.h +++ b/src/eu_statusbar.h @@ -41,10 +41,11 @@ extern "C" { extern HWND g_statusbar; +int on_statusbar_window_diff(void); int on_statusbar_create_dlg(HWND hwnd); int on_statusbar_height(void); int on_statusbar_btn_rw(eu_tabpage *pnode, bool m_auto); -void on_statusbar_size(eu_tabpage *pnode); +void on_statusbar_size(const RECT *prc, eu_tabpage *pnode); void on_statusbar_update(eu_tabpage *pnode); void on_statusbar_destroy(void); void on_statusbar_adjust_box(void); diff --git a/src/eu_tablectl.c b/src/eu_tablectl.c index 33d48c4..2616cf8 100644 --- a/src/eu_tablectl.c +++ b/src/eu_tablectl.c @@ -21,6 +21,7 @@ #define SQL_EXECUTE_FAIL(_n) (nret) = (_n); goto table_clean static volatile long last_hot_item = -1; +static volatile long last_hot_columu = -1; typedef struct _column_t { @@ -32,54 +33,20 @@ typedef struct _column_t db_libs db_funcs = {0}; redis_lib redis_funcs = {0}; -static void -on_table_draw_header(HWND hwnd) -{ - HWND hdr = ListView_GetHeader(hwnd); - if (hdr && on_dark_enable()) - { - const int bdh = GetSystemMetrics(SM_CYFRAME); - const HDC hdc_src = GetWindowDC(hdr); - RECT rcf = {0}; - int count = (int)SendMessage(hdr, HDM_GETITEMCOUNT, 0, 0); - for (int k = 0; k < count; ++k) - { - if (SendMessage(hdr, HDM_GETITEMRECT, k, (LPARAM)&rcf)) - { - for (int i = 1; i < bdh; ++i) - { - FrameRect(hdc_src, &rcf, (HBRUSH)on_dark_theme_brush()); - rcf.left -= 1; - rcf.top -= 1; - rcf.bottom += 1; - rcf.right += 1; - } - FrameRect(hdc_src, &rcf, GetSysColorBrush(COLOR_3DDKSHADOW)); - } - } - ReleaseDC(hdr, hdc_src); - } -} - void on_table_update_theme(eu_tabpage *pnode) { - EU_VERIFY(pnode != NULL); - if (pnode->hwnd_qrtable) + if (pnode && pnode->hwnd_qrtable) { + HWND hdr = NULL; SendMessage(pnode->hwnd_qrtable, WM_SETFONT, (WPARAM) on_theme_font_hwnd(), 0); SendMessage(pnode->hwnd_qrtable, LVM_SETTEXTCOLOR, 0, eu_get_theme()->item.text.color); SendMessage(pnode->hwnd_qrtable, LVM_SETOUTLINECOLOR, 0, eu_get_theme()->item.text.color); SendMessage(pnode->hwnd_qrtable, LVM_SETBKCOLOR, 0, eu_get_theme()->item.text.bgcolor); SendMessage(pnode->hwnd_qrtable, LVM_SETTEXTBKCOLOR, 0, eu_get_theme()->item.text.bgcolor); - on_dark_set_theme(pnode->hwnd_qrtable, L"Explorer", NULL); - HWND hdr = ListView_GetHeader(pnode->hwnd_qrtable); - if (hdr) + if ((hdr = ListView_GetHeader(pnode->hwnd_qrtable))) { - const intptr_t style = GetWindowLongPtr(hdr, GWL_STYLE); - SetWindowLongPtr(hdr, GWL_STYLE, style & ~HDS_FLAT); - // 移除主题渲染, 使用自绘 - on_dark_set_theme(hdr, L"", L""); + SetWindowLongPtr(hdr, GWL_STYLE, GetWindowLongPtr(hdr, GWL_STYLE) & ~HDS_BUTTONS); on_dark_set_theme(pnode->hwnd_qrtable, L"Explorer", NULL); } } @@ -94,13 +61,20 @@ on_table_listview_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR sub_i { return 1; } - case WM_PAINT: - { - on_table_draw_header(hwnd); - break; - } case WM_THEMECHANGED: { + const bool dark = on_dark_enable(); + HWND hdr = ListView_GetHeader(hwnd); + on_dark_allow_window(hwnd, dark); + on_dark_allow_window(hdr, dark); + if (eu_theme_index() == THEME_DEFAULT) + { + on_dark_set_theme(hdr, L"", L""); + } + else + { + on_dark_set_theme(hdr, dark ? L"ItemsView" : NULL, NULL); + } UpdateWindowEx(hwnd); break; } @@ -119,8 +93,8 @@ on_table_listview_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR sub_i } case WM_NOTIFY: { - NMHDR *lpnmhdr = (NMHDR *) lp; - HWND hdr = ListView_GetHeader(hwnd); + NMHDR *lpnmhdr = (NMHDR *)lp; + HWND hdr = ListView_GetHeader(hwnd); if (lpnmhdr->hwndFrom == hdr && lpnmhdr->code == NM_CUSTOMDRAW) { NMCUSTOMDRAW *lpnm = (LPNMCUSTOMDRAW)lp; @@ -132,13 +106,13 @@ on_table_listview_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR sub_i } case CDDS_ITEMPREPAINT: { - FillRect(lpnm->hdc, &lpnm->rc, (HBRUSH)on_dark_theme_brush()); - SetTextColor(lpnm->hdc, eu_get_theme()->item.text.color); - SetBkColor(lpnm->hdc, eu_get_theme()->item.text.bgcolor); - return CDRF_DODEFAULT; + set_text_color(lpnm->hdc, on_dark_enable()); + return CDRF_NEWFONT; } default: - break; + { + return CDRF_DODEFAULT; + } } } break; @@ -182,8 +156,7 @@ on_table_listview_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR sub_i { if (last_hot_item >= 0) { - int index = ListView_GetSelectedColumn(hwnd); - ListView_GetItemText(hwnd, (int)last_hot_item, index, text, LARGER_LEN); + ListView_GetItemText(hwnd, (int)last_hot_item, (int)last_hot_columu, text, LARGER_LEN); on_edit_push_clipboard(text); } break; @@ -231,9 +204,9 @@ on_table_listview_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR sub_i // 使当前行成为焦点 SendMessage(hwnd, WM_LBUTTONDOWN, 0, lp); _InterlockedExchange(&last_hot_item, (long)lvhti.iItem); + _InterlockedExchange(&last_hot_columu, (long)col); // 弹出右键菜单 menu_pop_track(hwnd, IDR_QTABLE_VIEW_POPUPMENU, 0, -1, NULL, NULL); - ListView_SetSelectedColumn(hwnd, col); return 1; } break; @@ -247,6 +220,7 @@ on_table_listview_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR sub_i { RemoveWindowSubclass(hwnd, on_table_listview_proc, sub_id); _InterlockedExchange(&last_hot_item, -1); + _InterlockedExchange(&last_hot_columu, -1); break; } } @@ -256,23 +230,26 @@ on_table_listview_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR sub_i int on_table_create_query_box(eu_tabpage *pnode) { - EU_VERIFY(pnode != NULL); - if (pnode->hwnd_qrtable) - { - DestroyWindow(pnode->hwnd_qrtable); - } - /* 创建结果表格控件 */ - const uint32_t style = WS_CHILD | WS_CLIPSIBLINGS | LVS_REPORT; - pnode->hwnd_qrtable = CreateWindow(WC_LISTVIEW, _T(""), style, 0, 0, 0, 0, eu_module_hwnd(), (HMENU)IDM_TABLE_BAR, eu_module_handle(), NULL); - if (pnode->hwnd_qrtable == NULL) + if (pnode) { - MSG_BOX(IDC_MSG_QUERY_ERR1, IDC_MSG_ERROR, MB_ICONERROR | MB_OK); - return 1; + const uint32_t style = WS_CHILD | WS_CLIPSIBLINGS | LVS_REPORT; + const uint32_t stylex = LVS_EX_DOUBLEBUFFER | LVS_EX_FLATSB | LVS_EX_HEADERINALLVIEWS | LVS_EX_FULLROWSELECT; + if (pnode->hwnd_qrtable) + { + DestroyWindow(pnode->hwnd_qrtable); + } + pnode->hwnd_qrtable = CreateWindow(WC_LISTVIEW, _T(""), style, 0, 0, 0, 0, eu_hwnd_self(), (HMENU)IDM_TABLE_BAR, eu_module_handle(), NULL); + if (pnode->hwnd_qrtable == NULL) + { + MSG_BOX(IDC_MSG_QUERY_ERR1, IDC_MSG_ERROR, MB_ICONERROR | MB_OK); + return SKYLARK_TB_FAILED; + } + SetWindowSubclass(pnode->hwnd_qrtable, on_table_listview_proc, TBCTL_LIST_SUBID, 0); + ListView_SetExtendedListViewStyle(pnode->hwnd_qrtable, stylex); + on_table_update_theme(pnode); + return SKYLARK_OK; } - SetWindowSubclass(pnode->hwnd_qrtable, on_table_listview_proc, TBCTL_LIST_SUBID, 0); - ListView_SetExtendedListViewStyle(pnode->hwnd_qrtable, LVS_EX_FLATSB | LVS_EX_DOUBLEBUFFER | LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT); - on_table_update_theme(pnode); - return 0; + return SKYLARK_TB_FAILED; } int diff --git a/src/eu_tabpage.c b/src/eu_tabpage.c index a925e7b..489d46e 100644 --- a/src/eu_tabpage.c +++ b/src/eu_tabpage.c @@ -823,9 +823,14 @@ on_tabpage_proc_callback(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) EndPaint(hwnd, &ps); break; } + case WM_THEMECHANGED: + { + on_dark_tips_theme(hwnd, TCM_GETTOOLTIPS); + break; + } case WM_DPICHANGED: { - on_tabpage_adjust_box(NULL); + on_tabpage_adjust_box(NULL, NULL); break; } case WM_COMMAND: @@ -1134,34 +1139,39 @@ on_tabpage_do_file(tab_callback func) } void -on_tabpage_size(void) +on_tabpage_size(const RECT *prc) { if (g_tabpages) { - RECT rc_tabbar; - on_tabpage_adjust_box(&rc_tabbar); + RECT rc_tabbar = {0}; + on_tabpage_adjust_box(prc, &rc_tabbar); MoveWindow(g_tabpages, rc_tabbar.left, rc_tabbar.top, rc_tabbar.right - rc_tabbar.left, rc_tabbar.bottom - rc_tabbar.top, TRUE); ShowWindow(g_tabpages, SW_SHOW); } } void -on_tabpage_adjust_box(RECT *ptp) +on_tabpage_adjust_box(const RECT *prc, RECT *ptp) { if (ptp) { - RECT rc_main; + RECT rc_main = { 0 }; RECT rc_treebar = { 0 }; - on_treebar_adjust_box(&rc_treebar, &rc_main); + if (prc == NULL) + { + GetClientRect(eu_hwnd_self(), &rc_main); + prc = &rc_main; + } + on_treebar_adjust_box(prc, &rc_treebar); if (!eu_get_config()->m_ftree_show) { - ptp->left = rc_main.left; + ptp->left = prc->left; } else { ptp->left = rc_treebar.right; } - ptp->right = rc_main.right; + ptp->right = prc->right; ptp->top = rc_treebar.top; ptp->bottom = rc_treebar.bottom; } @@ -1172,7 +1182,7 @@ on_tabpage_adjust_box(RECT *ptp) } void -on_tabpage_adjust_window(eu_tabpage *pnode, RECT *ptab) +on_tabpage_adjust_window(const RECT *prc, eu_tabpage *pnode, RECT *ptab) { RECT rc_tabpages = {0}; if (!ptab) @@ -1182,8 +1192,12 @@ on_tabpage_adjust_window(eu_tabpage *pnode, RECT *ptab) if (true) { RECT rc_main; - GetClientRect(eu_module_hwnd(), &rc_main); - on_tabpage_adjust_box(ptab); + if (!prc) + { + GetClientRect(eu_hwnd_self(), &rc_main); + prc = &rc_main; + } + on_tabpage_adjust_box(prc, ptab); pnode->rect_sc.left = ptab->left; if (eu_get_config()->m_ftree_show) { @@ -1585,9 +1599,9 @@ on_tabpage_selection(eu_tabpage *pnode, int index) } if(index >= 0 && index < count) { - HWND hwnd = eu_module_hwnd(); + HWND hwnd = eu_hwnd_self(); on_tabpage_set_active(index); - eu_window_resize(hwnd); + eu_window_resize(); if ((p = on_tabpage_get_ptr(index))) { // 窗口处理过程中可能改变了标签位置, 重置它 on_tabpage_deselect(index); diff --git a/src/eu_tabpage.h b/src/eu_tabpage.h index b4578d4..358d6a8 100644 --- a/src/eu_tabpage.h +++ b/src/eu_tabpage.h @@ -121,8 +121,8 @@ int on_tabpage_selection(eu_tabpage *pnode, int index); int on_tabpage_sel_number(int **pvec, const bool ascending); int on_tabpage_sel_path(wchar_t ***pvec, bool *hex); void on_tabpage_switch_next(HWND hwnd); -void on_tabpage_adjust_box(RECT *ptp); -void on_tabpage_adjust_window(eu_tabpage *pnode, RECT *ptab); +void on_tabpage_adjust_box(const RECT *prc, RECT *ptp); +void on_tabpage_adjust_window(const RECT *prc, eu_tabpage *pnode, RECT *ptab); void on_tabpage_set_title(int ntab, TCHAR *title); void on_tabpage_symlist_click(eu_tabpage *pnode); void on_tabpage_foreach(tab_ptr fntab); @@ -133,7 +133,7 @@ void on_tabpage_push_editor(int); void on_tabpage_do_file(tab_callback func); void on_tabpage_active_tab(eu_tabpage *pnode); void on_tabpage_active_one(int index); -void on_tabpage_size(void); +void on_tabpage_size(const RECT *prc); void on_tabpage_variable_reset(void); bool on_tabpage_exist_map(void); eu_tabpage *on_tabpage_get_handle(void *hwnd_sc); diff --git a/src/eu_theme_dark.c b/src/eu_theme_dark.c index b4d8580..417f0c4 100644 --- a/src/eu_theme_dark.c +++ b/src/eu_theme_dark.c @@ -76,7 +76,7 @@ on_dark_high_contrast(void) bool on_dark_enable(void) { - return g_dark_enabled && (eu_win11_or_later() ? true : on_dark_apps_use()) && !on_dark_high_contrast(); + return g_dark_enabled && (eu_win11_or_later() ? true : on_dark_apps_use() && !on_dark_high_contrast()); } HRESULT @@ -202,7 +202,7 @@ on_dark_set_titlebar(HWND hwnd, BOOL dark) SetProp(hwnd, _T("UseImmersiveDarkModeColors"), (HANDLE)(intptr_t)(dark)); #endif // USE_DWMAPI } - else if (fnSetWindowCompositionAttribute) // number < 22000 && + else if (fnSetWindowCompositionAttribute) // win 10.0.18362 or win11 { WINDOWCOMPOSITIONATTRIBDATA data = {WCA_USEDARKMODECOLORS, &dark, sizeof(dark)}; fnSetWindowCompositionAttribute(hwnd, &data); @@ -220,11 +220,12 @@ static bool on_dark_set_caption(void) { bool ret = false; + const HWND hwnd = eu_module_hwnd(); const uint32_t number = eu_win10_or_later(); if ((ret = number != (uint32_t)-1) && number >= 22000) { const bool white = eu_theme_index() == THEME_WHITE; - if (!(white && g_color_enable)) + if (hwnd && !(white && g_color_enable)) { #if USE_DWMAPI HMODULE dwm = np_load_plugin_library(_T("dwmapi.dll"), true); @@ -232,7 +233,7 @@ on_dark_set_caption(void) if ((ret = fnDwmSetWindowAttribute != NULL)) { colour mycolor = white ? rgb_dark_txt_color : DWMWA_COLOR_DEFAULT; - ret = S_OK == fnDwmSetWindowAttribute(eu_module_hwnd(), DWMWA_CAPTION_COLOR, &mycolor, sizeof mycolor); + ret = S_OK == fnDwmSetWindowAttribute(hwnd, DWMWA_CAPTION_COLOR, &mycolor, sizeof mycolor); g_color_enable = white && ret == S_OK; eu_logmsg("%s: ret = %d\n", __FUNCTION__, ret); } diff --git a/src/eu_toolbar.c b/src/eu_toolbar.c index a2d3edf..9a1135e 100644 --- a/src/eu_toolbar.c +++ b/src/eu_toolbar.c @@ -656,7 +656,7 @@ on_toolbar_lua_exec(eu_tabpage *pnode) int read_len = 0; char *std_buffer = NULL; pnode->presult->pwant = on_toolbar_no_highlight; - eu_window_resize(NULL); + eu_window_resize(); do_lua_setting_path(pnode); if ((std_buffer = (char *)calloc(1, MAX_OUTPUT_BUF+1))) { @@ -1069,16 +1069,20 @@ on_toolbar_redraw(HWND hwnd) } void -on_toolbar_size(void) +on_toolbar_size(const RECT *prc) { - HWND hwnd = on_toolbar_hwnd(); - if (hwnd) + RECT rc = {0}; + HWND hwnd = NULL; + if (prc == NULL) + { + GetClientRect(eu_hwnd_self(), &rc); + prc = &rc; + } + if ((hwnd = on_toolbar_hwnd())) { if (eu_get_config()->m_toolbar != IDB_SIZE_0) { - RECT rc; - GetClientRect(eu_hwnd_self(), &rc); - int width = rc.right - rc.left; + int width = prc->right - prc->left; eu_setpos_window(hwnd, HWND_TOP, 0, 0, width, on_toolbar_get_height(), SWP_SHOWWINDOW); } else diff --git a/src/eu_toolbar.h b/src/eu_toolbar.h index 379e378..34d734e 100644 --- a/src/eu_toolbar.h +++ b/src/eu_toolbar.h @@ -36,7 +36,7 @@ void on_toolbar_lua_exec(eu_tabpage *pnode); void on_toolbar_setup_button(int id, int flags); void on_toolbar_no_highlight(void *lp); void on_toolbar_redraw(HWND hwnd); -void on_toolbar_size(); +void on_toolbar_size(const RECT *prc); void on_toolbar_set_height(int resid); int on_toolbar_icon_get(void); int on_toolbar_get_height(void); diff --git a/src/eu_treebar.c b/src/eu_treebar.c index a52064e..6a22340 100644 --- a/src/eu_treebar.c +++ b/src/eu_treebar.c @@ -1786,6 +1786,31 @@ on_treebar_load_imglist(HWND hwnd) return himl; } +static int +on_treebar_tab_height(void) +{ + int height = 0; + if (g_treebar) + { + RECT rc = {0}; + TabCtrl_GetItemRect(g_treebar, 0, &rc); + height = rc.bottom - rc.top + 1; + } + return height; +} + +static void +on_treebar_adjust_filetree(const RECT *rect_filebar, RECT *rect_filetree) +{ + if (g_treebar) + { + rect_filetree->left = FILETREE_MARGIN_LEFT; + rect_filetree->right = rect_filebar->right - FILETREE_MARGIN_RIGHT; + rect_filetree->top = rect_filebar->top + on_treebar_tab_height(); + rect_filetree->bottom = rect_filebar->bottom - FILETREE_MARGIN_BOTTOM; + } +} + void on_treebar_update_theme(void) { @@ -1838,9 +1863,14 @@ treebar_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) EndPaint(hwnd, &ps); break; } + case WM_SIZE: + { + return 1; + } case WM_DPICHANGED: { - break; + util_tab_height(g_treebar, 0); + return 1; } case WM_THEMECHANGED: { @@ -1864,18 +1894,22 @@ int on_treebar_create_box(HWND hwnd) { TCITEM tci = {TCIF_TEXT}; + const int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TCS_TOOLTIPS | TCS_BUTTONS | TCS_OWNERDRAWFIXED | TCS_FOCUSNEVER; if (g_treebar) { DestroyWindow(g_treebar); } - g_treebar = CreateWindow(WC_TABCONTROL, NULL, WS_CHILD|TCS_FIXEDWIDTH|TCS_FOCUSNEVER, 0, 0, 0, 0, hwnd, (HMENU) IDM_TREE_BAR, eu_module_handle(), NULL); - if (g_treebar == NULL) + if (!(g_treebar = CreateWindow(WC_TABCONTROL, NULL, style, 0, 0, 0, 0, hwnd, (HMENU) IDM_TREE_BAR, eu_module_handle(), NULL))) { return EUE_POINT_NULL; } - TabCtrl_SetPadding(g_treebar, 20, 5); - LOAD_I18N_RESSTR(IDC_MSG_EXPLORER, m_text); - tci.pszText = m_text; + if (true) + { + TabCtrl_SetPadding(g_treebar, 20, 5); + util_tab_height(g_treebar, 0); + LOAD_I18N_RESSTR(IDC_MSG_EXPLORER, m_text); + tci.pszText = m_text; + } if (TabCtrl_InsertItem(g_treebar, 0, &tci) == -1) { eu_logmsg("%s: TabCtrl_InsertItem failed\n", __FUNCTION__); @@ -1974,24 +2008,24 @@ on_treebar_create_dlg(HWND hwnd) } void -on_treebar_size(void) +on_treebar_size(const RECT *prc) { HDWP hdwp = BeginDeferWindowPos(3); if (g_treebar && hdwp) { - RECT rect_treebar = {0}; - on_treebar_adjust_box(&rect_treebar, NULL); + RECT rc_treebar = {0}; + on_treebar_adjust_box(prc, &rc_treebar); if (eu_get_config()->m_ftree_show) { RECT rect_filetree = {0}; - on_treebar_adjust_filetree(&rect_treebar, &rect_filetree); + on_treebar_adjust_filetree(&rc_treebar, &rect_filetree); DeferWindowPos(hdwp, g_treebar, HWND_TOP, - rect_treebar.left, - rect_treebar.top, - rect_treebar.right - rect_treebar.left, - rect_treebar.bottom - rect_treebar.top, + rc_treebar.left, + rc_treebar.top, + rc_treebar.right - rc_treebar.left, + rc_treebar.bottom - rc_treebar.top, SWP_SHOWWINDOW); DeferWindowPos(hdwp, g_filetree, @@ -2004,7 +2038,7 @@ on_treebar_size(void) DeferWindowPos(hdwp, g_splitter_treebar, HWND_TOP, - rect_treebar.right, + rc_treebar.right, rect_filetree.top, SPLIT_WIDTH, rect_filetree.bottom - rect_filetree.top, @@ -2021,13 +2055,13 @@ on_treebar_size(void) } void -on_treebar_adjust_box(RECT *ptf, RECT *prc) +on_treebar_adjust_box(const RECT *prc, RECT *ptf) { - RECT rect_main = {0}; - GetClientRect(eu_module_hwnd(), prc ? prc : &rect_main); + RECT rc_main = {0}; if (prc == NULL) { - prc = &rect_main; + GetClientRect(eu_hwnd_self(), &rc_main); + prc = &rc_main; } if (!eu_get_config()->m_ftree_show) { @@ -2045,18 +2079,6 @@ on_treebar_adjust_box(RECT *ptf, RECT *prc) } } -void -on_treebar_adjust_filetree(const RECT *rect_filebar, RECT *rect_filetree) -{ - if (g_treebar) - { - rect_filetree->left = FILETREE_MARGIN_LEFT; - rect_filetree->right = rect_filebar->right - FILETREE_MARGIN_RIGHT; - rect_filetree->top = rect_filebar->top + util_tab_height(g_treebar, 0) + FILETREE_MARGIN_TOP; - rect_filetree->bottom = rect_filebar->bottom - FILETREE_MARGIN_BOTTOM; - } -} - tree_data * on_treebar_get_treeview(HTREEITEM hti) { @@ -2186,7 +2208,7 @@ on_treebar_locate_remote(const TCHAR *pathname) TreeView_SelectItem(g_filetree, hti); TreeView_EnsureVisible(g_filetree, hti); SendMessage(g_filetree, WM_SETFOCUS, 0, 0); - eu_window_resize(eu_module_hwnd()); + eu_window_resize(); } free(m_dup); return SKYLARK_OK; @@ -2261,8 +2283,8 @@ on_treebar_locate_path(const TCHAR *pathname) TreeView_SelectItem(g_filetree, hti); TreeView_EnsureVisible(g_filetree, hti); SendMessage(g_filetree, WM_SETFOCUS, 0, 0); - on_treebar_size(); - eu_window_resize(eu_module_hwnd()); + on_treebar_size(NULL); + eu_window_resize(); } util_free(m_dup); return SKYLARK_OK; diff --git a/src/eu_treebar.h b/src/eu_treebar.h index 6ad8772..fc7ab44 100644 --- a/src/eu_treebar.h +++ b/src/eu_treebar.h @@ -66,13 +66,12 @@ int on_treebar_create_box(HWND hwnd); int on_treebar_create_dlg(HWND hwnd); int on_treebar_refresh_node(HTREEITEM hti_parent); bool on_treebar_variable_initialized(HWND *pd); -void on_treebar_size(void); +void on_treebar_size(const RECT *prc); void on_treebar_wait_hwnd(void); void on_treebar_update_addr(remotefs *pserver); void on_treebar_data_destoy(tree_data **ptvd); void on_treebar_update_theme(void); -void on_treebar_adjust_box(RECT *ptf, RECT *prc); -void on_treebar_adjust_filetree(const RECT *rect_filebar, RECT *rect_filetree); +void on_treebar_adjust_box(const RECT *prc, RECT *ptf); HTREEITEM on_treebar_get_path(tree_data **ptvd); tree_data *on_treebar_get_treeview(HTREEITEM hti); tree_data *on_treebar_add_favorite(HTREEITEM parent, const int index, void *pdata); diff --git a/src/eu_updatechecker.c b/src/eu_updatechecker.c index 3d72dac..d8d423a 100644 --- a/src/eu_updatechecker.c +++ b/src/eu_updatechecker.c @@ -328,15 +328,14 @@ on_update_do(void) { int arg_c = 0; bool ret = false; - WCHAR wcmd[LARGER_LEN] = {0}; WCHAR self[MAX_PATH] = {0}; - WCHAR conf_path[MAX_PATH] = {0}; - WCHAR *param = NULL; WCHAR **ptr_arg = CommandLineToArgvW(GetCommandLineW(), &arg_c); - if (ptr_arg && GetModuleFileNameW(NULL, self, MAX_PATH - 1) > 0) + if (GetModuleFileNameW(NULL, self, MAX_PATH - 1) > 0 && ptr_arg != NULL) { HANDLE handle = NULL; - param = arg_c > 1 ? (WCHAR *)calloc(sizeof(WCHAR), MAX_PATH * (arg_c - 1)) : NULL; + WCHAR wcmd[LARGER_LEN] = {0}; + WCHAR conf_path[MAX_PATH] = {0}; + WCHAR *param = arg_c > 1 ? (WCHAR *)calloc(sizeof(WCHAR), MAX_PATH * (arg_c - 1)) : NULL; if (param) { // 把参数追加到命令行 for (int i = 1; i < arg_c; ++i) diff --git a/src/eu_view.c b/src/eu_view.c index 6e9ba64..f47f093 100644 --- a/src/eu_view.c +++ b/src/eu_view.c @@ -22,8 +22,8 @@ void on_view_filetree(void) { eu_get_config()->m_ftree_show ^= true; - on_treebar_size(); - eu_window_resize(NULL); + on_treebar_size(NULL); + eu_window_resize(); } void @@ -35,7 +35,7 @@ on_view_symtree(eu_tabpage *pnode) { pnode->map_show = false; } - eu_window_resize(NULL); + eu_window_resize(); } } @@ -48,7 +48,7 @@ on_view_document_map(eu_tabpage *pnode) { pnode->sym_show = false; } - eu_window_resize(NULL); + eu_window_resize(); } } @@ -64,7 +64,7 @@ on_view_result_show(eu_tabpage *pnode, const int key) if (RESULT_SHOW(pnode)) { pnode->presult->pwant = on_toolbar_no_highlight; - eu_window_resize(NULL); + eu_window_resize(); pnode->doc_ptr->fn_keydown(pnode, VK_F5, key); } } @@ -87,7 +87,7 @@ on_view_switch_type(const int m_type) } on_sci_before_file(pnode, false); on_sci_after_file(pnode, false); - eu_window_resize(eu_hwnd_self()); + eu_window_resize(); return 0; } return 1; @@ -195,7 +195,7 @@ on_view_refresh_theme(HWND hwnd, const bool reload) on_view_refresh_scroll(); on_toolbar_redraw(hwnd); on_splitter_redraw(); - SendMessage(hwnd, WM_SIZE, 0, 0); + on_proc_redraw(NULL); UpdateWindowEx(hwnd); } return SKYLARK_OK; @@ -797,7 +797,7 @@ on_view_font_quality(HWND hwnd, const int res_id) on_sci_after_file(p, false); } } - eu_window_resize(hwnd); + eu_window_resize(); } } } @@ -817,6 +817,6 @@ on_view_enable_rendering(HWND hwnd, const int res_id) on_sci_after_file(p, false); } } - eu_window_resize(hwnd); + eu_window_resize(); } } diff --git a/src/targetver.h b/src/targetver.h index 3633ca9..aa9139f 100644 --- a/src/targetver.h +++ b/src/targetver.h @@ -30,8 +30,11 @@ // 定义版本信息 #define __EU_INFO_VERSION 4 #define __EU_INFO_VERSION_MINOR 0 -#define __EU_INFO_VERSION_PATCHLEVEL 8 +#define __EU_INFO_VERSION_PATCHLEVEL 9 #define __ORIGINAL_NAME TEXT("skylark.exe") +#define SKYLARK_VERSION (__EU_INFO_VERSION * 10000 \ + + __EU_INFO_VERSION_MINOR * 100 \ + + __EU_INFO_VERSION_PATCHLEVEL) #if !__EU_INFO_VERSION_PATCHLEVEL #define __LIFE_CYCLE TEXT("-GA") diff --git a/src/version_display.txt b/src/version_display.txt index a2cec7a..7919852 100644 --- a/src/version_display.txt +++ b/src/version_display.txt @@ -1 +1 @@ -4.0.8 +4.0.9