Solve the conflicts

This commit is contained in:
Don Ho 2025-02-13 15:49:42 +01:00
commit 04b0d6c5f4
8 changed files with 96 additions and 18 deletions

View File

@ -1905,6 +1905,7 @@ bool doesPathExist(const wchar_t* path, DWORD milliSec2wait, bool* isTimeoutReac
return (attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES);
}
#if defined(__GNUC__)
#define LAMBDA_STDCALL __attribute__((__stdcall__))
#else
@ -1957,3 +1958,62 @@ bool isWindowVisibleOnAnyMonitor(const RECT& rectWndIn)
::EnumDisplayMonitors(NULL, &rectVirtualScreen, callback, reinterpret_cast<LPARAM>(&param4InOut));
return param4InOut.isWndVisibleOut;
}
#pragma warning(disable:4996) // 'GetVersionExW': was declared deprecated
bool isCoreWindows()
{
bool isCoreWindows = false;
// older Windows (Windows Server 2008 R2-) check 1st
OSVERSIONINFOEXW osviex{};
osviex.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
if (::GetVersionEx(reinterpret_cast<LPOSVERSIONINFOW>(&osviex)))
{
DWORD dwReturnedProductType = 0;
if (::GetProductInfo(osviex.dwMajorVersion, osviex.dwMinorVersion, osviex.wServicePackMajor, osviex.wServicePackMinor, &dwReturnedProductType))
{
switch (dwReturnedProductType)
{
case PRODUCT_STANDARD_SERVER_CORE:
case PRODUCT_STANDARD_A_SERVER_CORE:
case PRODUCT_STANDARD_SERVER_CORE_V:
case PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE:
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE:
case PRODUCT_ENTERPRISE_SERVER_CORE:
case PRODUCT_ENTERPRISE_SERVER_CORE_V:
case PRODUCT_DATACENTER_SERVER_CORE:
case PRODUCT_DATACENTER_A_SERVER_CORE:
case PRODUCT_DATACENTER_SERVER_CORE_V:
case PRODUCT_STORAGE_STANDARD_SERVER_CORE:
case PRODUCT_STORAGE_WORKGROUP_SERVER_CORE:
case PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE:
case PRODUCT_STORAGE_EXPRESS_SERVER_CORE:
case PRODUCT_WEB_SERVER_CORE:
isCoreWindows = true;
}
}
}
if (!isCoreWindows)
{
// in Core Server 2012+, the recommended way to determine is via the Registry
HKEY hKey = nullptr;
if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
constexpr size_t bufLen = 127;
wchar_t wszBuf[bufLen + 1]{}; // +1 ... to be always NULL-terminated string
DWORD dataSize = sizeof(wchar_t) * bufLen;
if (::RegQueryValueExW(hKey, L"InstallationType", nullptr, nullptr, reinterpret_cast<LPBYTE>(&wszBuf), &dataSize) == ERROR_SUCCESS)
{
if (lstrcmpiW(wszBuf, L"Server Core") == 0)
isCoreWindows = true;
}
::RegCloseKey(hKey);
hKey = nullptr;
}
}
return isCoreWindows;
}
#pragma warning(default:4996)

View File

