diff --git a/src/Edit.c b/src/Edit.c index 14f4413a5..4f9d51f6e 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -189,7 +189,6 @@ HWND EditCreate(HWND hwndParent) SendMessage(hwnd, SCI_INDICSETALPHA, INDIC_NP3_BAD_BRACE, 120); SendMessage(hwnd, SCI_INDICSETOUTLINEALPHA, INDIC_NP3_BAD_BRACE, 120); - // word delimiter handling EditInitWordDelimiter(hwnd); EditSetAccelWordNav(hwnd,bAccelWordNavigation); @@ -323,7 +322,7 @@ BOOL EditConvertText(HWND hwnd,int encSource,int encDest,BOOL bSetSavePoint) if (!(Encoding_IsValid(encSource) && Encoding_IsValid(encDest))) return(FALSE); - length = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + length = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); if (length == 0) { @@ -626,7 +625,7 @@ BOOL EditCopyAppend(HWND hwnd) } } else { - int cchText = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + int cchText = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); pszText = LocalAlloc(LPTR,cchText + 1); SendMessage(hwnd,SCI_GETTEXT,(int)LocalSize(pszText),(LPARAM)pszText); } @@ -1049,7 +1048,7 @@ BOOL EditSaveFile( EditStripTrailingBlanks(hwnd,TRUE); // get text - cbData = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + cbData = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); lpData = GlobalAlloc(GPTR, cbData + 4); //fix: +bom SendMessage(hwnd,SCI_GETTEXT,GlobalSize(lpData),(LPARAM)lpData); @@ -2174,8 +2173,7 @@ void EditMoveUp(HWND hwnd) SendMessage(hwnd,SCI_INSERTTEXT,(WPARAM)iLineDestStart,(LPARAM)chaEOL); SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM) SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLineDest,0),0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM) - SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0),0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)SciCall_GetTextLength(),0); SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); } @@ -2283,10 +2281,8 @@ void EditMoveDown(HWND hwnd) if (bLastLine) { SendMessage(hwnd,SCI_SETTARGETSTART,(WPARAM) - SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM) - SendMessage(hwnd,SCI_GETLINECOUNT,0,0)-2,0),0); - SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM) - SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0),0); + SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)SciCall_GetLineCount()-2,0),0); + SendMessage(hwnd,SCI_SETTARGETEND,(WPARAM)SciCall_GetTextLength(),0); SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)""); } @@ -2334,7 +2330,7 @@ void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend) //if (iSelStart == iSelEnd) { // iSelStart = 0; - // iSelEnd = SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + // iSelEnd = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); //} UINT mbcp = Encoding_SciGetCodePage(hwnd); @@ -3084,10 +3080,8 @@ void EditPadWithSpaces(HWND hwnd,BOOL bSkipEmpty,BOOL bNoUndoGroup) iRcAnchorLine = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iAnchorPos,0); iRcCurCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iCurPos,0); - //iRcCurCol += (int)SendMessage(hwnd, SCI_GETSELECTIONNCARETVIRTUALSPACE, 0, 0); iRcAnchorCol = (int)SendMessage(hwnd,SCI_GETCOLUMN,(WPARAM)iAnchorPos,0); - //iRcAnchorCol += (int)SendMessage(hwnd, SCI_GETSELECTIONNANCHORVIRTUALSPACE, 0, 0); bIsRectangular = TRUE; @@ -3099,7 +3093,6 @@ void EditPadWithSpaces(HWND hwnd,BOOL bSkipEmpty,BOOL bNoUndoGroup) int iPos = (int)SendMessage(hwnd,SCI_GETLINESELENDPOSITION,(WPARAM)iLine,0); if (iPos != INVALID_POSITION) { int iCol = (int)SendMessage(hwnd, SCI_GETCOLUMN, (WPARAM)iPos, 0); - //iCol += (int)SendMessage(hwndEdit, SCI_GETSELECTIONNCARETVIRTUALSPACE, 0, 0); iMaxColumn = max(iMaxColumn, iCol); } } @@ -3188,7 +3181,7 @@ void EditStripFirstCharacter(HWND hwnd) if (iSelStart == iSelEnd) { iSelStart = 0; - iSelEnd = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + iSelEnd = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); } if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) @@ -3235,7 +3228,7 @@ void EditStripLastCharacter(HWND hwnd) if (iSelStart == iSelEnd) { iSelStart = 0; - iSelEnd = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + iSelEnd = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); } if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) @@ -3341,7 +3334,7 @@ void EditCompressSpaces(HWND hwnd) int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); int iLineStart = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelStart,0); int iLineEnd = (int)SendMessage(hwnd,SCI_LINEFROMPOSITION,(WPARAM)iSelEnd,0); - int iLength = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + int iLength = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); char* pszIn; char* pszOut; @@ -3438,7 +3431,7 @@ void EditRemoveBlankLines(HWND hwnd,BOOL bMerge) if (iSelStart == iSelEnd) { iSelStart = 0; - iSelEnd = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + iSelEnd = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); } if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) @@ -4201,7 +4194,7 @@ void EditSelectEx(HWND hwnd,int iAnchorPos,int iCurrentPos) // void EditFixPositions(HWND hwnd) { - int iMaxPos = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0); + int iMaxPos = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); int iCurrentPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0); int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0); @@ -4275,7 +4268,7 @@ void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt) tr.chrg.cpMax = min(SendMessage(hwnd,SCI_GETLINEENDPOSITION,(WPARAM)iLine,0),(LONG)(tr.chrg.cpMin + COUNTOF(tch))); }*/ - tr.chrg.cpMax = min((int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0),tr.chrg.cpMax); + tr.chrg.cpMax = min((int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0), tr.chrg.cpMax); pszText = LocalAlloc(LPTR,(tr.chrg.cpMax - tr.chrg.cpMin)+2); pszTextW = LocalAlloc(LPTR,((tr.chrg.cpMax - tr.chrg.cpMin)*2)+2); @@ -5405,7 +5398,7 @@ BOOL EditReplace(HWND hwnd, LPCEDITFINDREPLACE lpefr) { // but this mayby not intended here if ((BOOL)SendMessage(hwnd, SCI_GETSELECTIONEMPTY, 0, 0)) { int start = (int)SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0); - int end = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, start, 0); + int end = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); int _start = start; int iPos = EditFindInTarget(hwnd, lpefr->szFind, StringCchLenA(lpefr->szFind, FNDRPL_BUFFER), @@ -5513,7 +5506,7 @@ int EditReplaceAllInRange(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bShowInfo, i BOOL EditReplaceAll(HWND hwnd,LPCEDITFINDREPLACE lpefr,BOOL bShowInfo) { int start = 0; - int end = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0); + int end = SciCall_GetTextLength(); int token = BeginSelUndoAction(); @@ -5793,6 +5786,54 @@ void EditCompleteWord(HWND hwnd, BOOL autoInsert) { } + +//============================================================================= +// +// EditUpdateUrlHotspots() +// Find and mark all URL hot-spots +// +void EditUpdateUrlHotspots(HWND hwnd, int startPos, int endPos) +{ + const char* pszUrlRegEx = "\\b(?:(?:https?|ftp|file)://|www\\.|ftp\\.)" + "(?:\\([-A-Z0-9+&@#/%=~_|$?!:,.]*\\)|[-A-Z0-9+&@#/%=~_|$?!:,.])*" + "(?:\\([-A-Z0-9+&@#/%=~_|$?!:,.]*\\)|[A-Z0-9+&@#/%=~_|$])"; + + const int iRegExLen = (int)strlen(pszUrlRegEx); + + if (endPos < startPos) { + int tmp = startPos; startPos = endPos; endPos = tmp; // swap + } + if (startPos < 0) { // current line only + int currPos = SciCall_GetCurrentPos(); + int lineNo = SciCall_LineFromPosition(currPos); + startPos = SciCall_PositionFromLine(lineNo); + endPos = SciCall_GetLineEndPosition(lineNo); + } + if (endPos == startPos) + return; + + int start = startPos; + int end = endPos; + while (TRUE) + { + int iPos = EditFindInTarget(hwnd, pszUrlRegEx, iRegExLen, SCFIND_NP3_REGEX, &start, &end, FALSE); + + if (iPos < 0) + break; // not found + + // mark this match + SciCall_StartStyling(iPos); + SciCall_SetStyling((end - start), Style_GetHotspotID(hwnd)); + + // next occurrence + start = end; + end = endPos; + if (start >= end) + break; + } +} + + //============================================================================= // // EditHighlightIfBrace() @@ -5834,15 +5875,17 @@ BOOL __fastcall EditHighlightIfBrace(HWND hwnd, int iPos) { // // EditMatchBrace() // -void EditMatchBrace(HWND hwnd) { - int iEndStyled = (int)SendMessage(hwnd, SCI_GETENDSTYLED, 0, 0); - if (iEndStyled < (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0)) { - int iLine = (int)SendMessage(hwnd, SCI_LINEFROMPOSITION, iEndStyled, 0); - int iEndStyled2 = (int)SendMessage(hwnd, SCI_POSITIONFROMLINE, iLine, 0); - SendMessage(hwnd, SCI_COLOURISE, iEndStyled2, -1); +void EditMatchBrace(HWND hwnd) +{ + int iEndStyled = SciCall_GetEndStyled(); + if (iEndStyled < SciCall_GetTextLength()) { + int iLine = SciCall_LineFromPosition(iEndStyled); + iEndStyled = SciCall_PositionFromLine(iLine); + SendMessage(hwnd, SCI_COLOURISE, iEndStyled, -1); + //~EditUpdateUrlHotspots(hwnd, iEndStyled, SciCall_GetLineEndPosition(iLine)); } - int iPos = (int)SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0); + int iPos = SciCall_GetCurrentPos(); if (!EditHighlightIfBrace(hwnd, iPos)) { // try one before diff --git a/src/Edit.h b/src/Edit.h index c355a7902..322b1f48e 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -20,6 +20,11 @@ BOOL Scintilla_RegisterClasses(void*); BOOL Scintilla_ReleaseResources(); + +//typedef Sci_Position tPos; +typedef ptrdiff_t tPos; + + #define FNDRPL_BUFFER 512 typedef struct _editfindreplace { @@ -51,6 +56,7 @@ typedef struct _editfindreplace #define INDIC_NP3_MATCH_BRACE 2 #define INDIC_NP3_BAD_BRACE 3 + HWND EditCreate(HWND); void EditInitWordDelimiter(HWND); void EditSetNewText(HWND,char*,DWORD); @@ -119,6 +125,7 @@ void EditPrintInit(); void EditMatchBrace(HWND); void EditClearAllMarks(HWND); void EditMarkAll(HWND,char*,int,BOOL,BOOL); +void EditUpdateUrlHotspots(HWND, int, int); void EditSetAccelWordNav(HWND,BOOL); void EditCompleteWord(HWND,BOOL); void EditGetBookmarkList(HWND,LPWSTR,int); diff --git a/src/Helpers.c b/src/Helpers.c index 6fe5995a3..1da2665da 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -6,8 +6,8 @@ * Helpers.c * * General helper functions * * Based on code from Notepad2, (c) Florian Balmer 1996-2011 * -* Parts taken from SciTE, (c) Neil Hodgson * -* MinimizeToTray, (c) 2000 Matthew Ellis * +* Parts taken from SciTE, (c) Neil Hodgson * +* MinimizeToTray, (c) 2000 Matthew Ellis * * * * (c) Rizonesoft 2008-2016 * * https://rizonesoft.com * diff --git a/src/Helpers.h b/src/Helpers.h index 651a5ad8c..421516fdb 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -439,7 +439,6 @@ inline HRESULT PathCchCanonicalize(PWSTR p,size_t l,PCWSTR a) { UNUSED(l); re inline HRESULT PathCchRenameExtension(PWSTR p,size_t l,PCWSTR a) { UNUSED(l); return (PathRenameExtension(p,a) ? S_OK : E_FAIL); } inline HRESULT PathCchRemoveFileSpec(PWSTR p,size_t l) { UNUSED(l); return (PathRemoveFileSpec(p) ? S_OK : E_FAIL); } - // special Drag and Drop Handling typedef struct tDROPDATA diff --git a/src/Notepad3.c b/src/Notepad3.c index 9a43d88c7..bc5089a06 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -131,6 +131,7 @@ BOOL bAutoIndent; BOOL bAutoCloseTags; BOOL bShowIndentGuides; BOOL bHiliteCurrentLine; +BOOL bHyperlinkHotspot; BOOL bTabsAsSpaces; BOOL bTabsAsSpacesG; BOOL bTabIndents; @@ -1030,6 +1031,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) UpdateToolbar(); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); // print file immediately and quit if (flagPrintFileAndLeave) @@ -1173,6 +1175,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) //UpdateToolbar(); //UpdateStatusbar(); //UpdateLineNumberWidth(); + //EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); //if (bPendingChangeNotify) // PostMessage(hwnd,WM_CHANGENOTIFY,0,0); break; @@ -1749,7 +1752,7 @@ void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam) UpdateToolbar(); UpdateStatusbar(); UpdateLineNumberWidth(); - + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); UNUSED(lParam); UNUSED(wParam); @@ -1830,6 +1833,7 @@ void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam) UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); UNUSED(hwnd); UNUSED(lParam); @@ -2026,6 +2030,7 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) UpdateToolbar(); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); } @@ -2388,7 +2393,8 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) i = (int)SendMessage(hwndEdit,SCI_GETLEXER,0,0); //EnableCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,(i == SCLEX_HTML || i == SCLEX_XML)); CheckCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,bAutoCloseTags /*&& (i == SCLEX_HTML || i == SCLEX_XML)*/); - CheckCmd(hmenu,IDM_VIEW_HILITECURRENTLINE,bHiliteCurrentLine); + CheckCmd(hmenu, IDM_VIEW_HILITECURRENTLINE, bHiliteCurrentLine); + CheckCmd(hmenu, IDM_VIEW_HYPERLINKHOTSPOTS, bHyperlinkHotspot); i = IniGetInt(L"Settings2",L"ReuseWindow",0); CheckCmd(hmenu,IDM_VIEW_REUSEWINDOW,i); @@ -2441,6 +2447,10 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) i = (StringCchLenW(szIniFile,COUNTOF(szIniFile)) > 0 || StringCchLenW(szIniFile2,COUNTOF(szIniFile2)) > 0); EnableCmd(hmenu,IDM_VIEW_SAVESETTINGSNOW,bEnableSaveSettings && i); + BOOL bIsHLink = ((int)SendMessage(hwndEdit, SCI_GETSTYLEAT, + SendMessage(hwndEdit, SCI_GETCURRENTPOS, 0, 0), 0) == Style_GetHotspotID(hwndEdit)); + EnableCmd(hmenu, CMD_OPEN_HYPERLINK, bIsHLink); + UNUSED(lParam); } @@ -2523,6 +2533,8 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) //SendMessage(hwndEdit,SCI_SETREADONLY,bReadOnly,0); //UpdateToolbar(); //UpdateStatusbar(); + //EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); + if (StringCchLenW(szCurFile,COUNTOF(szCurFile))) { DWORD dwFileAttributes = GetFileAttributes(szCurFile); @@ -2877,6 +2889,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) UpdateToolbar(); UpdateStatusbar(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); } } break; @@ -2920,6 +2933,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) EditFixPositions(hwndEdit); UpdateToolbar(); UpdateStatusbar(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); } break; @@ -3042,6 +3056,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) LocalFree(pClip); UpdateToolbar(); UpdateStatusbar(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); } break; @@ -4008,6 +4023,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) Style_SelectLexerDlg(hwndEdit); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; @@ -4015,6 +4031,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) Style_ToggleUse2ndDefault(hwndEdit); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; @@ -4022,6 +4039,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) Style_ConfigDlg(hwndEdit); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; @@ -4029,6 +4047,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) Style_SetDefaultFont(hwndEdit); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; @@ -4095,6 +4114,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) else SendMessage(hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0); UpdateStatusbar(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; @@ -4106,6 +4126,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) iLongLinesLimit = max(min(iLongLinesLimit,4096),0); SendMessage(hwndEdit,SCI_SETEDGECOLUMN,iLongLinesLimit,0); UpdateStatusbar(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); iLongLinesLimitG = iLongLinesLimit; } break; @@ -4281,9 +4302,16 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) case IDM_VIEW_HILITECURRENTLINE: bHiliteCurrentLine = (bHiliteCurrentLine) ? FALSE : TRUE; - Style_SetCurrentLineBackground(hwndEdit); + Style_SetCurrentLineBackground(hwndEdit, bHiliteCurrentLine); break; + case IDM_VIEW_HYPERLINKHOTSPOTS: + bHyperlinkHotspot = (bHyperlinkHotspot) ? FALSE : TRUE; + Style_SetUrlHotSpot(hwndEdit, bHyperlinkHotspot); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); + if (!bHyperlinkHotspot) + SendMessage(hwndEdit, SCI_COLOURISE, 0, (LPARAM)-1); + break; case IDM_VIEW_ZOOMIN: SendMessage(hwndEdit,SCI_ZOOMIN,0,0); @@ -4751,6 +4779,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) Style_SetDefaultLexer(hwndEdit); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; @@ -4758,6 +4787,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) Style_SetHTMLLexer(hwndEdit); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; @@ -4765,6 +4795,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) Style_SetXMLLexer(hwndEdit); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; @@ -5134,6 +5165,12 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) break; + case CMD_OPEN_HYPERLINK: + { + OpenHotSpotURL((int)SendMessage(hwndEdit, SCI_GETCURRENTPOS, 0, 0), FALSE); + } + break; + case IDT_FILE_NEW: if (IsCmdEnabled(hwnd,IDM_FILE_NEW)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_FILE_NEW,1),0); @@ -5340,6 +5377,103 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) } +//============================================================================= +// +// OpenHotSpotURL() - Handles WM_NOTIFY +// +// +void OpenHotSpotURL(int position, BOOL bForceBrowser) +{ + int iStyle = (int)SendMessage(hwndEdit, SCI_GETSTYLEAT, position, 0); + + if (Style_GetHotspotID(hwndEdit) != iStyle) + return; + + // get left most position of style + int pos = position; + int iNewStyle = iStyle; + while ((iNewStyle == iStyle) && (--pos > 0)) { + iNewStyle = (int)SendMessage(hwndEdit, SCI_GETSTYLEAT, pos, 0); + } + int firstPos = (pos != 0) ? (pos + 1) : 0; + + // get right most position of style + pos = position; + iNewStyle = iStyle; + int posTextLength = SciCall_GetTextLength(); + while ((iNewStyle == iStyle) && (++pos < posTextLength)) { + iNewStyle = (int)SendMessage(hwndEdit, SCI_GETSTYLEAT, pos, 0); + } + int lastPos = pos; + + int length = lastPos - firstPos; + + if ((length > 0) && (length < HUGE_BUFFER)) + { + char chURL[HUGE_BUFFER] = { '\0' }; + struct Sci_TextRange tr = { { 0, -1 }, NULL }; + tr.chrg.cpMin = (Sci_PositionCR)firstPos; + tr.chrg.cpMax = (Sci_PositionCR)lastPos; + tr.lpstrText = chURL; + + SendMessage(hwndEdit, SCI_GETTEXTRANGE, 0, (LPARAM)&tr); + + StrTrimA(chURL, " \t\n\r"); + + if (!StringCchLenA(chURL, COUNTOF(chURL))) + return; + + WCHAR wchURL[HUGE_BUFFER] = { L'\0' }; + MultiByteToWideCharStrg(Encoding_SciGetCodePage(hwndEdit), chURL, wchURL); + + const WCHAR* chkPreFix = L"file://"; + const int len = lstrlen(chkPreFix); + + if (!bForceBrowser && (StrStrIW(wchURL, chkPreFix) == wchURL)) + { + WCHAR* szFileName = &(wchURL[len]); + StrTrimW(szFileName, L"/"); + + PathCanonicalizeEx(szFileName, COUNTOF(wchURL) - len); + + if (PathIsDirectory(szFileName)) + { + WCHAR tchFile[MAX_PATH + 1] = { L'\0' }; + + if (OpenFileDlg(hwndMain, tchFile, COUNTOF(tchFile), szFileName)) + FileLoad(FALSE, FALSE, FALSE, FALSE, tchFile); + } + else + FileLoad(FALSE, FALSE, FALSE, FALSE, szFileName); + + } + else { // open in web browser + + WCHAR wchDirectory[MAX_PATH] = { L'\0' }; + if (StringCchLenW(szCurFile, COUNTOF(szCurFile))) { + StringCchCopy(wchDirectory, COUNTOF(wchDirectory), szCurFile); + PathRemoveFileSpec(wchDirectory); + } + + SHELLEXECUTEINFO sei; + ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO)); + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = SEE_MASK_NOZONECHECKS; + sei.hwnd = NULL; + sei.lpVerb = NULL; + sei.lpFile = wchURL; + sei.lpParameters = NULL; + sei.lpDirectory = wchDirectory; + sei.nShow = SW_SHOWNORMAL; + ShellExecuteEx(&sei); + + } + + } +} + + + //============================================================================= // // MsgNotify() - Handles WM_NOTIFY @@ -5357,6 +5491,19 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) switch(pnmh->code) { + case SCN_HOTSPOTCLICK: + { + if (scn->modifiers & SCMOD_CTRL) { + // open in browser + OpenHotSpotURL((int)scn->position, TRUE); + } + if (scn->modifiers & SCMOD_ALT) { + // open in application, if applicable (file://) + OpenHotSpotURL((int)scn->position, FALSE); + } + } + break; + case SCN_UPDATEUI: if (scn->updated & ~(SC_UPDATE_V_SCROLL | SC_UPDATE_H_SCROLL)) { @@ -5374,6 +5521,15 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) UpdateToolbar(); UpdateStatusbar(); } + break; // fall-through -> bad responsive UI !!! + + case SCN_STYLENEEDED: // this event needs SCI_SETLEXER(SCLEX_CONTAINER) + { + if (bHyperlinkHotspot) { + int lineNumber = SciCall_LineFromPosition(SciCall_GetEndStyled()); + EditUpdateUrlHotspots(hwndEdit, SciCall_PositionFromLine(lineNumber), (int)scn->position); + } + } break; case SCN_CHARADDED: @@ -5513,6 +5669,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) } else if (bAutoCompleteWords && !SendMessage(hwndEdit, SCI_AUTOCACTIVE, 0, 0)) EditCompleteWord(hwndEdit, FALSE); + break; case SCN_MODIFIED: @@ -5537,6 +5694,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) case SCN_SAVEPOINTREACHED: bModified = FALSE; UpdateToolbar(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; case SCN_MARGINCLICK: @@ -5552,6 +5710,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) case SCN_SAVEPOINTLEFT: bModified = TRUE; UpdateToolbar(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); break; } break; @@ -5758,6 +5917,8 @@ void LoadSettings() bHiliteCurrentLine = IniSectionGetBool(pIniSection,L"HighlightCurrentLine",FALSE); + bHyperlinkHotspot = IniSectionGetBool(pIniSection, L"HyperlinkHotspot", TRUE); + bAutoIndent = IniSectionGetBool(pIniSection,L"AutoIndent",TRUE); bAutoCompleteWords = IniSectionGetBool(pIniSection,L"AutoCompleteWords",FALSE); @@ -6078,6 +6239,7 @@ void SaveSettings(BOOL bSaveSettingsNow) { IniSectionSetBool(pIniSection, L"MatchBraces", bMatchBraces); IniSectionSetBool(pIniSection, L"AutoCloseTags", bAutoCloseTags); IniSectionSetBool(pIniSection, L"HighlightCurrentLine", bHiliteCurrentLine); + IniSectionSetBool(pIniSection, L"HyperlinkHotspot", bHyperlinkHotspot); IniSectionSetBool(pIniSection, L"AutoIndent", bAutoIndent); IniSectionSetBool(pIniSection, L"AutoCompleteWords", bAutoCompleteWords); IniSectionSetBool(pIniSection, L"AccelWordNavigation", bAccelWordNavigation); @@ -7457,7 +7619,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp InstallFileWatching(szCurFile); // the .LOG feature ... - if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) { + if (SciCall_GetTextLength() >= 4) { char tchLog[5] = { '\0' }; SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tchLog); if (StringCchCompareXA(tchLog,".LOG") == 0) { @@ -7486,6 +7648,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp UpdateToolbar(); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); // consistent settings file handling (if loaded in editor) bEnableSaveSettings = (StringCchCompareINW(szCurFile, COUNTOF(szCurFile), szIniFile, COUNTOF(szIniFile)) == 0) ? FALSE : TRUE; @@ -7653,6 +7816,7 @@ BOOL FileSave(BOOL bSaveAlways,BOOL bAsk,BOOL bSaveAs,BOOL bSaveCopy) Style_SetLexerFromFile(hwndEdit,szCurFile); UpdateStatusbar(); UpdateLineNumberWidth(); + EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength()); } else { StringCchCopy(tchLastSaveCopyDir,COUNTOF(tchLastSaveCopyDir),tchFile); diff --git a/src/Notepad3.h b/src/Notepad3.h index 08929339d..9c363e66d 100644 --- a/src/Notepad3.h +++ b/src/Notepad3.h @@ -149,6 +149,7 @@ int BeginSelUndoAction(); void EndSelUndoAction(int); void RestoreSelectionAction(int,DoAction); int UndoRedoSelectionMap(int,UndoRedoSelection_t*); +void OpenHotSpotURL(int, BOOL); BOOL FileIO(BOOL,LPCWSTR,BOOL,int*,int*,BOOL*,BOOL*,BOOL*,BOOL*,BOOL); diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 29cd5110f..d1721127a 100644 Binary files a/src/Notepad3.rc and b/src/Notepad3.rc differ diff --git a/src/SciCall.h b/src/SciCall.h index 6c1dc2cf4..269c835d0 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -83,11 +83,15 @@ __forceinline LRESULT SciCall_##fn(type1 var1, type2 var2) { \ // // DeclareSciCallR0(GetLineCount, GETLINECOUNT, int); +DeclareSciCallR0(GetTextLength, GETTEXTLENGTH, int); DeclareSciCallV2(SetSel, SETSEL, int, anchorPos, int, currentPos); DeclareSciCallV1(GotoPos, GOTOPOS, int, position); DeclareSciCallV1(GotoLine, GOTOLINE, int, line); DeclareSciCallR0(GetCurrentPos, GETCURRENTPOS, int); DeclareSciCallR1(LineFromPosition, LINEFROMPOSITION, int, Sci_Position, position); +DeclareSciCallR1(PositionFromLine, POSITIONFROMLINE, int, Sci_Position, line); +DeclareSciCallR1(GetLineEndPosition, GETLINEENDPOSITION, int, Sci_Position, line); +DeclareSciCallR0(GetEndStyled, GETENDSTYLED, int); //============================================================================= @@ -107,7 +111,8 @@ DeclareSciCallV2(SetYCaretPolicy, SETYCARETPOLICY, int, caretPolicy, int, caretS // DeclareSciCallR1(StyleGetFore, STYLEGETFORE, COLORREF, int, styleNumber); DeclareSciCallR1(StyleGetBack, STYLEGETBACK, COLORREF, int, styleNumber); - +DeclareSciCallV1(StartStyling, STARTSTYLING, Sci_Position, position); +DeclareSciCallV2(SetStyling, SETSTYLING, Sci_PositionCR, length, int, style); //============================================================================= // diff --git a/src/Styles.c b/src/Styles.c index 248c059a8..a1f98e308 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -71,25 +71,26 @@ EDITLEXER lexDefault = { SCLEX_NULL, 63000, L"Default Text", L"txt; text; wtx; /* 11 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63111, L"Extra Line Spacing (Size)", L"size:2", L"" }, /* 12 */ { SCI_MARKERSETBACK+SCI_MARKERSETALPHA, 63124, L"Book Marks (Colors)", L"back:#00FF00; alpha:20", L"" }, /* 13 */ { SCI_MARKERSETBACK+SCI_MARKERSETALPHA, 63262, L"Mark Occurrences (Colors)", L"", L"" }, - - /* 14 */ { STYLE_DEFAULT, 63112, L"2nd Default Style", L"font:Courier New; size:10", L"" }, - /* 15 */ { STYLE_LINENUMBER, 63113, L"2nd Margins and Line Numbers", L"font:Tahoma; size:-2; fore:#FF0000", L"" }, - /* 16 */ { STYLE_BRACELIGHT, 63114, L"2nd Matching Braces", L"bold; fore:#FF0000", L"" }, - /* 17 */ { STYLE_BRACEBAD, 63115, L"2nd Matching Braces Error", L"bold; fore:#000080", L"" }, - /* 18 */ { STYLE_CONTROLCHAR, 63116, L"2nd Control Characters (Font)", L"size:-1", L"" }, - /* 19 */ { STYLE_INDENTGUIDE, 63117, L"2nd Indentation Guide (Color)", L"fore:#A0A0A0", L"" }, - /* 20 */ { SCI_SETSELFORE+SCI_SETSELBACK, 63118, L"2nd Selected Text (Colors)", L"eolfilled", L"" }, - /* 21 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK+SCI_SETWHITESPACESIZE, 63119, L"2nd Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" }, - /* 22 */ { SCI_SETCARETLINEBACK, 63120, L"2nd Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" }, - /* 23 */ { SCI_SETCARETFORE+SCI_SETCARETWIDTH, 63121, L"2nd Caret (Color, Size 1-3)", L"", L"" }, - /* 24 */ { SCI_SETEDGECOLOUR, 63122, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" }, - /* 25 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63123, L"2nd Extra Line Spacing (Size)", L"", L"" }, - /* 26 */ { SCI_MARKERSETBACK+SCI_MARKERSETALPHA, 63125, L"2nd Book Marks (Colors)", L"back:#00FF00; alpha:20", L"" }, - /* 27 */ { SCI_MARKERSETBACK+SCI_MARKERSETALPHA, 63263, L"2nd Mark Occurrences (Colors)", L"fore:#0x00FF00; alpha:100; alpha2:100", L"" }, + /* 14 */ { SCI_SETHOTSPOTACTIVEFORE, 63264, L"Hyperlink Hotspots", L"italics; fore:#0000FF", L"" }, + + /* 15 */ { STYLE_DEFAULT, 63112, L"2nd Default Style", L"font:Courier New; size:10", L"" }, + /* 16 */ { STYLE_LINENUMBER, 63113, L"2nd Margins and Line Numbers", L"font:Tahoma; size:-2; fore:#FF0000", L"" }, + /* 17 */ { STYLE_BRACELIGHT, 63114, L"2nd Matching Braces", L"bold; fore:#FF0000", L"" }, + /* 18 */ { STYLE_BRACEBAD, 63115, L"2nd Matching Braces Error", L"bold; fore:#000080", L"" }, + /* 19 */ { STYLE_CONTROLCHAR, 63116, L"2nd Control Characters (Font)", L"size:-1", L"" }, + /* 20 */ { STYLE_INDENTGUIDE, 63117, L"2nd Indentation Guide (Color)", L"fore:#A0A0A0", L"" }, + /* 21 */ { SCI_SETSELFORE + SCI_SETSELBACK, 63118, L"2nd Selected Text (Colors)", L"eolfilled", L"" }, + /* 22 */ { SCI_SETWHITESPACEFORE + SCI_SETWHITESPACEBACK + SCI_SETWHITESPACESIZE, 63119, L"2nd Whitespace (Colors, Size 0-5)", L"fore:#FF4000", L"" }, + /* 23 */ { SCI_SETCARETLINEBACK, 63120, L"2nd Current Line Background (Color)", L"back:#FFFF00; alpha:50", L"" }, + /* 24 */ { SCI_SETCARETFORE + SCI_SETCARETWIDTH, 63121, L"2nd Caret (Color, Size 1-3)", L"", L"" }, + /* 25 */ { SCI_SETEDGECOLOUR, 63122, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" }, + /* 26 */ { SCI_SETEXTRAASCENT + SCI_SETEXTRADESCENT, 63123, L"2nd Extra Line Spacing (Size)", L"", L"" }, + /* 27 */ { SCI_MARKERSETBACK+SCI_MARKERSETALPHA, 63125, L"2nd Book Marks (Colors)", L"back:#00FF00; alpha:20", L"" }, + /* 28 */ { SCI_MARKERSETBACK+SCI_MARKERSETALPHA, 63263, L"2nd Mark Occurrences (Colors)", L"fore:#0x00FF00; alpha:100; alpha2:100", L"" }, + /* 29 */ { SCI_SETHOTSPOTACTIVEFORE, 63265, L"2nd Hyperlink Hotspots", L"bold; fore:#FF0000", L"" }, { -1, 00000, L"", L"", L"" } } }; - enum LexDefaultStyles { STY_DEFAULT = 0, STY_MARGIN = 1, @@ -105,8 +106,9 @@ enum LexDefaultStyles { STY_X_LN_SPACE = 11, STY_BOOK_MARK = 12, STY_MARK_OCC = 13, + STY_URL_HOTSPOT = 14, - STY_CNT_LAST = 14 // STY_2ND_XXX = STY_XXX + STY_CNT_LAST + STY_CNT_LAST = 15 // STY_2ND_XXX = STY_XXX + STY_CNT_LAST }; @@ -2845,6 +2847,7 @@ int cyStyleSelectDlg; extern int iDefaultCharSet; extern BOOL bHiliteCurrentLine; +extern BOOL bHyperlinkHotspot; extern BOOL bShowSelectionMargin; @@ -3168,11 +3171,16 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { fIsConsolasAvailable = IsFontAvailable(L"Consolas"); // Clear + SendMessage(hwnd, SCI_STYLECLEARALL, 0, 0); SendMessage(hwnd, SCI_CLEARDOCUMENTSTYLE, 0, 0); + // Idle Styling (very large text) + //SendMessage(hwnd, SCI_SETIDLESTYLING, SC_IDLESTYLING_ALL, 0); + // Default Values are always set SendMessage(hwnd, SCI_STYLERESETDEFAULT, 0, 0); SendMessage(hwnd, SCI_STYLESETCHARACTERSET, STYLE_DEFAULT, (LPARAM)DEFAULT_CHARSET); + iBaseFontSize = 10; Style_SetStyles(hwnd, lexDefault.Styles[STY_DEFAULT + iIdx].iStyle, lexDefault.Styles[STY_DEFAULT + iIdx].szValue); // default Style_StrGetSize(lexDefault.Styles[STY_DEFAULT + iIdx].szValue, &iBaseFontSize); // base size @@ -3187,7 +3195,6 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { if (pLexNew->iLexer != SCLEX_NULL || pLexNew == &lexANSI) Style_SetStyles(hwnd, pLexNew->Styles[STY_DEFAULT].iStyle, pLexNew->Styles[STY_DEFAULT].szValue); // lexer default - SendMessage(hwnd, SCI_STYLECLEARALL, 0, 0); Style_SetStyles(hwnd, lexDefault.Styles[STY_MARGIN + iIdx].iStyle, lexDefault.Styles[STY_MARGIN + iIdx].szValue); // linenumber @@ -3250,11 +3257,13 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { SendMessage(hwnd, SCI_INDICSETOUTLINEALPHA, INDIC_NP3_MARK_OCCURANCE, iValue); + // More default values... + if (pLexNew != &lexANSI) Style_SetStyles(hwnd, lexDefault.Styles[STY_CTRL_CHR + iIdx].iStyle, lexDefault.Styles[STY_CTRL_CHR + iIdx].szValue); // control char + Style_SetStyles(hwnd, lexDefault.Styles[STY_INDENT_GUIDE + iIdx].iStyle, lexDefault.Styles[STY_INDENT_GUIDE + iIdx].szValue); // indent guide - // More default values... if (Style_StrGetColor(TRUE, lexDefault.Styles[STY_SEL_TXT + iIdx].szValue, &rgb)) { // selection fore SendMessage(hwnd, SCI_SETSELFORE, TRUE, rgb); SendMessage(hwnd, SCI_SETADDITIONALSELFORE, rgb, 0); @@ -3326,24 +3335,8 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { } SendMessage(hwnd, SCI_SETWHITESPACESIZE, iValue, 0); - if (bHiliteCurrentLine) { - - if (Style_StrGetColor(FALSE, lexDefault.Styles[STY_CUR_LN_BCK + iIdx].szValue, &rgb)) // caret line back - { - SendMessage(hwnd, SCI_SETCARETLINEVISIBLE, TRUE, 0); - SendMessage(hwnd, SCI_SETCARETLINEBACK, rgb, 0); - - if (Style_StrGetAlpha(lexDefault.Styles[STY_CUR_LN_BCK + iIdx].szValue, &iValue, TRUE)) - SendMessage(hwnd, SCI_SETCARETLINEBACKALPHA, iValue, 0); - else - SendMessage(hwnd, SCI_SETCARETLINEBACKALPHA, SC_ALPHA_NOALPHA, 0); - } - else - SendMessage(hwnd, SCI_SETCARETLINEVISIBLE, FALSE, 0); - } - else - SendMessage(hwnd, SCI_SETCARETLINEVISIBLE, FALSE, 0); - + // current line background + Style_SetCurrentLineBackground(hwnd, bHiliteCurrentLine); // bookmark line or marker Style_SetCurrentMargin(hwnd, bShowSelectionMargin); @@ -3559,13 +3552,65 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { } } + // set URL Hotspot style + Style_SetUrlHotSpot(hwnd, bHyperlinkHotspot); + SendMessage(hwnd,SCI_COLOURISE,0,(LPARAM)-1); + EditUpdateUrlHotspots(hwnd, 0, SciCall_GetTextLength()); + // Save current lexer pLexCurrent = pLexNew; } +//============================================================================= +// +// Style_SetUrlHotSpot() +// +void Style_SetUrlHotSpot(HWND hwnd, BOOL bHotSpot) +{ + // Use 2nd default style ? + int iIdx = (bUse2ndDefaultStyle) ? STY_CNT_LAST : 0; + + // Hot Spot settings + const int iStyleHotSpot = (STY_URL_HOTSPOT + iIdx); + + if (bHotSpot) + { + const WCHAR* lpszStyleHotSpot = lexDefault.Styles[iStyleHotSpot].szValue; + + SendMessage(hwnd, SCI_STYLESETHOTSPOT, iStyleHotSpot, (LPARAM)TRUE); + SendMessage(hwnd, SCI_SETHOTSPOTSINGLELINE, TRUE, 0); + + // Font + Style_SetStyles(hwnd, iStyleHotSpot, lpszStyleHotSpot); + + //if (StrStrI(lpszStyleHotSpot, L"underline") != NULL) + // SendMessage(hwnd, SCI_SETHOTSPOTACTIVEUNDERLINE, TRUE, 0); + //else + // SendMessage(hwnd, SCI_SETHOTSPOTACTIVEUNDERLINE, FALSE, 0); + SendMessage(hwnd, SCI_SETHOTSPOTACTIVEUNDERLINE, TRUE, 0); + + int rgb = 0; + // Fore + if (Style_StrGetColor(TRUE, lpszStyleHotSpot, &rgb)) { + int inactiveFG = (int)((rgb * 75 + 50) / 100); + SendMessage(hwnd, SCI_STYLESETFORE, iStyleHotSpot, (LPARAM)inactiveFG); + SendMessage(hwnd, SCI_SETHOTSPOTACTIVEFORE, TRUE, (LPARAM)rgb); + } + // Back + if (Style_StrGetColor(FALSE, lpszStyleHotSpot, &rgb)) { + SendMessage(hwnd, SCI_STYLESETBACK, iStyleHotSpot, (LPARAM)rgb); + SendMessage(hwnd, SCI_SETHOTSPOTACTIVEBACK, TRUE, (LPARAM)rgb); + } + } + else + SendMessage(hwnd, SCI_STYLESETHOTSPOT, iStyleHotSpot, (LPARAM)FALSE); + +} + + //============================================================================= // // Style_SetLongLineColors() @@ -3596,12 +3641,13 @@ void Style_SetLongLineColors(HWND hwnd) // // Style_SetCurrentLineBackground() // -void Style_SetCurrentLineBackground(HWND hwnd) +void Style_SetCurrentLineBackground(HWND hwnd, BOOL bHiLitCurrLn) { - // Use 2nd default style - int iIdx = (bUse2ndDefaultStyle) ? STY_CNT_LAST : 0; + if (bHiLitCurrLn) { + + // Use 2nd default style ? + int iIdx = (bUse2ndDefaultStyle) ? STY_CNT_LAST : 0; - if (bHiliteCurrentLine) { int rgb = 0; if (Style_StrGetColor(FALSE,lexDefault.Styles[STY_CUR_LN_BCK + iIdx].szValue,&rgb)) // caret line back { @@ -5584,4 +5630,17 @@ void Style_SelectLexerDlg(HWND hwnd) } +//============================================================================= +// +// Style_GetHotspotID() +// +int Style_GetHotspotID(HWND hwnd) +{ + UNUSED(hwnd); + if (bHyperlinkHotspot) { + return (bUse2ndDefaultStyle ? (STY_URL_HOTSPOT + STY_CNT_LAST) : STY_URL_HOTSPOT); + } + return (bUse2ndDefaultStyle ? (STY_DEFAULT + STY_CNT_LAST) : STY_DEFAULT); +} + // End of Styles.c diff --git a/src/Styles.h b/src/Styles.h index a079bc953..fd580e430 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -67,8 +67,9 @@ void Style_Save(); BOOL Style_Import(HWND); BOOL Style_Export(HWND); void Style_SetLexer(HWND,PEDITLEXER); +void Style_SetUrlHotSpot(HWND, BOOL); void Style_SetLongLineColors(HWND); -void Style_SetCurrentLineBackground(HWND); +void Style_SetCurrentLineBackground(HWND, BOOL); void Style_SetCurrentMargin(HWND, BOOL); void Style_SetLexerFromFile(HWND,LPCWSTR); void Style_SetLexerFromName(HWND,LPCWSTR,LPCWSTR); @@ -101,6 +102,7 @@ INT_PTR CALLBACK Styles_ConfigDlgProc(HWND,UINT,WPARAM,LPARAM); void Style_ConfigDlg(HWND); INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND,UINT,WPARAM,LPARAM); void Style_SelectLexerDlg(HWND); +int Style_GetHotspotID(HWND); #endif //_NP3_STYLES_H_ diff --git a/src/Version.h b/src/Version.h index 457fb37d2..a30283509 100644 --- a/src/Version.h +++ b/src/Version.h @@ -58,7 +58,11 @@ // Compiler specific #if defined(_MSC_VER) - #if (_MSC_VER >= 1911) + #if (_MSC_VER >= 1912) + #if(_MSC_FULL_VER >= 191225830) + #define VER_CPL "Microsoft Visual C++ 2017 Version 15.5" + #endif + #elif (_MSC_VER >= 1911) #if((_MSC_FULL_VER >= 191125542) && (_MSC_FULL_VER <= 191125547)) #define VER_CPL "Microsoft Visual C++ 2017 Version 15.4" #elif((_MSC_FULL_VER >= 191125506) && (_MSC_FULL_VER <= 191125508)) diff --git a/src/resource.h b/src/resource.h index bcbc424b4..c3b9804fe 100644 --- a/src/resource.h +++ b/src/resource.h @@ -216,6 +216,7 @@ #define CMD_DEFAULTWINPOS 20038 #define CMD_OPENINIFILE 20039 #define CMD_CTRLENTER 20040 +#define CMD_OPEN_HYPERLINK 20041 #define IDM_FILE_NEW 40000 #define IDM_FILE_OPEN 40001 #define IDM_FILE_REVERT 40002 @@ -385,6 +386,7 @@ #define IDM_VIEW_AUTOCOMPLETEWORDS 40450 #define IDM_VIEW_ACCELWORDNAV 40451 #define IDM_VIEW_NOPRESERVECARET 40452 +#define IDM_VIEW_HYPERLINKHOTSPOTS 40453 #define IDM_HELP_ABOUT 40500 #define IDM_HELP_CMD 40501 #define IDM_TRAY_RESTORE 40600 @@ -471,7 +473,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 600 -#define _APS_NEXT_COMMAND_VALUE 700 +#define _APS_NEXT_COMMAND_VALUE 701 #define _APS_NEXT_CONTROL_VALUE 801 #define _APS_NEXT_SYMED_VALUE 900 #endif