mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
+ feature: enhanced URL Hotspot highlighting
This commit is contained in:
parent
7b562f9c82
commit
e10375fdcc
89
src/Edit.c
89
src/Edit.c
@ -322,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 = SciCall_GetTextLength();
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
@ -395,7 +395,7 @@ BOOL EditSetNewEncoding(HWND hwnd,int iNewEncoding,BOOL bNoUI,BOOL bSetSavePoint
|
||||
//return FALSE; // commented out ? : allow conversion between arbitrary encodings
|
||||
//}
|
||||
|
||||
if (SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0) == 0) {
|
||||
if (SciCall_GetTextLength() == 0) {
|
||||
|
||||
BOOL bIsEmptyUndoHistory = (SendMessage(hwnd, SCI_CANUNDO, 0, 0) == 0 && SendMessage(hwnd, SCI_CANREDO, 0, 0) == 0);
|
||||
|
||||
@ -625,7 +625,7 @@ BOOL EditCopyAppend(HWND hwnd)
|
||||
}
|
||||
}
|
||||
else {
|
||||
int cchText = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0);
|
||||
int cchText = SciCall_GetTextLength();
|
||||
pszText = LocalAlloc(LPTR,cchText + 1);
|
||||
SendMessage(hwnd,SCI_GETTEXT,(int)LocalSize(pszText),(LPARAM)pszText);
|
||||
}
|
||||
@ -1048,7 +1048,7 @@ BOOL EditSaveFile(
|
||||
EditStripTrailingBlanks(hwnd,TRUE);
|
||||
|
||||
// get text
|
||||
cbData = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0);
|
||||
cbData = SciCall_GetTextLength();
|
||||
lpData = GlobalAlloc(GPTR, cbData + 4); //fix: +bom
|
||||
SendMessage(hwnd,SCI_GETTEXT,GlobalSize(lpData),(LPARAM)lpData);
|
||||
|
||||
@ -2173,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)"");
|
||||
}
|
||||
|
||||
@ -2284,8 +2283,7 @@ void EditMoveDown(HWND hwnd)
|
||||
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_SETTARGETEND,(WPARAM)SciCall_GetTextLength(),0);
|
||||
SendMessage(hwnd,SCI_REPLACETARGET,0,(LPARAM)"");
|
||||
}
|
||||
|
||||
@ -2333,7 +2331,7 @@ void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend)
|
||||
|
||||
//if (iSelStart == iSelEnd) {
|
||||
// iSelStart = 0;
|
||||
// iSelEnd = SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0);
|
||||
// iSelEnd = SciCall_GetTextLength();
|
||||
//}
|
||||
|
||||
UINT mbcp = Encoding_SciGetCodePage(hwnd);
|
||||
@ -3187,7 +3185,7 @@ void EditStripFirstCharacter(HWND hwnd)
|
||||
|
||||
if (iSelStart == iSelEnd) {
|
||||
iSelStart = 0;
|
||||
iSelEnd = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0);
|
||||
iSelEnd = SciCall_GetTextLength();
|
||||
}
|
||||
|
||||
if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
|
||||
@ -3234,7 +3232,7 @@ void EditStripLastCharacter(HWND hwnd)
|
||||
|
||||
if (iSelStart == iSelEnd) {
|
||||
iSelStart = 0;
|
||||
iSelEnd = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0);
|
||||
iSelEnd = SciCall_GetTextLength();
|
||||
}
|
||||
|
||||
if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
|
||||
@ -3340,7 +3338,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 = SciCall_GetTextLength();
|
||||
|
||||
char* pszIn;
|
||||
char* pszOut;
|
||||
@ -3437,7 +3435,7 @@ void EditRemoveBlankLines(HWND hwnd,BOOL bMerge)
|
||||
|
||||
if (iSelStart == iSelEnd) {
|
||||
iSelStart = 0;
|
||||
iSelEnd = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0);
|
||||
iSelEnd = SciCall_GetTextLength();
|
||||
}
|
||||
|
||||
if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0))
|
||||
@ -4200,7 +4198,7 @@ void EditSelectEx(HWND hwnd,int iAnchorPos,int iCurrentPos)
|
||||
//
|
||||
void EditFixPositions(HWND hwnd)
|
||||
{
|
||||
int iMaxPos = (int)SendMessage(hwnd,SCI_GETTEXTLENGTH,0,0);
|
||||
int iMaxPos = SciCall_GetTextLength();
|
||||
int iCurrentPos = (int)SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
|
||||
int iAnchorPos = (int)SendMessage(hwnd,SCI_GETANCHOR,0,0);
|
||||
|
||||
@ -4274,7 +4272,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(SciCall_GetTextLength(),tr.chrg.cpMax);
|
||||
|
||||
pszText = LocalAlloc(LPTR,(tr.chrg.cpMax - tr.chrg.cpMin)+2);
|
||||
pszTextW = LocalAlloc(LPTR,((tr.chrg.cpMax - tr.chrg.cpMin)*2)+2);
|
||||
@ -4486,7 +4484,7 @@ RegExResult_t __fastcall EditFindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpefr, B
|
||||
int slen = EditGetFindStrg(hwnd, lpefr, szFind, COUNTOF(szFind));
|
||||
|
||||
int start = bFirstMatchOnly ? (int)SendMessage(hwnd, SCI_GETSELECTIONNSTART, 0, 0) : 0;
|
||||
int end = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0);
|
||||
int end = SciCall_GetTextLength();
|
||||
|
||||
int iPos = EditFindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, FALSE);
|
||||
|
||||
@ -5242,7 +5240,7 @@ BOOL EditFindNext(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bExtendSelection) {
|
||||
if (slen <= 0)
|
||||
return FALSE;
|
||||
|
||||
int iTextLength = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0);
|
||||
int iTextLength = SciCall_GetTextLength();
|
||||
|
||||
int start = (int)SendMessage(hwnd, SCI_GETSELECTIONEND, 0, 0);
|
||||
int end = iTextLength;
|
||||
@ -5309,7 +5307,7 @@ BOOL EditFindPrev(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bExtendSelection) {
|
||||
if (slen <= 0)
|
||||
return FALSE;
|
||||
|
||||
int iTextLength = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0);
|
||||
int iTextLength = SciCall_GetTextLength();
|
||||
|
||||
int start = max(0, (int)SendMessage(hwnd, SCI_GETSELECTIONSTART, 0, 0));
|
||||
int end = 0;
|
||||
@ -5403,8 +5401,8 @@ BOOL EditReplace(HWND hwnd, LPCEDITFINDREPLACE lpefr) {
|
||||
// w/o selection, replacement string is put into current position
|
||||
// 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 start = SciCall_GetCurrentPos();
|
||||
int end = SciCall_GetTextLength();
|
||||
int _start = start;
|
||||
int iPos = EditFindInTarget(hwnd, lpefr->szFind,
|
||||
StringCchLenA(lpefr->szFind, FNDRPL_BUFFER),
|
||||
@ -5512,7 +5510,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();
|
||||
|
||||
@ -5585,7 +5583,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, BOOL bMatchCase, BOOL bMat
|
||||
{
|
||||
EditClearAllMarks(hwnd);
|
||||
|
||||
int iTextLength = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0);
|
||||
int iTextLength = SciCall_GetTextLength();
|
||||
int iFindLength = 0;
|
||||
|
||||
char* pszText = pszFind;
|
||||
@ -5700,7 +5698,7 @@ void EditCompleteWord(HWND hwnd, BOOL autoInsert) {
|
||||
LocalFree(pLine);
|
||||
|
||||
int iRootLen = StringCchLenA(pRoot, cnt + 1);
|
||||
int iTextLength = (int)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0);
|
||||
int iTextLength = SciCall_GetTextLength();
|
||||
|
||||
int start = 0;
|
||||
int end = iTextLength;
|
||||
@ -5798,7 +5796,7 @@ void EditCompleteWord(HWND hwnd, BOOL autoInsert) {
|
||||
// EditUpdateUrlHotspots()
|
||||
// Find and mark all URL hot-spots
|
||||
//
|
||||
void EditUpdateUrlHotspots(HWND hwnd, tPos startPos, tPos endPos)
|
||||
void EditUpdateUrlHotspots(HWND hwnd, int startPos, int endPos)
|
||||
{
|
||||
const char* pszUrlRegEx = "\\b(?:(?:https?|ftp|file)://|www\\.|ftp\\.)"
|
||||
"(?:\\([-A-Z0-9+&@#/%=~_|$?!:,.]*\\)|[-A-Z0-9+&@#/%=~_|$?!:,.])*"
|
||||
@ -5806,36 +5804,32 @@ void EditUpdateUrlHotspots(HWND hwnd, tPos startPos, tPos endPos)
|
||||
|
||||
const int iRegExLen = (int)strlen(pszUrlRegEx);
|
||||
|
||||
tPos posCurr = (tPos)SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0);
|
||||
tPos posTextLength = (tPos)SendMessage(hwnd, SCI_GETTEXTLENGTH, 0, 0);
|
||||
|
||||
if ((startPos < 0) || (startPos >= posTextLength))
|
||||
{
|
||||
tPos cln = (tPos)SendMessage(hwnd, SCI_LINEFROMPOSITION, posCurr, 0);
|
||||
startPos = (tPos)SendMessage(hwnd, SCI_POSITIONFROMLINE, cln-1, 0);
|
||||
if (endPos < startPos) {
|
||||
int tmp = startPos; startPos = endPos; endPos = tmp; // swap
|
||||
}
|
||||
if ((endPos < 0) || (endPos >= posTextLength)) {
|
||||
tPos cln = (tPos)SendMessage(hwnd, SCI_LINEFROMPOSITION, posCurr, 0);
|
||||
endPos = (tPos)SendMessage(hwnd, SCI_GETLINEENDPOSITION, cln+1, 0);
|
||||
if (startPos < 0) { // current line only
|
||||
int currPos = SciCall_GetCurrentPos();
|
||||
int lineNo = SciCall_LineFromPosition(currPos);
|
||||
startPos = SciCall_PositionFromLine(lineNo);
|
||||
endPos = (int)SendMessage(hwnd, SCI_GETLINEENDPOSITION, lineNo, 0);
|
||||
}
|
||||
|
||||
int start = (int)startPos;
|
||||
int end = (int)endPos;
|
||||
int flags = SCFIND_NP3_REGEX;
|
||||
|
||||
int start = startPos;
|
||||
int end = endPos;
|
||||
while (TRUE)
|
||||
{
|
||||
int iPos = EditFindInTarget(hwnd, pszUrlRegEx, iRegExLen, flags, &start, &end, (end == start));
|
||||
int iPos = EditFindInTarget(hwnd, pszUrlRegEx, iRegExLen, SCFIND_NP3_REGEX, &start, &end, (end == start));
|
||||
|
||||
if (iPos < 0)
|
||||
break; // not found
|
||||
|
||||
// mark this match
|
||||
SendMessage(hwnd, SCI_STARTSTYLING, iPos, 0);
|
||||
SendMessage(hwnd, SCI_SETSTYLING, (end - start), STYLE_NP3_ID_HOTSPOT);
|
||||
SendMessage(hwnd, SCI_SETSTYLING, (end - start), Style_GetHotspotID(hwnd));
|
||||
|
||||
// next occurrence
|
||||
start = end;
|
||||
end = (int)endPos;
|
||||
end = endPos;
|
||||
|
||||
if (start >= end)
|
||||
break;
|
||||
@ -5884,15 +5878,16 @@ 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);
|
||||
void EditMatchBrace(HWND hwnd)
|
||||
{
|
||||
int iEndStyled = SciCall_GetEndStyled();
|
||||
if (iEndStyled < SciCall_GetTextLength()) {
|
||||
int iLine = SciCall_LineFromPosition(iEndStyled);
|
||||
int iEndStyled2 = SciCall_PositionFromLine(iLine);
|
||||
SendMessage(hwnd, SCI_COLOURISE, iEndStyled2, -1);
|
||||
}
|
||||
|
||||
int iPos = (int)SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0);
|
||||
int iPos = SciCall_GetCurrentPos();
|
||||
|
||||
if (!EditHighlightIfBrace(hwnd, iPos)) {
|
||||
// try one before
|
||||
|
||||
@ -56,8 +56,6 @@ typedef struct _editfindreplace
|
||||
#define INDIC_NP3_MATCH_BRACE 2
|
||||
#define INDIC_NP3_BAD_BRACE 3
|
||||
|
||||
#define STYLE_NP3_ID_HOTSPOT 222
|
||||
|
||||
|
||||
HWND EditCreate(HWND);
|
||||
void EditInitWordDelimiter(HWND);
|
||||
@ -127,7 +125,7 @@ void EditPrintInit();
|
||||
void EditMatchBrace(HWND);
|
||||
void EditClearAllMarks(HWND);
|
||||
void EditMarkAll(HWND,char*,int,BOOL,BOOL);
|
||||
void EditUpdateUrlHotspots(HWND, tPos, tPos);
|
||||
void EditUpdateUrlHotspots(HWND, int, int);
|
||||
void EditSetAccelWordNav(HWND,BOOL);
|
||||
void EditCompleteWord(HWND,BOOL);
|
||||
void EditGetBookmarkList(HWND,LPWSTR,int);
|
||||
|
||||
@ -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 *
|
||||
|
||||
@ -4008,6 +4008,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
Style_SelectLexerDlg(hwndEdit);
|
||||
UpdateStatusbar();
|
||||
UpdateLineNumberWidth();
|
||||
EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength());
|
||||
break;
|
||||
|
||||
|
||||
@ -4015,6 +4016,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
Style_ToggleUse2ndDefault(hwndEdit);
|
||||
UpdateStatusbar();
|
||||
UpdateLineNumberWidth();
|
||||
EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength());
|
||||
break;
|
||||
|
||||
|
||||
@ -4022,6 +4024,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
Style_ConfigDlg(hwndEdit);
|
||||
UpdateStatusbar();
|
||||
UpdateLineNumberWidth();
|
||||
EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength());
|
||||
break;
|
||||
|
||||
|
||||
@ -4029,6 +4032,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
Style_SetDefaultFont(hwndEdit);
|
||||
UpdateStatusbar();
|
||||
UpdateLineNumberWidth();
|
||||
EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength());
|
||||
break;
|
||||
|
||||
|
||||
@ -4281,7 +4285,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
|
||||
case IDM_VIEW_HILITECURRENTLINE:
|
||||
bHiliteCurrentLine = (bHiliteCurrentLine) ? FALSE : TRUE;
|
||||
Style_SetCurrentLineBackground(hwndEdit);
|
||||
Style_SetCurrentLineBackground(hwndEdit, bHiliteCurrentLine);
|
||||
break;
|
||||
|
||||
|
||||
@ -5360,11 +5364,11 @@ void OpenHotSpotURL(tPos position)
|
||||
// get right most position of style
|
||||
pos = position;
|
||||
iNewStyle = iStyle;
|
||||
tPos posTextLength = (tPos)SendMessage(hwndEdit, SCI_GETTEXTLENGTH, 0, 0);
|
||||
tPos posTextLength = (tPos)SciCall_GetTextLength();
|
||||
while ((iNewStyle == iStyle) && (++pos < posTextLength)) {
|
||||
iNewStyle = (int)SendMessage(hwndEdit, SCI_GETSTYLEAT, pos, 0);
|
||||
}
|
||||
tPos lastPos = (pos - 1);
|
||||
tPos lastPos = pos;
|
||||
|
||||
tPos length = lastPos - firstPos;
|
||||
|
||||
@ -5450,7 +5454,16 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
UpdateToolbar();
|
||||
UpdateStatusbar();
|
||||
}
|
||||
break;
|
||||
break; // fall-through -> too slow
|
||||
|
||||
case SCN_STYLENEEDED: // needs SCI_SETLEXER(SCLEX_CONTAINER)
|
||||
{
|
||||
int startPos = SciCall_GetEndStyled();
|
||||
int lineNumber = SciCall_LineFromPosition(startPos);
|
||||
startPos = SciCall_PositionFromLine(lineNumber);
|
||||
EditUpdateUrlHotspots(hwndEdit, startPos, (int)scn->position);
|
||||
}
|
||||
break;
|
||||
|
||||
case SCN_CHARADDED:
|
||||
// Auto indent
|
||||
@ -5602,7 +5615,6 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
}
|
||||
}
|
||||
if (scn->linesAdded != 0) {
|
||||
EditUpdateUrlHotspots(hwndEdit, -1, -1);
|
||||
UpdateLineNumberWidth();
|
||||
}
|
||||
bModified = TRUE;
|
||||
@ -5615,6 +5627,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
case SCN_SAVEPOINTREACHED:
|
||||
bModified = FALSE;
|
||||
UpdateToolbar();
|
||||
EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength());
|
||||
break;
|
||||
|
||||
case SCN_MARGINCLICK:
|
||||
@ -7406,6 +7419,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
|
||||
UpdateToolbar();
|
||||
UpdateStatusbar();
|
||||
UpdateLineNumberWidth();
|
||||
EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength());
|
||||
|
||||
// Terminate file watching
|
||||
if (bResetFileWatching)
|
||||
@ -7535,7 +7549,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
|
||||
InstallFileWatching(szCurFile);
|
||||
|
||||
// the .LOG feature ...
|
||||
if (SendMessage(hwndEdit,SCI_GETTEXTLENGTH,0,0) >= 4) {
|
||||
if (SciCall_GetTextLength() >= 4) {
|
||||
char tchLog[5] = { '\0' };
|
||||
SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tchLog);
|
||||
if (StringCchCompareXA(tchLog,".LOG") == 0) {
|
||||
@ -7564,8 +7578,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
|
||||
UpdateToolbar();
|
||||
UpdateStatusbar();
|
||||
UpdateLineNumberWidth();
|
||||
|
||||
EditUpdateUrlHotspots(hwndEdit, 0, (tPos)SendMessage(hwndEdit, SCI_GETTEXTLENGTH, 0, 0) - 1);
|
||||
EditUpdateUrlHotspots(hwndEdit, 0, SciCall_GetTextLength());
|
||||
|
||||
// consistent settings file handling (if loaded in editor)
|
||||
bEnableSaveSettings = (StringCchCompareINW(szCurFile, COUNTOF(szCurFile), szIniFile, COUNTOF(szIniFile)) == 0) ? FALSE : TRUE;
|
||||
@ -7733,6 +7746,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);
|
||||
|
||||
BIN
src/Notepad3.rc
BIN
src/Notepad3.rc
Binary file not shown.
@ -83,11 +83,14 @@ __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);
|
||||
DeclareSciCallR0(GetEndStyled, GETENDSTYLED, int);
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
138
src/Styles.c
138
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"URL Hotspot", 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 URL Hotspot", 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
|
||||
};
|
||||
|
||||
|
||||
@ -3250,11 +3252,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 +3330,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,16 +3547,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
|
||||
}
|
||||
}
|
||||
|
||||
// Hot Spot settings
|
||||
SendMessage(hwnd, SCI_STYLESETFORE, STYLE_NP3_ID_HOTSPOT, (LPARAM)RGB(0, 0, 200));
|
||||
SendMessage(hwnd, SCI_STYLESETITALIC, STYLE_NP3_ID_HOTSPOT, (LPARAM)TRUE);
|
||||
//SendMessage(hwnd, SCI_STYLESETUNDERLINE, iHotSpotStyle, (LPARAM)TRUE);
|
||||
|
||||
SendMessage(hwnd, SCI_STYLESETHOTSPOT, STYLE_NP3_ID_HOTSPOT, (LPARAM)TRUE);
|
||||
SendMessage(hwnd, SCI_SETHOTSPOTACTIVEFORE, TRUE, (LPARAM)RGB(0, 0, 255));
|
||||
SendMessage(hwnd, SCI_SETHOTSPOTACTIVEUNDERLINE, TRUE, 0);
|
||||
SendMessage(hwnd, SCI_SETHOTSPOTSINGLELINE, TRUE, 0);
|
||||
|
||||
Style_SetUrlHotSpot(hwnd, TRUE);
|
||||
|
||||
SendMessage(hwnd,SCI_COLOURISE,0,(LPARAM)-1);
|
||||
|
||||
@ -3577,6 +3556,54 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER 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);
|
||||
// Fore
|
||||
SendMessage(hwnd, SCI_SETHOTSPOTACTIVEUNDERLINE, TRUE, 0);
|
||||
|
||||
int rgb;
|
||||
|
||||
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()
|
||||
@ -3607,12 +3634,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
|
||||
{
|
||||
@ -5595,4 +5623,14 @@ void Style_SelectLexerDlg(HWND hwnd)
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Style_GetHotspotID()
|
||||
//
|
||||
int Style_GetHotspotID(HWND hwnd)
|
||||
{
|
||||
UNUSED(hwnd);
|
||||
return (bUse2ndDefaultStyle ? (STY_URL_HOTSPOT + STY_CNT_LAST) : STY_URL_HOTSPOT);
|
||||
}
|
||||
|
||||
// End of Styles.c
|
||||
|
||||
@ -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_
|
||||
|
||||
Loading…
Reference in New Issue
Block a user