3939#include "Extension/DPIHelper.h"
4040#include "Extension/SciCall.h"
4141#include "Extension/ProcessElevationUtils.h"
42+ #include "Extension/UnicodeQuotes.h"
4243#include "Extension/Utils.h"
4344
4445
@@ -6594,13 +6595,46 @@ INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd, UINT umsg, WPARAM wParam
65946595 const WCHAR * _left_braces = L"<{([" ;
65956596 const WCHAR * _right_braces = L">})]" ;
65966597 const WCHAR * _special_symbs = L"`~!@#%^*-_+=|\\/:;\"',.?" ;
6598+
6599+ // [2e]: Enclose Selection - add links with quotation marks #280
6600+ static int id_hover = 0 ;
6601+ static int id_capture = 0 ;
6602+ static HFONT hFontNormal = NULL ;
6603+ static HFONT hFontHover = NULL ;
6604+ static HCURSOR hCursorNormal = NULL ;
6605+ static HCURSOR hCursorHover = NULL ;
6606+ const DWORD iMinLinkID = 200 ;
6607+ const DWORD iMaxLinkID = iMinLinkID + iUnicodeQuotesCount ;
65976608 // [/2e]
6609+
65986610 static PENCLOSESELDATA pdata ;
65996611 switch (umsg )
66006612 {
66016613 DPI_CHANGED_HANDLER ();
66026614
66036615 case WM_INITDIALOG : {
6616+
6617+ // [2e]: Enclose Selection - add links with quotation marks #280
6618+ LOGFONT lf = { 0 };
6619+
6620+ if (NULL == (hFontNormal = (HFONT )SendDlgItemMessage (hwnd , 200 , WM_GETFONT , 0 , 0 )))
6621+ hFontNormal = GetStockObject (DEFAULT_GUI_FONT );
6622+ GetObject (hFontNormal , sizeof (LOGFONT ), & lf );
6623+ lf .lfUnderline = TRUE;
6624+ lf .lfHeight *= 1.25 ;
6625+ hFontHover = CreateFontIndirect (& lf );
6626+
6627+ hCursorNormal = LoadCursor (NULL , MAKEINTRESOURCE (IDC_ARROW ));
6628+ if (!(hCursorHover = LoadCursor (NULL , MAKEINTRESOURCE (IDC_HAND ))))
6629+ hCursorHover = LoadCursor (g_hInstance , MAKEINTRESOURCE (IDC_ARROW ));
6630+
6631+ for (DWORD dwId = iMinLinkID ; dwId <= iMaxLinkID ; ++ dwId )
6632+ {
6633+ WCHAR linkText [2 ] = { lpwstrUnicodeQuotes [dwId - iMinLinkID ], 0 };
6634+ SetDlgItemTextW (hwnd , dwId , linkText );
6635+ }
6636+ // [/2e]
6637+
66046638 pdata = (PENCLOSESELDATA )lParam ;
66056639 SendDlgItemMessage (hwnd , 100 , EM_LIMITTEXT , 255 , 0 );
66066640 SetDlgItemTextW (hwnd , 100 , pdata -> pwsz1 );
@@ -6610,6 +6644,123 @@ INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd, UINT umsg, WPARAM wParam
66106644 CenterDlgInParent (hwnd );
66116645 }
66126646 return TRUE;
6647+
6648+ // [2e]: Enclose Selection - add links with quotation marks #280
6649+ case WM_DESTROY :
6650+ DeleteObject (hFontHover );
6651+ return FALSE;
6652+
6653+ case WM_NCACTIVATE :
6654+ if (!(BOOL )wParam )
6655+ {
6656+ if (id_hover != 0 )
6657+ {
6658+ int _id_hover = id_hover ;
6659+ id_hover = 0 ;
6660+ id_capture = 0 ;
6661+ }
6662+ }
6663+ return FALSE;
6664+
6665+ case WM_CTLCOLORSTATIC : {
6666+ DWORD dwId = GetWindowLong ((HWND )lParam , GWL_ID );
6667+ HDC hdc = (HDC )wParam ;
6668+ if (dwId >= iMinLinkID && dwId <= iMaxLinkID )
6669+ {
6670+ SetBkMode (hdc , TRANSPARENT );
6671+ if (GetSysColorBrush (COLOR_HOTLIGHT ))
6672+ {
6673+ SetTextColor (hdc , GetSysColor (COLOR_HOTLIGHT ));
6674+ }
6675+ else
6676+ {
6677+ SetTextColor (hdc , RGB (0 , 0 , 255 ));
6678+ }
6679+ SelectObject (hdc , hFontHover );
6680+ return (LONG_PTR )GetSysColorBrush (COLOR_BTNFACE );
6681+ }
6682+ }
6683+ break ;
6684+
6685+ case WM_MOUSEMOVE : {
6686+ POINT pt = { LOWORD (lParam ), HIWORD (lParam ) };
6687+ HWND hwndHover = ChildWindowFromPoint (hwnd , pt );
6688+ DWORD dwId = GetWindowLong (hwndHover , GWL_ID );
6689+ if (GetActiveWindow () == hwnd )
6690+ {
6691+ if (dwId >= iMinLinkID && dwId <= iMaxLinkID )
6692+ {
6693+ if (id_capture == dwId || id_capture == 0 )
6694+ {
6695+ if (id_hover != id_capture || id_hover == 0 )
6696+ {
6697+ id_hover = dwId ;
6698+ }
6699+ }
6700+ else if (id_hover != 0 )
6701+ {
6702+ int _id_hover = id_hover ;
6703+ id_hover = 0 ;
6704+ }
6705+ }
6706+ else if (id_hover != 0 )
6707+ {
6708+ int _id_hover = id_hover ;
6709+ id_hover = 0 ;
6710+ }
6711+ SetCursor (id_hover != 0 ? hCursorHover : hCursorNormal );
6712+ }
6713+ }
6714+ break ;
6715+
6716+ case WM_LBUTTONDOWN : {
6717+ POINT pt = { LOWORD (lParam ), HIWORD (lParam ) };
6718+ HWND hwndHover = ChildWindowFromPoint (hwnd , pt );
6719+ DWORD dwId = GetWindowLong (hwndHover , GWL_ID );
6720+ if (dwId >= iMinLinkID && dwId <= iMaxLinkID )
6721+ {
6722+ GetCapture ();
6723+ id_hover = dwId ;
6724+ id_capture = dwId ;
6725+ }
6726+ SetCursor (id_hover != 0 ? hCursorHover : hCursorNormal );
6727+ }
6728+ break ;
6729+
6730+ case WM_LBUTTONUP : {
6731+ POINT pt = { LOWORD (lParam ), HIWORD (lParam ) };
6732+ HWND hwndHover = ChildWindowFromPoint (hwnd , pt );
6733+ DWORD dwId = GetWindowLong (hwndHover , GWL_ID );
6734+ if (id_capture != 0 )
6735+ {
6736+ ReleaseCapture ();
6737+ if (id_hover == id_capture )
6738+ {
6739+ int id_focus = GetWindowLong (GetFocus (), GWL_ID );
6740+ if (id_focus == 100 || id_focus == 101 )
6741+ {
6742+ WCHAR wch [8 ];
6743+ GetDlgItemText (hwnd , id_capture , wch , COUNTOF (wch ));
6744+ SendDlgItemMessage (hwnd , id_focus , EM_REPLACESEL , (WPARAM )TRUE, (LPARAM )wch );
6745+ }
6746+ }
6747+ id_capture = 0 ;
6748+ }
6749+ SetCursor (id_hover != 0 ? hCursorHover : hCursorNormal );
6750+ }
6751+ break ;
6752+
6753+ case WM_CANCELMODE :
6754+ if (id_capture != 0 )
6755+ {
6756+ ReleaseCapture ();
6757+ id_hover = 0 ;
6758+ id_capture = 0 ;
6759+ SetCursor (hCursorNormal );
6760+ }
6761+ break ;
6762+ // [/2e]
6763+
66136764 case WM_COMMAND :
66146765 switch (LOWORD (wParam ))
66156766 {
0 commit comments