Add back hovered blue underlined URLs

Fix #8654, close #8713
This commit is contained in:
Udo Hoffmann 2020-08-15 13:21:01 +02:00 committed by Don HO
parent 30d4516d23
commit 84430809df
11 changed files with 62 additions and 61 deletions

View File

@ -1018,6 +1018,7 @@ You can define several column markers by using white space to separate the diffe
<Item id="6331" name="Show only filename in title bar"/>
<Item id="6334" name="Autodetect character encoding"/>
<Item id="6349" name="Use DirectWrite (May improve rendering special characters, need to restart Notepad++)"/>
<Item id="6350" name="Enable fullbox mode"/>
<Item id="6337" name="Workspace file ext.:"/>
<Item id="6114" name="Enable"/>
<Item id="6117" name="Enable MRU behaviour"/>

View File

@ -2503,15 +2503,15 @@ void Notepad_plus::addHotSpot(ScintillaEditView* view)
ScintillaEditView* pView = view ? view : _pEditView;
int urlAction = (NppParameters::getInstance()).getNppGUI()._styleURL;
LPARAM indicStyle = (urlAction == 2) ? INDIC_PLAIN : INDIC_HIDDEN;
LPARAM indicStyle = (urlAction == urlNoUnderLineFg) || (urlAction == urlNoUnderLineBg) ? INDIC_HIDDEN : INDIC_PLAIN;
LPARAM indicHoverStyle = (urlAction == urlNoUnderLineBg) || (urlAction == urlUnderLineBg) ? INDIC_FULLBOX : INDIC_EXPLORERLINK;
LPARAM indicStyleCur = pView->execute(SCI_INDICGETSTYLE, URL_INDIC);
LPARAM indicHoverStyleCur = pView->execute(SCI_INDICGETHOVERSTYLE, URL_INDIC);
if ((indicStyleCur != indicStyle) || (indicHoverStyleCur != INDIC_FULLBOX))
if ((indicStyleCur != indicStyle) || (indicHoverStyleCur != indicHoverStyle))
{
pView->execute(SCI_INDICSETSTYLE, URL_INDIC, indicStyle);
pView->execute(SCI_INDICSETHOVERSTYLE, URL_INDIC, INDIC_FULLBOX);
pView->execute(SCI_INDICSETHOVERSTYLE, URL_INDIC, indicHoverStyle);
pView->execute(SCI_INDICSETALPHA, URL_INDIC, 70);
pView->execute(SCI_INDICSETFLAGS, URL_INDIC, SC_INDICFLAG_VALUEFORE);
}
@ -2521,25 +2521,32 @@ void Notepad_plus::addHotSpot(ScintillaEditView* view)
pView->getVisibleStartAndEndPosition(&startPos, &endPos);
if (startPos >= endPos) return;
pView->execute(SCI_SETINDICATORCURRENT, URL_INDIC);
pView->execute(SCI_INDICATORCLEARRANGE, startPos, endPos - startPos);
if (!urlAction) return;
if (urlAction == urlDisable)
{
pView->execute(SCI_INDICATORCLEARRANGE, startPos, endPos - startPos);
return;
}
LRESULT indicFore = pView->execute(SCI_STYLEGETFORE, STYLE_DEFAULT);
pView->execute(SCI_SETINDICATORVALUE, indicFore);
pView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX);
pView->execute(SCI_SETTARGETRANGE, startPos, endPos);
int posFound = static_cast<int32_t>(pView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), reinterpret_cast<LPARAM>(URL_REG_EXPR)));
while (posFound != -1 && posFound != -2)
{
int start = int(pView->execute(SCI_GETTARGETSTART));
int end = int(pView->execute(SCI_GETTARGETEND));
int foundTextLen = end - start;
pView->execute(SCI_SETINDICATORCURRENT, URL_INDIC);
pView->execute(SCI_SETINDICATORVALUE, indicFore);
pView->execute(SCI_INDICATORFILLRANGE, start, foundTextLen);
pView->execute(SCI_SETTARGETRANGE, posFound + foundTextLen, endPos);
int foundTextLen = end - posFound;
if (posFound > startPos)
pView->execute(SCI_INDICATORCLEARRANGE, startPos, posFound - startPos);
pView->execute(SCI_INDICATORFILLRANGE, posFound, foundTextLen);
startPos = posFound + foundTextLen;
pView->execute(SCI_SETTARGETRANGE, startPos, endPos);
posFound = static_cast<int32_t>(pView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), reinterpret_cast<LPARAM>(URL_REG_EXPR)));
}
if (endPos > startPos)
pView->execute(SCI_INDICATORCLEARRANGE, startPos, endPos - startPos);
}
bool Notepad_plus::isConditionExprLine(int lineNumber)

