Merge pull request #1148 from RaiKoHoff/Dev_UCHARDET

Repair Hyperlink styling
This commit is contained in:
Rainer Kottenhoff 2019-04-27 23:05:50 +02:00 committed by GitHub
commit a06cff0361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 97 additions and 99 deletions

View File

@ -1 +1 @@
1676
1678

View File

@ -3,7 +3,7 @@
<assemblyIdentity
name="Notepad3"
processorArchitecture="*"
version="5.19.427.1676"
version="5.19.427.1678"
type="win32"
/>
<description>Notepad3 develop</description>

View File

@ -316,9 +316,7 @@ void _ClearTextBuffer(HWND hwnd)
if (SciCall_GetReadOnly()) { SciCall_SetReadOnly(false); }
EditClearAllOccurrenceMarkers();
if (EditToggleView(Globals.hwndEdit, false)) {
EditToggleView(Globals.hwndEdit, true);
}
if (Globals.bHideNonMatchedLines) { EditToggleView(hwnd); }
SendMessage(hwnd, SCI_CLEARALL, 0, 0);
SendMessage(hwnd, SCI_MARKERDELETEALL, (WPARAM)MARKER_NP3_BOOKMARK, 0);
@ -4428,7 +4426,7 @@ void EditSetSelectionEx(HWND hwnd, DocPos iAnchorPos, DocPos iCurrentPos, DocPos
// remember x-pos for moving caret vertically
SciCall_ChooseCaretX();
EditApplyVisibleStyle();
EditApplyVisibleStyle(hwnd);
UpdateToolbar();
UpdateStatusbar(false);
@ -5261,9 +5259,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
Globals.iReplacedOccurrences = 0;
Globals.FindReplaceMatchFoundState = FND_NOP;
if (EditToggleView(Globals.hwndEdit, false)) {
EditToggleView(Globals.hwndEdit, true);
}
if (Globals.bHideNonMatchedLines) { EditToggleView(hwnd); }
MarkAllOccurrences(50, true);
if (s_InitialTopLine >= 0) {
@ -5456,7 +5452,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
if (sg_pefrData->bMarkOccurences) {
if (sg_pefrData->bStateChanged || (StringCchCompareXA(s_lastFind, sg_pefrData->szFind) != 0)) {
_IGNORE_NOTIFY_CHANGE_;
if (EditToggleView(Globals.hwndEdit, false)) { _DeleteLineStateAll(LINESTATE_OCCURRENCE_MARK); }
if (Globals.bHideNonMatchedLines) { _DeleteLineStateAll(LINESTATE_OCCURRENCE_MARK); }
StringCchCopyA(s_lastFind, COUNTOF(s_lastFind), sg_pefrData->szFind);
RegExResult_t match = _FindHasMatch(Globals.hwndEdit, sg_pefrData, 0, (sg_pefrData->bMarkOccurences), false);
if (s_anyMatch != match) { s_anyMatch = match; }
@ -5480,7 +5476,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
}
}
_OBSERVE_NOTIFY_CHANGE_;
if (EditToggleView(Globals.hwndEdit, false)) { EditHideNotMarkedLineRange(Globals.hwndEdit, -1, -1, true); }
if (Globals.bHideNonMatchedLines) { EditHideNotMarkedLineRange(Globals.hwndEdit, 0, -1, true); }
}
}
else {
@ -5512,7 +5508,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
Settings.MarkOccurrencesMatchVisible = bSaveOccVisible;
//DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, (Settings.MarkOccurrences > 0) && !Settings.MarkOccurrencesMatchVisible);
DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, false);
if (EditToggleView(Globals.hwndEdit, false)) {
if (Globals.bHideNonMatchedLines) {
PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_TOGGLE_VISIBILITY, 1), 0);
}
InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true);
@ -5527,15 +5523,15 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
case IDC_TOGGLE_VISIBILITY:
if (EditToggleView(Globals.hwndEdit, false)) {
EditToggleView(Globals.hwndEdit, true);
if (Globals.bHideNonMatchedLines) {
EditToggleView(hwnd);
sg_pefrData->bStateChanged = true;
s_InitialTopLine = -1;
EditClearAllOccurrenceMarkers();
_DelayMarkAll(hwnd, 0, s_InitialSearchStart);
}
else {
EditToggleView(Globals.hwndEdit, true);
EditToggleView(hwnd);
}
break;
@ -6149,11 +6145,7 @@ void EditUpdateVisibleUrlHotspot(bool bEnabled)
DocLn const iEndLine = min_ln((iStartLine + SciCall_LinesOnScreen()), (SciCall_GetLineCount() - 1));
_IGNORE_NOTIFY_CHANGE_;
_ENTER_TARGET_TRANSACTION_;
EditUpdateUrlHotspots(Globals.hwndEdit, SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine), bEnabled);
_LEAVE_TARGET_TRANSACTION_;
_OBSERVE_NOTIFY_CHANGE_;
}
}
@ -6162,15 +6154,19 @@ void EditUpdateVisibleUrlHotspot(bool bEnabled)
//
// EditApplyVisibleStyle()
//
void EditApplyVisibleStyle()
void EditApplyVisibleStyle(HWND hwnd)
{
DocLn const iStartLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine());
DocLn const iEndLine = min_ln((iStartLine + SciCall_LinesOnScreen()), (SciCall_GetLineCount() - 1));
Sci_ApplyStyle(SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine));
if (Settings.HyperlinkHotspot && !_IsInTargetTransaction()) {
EditUpdateUrlHotspots(hwnd, SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine), true);
}
else if (!Globals.bHideNonMatchedLines) {
Sci_ApplyStyle(SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine));
}
}
//=============================================================================
//
// _GetReplaceString()
@ -6468,50 +6464,40 @@ void EditClearAllOccurrenceMarkers()
//
// EditToggleView()
//
bool EditToggleView(HWND hwnd, bool bToggleView)
void EditToggleView(HWND hwnd)
{
UNUSED(hwnd);
static bool bHideNonMatchedLines = false;
if (bToggleView)
{
bool const bWaitCursor = ((Globals.iMarkOccurrencesCount > 1000) || (SciCall_GetLineCount() > 2000)) ? true : false;
static bool bSaveHyperlinkHotspots = false;
static bool bSaveFoldingAvailable = false;
static bool bSaveShowFolding = false;
if (bWaitCursor) { BeginWaitCursor(NULL); }
_IGNORE_NOTIFY_CHANGE_;
if (!bHideNonMatchedLines) {
bSaveFoldingAvailable = Globals.bCodeFoldingAvailable;
bSaveShowFolding = Settings.ShowCodeFolding;
bSaveHyperlinkHotspots = Settings.HyperlinkHotspot;
Settings.HyperlinkHotspot = false;
}
else {
Globals.bCodeFoldingAvailable = bSaveFoldingAvailable;
Settings.ShowCodeFolding = bSaveShowFolding;
Settings.HyperlinkHotspot = bSaveHyperlinkHotspots;
}
EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_HYPERLINKHOTSPOTS, Settings.HyperlinkHotspot);
static bool bSaveFoldingAvailable = false;
static bool bSaveShowFolding = false;
bHideNonMatchedLines = bHideNonMatchedLines ? false : true; // toggle
bool const bWaitCursor = ((Globals.iMarkOccurrencesCount > 1000) || (SciCall_GetLineCount() > 2000)) ? true : false;
if (bWaitCursor) { BeginWaitCursor(NULL); }
_IGNORE_NOTIFY_CHANGE_;
EditHideNotMarkedLineRange(hwnd, -1, -1, bHideNonMatchedLines);
if (bHideNonMatchedLines) {
EditScrollTo(hwnd, 0, false);
SciCall_SetReadOnly(true);
}
else {
EditScrollTo(hwnd, Sci_GetCurrentLineNumber(), true);
SciCall_SetReadOnly(false);
}
_OBSERVE_NOTIFY_CHANGE_;
if (bWaitCursor) { EndWaitCursor(); }
if (!Globals.bHideNonMatchedLines) {
bSaveFoldingAvailable = Globals.bCodeFoldingAvailable;
bSaveShowFolding = Settings.ShowCodeFolding;
}
else {
Globals.bCodeFoldingAvailable = bSaveFoldingAvailable;
Settings.ShowCodeFolding = bSaveShowFolding;
}
return bHideNonMatchedLines;
}
Globals.bHideNonMatchedLines = !Globals.bHideNonMatchedLines; // toggle
EditHideNotMarkedLineRange(hwnd, 0, -1, Globals.bHideNonMatchedLines);
if (Globals.bHideNonMatchedLines) {
EditScrollTo(hwnd, 0, false);
SciCall_SetReadOnly(true);
}
else {
EditScrollTo(hwnd, Sci_GetCurrentLineNumber(), true);
SciCall_SetReadOnly(false);
}
_OBSERVE_NOTIFY_CHANGE_;
if (bWaitCursor) { EndWaitCursor(); }
}
//=============================================================================
@ -6871,6 +6857,8 @@ void EditUpdateUrlHotspots(HWND hwnd, DocPos startPos, DocPos endPos, bool bActi
// 1st apply current lexer style
EditFinalizeStyling(startPos);
_ENTER_TARGET_TRANSACTION_;
DocPos start = startPos;
DocPos end = endPos;
do {
@ -6897,10 +6885,13 @@ void EditUpdateUrlHotspots(HWND hwnd, DocPos startPos, DocPos endPos, bool bActi
} while (start < end);
_LEAVE_TARGET_TRANSACTION_;
SciCall_StartStyling(endPos);
}
//=============================================================================
//
// EditHideNotMarkedLineRange()
@ -6927,8 +6918,10 @@ void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, boo
for (DocLn iLine = 0; iLine < iLnCount; ++iLine) { SciCall_SetFoldLevel(iLine, SC_FOLDLEVELBASE); }
SciCall_SetFoldFlags(0);
Style_SetFolding(hwnd, Globals.bCodeFoldingAvailable && Settings.ShowCodeFolding);
Sci_ApplyStyle(0, -1);
SciCall_FoldAll(EXPAND);
Sci_ApplyStyle(0, -1);
EditUpdateUrlHotspots(hwnd, 0, -1, Settings.HyperlinkHotspot);
EditFinalizeStyling(-1);
}
else // ===== hide lines without marker =====
{

View File

@ -99,7 +99,7 @@ void EditPrintSetup(HWND);
void EditPrintInit();
void EditMatchBrace(HWND hwnd);
void EditClearAllOccurrenceMarkers();
bool EditToggleView(HWND hwnd, bool bToggleView);
void EditToggleView(HWND hwnd);
void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos rangeEnd, bool, bool);
void EditUpdateUrlHotspots(HWND hwnd, DocPos startPos, DocPos endPos, bool);
void EditSetAccelWordNav(HWND hwnd,bool);
@ -110,7 +110,7 @@ void EditSetBookmarkList(HWND hwnd,LPCWSTR pszBookMarks);
void EditFinalizeStyling(DocPos iEndPos);
void EditMarkAllOccurrences(HWND hwnd, bool bForceClear);
void EditUpdateVisibleUrlHotspot(bool);
void EditApplyVisibleStyle();
void EditApplyVisibleStyle(HWND hwnd);
void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, bool);

