Merge pull request #4695 from RaiKoHoff/Dev_Master

Book/Change-Marker search: high prio on Book-Marker
This commit is contained in:
Pairi Daiza 2023-03-24 14:07:50 +01:00 committed by GitHub
commit 92b03a03b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 155 additions and 126 deletions

16
Notepad3_sln_ASAN.cmd Normal file
View File

@ -0,0 +1,16 @@
@echo off
setlocal enableextensions
set SDIR=%~dp0
::set DEVENV=C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe
set DEVENV=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe
set SLN=%SDIR%Notepad3.sln
set ASAN_OPTIONS=windows_hook_legacy_allocators=false
start "devenv" /MAX /B "%DEVENV%" "%SLN%"
endlocal
::pause
exit

View File

@ -65,6 +65,17 @@
// ==========================================
#define IDR_MAINWND 1000
#define IDR_MAINWNDTB 1001
#define IDR_MAINWNDTBHOT 1002
#define IDR_MAINWNDTBDIS 1003
#define IDR_MAINWNDTB2 1004
#define IDR_MAINWNDTB2HOT 1005
#define IDR_MAINWNDTB2DIS 1006
#define IDR_STD_DARKMODE_THEME 1050
// ==========================================
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
@ -259,16 +270,6 @@
#define IDS_MUI_SB_RECODING_DOC 15505
#define IDS_MUI_SB_LEXER_STYLING 15506
#define IDR_MAINWND 16000
#define IDR_MAINWNDTB 16001
#define IDR_MAINWNDTBHOT 16002
#define IDR_MAINWNDTBDIS 16003
#define IDR_MAINWNDTB2 16004
#define IDR_MAINWNDTB2HOT 16005
#define IDR_MAINWNDTB2DIS 16006
#define IDR_STD_DARKMODE_THEME 16050
#define IDI_MUI_RUN 16100
#define IDI_MUI_STYLES 16101

View File

@ -252,7 +252,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FunctionLevelLinking>false</FunctionLevelLinking>
<EnableEnhancedInstructionSet />
<OmitFramePointers />
<OmitFramePointers>false</OmitFramePointers>
<MinimalRebuild>false</MinimalRebuild>
<SmallerTypeCheck>false</SmallerTypeCheck>
<TreatWarningAsError>true</TreatWarningAsError>
@ -369,6 +369,7 @@
<LanguageStandard_C>stdc17</LanguageStandard_C>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<OmitFramePointers>false</OmitFramePointers>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -149,7 +149,7 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel>
<SmallerTypeCheck>false</SmallerTypeCheck>
<OmitFramePointers />
<OmitFramePointers>false</OmitFramePointers>
<StringPooling>true</StringPooling>
<EnableEnhancedInstructionSet>
</EnableEnhancedInstructionSet>
@ -189,6 +189,7 @@
<TreatWarningAsError>true</TreatWarningAsError>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<OmitFramePointers>false</OmitFramePointers>
</ClCompile>
<Lib>
<TargetMachine>MachineX64</TargetMachine>

View File

@ -61,8 +61,8 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{1f757558-0e57-4de5-82d6-a14e9d81f05f}</ProjectGuid>
<RootNamespace>user32stub</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>user32-stub</ProjectName>
<WindowsTargetPlatformVersion />
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

View File

@ -61,7 +61,7 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{0873b090-7ffd-4abd-9b42-619a06c5041f}</ProjectGuid>
<RootNamespace>uxthemestub</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion />
<ProjectName>uxtheme-stub</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

View File