View File

@ -4394,12 +4394,9 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
const TCHAR* val = n->Value();
if (val)
{
if (!lstrcmp(val, TEXT("1")))
_nppGUI._styleURL = 1;
else if (!lstrcmp(val, TEXT("2")))
_nppGUI._styleURL = 2;
else
_nppGUI._styleURL = 0;
int const i = generic_atoi (val);
if ((i >= urlMin) && (i <= urlMax))
_nppGUI._styleURL = urlMode(i);
}
}
}
@ -5811,15 +5808,11 @@ void NppParameters::createXmlTreeFromGUIParams()
// <GUIConfig name="URL">2</GUIConfig>
{
const TCHAR *pStr = TEXT("0");
if (_nppGUI._styleURL == 1)
pStr = TEXT("1");
else if (_nppGUI._styleURL == 2)
pStr = TEXT("2");
TCHAR szStr [12] = TEXT("0");
generic_itoa(_nppGUI._styleURL, szStr, 10);
TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("URL"));
GUIConfigElement->InsertEndChild(TiXmlText(pStr));
GUIConfigElement->InsertEndChild(TiXmlText(szStr));
}
// <GUIConfig name = "globalOverride" fg = "no" bg = "no" font = "no" fontSize = "no" bold = "no" italic = "no" underline = "no" / >

View File

@ -92,6 +92,9 @@ enum BackupFeature {bak_none = 0, bak_simple = 1, bak_verbose = 2};
enum OpenSaveDirSetting {dir_followCurrent = 0, dir_last = 1, dir_userDef = 2};
enum MultiInstSetting {monoInst = 0, multiInstOnSession = 1, multiInst = 2};
enum writeTechnologyEngine {defaultTechnology = 0, directWriteTechnology = 1};
enum urlMode {urlDisable = 0, urlNoUnderLineFg, urlUnderLineFg, urlNoUnderLineBg, urlUnderLineBg,
urlMin = urlDisable,
urlMax = urlUnderLineBg};
const int LANG_INDEX_INSTR = 0;
const int LANG_INDEX_INSTR2 = 1;
@ -843,12 +846,7 @@ struct NppGUI final
writeTechnologyEngine _writeTechnologyEngine = defaultTechnology;
bool _isWordCharDefault = true;
std::string _customWordChars;
// 0 : do nothing
// 1 : don't draw underline
// 2 : draw underline
int _styleURL = 2;
urlMode _styleURL = urlUnderLineFg;
NewDocDefaultSettings _newDocDefaultSettings;

View File