View File

@ -260,6 +260,8 @@ void ObserveNotifyChangeEvent()
InterlockedDecrement(&iNotifyChangeStackCounter);
}
if (CheckNotifyChangeEvent()) {
EditUpdateUrlHotspots(Globals.hwndEdit, 0, -1, Settings.HyperlinkHotspot);
EditFinalizeStyling(-1);
UpdateAllBars(false);
}
}
@ -482,6 +484,7 @@ static void _InitGlobals()
Globals.bIniFileFromScratch = false;
Globals.bFindReplCopySelOrClip = true;
Globals.bReplaceInitialized = false;
Globals.bHideNonMatchedLines = false;
Globals.FindReplaceMatchFoundState = FND_NOP;
Flags.bDevDebugMode = DefaultFlags.bDevDebugMode = false;
@ -1323,7 +1326,8 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
// update Scintilla colors
case WM_SYSCOLORCHANGE:
MarkAllOccurrences(0, true);
UpdateVisibleUrlHotspot(0);
EditUpdateUrlHotspots(Globals.hwndEdit, 0, -1, Settings.HyperlinkHotspot);
EditFinalizeStyling(-1);
UpdateAllBars(false);
return DefWindowProc(hwnd,umsg,wParam,lParam);
@ -2276,6 +2280,8 @@ LRESULT MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam)
SendWMSize(hwnd, rc);
UpdateUI();
EditUpdateUrlHotspots(Globals.hwndEdit, 0, -1, Settings.HyperlinkHotspot);
EditFinalizeStyling(-1);
UpdateAllBars(false);
return 0;
@ -2336,12 +2342,10 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam)
SendWMSize(hwnd, NULL);
if (EditToggleView(Globals.hwndEdit, false)) {
EditToggleView(Globals.hwndEdit, true);
}
if (Globals.bHideNonMatchedLines) { EditToggleView(Globals.hwndEdit); }
MarkAllOccurrences(0, true);
EditUpdateUrlHotspots(Globals.hwndEdit, 0, -1, Settings.HyperlinkHotspot);
EditFinalizeStyling(-1);
UpdateUI();
UpdateAllBars(false);
@ -3014,7 +3018,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_CASE, Settings.MarkOccurrencesMatchCase);
EnableCmd(hmenu, IDM_VIEW_TOGGLE_VIEW, (Settings.MarkOccurrences > 0) && !Settings.MarkOccurrencesMatchVisible);
CheckCmd(hmenu, IDM_VIEW_TOGGLE_VIEW, EditToggleView(Globals.hwndEdit, false));
CheckCmd(hmenu, IDM_VIEW_TOGGLE_VIEW, Globals.bHideNonMatchedLines);
if (Settings.MarkOccurrencesMatchWholeWords) {
i = IDM_VIEW_MARKOCCUR_WORD;
@ -4934,14 +4938,14 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break;
case IDM_VIEW_TOGGLE_VIEW:
if (EditToggleView(Globals.hwndEdit, false)) {
EditToggleView(Globals.hwndEdit, true);
if (Globals.bHideNonMatchedLines) {
EditToggleView(Globals.hwndEdit);
MarkAllOccurrences(0, true);
}
else {
EditToggleView(Globals.hwndEdit, true);
EditToggleView(Globals.hwndEdit);
}
CheckCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, EditToggleView(Globals.hwndEdit, false));
CheckCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, Globals.bHideNonMatchedLines);
UpdateToolbar();
break;
@ -6460,9 +6464,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam)
_SetSaveNeededFlag(true);
}
else if (pnmh->code == SCN_MODIFYATTEMPTRO) {
if (EditToggleView(Globals.hwndEdit, false)) {
EditToggleView(Globals.hwndEdit, true);
}
if (Globals.bHideNonMatchedLines) { EditToggleView(Globals.hwndEdit); }
}
}
return TRUE;
@ -6564,7 +6566,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam)
if (Settings.HyperlinkHotspot) {
UpdateVisibleUrlHotspot(Settings2.UpdateDelayHyperlinkStyling);
}
EditApplyVisibleStyle();
//@@@~EditApplyVisibleStyle(Globals.hwndEdit);
}
}
break;
@ -8422,7 +8424,7 @@ static void _UpdateToolbarDelayed()
bool b1 = SciCall_IsSelectionEmpty();
bool b2 = (bool)(SciCall_GetTextLength() > 0);
bool ro = SciCall_GetReadOnly();
bool tv = EditToggleView(Globals.hwndEdit, false);
bool tv = Globals.bHideNonMatchedLines;
EnableTool(IDT_EDIT_UNDO, SciCall_CanUndo() && !ro);
EnableTool(IDT_EDIT_REDO, SciCall_CanRedo() && !ro);
@ -9164,7 +9166,7 @@ void UpdateMarginWidth()
SciCall_SetMarginWidthN(MARGIN_SCI_LINENUM, 0);
}
if (!EditToggleView(Globals.hwndEdit, false)) {
if (!Globals.bHideNonMatchedLines) {
Style_SetBookmark(Globals.hwndEdit, Settings.ShowSelectionMargin);
Style_SetFolding(Globals.hwndEdit, (Globals.bCodeFoldingAvailable && Settings.ShowCodeFolding));
}
@ -9197,10 +9199,9 @@ void UpdateUI()
scn.nmhdr.hwndFrom = Globals.hwndEdit;
scn.nmhdr.idFrom = IDC_EDIT;
scn.nmhdr.code = SCN_UPDATEUI;
scn.updated = (SC_UPDATE_CONTENT | SC_UPDATE_NP3_INTERNAL_NOTIFY);
scn.updated = (SC_UPDATE_CONTENT/* | SC_UPDATE_NP3_INTERNAL_NOTIFY */);
SendMessage(Globals.hwndMain, WM_NOTIFY, IDC_EDIT, (LPARAM)&scn);
//PostMessage(Globals.hwndMain, WM_NOTIFY, IDC_EDIT, (LPARAM)&scn);
Sci_ApplyStyle(0, -1);
COND_SHOW_ZOOM_CALLTIP();
}
@ -9581,9 +9582,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
fioStatus.iEncoding = CPI_ANSI_DEFAULT;
if (bNew || bReload) {
if (EditToggleView(Globals.hwndEdit, false)) {
EditToggleView(Globals.hwndEdit, true);
}
if (Globals.bHideNonMatchedLines) { EditToggleView(Globals.hwndEdit); }
}
if (!bDontSave)
@ -9760,7 +9759,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
//bReadOnly = false;
_SetSaveNeededFlag(false);
UpdateVisibleUrlHotspot(0);
UpdateAllBars(false);
UpdateAllBars(true);
// consistent settings file handling (if loaded in editor)
s_bEnableSaveSettings = (StringCchCompareNIW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile), Globals.IniFile, COUNTOF(Globals.IniFile)) == 0) ? false : true;