@ -9421,16 +9421,24 @@ void EditSetBookmarkList(HWND hwnd, LPCWSTR pszBookMarks)
#define NOT_FOUND_LN ((DocLn)-1)
__forceinline int _GetAllNP3Markers(const DocLn iLine) {
return (SciCall_MarkerGet(iLine) & (ALL_MARKERS_BITMASK() | CHANGE_HISTORY_MARKER_BITMASK()));
}
static int _RespectLastSearch(const int bitmask, const DocLn iLine)
{
static int _LastSearchBitmask = BOOKMARK_BITMASK();
static DocLn _LastSearchStart = NOT_FOUND_LN;
static int _RespectLastSearch(const int bitmask) {
static int s_LastSearchBitmask = 0;
if (!(bitmask & s_LastSearchBitmask)) {
s_LastSearchBitmask = bitmask;
if (iLine == _LastSearchStart) {
if (bitmask & _LastSearchBitmask) {
return _LastSearchBitmask;
}
}
return s_LastSearchBitmask;
if (bitmask & BOOKMARK_BITMASK()) { // BOOKMARKS got prio
_LastSearchBitmask = BOOKMARK_BITMASK();
}
else {
_LastSearchBitmask = bitmask ? bitmask : BOOKMARK_BITMASK();
}
_LastSearchStart = iLine;
return _LastSearchBitmask;
}
@ -9448,46 +9456,43 @@ static inline DocLn _MarkerNext(const DocLn iLine, const int bitmask)
return SciCall_MarkerNext(iLine, bitmask);
}
void EditBookmarkNext(HWND hwnd, DocLn iLine)
{
UNREFERENCED_PARAMETER(hwnd);
DocLn iNextLine = NOT_FOUND_LN;
bool bWrapedAround = true;
do {
int bitmask = _RespectLastSearch(_GetAllNP3Markers(iLine));
if (!bitmask) {
bitmask = BOOKMARK_BITMASK();
int bitmask = _RespectLastSearch(SciCall_MarkerGet(iLine), iLine);
DocLn iNextLine = _MarkerNext(iLine + 1, bitmask);
// skip consecutive change marker
if (bitmask & CHANGE_HISTORY_MARKER_BITMASK()) {
while ((iLine + 1) == iNextLine) {
iNextLine = _MarkerNext(++iLine + 1, bitmask);
}
}
if ((iNextLine == NOT_FOUND_LN) && (iLine > 0)) {
iNextLine = _MarkerNext(0, bitmask); // wrap around
}
if (iNextLine == NOT_FOUND_LN) { // find any bookmark
bitmask = ALL_MARKERS_BITMASK();
iNextLine = _MarkerNext(iLine + 1, bitmask);
if (iNextLine == NOT_FOUND_LN) {
if ((iNextLine == NOT_FOUND_LN) && (iLine > 0)) {
iNextLine = _MarkerNext(0, bitmask); // wrap around
}
if (iNextLine == NOT_FOUND_LN) {
bitmask = ALL_MARKERS_BITMASK();
iNextLine = _MarkerNext(iLine + 1, bitmask); // find any bookmark
}
if (iNextLine == NOT_FOUND_LN) { // find change history marker
bitmask = CHANGE_HISTORY_MARKER_BITMASK();
iNextLine = _MarkerNext(iLine + 1, bitmask);
if ((iNextLine == NOT_FOUND_LN) && (iLine > 0)) {
iNextLine = _MarkerNext(0, bitmask); // wrap around
}
if (iNextLine == NOT_FOUND_LN) {
bitmask = CHANGE_HISTORY_MARKER_BITMASK();
iNextLine = _MarkerNext(iLine + 1, bitmask); // find change history marker
}
if (iNextLine == NOT_FOUND_LN) {
// initial search not started from beginning?
if (iLine != 0) {
iLine = 0;
}
}
else { // check for consecutive change marker
if (bitmask & CHANGE_HISTORY_MARKER_BITMASK()) {
while ((iLine + 1) == iNextLine) {
iLine = iNextLine;
iNextLine = _MarkerNext(iLine + 1, bitmask);
}
}
}
bWrapedAround = !bWrapedAround;
} while ((iNextLine == NOT_FOUND_LN) && !bWrapedAround);
}
if (iNextLine != NOT_FOUND_LN) {
_RespectLastSearch(bitmask, iNextLine); // reset
SciCall_GotoLine(iNextLine);
}
}
@ -9512,47 +9517,45 @@ static inline DocLn _MarkerPrevious(const DocLn iLine, const int bitmask)
void EditBookmarkPrevious(HWND hwnd, DocLn iLine)
{
UNREFERENCED_PARAMETER(hwnd);
DocLn iPrevLine = NOT_FOUND_LN;
bool bWrapedAround = true;
do {
int bitmask = _RespectLastSearch(_GetAllNP3Markers(iLine));
if (!bitmask) {
bitmask = BOOKMARK_BITMASK();
DocLn const docLnCount = SciCall_GetLineCount();
int bitmask = _RespectLastSearch(SciCall_MarkerGet(iLine), iLine);
iLine = (iLine <= 0) ? docLnCount + 1 : iLine;
DocLn iPrevLine = _MarkerPrevious(iLine - 1, bitmask);
// skip consecutive change marker
if (bitmask & CHANGE_HISTORY_MARKER_BITMASK()) {
while ((iLine - 1) == iPrevLine) {
iPrevLine = _MarkerPrevious(--iLine - 1, bitmask);
}
iLine = (iLine <= 0) ? SciCall_GetLineCount() + 1 : iLine;
}
if ((iPrevLine == NOT_FOUND_LN) && (iLine < docLnCount)) {
iPrevLine = _MarkerPrevious(docLnCount, bitmask); // wrap around
}
if (iPrevLine == NOT_FOUND_LN) { // find any bookmark
bitmask = ALL_MARKERS_BITMASK();
iPrevLine = _MarkerPrevious(iLine - 1, bitmask);
if (iPrevLine == NOT_FOUND_LN) {
iPrevLine = _MarkerPrevious(SciCall_GetLineCount(), bitmask); // wrap around
if ((iPrevLine == NOT_FOUND_LN) && (iLine < docLnCount)) {
iPrevLine = _MarkerPrevious(docLnCount, bitmask); // wrap around
}
if (iPrevLine == NOT_FOUND_LN) {
bitmask = ALL_MARKERS_BITMASK();
iPrevLine = _MarkerPrevious(iLine - 1, bitmask); // find any bookmark
}
if (iPrevLine == NOT_FOUND_LN) { // find change history marker
bitmask = CHANGE_HISTORY_MARKER_BITMASK();
iPrevLine = _MarkerPrevious(iLine - 1, bitmask);
if ((iPrevLine == NOT_FOUND_LN) && (iLine < docLnCount)) {
iPrevLine = _MarkerPrevious(docLnCount, bitmask); // wrap around
}
if (iPrevLine == NOT_FOUND_LN) {
bitmask = CHANGE_HISTORY_MARKER_BITMASK();
iPrevLine = _MarkerPrevious(iLine - 1, bitmask); // find change history marker
}
if (iPrevLine == NOT_FOUND_LN) {
// initial search not started from bottom?
if (iLine != SciCall_GetLineCount()) {
iLine = SciCall_GetLineCount();
}
}
else { // check for consecutive change marker
if (bitmask & CHANGE_HISTORY_MARKER_BITMASK()) {
while ((iLine - 1) == iPrevLine) {
iLine = iPrevLine;
iPrevLine = _MarkerPrevious(iLine - 1, bitmask);
}
}
}
bWrapedAround = !bWrapedAround;
} while ((iPrevLine == NOT_FOUND_LN) && !bWrapedAround);
}
if (iPrevLine != NOT_FOUND_LN) {
// find beginning of consecutive change marker
int const bm = _GetAllNP3Markers(iPrevLine);
int const bm = bitmask & CHANGE_HISTORY_MARKER_BITMASK();
while ((--iPrevLine >= 0) && (bm & SciCall_MarkerGet(iPrevLine))) {}
_RespectLastSearch(bitmask, iPrevLine + 1); // reset
SciCall_GotoLine(iPrevLine + 1);
}
}

View File

@ -91,17 +91,18 @@ CONSTANTS_T const Constants = {
};
FLAGS_T Flags;
FLAGS_T DefaultFlags;
FLAGS_T Flags = { 0 };
FLAGS_T DefaultFlags = { 0 };
PATHS_T Paths;
GLOBALS_T Globals;
SETTINGS_T Settings;
SETTINGS_T Defaults;
SETTINGS2_T Settings2;
GLOBALS_T Globals = { 0 };
SETTINGS_T Settings = { 0 };
SETTINGS_T Defaults = { 0 };
SETTINGS2_T Settings2 = { 0 };
FOCUSEDVIEW_T FocusedView;
FILEWATCHING_T FileWatching;
PATHS_T Paths = { 0 };
FOCUSEDVIEW_T FocusedView = { 0 };
FILEWATCHING_T FileWatching = { 0 };
// set by InitScintillaHandle()
HWND g_hwndEditWindow = NULL;
@ -113,8 +114,8 @@ WININFO g_DefWinInfo = INIT_WININFO;
COLORREF g_colorCustom[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
prefix_t g_mxSBPrefix[STATUS_SECTOR_COUNT];
prefix_t g_mxSBPostfix[STATUS_SECTOR_COUNT];
prefix_t g_mxSBPrefix[STATUS_SECTOR_COUNT] = { L'\0' };
prefix_t g_mxSBPostfix[STATUS_SECTOR_COUNT] = { L'\0' };
int g_flagMatchText = 0;
bool g_iStatusbarVisible[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO;
@ -125,7 +126,7 @@ HPATHL g_tchToolbarBitmap = NULL;
HPATHL g_tchToolbarBitmapHot = NULL;
HPATHL g_tchToolbarBitmapDisabled = NULL;
WCHAR Default_PreferredLanguageLocaleName[LOCALE_NAME_MAX_LENGTH + 1];
WCHAR Default_PreferredLanguageLocaleName[LOCALE_NAME_MAX_LENGTH + 1] = { L'\0' };
// ------------------------------------
@ -159,14 +160,14 @@ static bool s_bLastCopyFromMe = false;
static bool s_bInMultiEditMode = false;
static bool s_bCallTipEscDisabled = false;
static int s_iInitialLine;
static int s_iInitialColumn;
static int s_iInitialLexer;
static int s_iInitialLine = 0;
static int s_iInitialColumn = 0;
static int s_iInitialLexer = 0;
static int s_cyReBar;
static int s_cyReBarFrame;
static int s_cxEditFrame;
static int s_cyEditFrame;
static int s_cyReBar = 0;
static int s_cyReBarFrame = 0;
static int s_cxEditFrame = 0;
static int s_cyEditFrame = 0;
static bool s_bUndoRedoScroll = false;
// for tiny expression calculation
@ -712,15 +713,6 @@ static void _UpdateTitlebarDelayed(const HWND hwnd);
static void _InitGlobals()
{
ZeroMemory(&Paths, sizeof(PATHS_T));
ZeroMemory(&Globals, sizeof(GLOBALS_T));
ZeroMemory(&Defaults, sizeof(SETTINGS_T));
ZeroMemory(&Settings, sizeof(SETTINGS_T));
ZeroMemory(&Settings2, sizeof(SETTINGS2_T));
ZeroMemory(&Flags, sizeof(FLAGS_T));
ZeroMemory(&(Globals.fvCurFile), sizeof(FILEVARS));
Globals.hLngResContainer = NULL;
Globals.hDlgIcon256 = NULL;
@ -1180,33 +1172,49 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
int const cxs = GetSystemMetrics(SM_CXSMICON) << 1;
int const cys = GetSystemMetrics(SM_CYSMICON) << 1;
//UINT const fuLoad = LR_DEFAULTCOLOR | LR_SHARED;
UINT const fuLoad = LR_DEFAULTCOLOR | LR_SHARED;
if (!Globals.hDlgIcon256) {
LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), 256, 256, &(Globals.hDlgIcon256));
if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), 256, 256, &(Globals.hDlgIcon256)))) {
Globals.hDlgIcon256 = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, 256, 256, fuLoad);
}
}
if (!Globals.hDlgIcon128) {
LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), 128, 128, &(Globals.hDlgIcon128));
if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), 128, 128, &(Globals.hDlgIcon128)))) {
Globals.hDlgIcon128 = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, 128, 128, fuLoad);
}
}
if (!Globals.hDlgIconBig) {
LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxb, cyb, &(Globals.hDlgIconBig));
if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxb, cyb, &(Globals.hDlgIconBig)))) {
Globals.hDlgIconBig = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, cxb, cyb, fuLoad);
}
}
if (!Globals.hDlgIconSmall) {
LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxs, cys, &(Globals.hDlgIconSmall));
if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxs, cys, &(Globals.hDlgIconSmall)))) {
Globals.hDlgIconSmall = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, cxs, cys, fuLoad);
}
}
if (!Globals.hDlgIconPrefs256) {
LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 256, 256, &(Globals.hDlgIconPrefs256));
if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 256, 256, &(Globals.hDlgIconPrefs256)))) {
Globals.hDlgIconPrefs256 = LoadImage(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), IMAGE_ICON, 256, 256, fuLoad);
}
}
if (!Globals.hDlgIconPrefs128) {
LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 128, 128, &(Globals.hDlgIconPrefs128));
if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 128, 128, &(Globals.hDlgIconPrefs128)))) {
Globals.hDlgIconPrefs128 = LoadImage(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), IMAGE_ICON, 128, 128, fuLoad);
}
}
if (!Globals.hDlgIconPrefs64) {
LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 64, 64, &(Globals.hDlgIconPrefs64));
if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 64, 64, &(Globals.hDlgIconPrefs64)))) {
Globals.hDlgIconPrefs64 = LoadImage(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), IMAGE_ICON, 64, 64, fuLoad);
}
}
if (!Globals.hIconMsgUser) {
LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxb, cyb, &(Globals.hIconMsgUser));
if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxb, cyb, &(Globals.hIconMsgUser)))) {
Globals.hIconMsgUser = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, cxb, cyb, fuLoad);
}
}
if (!Globals.hIconMsgInfo) {
LoadIconWithScaleDown(NULL, IDI_INFORMATION, cxb, cyb, &(Globals.hIconMsgInfo));

View File

@ -181,7 +181,7 @@
<CompileAsWinRT>false</CompileAsWinRT>
<AdditionalOptions>/Zc:threadSafeInit /utf-8 %(AdditionalOptions)</AdditionalOptions>
<ExceptionHandling>Sync</ExceptionHandling>
<OmitFramePointers />
<OmitFramePointers>false</OmitFramePointers>
<SmallerTypeCheck>false</SmallerTypeCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<LanguageStandard_C>stdc17</LanguageStandard_C>
@ -254,8 +254,7 @@
<AdditionalOptions>/Zc:threadSafeInit /utf-8 %(AdditionalOptions)</AdditionalOptions>
<ExceptionHandling>Sync</ExceptionHandling>
<EnableEnhancedInstructionSet />
<OmitFramePointers>
</OmitFramePointers>
<OmitFramePointers>false</OmitFramePointers>
<SmallerTypeCheck>false</SmallerTypeCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<LanguageStandard_C>stdc17</LanguageStandard_C>

View File

@ -198,7 +198,7 @@ inline LPCWSTR _Win10BuildToReleaseId(const DWORD build)
#endif
#elif (_MSC_VER == 1929)
#if (_MSC_FULL_VER >= 192930148)
#define VER_CPL MS Visual C++ 2019 v16.11.24
#define VER_CPL MS Visual C++ 2019 v16.11.(24-25)
#elif (_MSC_FULL_VER >= 192930147)
#define VER_CPL MS Visual C++ 2019 v16 .11.(21-23)
#elif (_MSC_FULL_VER >= 192930146)