@ -130,15 +130,17 @@ BEGIN
CONTROL "Use DirectWrite (May improve rendering special characters, need to restart Notepad++)",IDC_CHECK_DIRECTWRITE_ENABLE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,188,377,10
CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,15,140,10
CONTROL "No underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,28,140,10
COMBOBOX IDC_COMBO_FILEUPDATECHOICE,267, 60,140,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Update silently",IDC_CHECK_UPDATESILENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,76,140,10
CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,88,140,10
CONTROL "Enable fullbox mode",IDC_CHECK_CLICKABLELINK_FULLBOXMODE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,41,140,10
COMBOBOX IDC_COMBO_FILEUPDATECHOICE,267, 73,140,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Update silently",IDC_CHECK_UPDATESILENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,89,140,10
CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,101,140,10
EDITTEXT IDC_EDIT_SESSIONFILEEXT,381,135,34,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_WORKSPACEFILEEXT,381,152,34,14,ES_AUTOHSCROLL
GROUPBOX "Document Switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,37,4,155,39,BS_CENTER
GROUPBOX "Clickable Link Settings",IDC_CLICKABLELINK_STATIC,259,4,155,39,BS_CENTER
GROUPBOX "Clickable Link Settings",IDC_CLICKABLELINK_STATIC,259,4,155,52,BS_CENTER
GROUPBOX "Document Peeker",IDC_DOCUMENTPEEK_STATIC,37,47,155,39,BS_CENTER
GROUPBOX "File Status Auto-Detection",IDC_FILEAUTODETECTION_STATIC,259,47,155,60,BS_CENTER
GROUPBOX "File Status Auto-Detection",IDC_FILEAUTODETECTION_STATIC,259,60,155,60,BS_CENTER
RTEXT "Session file ext.:",IDC_SESSIONFILEEXT_STATIC,271,138,108,8
RTEXT "Workspace file ext.:",IDC_WORKSPACEFILEEXT_STATIC,271,155,108,8
END

View File

@ -919,26 +919,15 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_AUTOUPDATE), nppGUI._doesExistUpdater?SW_SHOW:SW_HIDE);
BOOL linkEnable = FALSE;
BOOL dontUnderline = FALSE;
BOOL dontUnderlineState = FALSE;
if (nppGUI._styleURL == 1)
{
linkEnable = TRUE;
dontUnderline = TRUE;
dontUnderlineState = TRUE;
}
else if (nppGUI._styleURL == 2)
{
linkEnable = TRUE;
dontUnderline = FALSE;
dontUnderlineState = TRUE;
}
BOOL linkEnable = nppGUI._styleURL != urlDisable;
BOOL dontUnderline = (nppGUI._styleURL == urlNoUnderLineFg) || (nppGUI._styleURL == urlNoUnderLineBg);
BOOL roundBoxMode = (nppGUI._styleURL == urlNoUnderLineBg) || (nppGUI._styleURL == urlUnderLineBg);
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_ENABLE, BM_SETCHECK, linkEnable, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_NOUNDERLINE, BM_SETCHECK, dontUnderline, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_CLICKABLELINK_NOUNDERLINE), dontUnderlineState);
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_FULLBOXMODE, BM_SETCHECK, roundBoxMode, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_CLICKABLELINK_NOUNDERLINE), linkEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_CLICKABLELINK_FULLBOXMODE), linkEnable);
::SendDlgItemMessage(_hSelf, IDC_EDIT_SESSIONFILEEXT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(nppGUI._definedSessionExt.c_str()));
::SendDlgItemMessage(_hSelf, IDC_EDIT_WORKSPACEFILEEXT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(nppGUI._definedWorkspaceExt.c_str()));
@ -1010,19 +999,28 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{
bool isChecked = isCheckedOrNot(IDC_CHECK_CLICKABLELINK_ENABLE);
if (!isChecked)
{
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_NOUNDERLINE, BM_SETCHECK, BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_CLICKABLELINK_FULLBOXMODE, BM_SETCHECK, BST_UNCHECKED, 0);
}
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_CLICKABLELINK_NOUNDERLINE), isChecked);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_CLICKABLELINK_FULLBOXMODE), isChecked);
nppGUI._styleURL = isChecked?2:0;
nppGUI._styleURL = isChecked ? urlUnderLineFg : urlDisable;
HWND grandParent = ::GetParent(_hParent);
::SendMessage(grandParent, NPPM_INTERNAL_UPDATECLICKABLELINKS, 0, 0);
}
return TRUE;
case IDC_CHECK_CLICKABLELINK_NOUNDERLINE:
case IDC_CHECK_CLICKABLELINK_FULLBOXMODE:
{
bool isChecked = isCheckedOrNot(IDC_CHECK_CLICKABLELINK_NOUNDERLINE);
nppGUI._styleURL = isChecked?1:2;
bool isNoUnderline = isCheckedOrNot(IDC_CHECK_CLICKABLELINK_NOUNDERLINE);
bool isRoundBoxMode = isCheckedOrNot(IDC_CHECK_CLICKABLELINK_FULLBOXMODE);
if (isRoundBoxMode)
nppGUI._styleURL = isNoUnderline ? urlNoUnderLineBg : urlUnderLineBg;
else
nppGUI._styleURL = isNoUnderline ? urlNoUnderLineFg : urlUnderLineFg;
HWND grandParent = ::GetParent(_hParent);
::SendMessage(grandParent, NPPM_INTERNAL_UPDATECLICKABLELINKS, 0, 0);
}