View File

@ -144,7 +144,7 @@ void UpdateStatusbar(bool);
void UpdateMarginWidth();
void UpdateSettingsCmds();
void UpdateVisibleUrlHotspot(int delay);
inline void UpdateAllBars(bool force) { UpdateToolbar(); UpdateStatusbar(force); UpdateMarginWidth(); Sci_ApplyStyle(0,-1); }
inline void UpdateAllBars(bool force) { UpdateToolbar(); UpdateStatusbar(force); UpdateMarginWidth(); }
void UndoRedoRecordingStart();
void UndoRedoRecordingStop();

View File

@ -498,11 +498,11 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam,
SendDlgItemMessage(hwnd,1137,CB_SETEXTENDEDUI,true,0);
SendDlgItemMessage(hwnd,1138,CB_SETEXTENDEDUI,true,0);
}
return true;
break;
case WM_DPICHANGED:
UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0);
return true;
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
@ -519,12 +519,12 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam,
{
PostMessage(hwnd, WM_COMMAND, MAKELONG(1026, 1), 0);
}
return true;
break;
default:
break;
}
return false;
return 0;
}

View File

@ -1308,10 +1308,12 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
}
Style_SetInvisible(hwnd, false); // set fixed invisible style
Style_SetUrlHotSpot(hwnd, Settings.HyperlinkHotspot);
// apply lexer styles
Style_SetUrlHotSpot(hwnd, Settings.HyperlinkHotspot);
Sci_ApplyStyle(0, -1);
EditUpdateUrlHotspots(hwnd, 0, -1, Settings.HyperlinkHotspot);
EditFinalizeStyling(-1);
UpdateAllBars(false);
}
@ -1860,14 +1862,17 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
void Style_SetLexerFromName(HWND hwnd,LPCWSTR lpszFile,LPCWSTR lpszName)
{
PEDITLEXER pLexNew = Style_MatchLexer(lpszName, false);
if (pLexNew)
Style_SetLexer(hwnd,pLexNew);
if (pLexNew) {
Style_SetLexer(hwnd, pLexNew);
}
else {
pLexNew = Style_MatchLexer(lpszName, true);
if (pLexNew)
if (pLexNew) {
Style_SetLexer(hwnd, pLexNew);
else
}
else {
Style_SetLexerFromFile(hwnd, lpszFile);
}
}
}
@ -1898,7 +1903,7 @@ void Style_SetDefaultLexer(HWND hwnd)
//
void Style_SetHTMLLexer(HWND hwnd)
{
Style_SetLexer(hwnd,Style_MatchLexer(L"Web Source Code",true));
Style_SetLexer(hwnd,&lexHTML);
}
@ -1908,7 +1913,7 @@ void Style_SetHTMLLexer(HWND hwnd)
//
void Style_SetXMLLexer(HWND hwnd)
{
Style_SetLexer(hwnd,Style_MatchLexer(L"XML Document",true));
Style_SetLexer(hwnd,&lexXML);
}

View File

@ -308,6 +308,7 @@ typedef struct _globals_t
bool bIniFileFromScratch;
bool bFindReplCopySelOrClip;
bool bReplaceInitialized;
bool bHideNonMatchedLines;
FR_STATES FindReplaceMatchFoundState;

View File

@ -8,7 +8,7 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 19
#define VERSION_REV 427
#define VERSION_BUILD 1676
#define VERSION_BUILD 1678
#define SCINTILLA_VER 415
#define ONIGMO_REGEX_VER 6.2.0
#define VERSION_PATCH develop