From af586d5410af56d433717b54371dbd284bb02416 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 2 Oct 2016 18:34:40 -0500 Subject: [PATCH 1/5] add use-ConEmu.xml --- launcher/src/CmderLauncher.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 24f35c8..a16bbc2 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -118,15 +118,25 @@ void StartCmder(std::wstring path, bool is_single_mode) PathCombine(icoPath, exeDir, L"icons\\cmder.ico"); // Check for machine-specific config file. - PathCombine(oldCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml"); - ExpandEnvironmentStrings(oldCfgPath, oldCfgPath, sizeof(oldCfgPath) / sizeof(oldCfgPath[0])); - if (!PathFileExists(oldCfgPath)) { + PathCombine(cpuCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml"); + ExpandEnvironmentStrings(cpuCfgPath, cpuCfgPath, sizeof(cpuCfgPath) / sizeof(cpuCfgPath[0])); + + // Check for user-specific config file. + PathCombine(userCfgPath, exeDir, L"config\\user-ConEmu.xml"); + + if (PathFileExists(cpuCfgPath)) { + PathCombine(oldCfgPath, exeDir, cpuCfgPath.GetBuffer(sizeof(cpuCfgPath))); + } + else if (!PathFileExists(userCfgPath)) { + PathCombine(oldCfgPath, exeDir, userCfgPath.GetBuffer(sizeof(userCfgPath))); + } + else { PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml"); - } + } // Check for machine-specific config file. - PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu-%COMPUTERNAME%.xml"); - ExpandEnvironmentStrings(cfgPath, cfgPath, sizeof(cfgPath) / sizeof(cfgPath[0])); + PathCombine(cfgPath, exeDir, oldCfgPath.GetBufer(sizeof(oldCfgPath); + // ExpandEnvironmentStrings(cfgPath, cfgPath, sizeof(cfgPath) / sizeof(cfgPath[0])); if (!PathFileExists(cfgPath)) { PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml"); } From 66c6d5bbb3955d5d8fa38cb88750087140160246 Mon Sep 17 00:00:00 2001 From: Dax Games Date: Sun, 2 Oct 2016 21:50:56 -0500 Subject: [PATCH 2/5] added ability to have a user-ConEmu.xml file in addition to the computer specific and default ConEmu.xml files --- launcher/src/CmderLauncher.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index a16bbc2..5537d5f 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -103,6 +103,8 @@ void StartCmder(std::wstring path, bool is_single_mode) wchar_t exeDir[MAX_PATH] = { 0 }; wchar_t icoPath[MAX_PATH] = { 0 }; wchar_t cfgPath[MAX_PATH] = { 0 }; + wchar_t cpuCfgPath[MAX_PATH] = { 0 }; + wchar_t userCfgPath[MAX_PATH] = { 0 }; wchar_t oldCfgPath[MAX_PATH] = { 0 }; wchar_t conEmuPath[MAX_PATH] = { 0 }; wchar_t args[MAX_PATH * 2 + 256] = { 0 }; @@ -117,29 +119,24 @@ void StartCmder(std::wstring path, bool is_single_mode) PathCombine(icoPath, exeDir, L"icons\\cmder.ico"); - // Check for machine-specific config file. + // Check for machine-specific then user config source file. PathCombine(cpuCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml"); ExpandEnvironmentStrings(cpuCfgPath, cpuCfgPath, sizeof(cpuCfgPath) / sizeof(cpuCfgPath[0])); - // Check for user-specific config file. PathCombine(userCfgPath, exeDir, L"config\\user-ConEmu.xml"); - if (PathFileExists(cpuCfgPath)) { - PathCombine(oldCfgPath, exeDir, cpuCfgPath.GetBuffer(sizeof(cpuCfgPath))); - } - else if (!PathFileExists(userCfgPath)) { - PathCombine(oldCfgPath, exeDir, userCfgPath.GetBuffer(sizeof(userCfgPath))); - } - else { - PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml"); - } - - // Check for machine-specific config file. - PathCombine(cfgPath, exeDir, oldCfgPath.GetBufer(sizeof(oldCfgPath); - // ExpandEnvironmentStrings(cfgPath, cfgPath, sizeof(cfgPath) / sizeof(cfgPath[0])); - if (!PathFileExists(cfgPath)) { - PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml"); + if (PathFileExists(cpuCfgPath)) { + wcsncpy_s(oldCfgPath, cpuCfgPath, sizeof(cpuCfgPath)); } + else if (PathFileExists(userCfgPath)) { + wcsncpy_s(oldCfgPath, userCfgPath,sizeof(userCfgPath)); + } + else { + PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml"); + } + + // Set path to vendored ConEmu config file + PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml"); SYSTEM_INFO sysInfo; GetNativeSystemInfo(&sysInfo); From abd7db99b69be86d8ffde4f52bff8b2e3a36a6ae Mon Sep 17 00:00:00 2001 From: Dax Games Date: Sun, 2 Oct 2016 22:16:22 -0500 Subject: [PATCH 3/5] added backup of ConEmu.xml to ./config folder at cmder launch if it exists --- launcher/src/CmderLauncher.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 5537d5f..e5a438f 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -158,6 +158,16 @@ void StartCmder(std::wstring path, bool is_single_mode) exit(1); } } + else { + if (!CopyFile(cfgPath, oldCfgPath, FALSE)) + { + MessageBox(NULL, + (GetLastError() == ERROR_ACCESS_DENIED) + ? L"Failed to backup ConEmu.xml file to ./config folder!" + : L"Failed to backup ConEmu.xml file to ./config folder!", MB_TITLE, MB_ICONSTOP); + exit(1); + } + } if (is_single_mode) { From 5feccb3c7c5ce0f9146d67bb67188e6da591d51c Mon Sep 17 00:00:00 2001 From: Dax Games Date: Sun, 2 Oct 2016 22:23:12 -0500 Subject: [PATCH 4/5] added backup of ConEmu.xml to ./config/user-ConEmu.xml at cmder launch if it exists --- launcher/src/CmderLauncher.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index e5a438f..2fef05e 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -103,6 +103,7 @@ void StartCmder(std::wstring path, bool is_single_mode) wchar_t exeDir[MAX_PATH] = { 0 }; wchar_t icoPath[MAX_PATH] = { 0 }; wchar_t cfgPath[MAX_PATH] = { 0 }; + wchar_t backupCfgPath[MAX_PATH] = { 0 }; wchar_t cpuCfgPath[MAX_PATH] = { 0 }; wchar_t userCfgPath[MAX_PATH] = { 0 }; wchar_t oldCfgPath[MAX_PATH] = { 0 }; @@ -127,12 +128,15 @@ void StartCmder(std::wstring path, bool is_single_mode) if (PathFileExists(cpuCfgPath)) { wcsncpy_s(oldCfgPath, cpuCfgPath, sizeof(cpuCfgPath)); + wcsncpy_s(backupCfgPath, cpuCfgPath, sizeof(cpuCfgPath)); } else if (PathFileExists(userCfgPath)) { wcsncpy_s(oldCfgPath, userCfgPath,sizeof(userCfgPath)); + wcsncpy_s(backupCfgPath, userCfgPath, sizeof(userCfgPath)); } else { PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml"); + wcsncpy_s(backupCfgPath, userCfgPath, sizeof(userCfgPath)); } // Set path to vendored ConEmu config file @@ -158,15 +162,13 @@ void StartCmder(std::wstring path, bool is_single_mode) exit(1); } } - else { - if (!CopyFile(cfgPath, oldCfgPath, FALSE)) - { - MessageBox(NULL, - (GetLastError() == ERROR_ACCESS_DENIED) - ? L"Failed to backup ConEmu.xml file to ./config folder!" - : L"Failed to backup ConEmu.xml file to ./config folder!", MB_TITLE, MB_ICONSTOP); - exit(1); - } + else if (!CopyFile(cfgPath, backupCfgPath, FALSE)) + { + MessageBox(NULL, + (GetLastError() == ERROR_ACCESS_DENIED) + ? L"Failed to backup ConEmu.xml file to ./config folder!" + : L"Failed to backup ConEmu.xml file to ./config folder!", MB_TITLE, MB_ICONSTOP); + exit(1); } if (is_single_mode) From 4c522aa0c4b8660b272ba5f88de3354eea5cecad Mon Sep 17 00:00:00 2001 From: Dax Games Date: Sun, 30 Oct 2016 18:22:29 -0500 Subject: [PATCH 5/5] trigger push --- Cmder.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cmder.bat b/Cmder.bat index 18d9ff0..6a95148 100644 --- a/Cmder.bat +++ b/Cmder.bat @@ -1,7 +1,7 @@ @echo off SET CMDER_ROOT=%~dp0 -:: Remove trailing '\' +:: Remove Trailing '\' @if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1% if exist "%~1" (