View File

@ -209,6 +209,7 @@
#define IDC_CHECK_ENABLEDOCPEEKONMAP (IDD_PREFERENCE_SETTING_BOX + 46)
#define IDC_COMBO_FILEUPDATECHOICE (IDD_PREFERENCE_SETTING_BOX + 47)
#define IDC_CHECK_DIRECTWRITE_ENABLE (IDD_PREFERENCE_SETTING_BOX + 49)
#define IDC_CHECK_CLICKABLELINK_FULLBOXMODE (IDD_PREFERENCE_SETTING_BOX + 50)
#define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400)
#define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 1)

View File

@ -293,6 +293,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define INDIC_POINTCHARACTER 19
#define INDIC_GRADIENT 20
#define INDIC_GRADIENTCENTRE 21
#define INDIC_EXPLORERLINK 22
#define INDIC_CONTAINER 8
#define INDIC_IME 32
#define INDIC_IME_MAX 35

View File

@ -1814,11 +1814,11 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
((model.hoverIndicatorPos >= ts.start + posLineStart) &&
(model.hoverIndicatorPos <= ts.end() + posLineStart));
if (hover) {
if (indicator.sacHover.style == INDIC_TEXTFORE) {
if ((indicator.sacHover.style == INDIC_TEXTFORE) || (indicator.sacHover.style == INDIC_EXPLORERLINK)) {
textFore = indicator.sacHover.fore;
}
} else {
if (indicator.sacNormal.style == INDIC_TEXTFORE) {
if ((indicator.sacNormal.style == INDIC_TEXTFORE) || (indicator.sacNormal.style == INDIC_EXPLORERLINK)) {
if (indicator.Flags() & SC_INDICFLAG_VALUEFORE)
textFore = ColourDesired(indicatorValue & SC_INDICVALUEMASK);
else

View File

@ -212,7 +212,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
};
surface->Polygon(pts, std::size(pts), sacDraw.fore, sacDraw.fore);
}
} else { // Either INDIC_PLAIN or unknown
} else { // Either INDIC_PLAIN, INDIC_EXPLORERLINK or unknown
surface->MoveTo(irc.left, ymid);
surface->LineTo(irc.right, ymid);
}

View File

@ -43,7 +43,7 @@ public:
return !(sacNormal == sacHover);
}
bool OverridesTextFore() const noexcept {
return sacNormal.style == INDIC_TEXTFORE || sacHover.style == INDIC_TEXTFORE;
return sacNormal.style == INDIC_TEXTFORE || sacHover.style == INDIC_TEXTFORE || sacNormal.style == INDIC_EXPLORERLINK || sacHover.style == INDIC_EXPLORERLINK;
}
int Flags() const noexcept {
return attributes;