@ -292,3 +292,5 @@ bool doesPathExist(const wchar_t* path, DWORD milliSec2wait = 0, bool* isTimeout
// check if the window rectangle intersects with any currently active monitor's working area
bool isWindowVisibleOnAnyMonitor(const RECT& rectWndIn);
bool isCoreWindows();

View File

@ -2192,7 +2192,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_UNFOLD_CURRENT:
{
bool isToggleEnabled = NppParameters::getInstance().getNppGUI()._enableFoldCmdToggable;
bool mode = id == IDM_VIEW_FOLD_CURRENT ? folding_fold : folding_unfold;
bool mode = id == IDM_VIEW_FOLD_CURRENT ? fold_collapse : fold_expand;
intptr_t headerLine = _pEditView->getHeaderLine();
if (headerLine != -1)
@ -2200,7 +2200,7 @@ void Notepad_plus::command(int id)
if (isToggleEnabled)
{
bool isFolded = _pEditView->isCurrentLineFolded(headerLine);
mode = isFolded ? folding_unfold : folding_fold;
mode = isFolded ? fold_expand : fold_collapse;
}
_pEditView->foldCurrentPos(headerLine, mode);
@ -2212,11 +2212,13 @@ void Notepad_plus::command(int id)
case IDM_VIEW_UNFOLDALL:
{
_isFolding = true; // So we can ignore events while folding is taking place
bool doFold = (id == IDM_VIEW_FOLDALL) ? folding_fold : folding_unfold;
_pEditView->foldAll(doFold);
bool doCollapse = (id == IDM_VIEW_FOLDALL) ? fold_collapse : fold_expand;
_pEditView->foldAll(doCollapse);
if (_pDocMap)
{
_pDocMap->foldAll(doFold);
_pDocMap->foldAll(doCollapse);
}
_isFolding = false;
}
@ -2231,7 +2233,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_FOLD_7:
case IDM_VIEW_FOLD_8:
_isFolding = true; // So we can ignore events while folding is taking place
_pEditView->collapse(id - IDM_VIEW_FOLD - 1, folding_fold);
_pEditView->collapse(id - IDM_VIEW_FOLD - 1, fold_collapse);
_isFolding = false;
break;
@ -2244,7 +2246,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_UNFOLD_7:
case IDM_VIEW_UNFOLD_8:
_isFolding = true; // So we can ignore events while folding is taking place
_pEditView->collapse(id - IDM_VIEW_UNFOLD - 1, folding_unfold);
_pEditView->collapse(id - IDM_VIEW_UNFOLD - 1, fold_expand);
_isFolding = false;
break;

View File

@ -117,7 +117,7 @@ enum ChangeDetect { cdDisabled = 0x0, cdEnabledOld = 0x01, cdEnabledNew = 0x02,
enum BackupFeature {bak_none = 0, bak_simple = 1, bak_verbose = 2};
enum OpenSaveDirSetting {dir_followCurrent = 0, dir_last = 1, dir_userDef = 2};
enum MultiInstSetting {monoInst = 0, multiInstOnSession = 1, multiInst = 2};
enum writeTechnologyEngine {defaultTechnology = 0, directWriteTechnology = 1};
enum writeTechnologyEngine {defaultTechnology = 0, directWriteTechnology = 1, directWriteTechnologyUnavailable = 2};
enum urlMode {urlDisable = 0, urlNoUnderLineFg, urlUnderLineFg, urlNoUnderLineBg, urlUnderLineBg,
urlMin = urlDisable,
urlMax = urlUnderLineBg};

View File

@ -5581,7 +5581,7 @@ void Finder::beginNewFilesSearch()
_nbFoundFiles = 0;
// fold all old searches (1st level only)
_scintView.collapse(searchHeaderLevel - SC_FOLDLEVELBASE, folding_fold);
_scintView.collapse(searchHeaderLevel - SC_FOLDLEVELBASE, fold_collapse);
}
void Finder::finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection, const FindOption* pFindOpt)
@ -5720,13 +5720,13 @@ intptr_t CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam
case NPPM_INTERNAL_SCINTILLAFINDERCOLLAPSE :
{
_scintView.foldAll(folding_fold, false);
_scintView.foldAll(fold_collapse, false);
return TRUE;
}
case NPPM_INTERNAL_SCINTILLAFINDERUNCOLLAPSE :
{
_scintView.foldAll(folding_unfold, false);
_scintView.foldAll(fold_expand, false);
return TRUE;
}

View File

@ -320,8 +320,16 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
isWINE = ::GetProcAddress(hNtdllModule, "wine_get_version");
if (isWINE || // There is a performance issue under WINE when DirectWrite is ON, so we turn it off if user uses Notepad++ under WINE
::IsWindowsServer()) // In the case of Windows Server Core, DirectWrite cannot be on.
nppGui._writeTechnologyEngine = defaultTechnology;
isCoreWindows()) // In the case of Windows Server Core, DirectWrite cannot be on.
{
nppGui._writeTechnologyEngine = directWriteTechnologyUnavailable;
}
else
{
// allow IDC_CHECK_DIRECTWRITE_ENABLE to be set in Preferences > MISC. again
if (nppGui._writeTechnologyEngine == directWriteTechnologyUnavailable)
nppGui._writeTechnologyEngine = defaultTechnology;
}
if (nppGui._writeTechnologyEngine == directWriteTechnology)
{
@ -546,6 +554,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
SHORT ctrl = GetKeyState(VK_CONTROL);
SHORT alt = GetKeyState(VK_MENU);
SHORT shift = GetKeyState(VK_SHIFT);
if (!(shift & 0x8000) && !(ctrl & 0x8000) && !(alt & 0x8000)) // DEL & Multi-edit
{
size_t nbSelections = execute(SCI_GETSELECTIONS);
@ -568,6 +577,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
char eolStr[3] = { '\0' };
Sci_TextRangeFull tr{};
tr.chrg.cpMin = posStart;
tr.chrg.cpMax = posEnd + 2;
if (tr.chrg.cpMax > static_cast<Sci_Position>(docLen))
@ -1711,7 +1721,7 @@ void ScintillaEditView::setLanguage(LangType langType)
{
unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask();
if (_currentBuffer->getLastLangType() != -1)
if (_currentBuffer->getLastLangType() > 0)
{
saveCurrentPos();
Document prev = execute(SCI_GETDOCPOINTER);
@ -2328,7 +2338,9 @@ void ScintillaEditView::activateBuffer(BufferID buffer, bool force)
_currentBufferID = buffer; //the magical switch happens here
_currentBuffer = newBuf;
const bool isSameLangType = (_prevBuffer != nullptr) && (_prevBuffer->getLangType() == _currentBuffer->getLangType());
const bool isSameLangType = (_prevBuffer != nullptr) && (_prevBuffer->getLangType() == _currentBuffer->getLangType()) &&
(_currentBuffer->getLangType() != L_USER || wcscmp(_prevBuffer->getUserDefineLangName(), _currentBuffer->getUserDefineLangName()) == 0);
const int currentLangInt = static_cast<int>(_currentBuffer->getLangType());
const bool isFirstActiveBuffer = (_currentBuffer->getLastLangType() != currentLangInt);
@ -2480,7 +2492,7 @@ void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask)
if (mask & BufferChangeLanguage)
{
defineDocType(buffer->getLangType());
foldAll(folding_unfold);
foldAll(fold_expand);
}
if (mask & BufferChangeLexing)

View File

@ -89,8 +89,9 @@ const int CP_GREEK = 1253;
#define LIST_7 128
#define LIST_8 256
const bool folding_unfold = true;
const bool folding_fold = false;
const bool fold_expand = true;
const bool fold_collapse = false;
#define MAX_FOLD_COLLAPSE_LEVEL 8
#define MODEVENTMASK_OFF 0

View File

@ -2487,6 +2487,7 @@ intptr_t CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
::SendDlgItemMessage(_hSelf, IDC_CHECK_DETECTENCODING, BM_SETCHECK, nppGUI._detectEncoding, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SAVEALLCONFIRM, BM_SETCHECK, nppGUI._saveAllConfirm, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_AUTOUPDATE, BM_SETCHECK, nppGUI._autoUpdateOpt._doAutoUpdate, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_DIRECTWRITE_ENABLE), nppGUI._writeTechnologyEngine != directWriteTechnologyUnavailable);
::SendDlgItemMessage(_hSelf, IDC_CHECK_DIRECTWRITE_ENABLE, BM_SETCHECK, nppGUI._writeTechnologyEngine == directWriteTechnology, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKER, BM_SETCHECK, nppGUI._isDocPeekOnTab ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKONMAP, BM_SETCHECK, nppGUI._isDocPeekOnMap ? BST_CHECKED : BST_UNCHECKED, 0);