diff --git a/src/Dialogs.c b/src/Dialogs.c index 2baba9a28..75563b1aa 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -1241,11 +1241,13 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) ResizeDlg_Init(hwnd,cxFileMRUDlg,cyFileMRUDlg,IDC_RESIZEGRIP); ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU), - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX), + (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY, + &shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES), LVSIL_SMALL); ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU), - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX), + (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY, + &shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES), LVSIL_NORMAL); //SetExplorerTheme(GetDlgItem(hwnd,IDC_FILEMRU)); @@ -1445,7 +1447,7 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) lvi.mask = LVIF_TEXT | LVIF_IMAGE; SHGetFileInfo(L"Icon",FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), - SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES); lvi.iImage = shfi.iIcon; diff --git a/src/Dlapi.c b/src/Dlapi.c index 9adcbf80e..78364444f 100644 --- a/src/Dlapi.c +++ b/src/Dlapi.c @@ -83,13 +83,13 @@ BOOL DirList_Init(HWND hwnd,LPCWSTR pszHeader) StringCchCopy(lpdl->szPath,COUNTOF(lpdl->szPath),L""); // Add Imagelists - hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), - SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO), + SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES); ListView_SetImageList(hwnd,hil,LVSIL_SMALL); - hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), - SHGFI_LARGEICON | SHGFI_SYSICONINDEX); + hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO), + SHGFI_LARGEICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES); ListView_SetImageList(hwnd,hil,LVSIL_NORMAL); @@ -450,8 +450,19 @@ DWORD WINAPI DirList_IconThread(LPVOID lpParam) if (!lpshi || NOERROR != lpshi->lpVtbl->GetIconOf(lpshi,lplvid->pidl,GIL_FORSHELL,&lvi.iImage)) { - pidl = IL_Create(lpdl->pidl,lpdl->cbidl,lplvid->pidl,0); - SHGetFileInfo((LPCWSTR)pidl,0,&shfi,sizeof(SHFILEINFO),SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + // get attributes of the shell object using its pidl. + lplvid->lpsf->lpVtbl->GetAttributesOf(lplvid->lpsf, 1, &lplvid->pidl, &dwAttributes); + + DWORD attr = 0; + if ((dwAttributes & SFGAO_FOLDER) == SFGAO_FOLDER) + attr = FILE_ATTRIBUTE_DIRECTORY; + else + attr = FILE_ATTRIBUTE_NORMAL; + + pidl = IL_Create(lpdl->pidl, lpdl->cbidl, lplvid->pidl, 0); + + SHGetFileInfo((LPCWSTR)pidl,attr,&shfi,sizeof(SHFILEINFO), + SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES); CoTaskMemFree(pidl); lvi.iImage = shfi.iIcon; } @@ -461,10 +472,7 @@ DWORD WINAPI DirList_IconThread(LPVOID lpParam) lvi.state = 0; // Link and Share Overlay - lplvid->lpsf->lpVtbl->GetAttributesOf( - lplvid->lpsf, - 1,&lplvid->pidl, - &dwAttributes); + lplvid->lpsf->lpVtbl->GetAttributesOf(lplvid->lpsf,1,&lplvid->pidl,&dwAttributes); if (dwAttributes & SFGAO_LINK) { @@ -1019,17 +1027,14 @@ typedef struct tagDC_ITEMDATA // BOOL DriveBox_Init(HWND hwnd) { - - HIMAGELIST hil; SHFILEINFO shfi; - hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), - SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + HIMAGELIST hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO), + SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES); SendMessage(hwnd,CBEM_SETIMAGELIST,0,(LPARAM)hil); SendMessage(hwnd,CBEM_SETEXTENDEDSTYLE,CBES_EX_NOSIZELIMIT,CBES_EX_NOSIZELIMIT); return TRUE; - } @@ -1376,7 +1381,7 @@ LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam) NMCOMBOBOXEX *lpnmcbe; LPDC_ITEMDATA lpdcid; SHFILEINFO shfi; - WCHAR szTemp[256] = { L'\0' }; + WCHAR szTemp[MAX_PATH] = { L'\0' }; lpnmcbe = (LPVOID)lParam; lpdcid = (LPDC_ITEMDATA)lpnmcbe->ceItem.lParam; @@ -1391,8 +1396,19 @@ LRESULT DriveBox_GetDispInfo(HWND hwnd,LPARAM lParam) // Get Icon Index if (lpnmcbe->ceItem.mask & (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE)) { - IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szTemp,256); - SHGetFileInfo(szTemp,0,&shfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + DWORD dwAttributes = 0; + // get attributes of the shell object using its pidl. + lpdcid->lpsf->lpVtbl->GetAttributesOf(lpdcid->lpsf, 1, &lpdcid->pidl, &dwAttributes); + + DWORD attr = 0; + if ((dwAttributes & SFGAO_FOLDER) == SFGAO_FOLDER) + attr = FILE_ATTRIBUTE_DIRECTORY; + else + attr = FILE_ATTRIBUTE_NORMAL; + + IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szTemp,MAX_PATH); + SHGetFileInfo(szTemp,attr,&shfi,sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES); lpnmcbe->ceItem.iImage = shfi.iIcon; lpnmcbe->ceItem.iSelectedImage = shfi.iIcon; } diff --git a/src/Edit.c b/src/Edit.c index 866e9c946..6291bc960 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -76,10 +76,10 @@ extern BOOL bFindReplCopySelOrClip; static EDITFINDREPLACE efrSave; static BOOL bSwitchedFindReplace = FALSE; -static int xFindReplaceDlgSave; -static int yFindReplaceDlgSave; extern int xFindReplaceDlg; extern int yFindReplaceDlg; +static int xFindReplaceDlgSave; +static int yFindReplaceDlgSave; extern int g_iDefaultEOLMode; extern int iLineEndings[3]; @@ -800,7 +800,7 @@ BOOL EditPasteClipboard(HWND hwnd, BOOL bSwapClipBoard) if (SciCall_IsSelectionEmpty() || (lineCount <= 1)) { - if (SciCall_IsSelectionEmpty()) + if (SciCall_IsSelectionEmpty()) // SC_SEL_THIN { SciCall_Paste(); if (bSwapClipBoard) { @@ -834,7 +834,7 @@ BOOL EditPasteClipboard(HWND hwnd, BOOL bSwapClipBoard) EditPaste2RectSel(hwnd, pClip); // TODO: restore selection in case of swap clipboard } - else // Selection: SC_SEL_STREAM, SC_SEL_LINES, SC_SEL_THIN + else // Selection: SC_SEL_STREAM, SC_SEL_LINES { if (bSwapClipBoard) { SciCall_Copy(); @@ -4811,7 +4811,6 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA CopyMemory(lpefr, &efrSave, sizeof(EDITFINDREPLACE)); } - HMENU hmenu = GetSystemMenu(hwnd, FALSE); GetString(IDS_SAVEPOS, tchBuf, COUNTOF(tchBuf)); InsertMenu(hmenu, 0, MF_BYPOSITION | MF_STRING | MF_ENABLED, IDS_SAVEPOS, tchBuf); @@ -4829,11 +4828,13 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } return TRUE; + case WM_DESTROY: { DeleteObject(hBrushRed); DeleteObject(hBrushGreen); DeleteObject(hBrushBlue); + KillTimer(hwnd, IDT_TIMER_MRKALL); if (iSaveMarkOcc >= 0) { EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, TRUE); @@ -4845,8 +4846,6 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, bMarkOccurrencesMatchVisible); iReplacedOccurrences = 0; - - KillTimer(hwnd, IDT_TIMER_MRKALL); } return FALSE; @@ -5328,6 +5327,10 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_FINDTEXT)), 1); break; + case IDACC_VIEWSCHEMECONFIG: + PostMessage(GetParent(hwnd), WM_COMMAND, MAKELONG(IDM_VIEW_SCHEMECONFIG, 1), 0); + break; + default: //return FALSE; ??? break; @@ -6033,10 +6036,9 @@ void EditCompleteWord(HWND hwnd, BOOL autoInsert) { const char* NON_WORD = bAccelWordNavigation ? DelimCharsAccel : DelimChars; - DocPos iCurrentPos = (int)SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0); - DocLn iLine = (int)SendMessage(hwnd, SCI_LINEFROMPOSITION, iCurrentPos, 0); - DocPos iCurrentLinePos = iCurrentPos - (int)SendMessage(hwnd, SCI_POSITIONFROMLINE, (WPARAM)iLine, 0); - DocPos iStartWordPos = iCurrentLinePos; + const DocPos iCurrentPos = SciCall_GetCurrentPos(); + const DocLn iLine = SciCall_LineFromPosition(iCurrentPos); + const DocPos iCurrentLinePos = iCurrentPos - SciCall_PositionFromLine(iLine); struct Sci_TextRange tr = { { 0, -1 }, NULL }; BOOL bWordAllNumbers = TRUE; struct WLIST* lListHead = NULL; @@ -6045,8 +6047,9 @@ void EditCompleteWord(HWND hwnd, BOOL autoInsert) char* pLine = LocalAlloc(LPTR, (int)SendMessage(hwnd, SCI_GETLINE, (WPARAM)iLine, 0) + 1); SendMessage(hwnd, SCI_GETLINE, (WPARAM)iLine, (LPARAM)pLine); + DocPos iStartWordPos = iCurrentLinePos; while (iStartWordPos > 0 && !StrChrIA(NON_WORD, pLine[iStartWordPos - 1])) { - iStartWordPos--; + --iStartWordPos; if (pLine[iStartWordPos] < '0' || pLine[iStartWordPos] > '9') { bWordAllNumbers = FALSE; } diff --git a/src/Helpers.c b/src/Helpers.c index ee132a3b7..652808509 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -520,7 +520,7 @@ BOOL SetWindowTitle(HWND hwnd,UINT uIDAppName,BOOL bIsElevated,UINT uIDUntitled, if (StringCchCompareN(szCachedFile,COUNTOF(szCachedFile),lpszFile,MAX_PATH) != 0) { SHFILEINFO shfi; StringCchCopy(szCachedFile,COUNTOF(szCachedFile),lpszFile); - if (SHGetFileInfo2(lpszFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME)) + if (SHGetFileInfo2(lpszFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES)) StringCchCopy(szCachedDisplayName,COUNTOF(szCachedDisplayName),shfi.szDisplayName); else StringCchCopy(szCachedDisplayName,COUNTOF(szCachedDisplayName),PathFindFileName(lpszFile)); diff --git a/src/Helpers.h b/src/Helpers.h index 65c7cdb7e..95be4d432 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -42,6 +42,9 @@ extern WCHAR g_wchIniFile[MAX_PATH]; __forceinline void swapi(int* a, int* b) { int t = *a; *a = *b; *b = t; } __forceinline void swapos(DocPos* a, DocPos* b) { DocPos t = *a; *a = *b; *b = t; } +__forceinline bool HasFractionCent(float f) { return ((((int)(f * 100.0)) % 100) != 0); } + + #define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \ GetPrivateProfileString(lpSection,lpName,(lpDefault),(lpReturnedStr),(nSize),g_wchIniFile) #define IniGetInt(lpSection,lpName,nDefault) \ diff --git a/src/Notepad3.c b/src/Notepad3.c index 30b3c8f8d..f57823982 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -62,6 +62,7 @@ HWND g_hwndEdit = NULL; HWND g_hwndStatus = NULL; HWND g_hwndToolbar = NULL; HWND g_hwndDlgFindReplace = NULL; +HWND g_hwndDlgCustomizeSchemes = NULL; HWND hwndReBar = NULL; HWND hwndEditFrame = NULL; HWND hwndNextCBChain = NULL; @@ -245,6 +246,9 @@ int cxFavoritesDlg; int cyFavoritesDlg; int xFindReplaceDlg; int yFindReplaceDlg; +int xCustomSchemesDlg; +int yCustomSchemesDlg; + LPWSTR lpFileList[32] = { NULL }; int cFileList = 0; @@ -427,6 +431,7 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int n HWND hwnd; HACCEL hAccMain; HACCEL hAccFindReplace; + HACCEL hAccCoustomizeSchemes; INITCOMMONCONTROLSEX icex; //HMODULE hSciLexer; WCHAR wchAppDir[2*MAX_PATH+4] = { L'\0' }; @@ -547,7 +552,8 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int n hAccMain = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_MAINWND)); hAccFindReplace = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCFINDREPLACE)); - + hAccCoustomizeSchemes = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCCUSTOMSCHEMES)); + UpdateLineNumberWidth(); ObserveNotifyChangeEvent(); @@ -555,10 +561,15 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int n { if (IsWindow(g_hwndDlgFindReplace) && ((msg.hwnd == g_hwndDlgFindReplace) || IsChild(g_hwndDlgFindReplace, msg.hwnd))) { - int iTr = TranslateAccelerator(g_hwndDlgFindReplace, hAccFindReplace, &msg); + const int iTr = TranslateAccelerator(g_hwndDlgFindReplace, hAccFindReplace, &msg); if (iTr || IsDialogMessage(g_hwndDlgFindReplace, &msg)) continue; } + if (IsWindow(g_hwndDlgCustomizeSchemes) && ((msg.hwnd == g_hwndDlgCustomizeSchemes) || IsChild(g_hwndDlgCustomizeSchemes, msg.hwnd))) { + const int iTr = TranslateAccelerator(g_hwndDlgCustomizeSchemes, hAccCoustomizeSchemes, &msg); + if (iTr || IsDialogMessage(g_hwndDlgCustomizeSchemes, &msg)) + continue; + } if (!TranslateAccelerator(hwnd,hAccMain,&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); @@ -927,7 +938,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) WCHAR tchPageFmt[32] = { L'\0' }; if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - SHGetFileInfo2(g_wchCurFile, 0, &shfi, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME); + SHGetFileInfo2(g_wchCurFile, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); pszTitle = shfi.szDisplayName; } else { @@ -1543,6 +1554,10 @@ void MsgEndSession(HWND hwnd, UINT umsg) if (IsWindow(g_hwndDlgFindReplace)) DestroyWindow(g_hwndDlgFindReplace); + // Destroy customize schemes + if (IsWindow(g_hwndDlgCustomizeSchemes)) + DestroyWindow(g_hwndDlgCustomizeSchemes); + // call SaveSettings() when g_hwndToolbar is still valid SaveSettings(FALSE); @@ -2254,6 +2269,9 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) EnableCmd(hmenu, CMD_CTRLDEL, i); EnableCmd(hmenu, CMD_TIMESTAMPS, i); + EnableCmd(hmenu, IDM_VIEW_FONT, !IsWindow(g_hwndDlgCustomizeSchemes)); + EnableCmd(hmenu, IDM_VIEW_CURRENTSCHEME, !IsWindow(g_hwndDlgCustomizeSchemes)); + EnableCmd(hmenu,IDM_VIEW_TOGGLEFOLDS,i && (g_bCodeFoldingAvailable && g_bShowCodeFolding)); CheckCmd(hmenu,IDM_VIEW_FOLDING, (g_bCodeFoldingAvailable && g_bShowCodeFolding)); EnableCmd(hmenu, IDM_VIEW_FOLDING, g_bCodeFoldingAvailable); @@ -2557,7 +2575,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) WCHAR tchPageFmt[32] = { L'\0' }; if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - SHGetFileInfo2(g_wchCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + SHGetFileInfo2(g_wchCurFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); pszTitle = shfi.szDisplayName; } else { @@ -2628,7 +2646,8 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_FILE_ADDTOFAV: if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { SHFILEINFO shfi; - SHGetFileInfo2(g_wchCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + SHGetFileInfo2(g_wchCurFile,FILE_ATTRIBUTE_NORMAL, + &shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); AddToFavDlg(hwnd,shfi.szDisplayName,g_wchCurFile); } break; @@ -3409,13 +3428,13 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { if (LOWORD(wParam) == IDM_EDIT_INSERT_FILENAME) { - SHGetFileInfo2(g_wchCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + SHGetFileInfo2(g_wchCurFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), + SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); pszInsert = shfi.szDisplayName; } else pszInsert = g_wchCurFile; } - else { GetString(IDS_UNTITLED,tchUntitled,COUNTOF(tchUntitled)); pszInsert = tchUntitled; @@ -3852,27 +3871,31 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_VIEW_SCHEMECONFIG: - Style_ConfigDlg(g_hwndEdit); - UpdateToolbar(); - UpdateStatusbar(); - UpdateLineNumberWidth(); + if (!IsWindow(g_hwndDlgCustomizeSchemes)) { + g_hwndDlgCustomizeSchemes = Style_CustomizeSchemesDlg(g_hwndEdit); + } + else { + SetForegroundWindow(g_hwndDlgCustomizeSchemes); + } + PostMessage(g_hwndDlgCustomizeSchemes, WM_COMMAND, MAKELONG(IDC_SETCURLEXERTV, 1), 0); break; case IDM_VIEW_FONT: - Style_SetDefaultFont(g_hwndEdit, TRUE); + if (!IsWindow(g_hwndDlgCustomizeSchemes)) + Style_SetDefaultFont(g_hwndEdit, TRUE); UpdateToolbar(); - UpdateStatusbar(); UpdateLineNumberWidth(); break; case IDM_VIEW_CURRENTSCHEME: - Style_SetDefaultFont(g_hwndEdit, FALSE); + if (!IsWindow(g_hwndDlgCustomizeSchemes)) + Style_SetDefaultFont(g_hwndEdit, FALSE); UpdateToolbar(); - UpdateStatusbar(); UpdateLineNumberWidth(); break; + case IDM_VIEW_WORDWRAP: bWordWrap = (bWordWrap) ? FALSE : TRUE; if (!bWordWrap) @@ -5484,6 +5507,17 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) else if (bAutoCompleteWords && !SendMessage(g_hwndEdit, SCI_AUTOCACTIVE, 0, 0)) { EditCompleteWord(g_hwndEdit, FALSE); } + //else if (SciCall_IsSelectionRectangle() || IsThinRectangleSelected()) { + // WCHAR wch[8] = { L'\0' }; + // StringCchPrintfW(wch, COUNTOF(wch), L"%lc", (WCHAR)(scn->ch)); + // char chr[8] = { '\0' }; + // WideCharToMultiByteStrg(Encoding_SciGetCodePage(g_hwndEdit), wch, chr); + + // if (SciCall_IsSelectionRectangle()) + // EditPaste2RectSel(g_hwndEdit, chr); + // else + // SciCall_ReplaceSel(chr); + //} } break; @@ -5905,6 +5939,8 @@ void LoadSettings() xFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosX",0); yFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosY",0); + xCustomSchemesDlg = IniSectionGetInt(pIniSection, L"CustomSchemesDlgPosX", 0); + yCustomSchemesDlg = IniSectionGetInt(pIniSection, L"CustomSchemesDlgPosY", 0); LoadIniSection(L"Settings2",pIniSection,cchIniSection); @@ -6144,8 +6180,10 @@ void SaveSettings(BOOL bSaveSettingsNow) { IniSectionSetInt(pIniSection, L"FavoritesDlgSizeY", cyFavoritesDlg); IniSectionSetInt(pIniSection, L"FindReplaceDlgPosX", xFindReplaceDlg); IniSectionSetInt(pIniSection, L"FindReplaceDlgPosY", yFindReplaceDlg); + IniSectionSetInt(pIniSection, L"CustomSchemesDlgPosX", xCustomSchemesDlg); + IniSectionSetInt(pIniSection, L"CustomSchemesDlgPosY", yCustomSchemesDlg); - Toolbar_GetButtons(g_hwndToolbar, IDT_FILE_NEW, tchToolbarButtons, COUNTOF(tchToolbarButtons)); + Toolbar_GetButtons(g_hwndToolbar, IDT_FILE_NEW, tchToolbarButtons, COUNTOF(tchToolbarButtons)); if (StringCchCompareX(tchToolbarButtons, TBBUTTON_DEFAULT_IDS) == 0) { tchToolbarButtons[0] = L'\0'; } IniSectionSetString(pIniSection, L"ToolbarButtons", tchToolbarButtons); @@ -8482,7 +8520,8 @@ void SetNotifyIconTitle(HWND hwnd) } else if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - SHGetFileInfo2(g_wchCurFile,0,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME); + SHGetFileInfo2(g_wchCurFile,FILE_ATTRIBUTE_NORMAL, + &shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); PathCompactPathEx(tchTitle,shfi.szDisplayName,COUNTOF(tchTitle)-4,0); } else diff --git a/src/Notepad3.rc b/src/Notepad3.rc index ad41c3f6d..4b289a6ba 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -621,8 +621,8 @@ IDR_ACCFINDREPLACE ACCELERATORS BEGIN "F", IDACC_FIND, VIRTKEY, CONTROL, NOINVERT "H", IDACC_REPLACE, VIRTKEY, CONTROL, NOINVERT - "O", IDACC_SAVEPOS, VIRTKEY, CONTROL, NOINVERT - "P", IDACC_RESETPOS, VIRTKEY, CONTROL, NOINVERT + "S", IDACC_SAVEPOS, VIRTKEY, CONTROL, NOINVERT + "R", IDACC_RESETPOS, VIRTKEY, CONTROL, NOINVERT VK_F2, IDACC_SELTONEXT, VIRTKEY, CONTROL, ALT, NOINVERT VK_F2, IDACC_SELTOPREV, VIRTKEY, SHIFT, CONTROL, ALT, NOINVERT VK_F3, IDACC_FINDNEXT, VIRTKEY, NOINVERT @@ -631,6 +631,13 @@ BEGIN VK_F4, IDACC_REPLACENEXT, VIRTKEY, NOINVERT END +IDR_ACCCUSTOMSCHEMES ACCELERATORS +BEGIN + "S", IDACC_SAVEPOS, VIRTKEY, CONTROL, NOINVERT + "R", IDACC_RESETPOS, VIRTKEY, CONTROL, NOINVERT + "S", IDACC_PREVIEW, VIRTKEY, CONTROL, NOINVERT + VK_F12, IDACC_VIEWSCHEMECONFIG, VIRTKEY, CONTROL, NOINVERT +END ///////////////////////////////////////////////////////////////////////////// // @@ -1559,8 +1566,9 @@ END STRINGTABLE BEGIN - IDS_SAVEPOS "&Save Position\tCtrl+O" - IDS_RESETPOS "&Reset Position\tCtrl+P" + IDS_SAVEPOS "&Save Position\tCtrl+S" + IDS_RESETPOS "&Reset Position\tCtrl+R" + IDS_PREVIEW "&Preview Settings\tCtrl+P" END STRINGTABLE diff --git a/src/Styles.c b/src/Styles.c index 949046212..72fe97e4d 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -47,6 +47,7 @@ extern HINSTANCE g_hInstance; extern HWND g_hwndMain; extern HWND g_hwndEdit; +extern HWND g_hwndDlgCustomizeSchemes; extern int iSciFontQuality; extern const int FontQuality[4]; @@ -58,11 +59,14 @@ extern BOOL g_bShowSelectionMargin; extern int iMarkOccurrences; extern BOOL bUseOldStyleBraceMatching; +extern int xCustomSchemesDlg; +extern int yCustomSchemesDlg; + + #define MULTI_STYLE(a,b,c,d) ((a)|(b<<8)|(c<<16)|(d<<24)) #define INITIAL_BASE_FONT_SIZE (10) - KEYWORDLIST KeyWords_NULL = { "", "", "", "", "", "", "", "", "" }; @@ -80,7 +84,7 @@ EDITLEXER lexStandard = { SCLEX_NULL, 63000, L"Default Text", L"txt; text; wtx; /* 9 */ { SCI_SETCARETFORE+SCI_SETCARETWIDTH, 63109, L"Caret (Color, Size 1-3)", L"", L"" }, /* 10 */ { SCI_SETEDGECOLOUR, 63110, L"Long Line Marker (Colors)", L"fore:#FFC000", L"" }, /* 11 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63111, L"Extra Line Spacing (Size)", L"size:2", L"" }, - /* 12 */ { SCI_FOLDALL+SCI_MARKERSETALPHA, 63124, L"Bookmarks and Folding (Colors)", L"fore:#000000; back:#00FF00; alpha:80", L"" }, + /* 12 */ { SCI_FOLDALL+SCI_MARKERSETALPHA, 63124, L"Bookmarks and Folding (Colors)", L"fore:#000000; back:#808080; alpha:80", L"" }, /* 13 */ { SCI_MARKERSETBACK+SCI_MARKERSETALPHA, 63262, L"Mark Occurrences (Indicator)", L"indic_roundbox", L"" }, /* 14 */ { SCI_SETHOTSPOTACTIVEFORE, 63264, L"Hyperlink Hotspots", L"italic; fore:#0000FF", L"" }, { -1, 00000, L"", L"", L"" } } }; @@ -99,8 +103,8 @@ EDITLEXER lexStandard2nd = { SCLEX_NULL, 63266, L"2nd Default Text", L"txt; text /* 9 */ { SCI_SETCARETFORE + SCI_SETCARETWIDTH, 63121, L"2nd Caret (Color, Size 1-3)", L"", L"" }, /* 10 */ { SCI_SETEDGECOLOUR, 63122, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" }, /* 11 */ { SCI_SETEXTRAASCENT + SCI_SETEXTRADESCENT, 63123, L"2nd Extra Line Spacing (Size)", L"", L"" }, - /* 12 */ { SCI_FOLDALL + SCI_MARKERSETALPHA, 63125, L"2nd Bookmarks and Folding (Colors)", L"fore:#000000; back:#00FF00; alpha:80; charset:2; case:U", L"" }, - /* 13 */ { SCI_MARKERSETBACK + SCI_MARKERSETALPHA, 63263, L"2nd Mark Occurrences (Indicator)", L"fore:#0x00FF00; alpha:100; alpha2:220; indic_box", L"" }, + /* 12 */ { SCI_FOLDALL + SCI_MARKERSETALPHA, 63125, L"2nd Bookmarks and Folding (Colors)", L"fore:#000000; back:#808080; alpha:80; charset:2; case:U", L"" }, + /* 13 */ { SCI_MARKERSETBACK + SCI_MARKERSETALPHA, 63263, L"2nd Mark Occurrences (Indicator)", L"fore:#0x000000; alpha:100; alpha2:220; indic_box", L"" }, /* 14 */ { SCI_SETHOTSPOTACTIVEFORE, 63265, L"2nd Hyperlink Hotspots", L"bold; fore:#FF0000", L"" }, { -1, 00000, L"", L"", L"" } } }; @@ -3001,7 +3005,7 @@ extern BOOL bHyperlinkHotspot; BOOL __fastcall IsLexerStandard(PEDITLEXER pLexer) { - return ( (pLexer == &lexStandard) || (pLexer == &lexStandard2nd) ); + return ( pLexer && ((pLexer == &lexStandard) || (pLexer == &lexStandard2nd)) ); } PEDITLEXER __fastcall GetCurrentStdLexer() @@ -3011,17 +3015,17 @@ PEDITLEXER __fastcall GetCurrentStdLexer() BOOL __fastcall IsStyleStandardDefault(PEDITSTYLE pStyle) { - return ((pStyle->rid == 63100) || (pStyle->rid == 63112)); + return (pStyle && ((pStyle->rid == 63100) || (pStyle->rid == 63112))); } BOOL __fastcall IsStyleSchemeDefault(PEDITSTYLE pStyle) { - return (pStyle->rid == 63126); + return (pStyle && (pStyle->rid == 63126)); } PEDITLEXER __fastcall GetDefaultLexer() { - return g_pLexArray[g_iDefaultLexer]; + return g_pLexArray[g_iDefaultLexer]; } @@ -3396,11 +3400,11 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SendMessage(hwnd, SCI_STYLESETFONT, STYLE_DEFAULT, (LPARAM)chFontName); } - int iBaseFontSize = INITIAL_BASE_FONT_SIZE; // init - Style_StrGetSize(wchStandardStyleStrg, &iBaseFontSize); - iBaseFontSize = max(0, iBaseFontSize); - Style_SetBaseFontSize(hwnd, iBaseFontSize); - Style_SetCurrentFontSize(hwnd, iBaseFontSize); + float fBaseFontSize = INITIAL_BASE_FONT_SIZE * 1.0; // init + Style_StrGetSize(wchStandardStyleStrg, &fBaseFontSize); + fBaseFontSize = (float)max(0.0, fBaseFontSize); + Style_SetBaseFontSize(hwnd, fBaseFontSize); + Style_SetCurrentFontSize(hwnd, fBaseFontSize); if (!Style_StrGetCharSet(wchStandardStyleStrg, &iValue)) { SendMessage(hwnd, SCI_STYLESETCHARACTERSET, STYLE_DEFAULT, (LPARAM)DEFAULT_CHARSET); @@ -3434,11 +3438,11 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // merge lexer styles Style_SetStyles(hwnd, STYLE_DEFAULT, wchCurrentLexerStyleStrg); // use this font size as current lexer's base - iBaseFontSize = Style_GetBaseFontSize(hwnd); - Style_StrGetSize(wchCurrentLexerStyleStrg, &iBaseFontSize); - iBaseFontSize = max(0, iBaseFontSize); - Style_SetCurrentFontSize(hwnd, iBaseFontSize); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_CURRENTSCHEME, TRUE); + fBaseFontSize = Style_GetBaseFontSize(hwnd); + Style_StrGetSize(wchCurrentLexerStyleStrg, &fBaseFontSize); + fBaseFontSize = (float)max(0.0, fBaseFontSize); + Style_SetCurrentFontSize(hwnd, fBaseFontSize); + EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_CURRENTSCHEME, TRUE && !IsWindow(g_hwndDlgCustomizeSchemes)); } else { EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_CURRENTSCHEME, FALSE); @@ -3456,7 +3460,6 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) Style_SetMargin(hwnd, pCurrentStandard->Styles[STY_MARGIN].iStyle, pCurrentStandard->Styles[STY_MARGIN].szValue); // margin (line number, bookmarks, folding) style - if (bUseOldStyleBraceMatching) { Style_SetStyles(hwnd, pCurrentStandard->Styles[STY_BRACE_OK].iStyle, pCurrentStandard->Styles[STY_BRACE_OK].szValue); // brace light @@ -3595,9 +3598,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // whitespace dot size iValue = 1; - if (Style_StrGetSize(pCurrentStandard->Styles[STY_WHITESPACE].szValue, &iValue)) + float fValue = 1.0; + if (Style_StrGetSize(pCurrentStandard->Styles[STY_WHITESPACE].szValue, &fValue)) { - iValue = max(min(iValue, 5), 0); + iValue = (int)max(min(fValue, 5.0), 0.0); WCHAR tch[32] = { L'\0' }; WCHAR wchStyle[BUFSIZE_STYLE_VALUE]; @@ -3642,9 +3646,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SendMessage(hwnd, SCI_SETCARETSTYLE, CARETSTYLE_LINE, 0); WCHAR wch[32] = { L'\0' }; - iValue = 1; // default caret width - if (Style_StrGetSize(pCurrentStandard->Styles[STY_CARET].szValue,&iValue)) { - iValue = max(min(iValue,3),1); + iValue = 1; + fValue = 1.0; // default caret width + if (Style_StrGetSize(pCurrentStandard->Styles[STY_CARET].szValue,&fValue)) { + iValue = (int)max(min(fValue,3.0),1.0); StringCchPrintf(wch,COUNTOF(wch),L"size:%i",iValue); StringCchCat(wchSpecificStyle,COUNTOF(wchSpecificStyle),wch); } @@ -3697,8 +3702,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // Extra Line Spacing iValue = 0; - if (Style_StrGetSize(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue,&iValue) && (pLexNew != &lexANSI)) { - const int iCurFontSizeDbl = 2 * Style_GetCurrentFontSize(hwnd); + fValue = 0.0; + if (Style_StrGetSize(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue,&fValue) && (pLexNew != &lexANSI)) { + iValue = (int)fValue; + const int iCurFontSizeDbl = (int)(2.0 * Style_GetCurrentFontSize(hwnd)); int iValAdj = min(max(iValue,(0 - iCurFontSizeDbl)), 256 * iCurFontSizeDbl); if (iValAdj != iValue) StringCchPrintf(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue, @@ -3956,9 +3963,9 @@ void Style_SetCurrentLineBackground(HWND hwnd, BOOL bHiLitCurrLn) // void Style_SetFolding(HWND hwnd, BOOL bShowCodeFolding) { - int size = INITIAL_BASE_FONT_SIZE + 1; - Style_StrGetSize(GetCurrentStdLexer()->Styles[STY_BOOK_MARK].szValue, &size); - SciCall_SetMarginWidth(MARGIN_SCI_FOLDING, (bShowCodeFolding) ? size : 0); + float fSize = INITIAL_BASE_FONT_SIZE + 1.0; + Style_StrGetSize(GetCurrentStdLexer()->Styles[STY_BOOK_MARK].szValue, &fSize); + SciCall_SetMarginWidth(MARGIN_SCI_FOLDING, (bShowCodeFolding) ? (int)fSize : 0); UNUSED(hwnd); } @@ -3969,9 +3976,9 @@ void Style_SetFolding(HWND hwnd, BOOL bShowCodeFolding) // void Style_SetBookmark(HWND hwnd, BOOL bShowSelMargin) { - int size = INITIAL_BASE_FONT_SIZE + 1; - Style_StrGetSize(GetCurrentStdLexer()->Styles[STY_BOOK_MARK].szValue, &size); - SciCall_SetMarginWidth(MARGIN_SCI_BOOKMRK, (bShowSelMargin) ? (size + 4) : 0); + float fSize = INITIAL_BASE_FONT_SIZE + 1.0; + Style_StrGetSize(GetCurrentStdLexer()->Styles[STY_BOOK_MARK].szValue, &fSize); + SciCall_SetMarginWidth(MARGIN_SCI_BOOKMRK, (bShowSelMargin) ? (int)fSize + 4 : 0); // Depending on if the margin is visible or not, choose different bookmark indication if (bShowSelMargin) { @@ -4460,20 +4467,22 @@ BOOL Style_GetUse2ndDefault() // // Style_SetBaseFontSize(), Style_GetBaseFontSize() // -int Style_SetBaseFontSize(HWND hwnd, int bfSize) +float Style_SetBaseFontSize(HWND hwnd, float fSize) { - static int iBaseFontSize = INITIAL_BASE_FONT_SIZE; + static float fBaseFontSize = INITIAL_BASE_FONT_SIZE * 1.0; - if (bfSize >= 0) { - iBaseFontSize = bfSize; - SendMessage(hwnd, SCI_STYLESETSIZE, STYLE_DEFAULT, (LPARAM)iBaseFontSize); + if (fSize >= 0.0) { + fBaseFontSize = (float)(((int)(fSize * 100 + 0.5)) / 100.0); + //SendMessage(hwnd, SCI_STYLESETSIZE, STYLE_DEFAULT, (LPARAM)iBaseFontSize); + SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, STYLE_DEFAULT, (LPARAM)((int)(fBaseFontSize * SC_FONT_SIZE_MULTIPLIER + 0.5))); + } - return iBaseFontSize; + return fBaseFontSize; } -int Style_GetBaseFontSize(HWND hwnd) +float Style_GetBaseFontSize(HWND hwnd) { - return Style_SetBaseFontSize(hwnd, -1); + return Style_SetBaseFontSize(hwnd, -1.0); } @@ -4482,20 +4491,22 @@ int Style_GetBaseFontSize(HWND hwnd) // // Style_SetCurrentFontSize(), Style_GetCurrentFontSize() // -int Style_SetCurrentFontSize(HWND hwnd, int cfSize) +float Style_SetCurrentFontSize(HWND hwnd, float fSize) { - static int iCurrentFontSize = INITIAL_BASE_FONT_SIZE; + static float fCurrentFontSize = INITIAL_BASE_FONT_SIZE * 1.0; + + if (fSize >= 0.0) { + fCurrentFontSize = (float)(((int)(fSize * 100 + 0.5)) / 100.0); + //SendMessage(hwnd, SCI_STYLESETSIZE, STYLE_DEFAULT, (LPARAM)iCurrentFontSize); + SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, STYLE_DEFAULT, (LPARAM)((int)(fCurrentFontSize * SC_FONT_SIZE_MULTIPLIER + 0.5))); - if (cfSize >= 0) { - iCurrentFontSize = cfSize; - SendMessage(hwnd, SCI_STYLESETSIZE, STYLE_DEFAULT, (LPARAM)iCurrentFontSize); } - return iCurrentFontSize; + return fCurrentFontSize; } -int Style_GetCurrentFontSize(HWND hwnd) +float Style_GetCurrentFontSize(HWND hwnd) { - return Style_SetCurrentFontSize(hwnd, -1); + return Style_SetCurrentFontSize(hwnd, -1.0); } @@ -4638,37 +4649,37 @@ BOOL Style_StrGetCharSet(LPCWSTR lpszStyle, int* i) // // Style_StrGetSize() // -BOOL Style_StrGetSize(LPCWSTR lpszStyle, int* i) +BOOL Style_StrGetSize(LPCWSTR lpszStyle, float* f) { WCHAR *p = StrStrI(lpszStyle, L"size:"); if (p) { - int iSign = 0; + float fSign = 0.0; WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; StringCchCopy(tch,COUNTOF(tch),p + CSTRLEN(L"size:")); if (tch[0] == L'+') { - iSign = 1; + fSign = 1.0; tch[0] = L' '; } else if (tch[0] == L'-') { - iSign = -1; + fSign = -1.0; tch[0] = L' '; } p = StrChr(tch, L';'); if (p) { *p = L'\0'; } TrimString(tch); - int iValue = 0; - const int itok = swscanf_s(tch,L"%i",&iValue); + float fValue = 0; + const int itok = swscanf_s(tch,L"%f",&fValue); if (itok == 1) { - if (iSign == 0) - *i = iValue; + if (fSign == 0.0) + *f = fValue; else { // relative size calculation - const int base = *i; // base is input - *i = (base + (iSign * iValue)); // can be negative + const float base = *f; // base is input + *f = (base + (fSign * fValue)); // can be negative } return TRUE; } @@ -5122,20 +5133,20 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam // is "size:" definition relative ? BOOL bRelFontSize = (!StrStrI(lpszStyle, L"size:") || StrStrI(lpszStyle, L"size:+") || StrStrI(lpszStyle, L"size:-")); - const int iBaseFontSize = (bGlobalDefaultStyle ? INITIAL_BASE_FONT_SIZE : + const float fBaseFontSize = (float)(bGlobalDefaultStyle ? (INITIAL_BASE_FONT_SIZE * 1.0) : (bCurrentDefaultStyle ? Style_GetBaseFontSize(hwnd) : Style_GetCurrentFontSize(hwnd))); // Font Height int iFontHeight = 0; - int iFontSize = iBaseFontSize; - if (Style_StrGetSize(lpszStyle,&iFontSize) > 0) { + float fFontSize = fBaseFontSize; + if (Style_StrGetSize(lpszStyle,&fFontSize) > 0.0) { HDC hdc = GetDC(hwnd); - iFontHeight = -MulDiv(iFontSize,GetDeviceCaps(hdc,LOGPIXELSY),72); + iFontHeight = -MulDiv((int)(fFontSize * 100.0 + 0.5), GetDeviceCaps(hdc, LOGPIXELSY), 7200); ReleaseDC(hwnd,hdc); } else { HDC hdc = GetDC(hwnd); - iFontHeight = -MulDiv(iBaseFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); + iFontHeight = -MulDiv((int)(fBaseFontSize * 100.0 + 0.5), GetDeviceCaps(hdc, LOGPIXELSY), 7200); ReleaseDC(hwnd, hdc); } @@ -5234,26 +5245,42 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam } - int iNewFontSize = (int)((cf.iPointSize + 5) / 10); + float fNewFontSize = (float)(cf.iPointSize / 10.0); WCHAR newSize[64] = { L'\0' }; if (bRelFontSize) { - int iNewRelSize = iNewFontSize - iBaseFontSize; + float fNewRelSize = fNewFontSize - fBaseFontSize; - if (iNewRelSize >= 0) - StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:+%i", iNewRelSize); - else - StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:-%i", (0 - iNewRelSize)); + if (fNewRelSize >= 0.0) { + if (HasFractionCent(fNewRelSize)) + StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:+%.2f", fNewRelSize); + else + StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:+%i", (int)fNewRelSize); + } + else { + if (HasFractionCent(fNewRelSize)) + StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:-%.2f", (0.0 - fNewRelSize)); + else + StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:-%i", (int)(0.0 - fNewRelSize)); + } } else { - if (iNewFontSize == iFontSize) { + fFontSize = (float)(((int)(fFontSize * 100.0 + 0.5)) / 100.0); + fNewFontSize = (float)(((int)(fNewFontSize * 100.0 + 0.5)) / 100.0); + if (fNewFontSize == fFontSize) { if (StrStrI(lpszStyle, L"size:")) { - StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:%i", iNewFontSize); + if (HasFractionCent(fNewFontSize)) + StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:%.2f", fNewFontSize); + else + StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:%i", (int)fNewFontSize); } } else { - StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:%i", iNewFontSize); + if (HasFractionCent(fNewFontSize)) + StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:%.2f", fNewFontSize); + else + StringCchPrintfW(newSize, COUNTOF(newSize), L"; size:%i", (int)fNewFontSize); } } StringCchCat(szNewStyle, COUNTOF(szNewStyle), newSize); @@ -5450,15 +5477,15 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle) } } - // Size values are relative to iBaseFontSize - int iValue = IsLexerStandard(g_pLexCurrent) ? Style_GetBaseFontSize(hwnd) : Style_GetCurrentFontSize(hwnd); + // Size values are relative to fBaseFontSize + float fValue = IsLexerStandard(g_pLexCurrent) ? Style_GetBaseFontSize(hwnd) : Style_GetCurrentFontSize(hwnd); - if (Style_StrGetSize(lpszStyle, &iValue) > 0) { - SendMessage(hwnd, SCI_STYLESETSIZE, iStyle, (LPARAM)iValue); - //or Fractional - //SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, iStyle, (LPARAM)(iValue * SC_FONT_SIZE_MULTIPLIER)); + if (Style_StrGetSize(lpszStyle, &fValue) > 0.0) { + //SendMessage(hwnd, SCI_STYLESETSIZE, iStyle, (LPARAM)iValue); + SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, iStyle, (LPARAM)((int)(fValue * SC_FONT_SIZE_MULTIPLIER + 0.5))); } + int iValue = 0; COLORREF dColor = 0L; // Fore if (Style_StrGetColor(TRUE,lpszStyle,&dColor)) @@ -5662,9 +5689,9 @@ void Style_AddLexerToListView(HWND hwnd,PEDITLEXER plex) //============================================================================= // -// Style_ConfigDlgProc() +// Style_CustomizeSchemesDlgProc() // -INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { static HWND hwndTV; @@ -5676,25 +5703,41 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP static HBRUSH hbrBack; static BOOL bIsStyleSelected = FALSE; + static WCHAR* Style_StylesBackup[NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER]; + + WCHAR tchBuf[128] = { L'\0' }; + switch(umsg) { - case WM_INITDIALOG: { - SHFILEINFO shfi; - LOGFONT lf; + // Backup Styles + ZeroMemory(&Style_StylesBackup, NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER * sizeof(WCHAR*)); + int cnt = 0; + for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { + Style_StylesBackup[cnt++] = StrDup(g_pLexArray[iLexer]->szExtensions); + int i = 0; + while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { + Style_StylesBackup[cnt++] = StrDup(g_pLexArray[iLexer]->Styles[i].szValue); + ++i; + } + } hwndTV = GetDlgItem(hwnd,IDC_STYLELIST); fDragging = FALSE; + + SHFILEINFO shfi; + ZeroMemory(&shfi, sizeof(SHFILEINFO)); TreeView_SetImageList(hwndTV, - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO), - SHGFI_SMALLICON | SHGFI_SYSICONINDEX),TVSIL_NORMAL); + (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY,&shfi,sizeof(SHFILEINFO), + SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES),TVSIL_NORMAL); // find current non-standard lexer int found = -1; - for (int i = 2; i < COUNTOF(g_pLexArray); i++) { - if (StringCchCompareX(g_pLexArray[i]->pszName, g_pLexCurrent->pszName) == 0) { + for (int i = 2; i < COUNTOF(g_pLexArray); ++i) { + //if (StringCchCompareX(g_pLexArray[i]->pszName, g_pLexCurrent->pszName) == 0) { + if (g_pLexArray[i] == g_pLexCurrent) { found = i; break; } @@ -5715,12 +5758,11 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP if (Style_GetUse2ndDefault()) hCurrentTVLex = TreeView_GetNextSibling(hwndTV, hCurrentTVLex); } - - pCurrentLexer = NULL; - pCurrentStyle = NULL; - TreeView_Select(hwndTV, hCurrentTVLex, TVGN_CARET); + pCurrentLexer = (found >= 0) ? g_pLexCurrent : GetDefaultLexer(); + pCurrentStyle = &(pCurrentLexer->Styles[STY_DEFAULT]); + SendDlgItemMessage(hwnd,IDC_STYLEEDIT,EM_LIMITTEXT, max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)-1,0); MakeBitmapButton(hwnd,IDC_PREVSTYLE,g_hInstance,IDB_PREV); @@ -5729,27 +5771,64 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP // Setup title font if (hFontTitle) DeleteObject(hFontTitle); + if (NULL == (hFontTitle = (HFONT)SendDlgItemMessage(hwnd,IDC_TITLE,WM_GETFONT,0,0))) hFontTitle = GetStockObject(DEFAULT_GUI_FONT); + + LOGFONT lf; GetObject(hFontTitle,sizeof(LOGFONT),&lf); lf.lfHeight += lf.lfHeight / 5; lf.lfWeight = FW_BOLD; hFontTitle = CreateFontIndirect(&lf); SendDlgItemMessage(hwnd,IDC_TITLE,WM_SETFONT,(WPARAM)hFontTitle,TRUE); - CenterDlgInParent(hwnd); + if (xCustomSchemesDlg == 0 || yCustomSchemesDlg == 0) + CenterDlgInParent(hwnd); + else + SetDlgPos(hwnd, xCustomSchemesDlg, yCustomSchemesDlg); + + HMENU hmenu = GetSystemMenu(hwnd, FALSE); + GetString(IDS_PREVIEW, tchBuf, COUNTOF(tchBuf)); + InsertMenu(hmenu, 0, MF_BYPOSITION | MF_STRING | MF_ENABLED, IDS_PREVIEW, tchBuf); + InsertMenu(hmenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + GetString(IDS_SAVEPOS, tchBuf, COUNTOF(tchBuf)); + InsertMenu(hmenu, 2, MF_BYPOSITION | MF_STRING | MF_ENABLED, IDS_SAVEPOS, tchBuf); + GetString(IDS_RESETPOS, tchBuf, COUNTOF(tchBuf)); + InsertMenu(hmenu, 3, MF_BYPOSITION | MF_STRING | MF_ENABLED, IDS_RESETPOS, tchBuf); + InsertMenu(hmenu, 4, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + } return TRUE; - case WM_DESTROY: - DeleteBitmapButton(hwnd,IDC_STYLEFORE); - DeleteBitmapButton(hwnd,IDC_STYLEBACK); - DeleteBitmapButton(hwnd,IDC_PREVSTYLE); - DeleteBitmapButton(hwnd,IDC_NEXTSTYLE); + { + DeleteBitmapButton(hwnd, IDC_STYLEFORE); + DeleteBitmapButton(hwnd, IDC_STYLEBACK); + DeleteBitmapButton(hwnd, IDC_PREVSTYLE); + DeleteBitmapButton(hwnd, IDC_NEXTSTYLE); + // free old backup + int cnt = 0; + for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { + if (Style_StylesBackup[cnt]) { + LocalFree(Style_StylesBackup[cnt]); + Style_StylesBackup[cnt] = NULL; + } + ++cnt; + int i = 0; + while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { + if (Style_StylesBackup[cnt]) { + LocalFree(Style_StylesBackup[cnt]); + Style_StylesBackup[cnt] = NULL; + } + ++cnt; + ++i; + } + } + pCurrentLexer = NULL; + pCurrentStyle = NULL; + } return FALSE; - #define APPLY_DIALOG_ITEM_TEXT { \ BOOL bChgNfy = FALSE; \ WCHAR szBuf[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)]; \ @@ -5772,6 +5851,20 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP } \ } + + case WM_SYSCOMMAND: + if (wParam == IDS_SAVEPOS) { + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDACC_SAVEPOS, 0), 0); + return TRUE; + } + else if (wParam == IDS_RESETPOS) { + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDACC_RESETPOS, 0), 0); + return TRUE; + } + else + return FALSE; + + case WM_NOTIFY: if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) @@ -5931,10 +6024,8 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP { if (fDragging && bIsStyleSelected) { - HTREEITEM htiTarget; - //ImageList_EndDrag(); - htiTarget = TreeView_GetDropHilight(hwndTV); + HTREEITEM htiTarget = TreeView_GetDropHilight(hwndTV); if (htiTarget) { WCHAR tchCopy[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; @@ -5969,56 +6060,91 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case WM_COMMAND: - - switch(LOWORD(wParam)) { - case IDC_STYLEFORE: - if (pCurrentStyle) + switch (LOWORD(wParam)) + { + case IDC_SETCURLEXERTV: { + // find current lexer's tree entry + HTREEITEM hCurrentTVLex = TreeView_GetRoot(hwndTV); + for (int i = 0; i < COUNTOF(g_pLexArray); ++i) { + if (g_pLexArray[i] == g_pLexCurrent) { + break; + } + hCurrentTVLex = TreeView_GetNextSibling(hwndTV, hCurrentTVLex); // next + } + if (g_pLexCurrent == pCurrentLexer) + break; // no change + + // collaps current node + HTREEITEM hSel = TreeView_GetSelection(hwndTV); + if (hSel) { + HTREEITEM hPar = TreeView_GetParent(hwndTV, hSel); + TreeView_Expand(hwndTV, hSel, TVE_COLLAPSE); + if (hPar) + TreeView_Expand(hwndTV, hPar, TVE_COLLAPSE); + } + + // set new lexer + TreeView_Select(hwndTV, hCurrentTVLex, TVGN_CARET); + TreeView_Expand(hwndTV, hCurrentTVLex, TVE_EXPAND); + + pCurrentLexer = g_pLexCurrent; + pCurrentStyle = &(pCurrentLexer->Styles[STY_DEFAULT]); + + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); + } + break; + + + case IDC_STYLEFORE: + if (pCurrentStyle) { WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; - GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - if (Style_SelectColor(hwnd,TRUE,tch,COUNTOF(tch), TRUE)) { - SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + GetDlgItemText(hwnd, IDC_STYLEEDIT, tch, COUNTOF(tch)); + if (Style_SelectColor(hwnd, TRUE, tch, COUNTOF(tch), TRUE)) { + SetDlgItemText(hwnd, IDC_STYLEEDIT, tch); } } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); break; + case IDC_STYLEBACK: - if (pCurrentStyle) - { + if (pCurrentStyle) { WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; - GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); - if (Style_SelectColor(hwnd,FALSE,tch,COUNTOF(tch), TRUE)) { - SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); + GetDlgItemText(hwnd, IDC_STYLEEDIT, tch, COUNTOF(tch)); + if (Style_SelectColor(hwnd, FALSE, tch, COUNTOF(tch), TRUE)) { + SetDlgItemText(hwnd, IDC_STYLEEDIT, tch); } } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); break; + case IDC_STYLEFONT: if (pCurrentStyle) { WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; GetDlgItemText(hwnd, IDC_STYLEEDIT, tch, COUNTOF(tch)); if (Style_SelectFont(hwnd, tch, COUNTOF(tch), pCurrentLexer->pszName, pCurrentStyle->pszName, - IsStyleStandardDefault(pCurrentStyle), IsStyleSchemeDefault(pCurrentStyle), FALSE, TRUE)) - { + IsStyleStandardDefault(pCurrentStyle), IsStyleSchemeDefault(pCurrentStyle), FALSE, TRUE)) { SetDlgItemText(hwnd, IDC_STYLEEDIT, tch); } } PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); break; + case IDC_STYLEDEFAULT: SetDlgItemText(hwnd, IDC_STYLEEDIT, pCurrentStyle->pszDefault); if (!bIsStyleSelected) { SetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, pCurrentLexer->pszDefExt); } APPLY_DIALOG_ITEM_TEXT; - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); break; + case IDC_STYLEEDIT: { if (HIWORD(wParam) == EN_CHANGE) { @@ -6037,21 +6163,23 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP } break; + case IDC_IMPORT: { - hwndTV = GetDlgItem(hwnd,IDC_STYLELIST); + hwndTV = GetDlgItem(hwnd, IDC_STYLELIST); if (Style_Import(hwnd)) { SetDlgItemText(hwnd, IDC_STYLEEDIT, pCurrentStyle->szValue); if (!bIsStyleSelected) { SetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, pCurrentLexer->szExtensions); } - TreeView_Select(hwndTV,TreeView_GetRoot(hwndTV),TVGN_CARET); + TreeView_Select(hwndTV, TreeView_GetRoot(hwndTV), TVGN_CARET); Style_SetLexer(g_hwndEdit, g_pLexCurrent); } } break; + case IDC_EXPORT: { APPLY_DIALOG_ITEM_TEXT; @@ -6059,12 +6187,14 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP } break; + case IDC_PREVIEW: { APPLY_DIALOG_ITEM_TEXT; } break; + case IDC_PREVSTYLE: { APPLY_DIALOG_ITEM_TEXT; @@ -6078,6 +6208,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP } break; + case IDC_NEXTSTYLE: { APPLY_DIALOG_ITEM_TEXT; @@ -6091,79 +6222,87 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP } break; + case IDOK: APPLY_DIALOG_ITEM_TEXT; - EndDialog(hwnd,IDOK); + g_fStylesModified = TRUE; + if (!g_fWarnedNoIniFile && (StringCchLenW(g_wchIniFile, COUNTOF(g_wchIniFile)) == 0)) { + MsgBox(MBWARN, IDS_SETTINGSNOTSAVED); + g_fWarnedNoIniFile = TRUE; + } + //EndDialog(hwnd,IDOK); + DestroyWindow(hwnd); break; + case IDCANCEL: - if (fDragging) - SendMessage(hwnd,WM_CANCELMODE,0,0); - else - EndDialog(hwnd,IDCANCEL); + if (fDragging) { + SendMessage(hwnd, WM_CANCELMODE, 0, 0); + } + else { + APPLY_DIALOG_ITEM_TEXT; + // Restore Styles + int cnt = 0; + for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { + StringCchCopy(g_pLexArray[iLexer]->szExtensions, COUNTOF(g_pLexArray[iLexer]->szExtensions), Style_StylesBackup[cnt]); + ++cnt; + int i = 0; + while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { + StringCchCopy(g_pLexArray[iLexer]->Styles[i].szValue, COUNTOF(g_pLexArray[iLexer]->Styles[i].szValue), Style_StylesBackup[cnt]); + ++cnt; + ++i; + } + } + Style_SetLexer(g_hwndEdit, g_pLexCurrent); + //EndDialog(hwnd,IDCANCEL); + DestroyWindow(hwnd); + } break; - } + case IDACC_VIEWSCHEMECONFIG: + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_SETCURLEXERTV, 1), 0); + break; + + case IDACC_PREVIEW: + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_PREVIEW, 1), 0); + break; + + case IDACC_SAVEPOS: + GetDlgPos(hwnd, &xCustomSchemesDlg, &yCustomSchemesDlg); + break; + + case IDACC_RESETPOS: + CenterDlgInParent(hwnd); + xCustomSchemesDlg = yCustomSchemesDlg = 0; + break; + + + default: + // return FALSE??? + break; + + } // switch() + } // WM_COMMAND return TRUE; - } - return FALSE; - } //============================================================================= // -// Style_ConfigDlg() +// Style_CustomizeSchemesDlg() // -void Style_ConfigDlg(HWND hwnd) +HWND Style_CustomizeSchemesDlg(HWND hwnd) { - WCHAR* StyleBackup[NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER]; - int c,cItems,i,iLexer; - - // Backup Styles - c = 0; - for (iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) { - StyleBackup[c++] = StrDup(g_pLexArray[iLexer]->szExtensions); - i = 0; - while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { - StyleBackup[c++] = StrDup(g_pLexArray[iLexer]->Styles[i].szValue); - i++; - } - } - cItems = c; - - if (IDCANCEL == ThemedDialogBoxParam(g_hInstance, - MAKEINTRESOURCE(IDD_STYLECONFIG), - GetParent(hwnd),Style_ConfigDlgProc, - (LPARAM)&StyleBackup)) - { - // Restore Styles - c = 0; - for (iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) { - StringCchCopy(g_pLexArray[iLexer]->szExtensions,COUNTOF(g_pLexArray[iLexer]->szExtensions),StyleBackup[c++]); - i = 0; - while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { - StringCchCopy(g_pLexArray[iLexer]->Styles[i].szValue,COUNTOF(g_pLexArray[iLexer]->Styles[i].szValue),StyleBackup[c++]); - i++; - } - } - } - else { - g_fStylesModified = TRUE; - if (!g_fWarnedNoIniFile && (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) == 0)) { - MsgBox(MBWARN,IDS_SETTINGSNOTSAVED); - g_fWarnedNoIniFile = TRUE; - } - } - - for (c = 0; c < cItems; c++) { - LocalFree(StyleBackup[c]); - } - // Apply new (or previous) Styles - Style_SetLexer(hwnd,g_pLexCurrent); + HWND hDlg = CreateThemedDialogParam(g_hInstance, + MAKEINTRESOURCE(IDD_STYLECONFIG), + GetParent(hwnd), + Style_CustomizeSchemesDlgProc, + (LPARAM)NULL); + ShowWindow(hDlg, SW_SHOW); + return hDlg; } @@ -6184,10 +6323,8 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR switch(umsg) { - case WM_INITDIALOG: { - int i; int lvItems; LVITEM lvi; SHFILEINFO shfi; @@ -6228,11 +6365,13 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR hwndLV = GetDlgItem(hwnd,IDC_STYLELIST); ListView_SetImageList(hwndLV, - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX), + (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY, + &shfi,sizeof(SHFILEINFO),SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES), LVSIL_SMALL); ListView_SetImageList(hwndLV, - (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX), + (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY, + &shfi,sizeof(SHFILEINFO),SHGFI_LARGEICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES), LVSIL_NORMAL); //SetExplorerTheme(hwndLV); @@ -6240,7 +6379,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR ListView_InsertColumn(hwndLV,0,&lvc); // Add lexers - for (i = 0; i < COUNTOF(g_pLexArray); i++) { + for (int i = 0; i < COUNTOF(g_pLexArray); i++) { Style_AddLexerToListView(hwndLV, g_pLexArray[i]); } ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER); @@ -6248,7 +6387,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR // Select current lexer lvItems = ListView_GetItemCount(hwndLV); lvi.mask = LVIF_PARAM; - for (i = 0; i < lvItems; i++) { + for (int i = 0; i < lvItems; i++) { lvi.iItem = i; ListView_GetItem(hwndLV,&lvi); if (StringCchCompareX(((PEDITLEXER)lvi.lParam)->pszName, g_pLexCurrent->pszName) == 0) @@ -6275,7 +6414,6 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR case WM_DESTROY: { RECT rc; - GetWindowRect(hwnd,&rc); g_cxStyleSelectDlg = rc.right-rc.left; g_cyStyleSelectDlg = rc.bottom-rc.top; @@ -6336,41 +6474,40 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR return TRUE; - case WM_NOTIFY: { - if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) { + case WM_NOTIFY: + { + if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) { - switch (((LPNMHDR)(lParam))->code) { + switch (((LPNMHDR)(lParam))->code) { - case NM_DBLCLK: - SendMessage(hwnd,WM_COMMAND,MAKELONG(IDOK,1),0); - break; + case NM_DBLCLK: + SendMessage(hwnd, WM_COMMAND, MAKELONG(IDOK, 1), 0); + break; - case LVN_ITEMCHANGED: - case LVN_DELETEITEM: { - int i = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); - if (iInternalDefault == i) - CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_CHECKED); - else - CheckDlgButton(hwnd,IDC_DEFAULTSCHEME,BST_UNCHECKED); - DialogEnableWindow(hwnd,IDC_DEFAULTSCHEME,i != -1); - DialogEnableWindow(hwnd,IDOK,i != -1); + case LVN_ITEMCHANGED: + case LVN_DELETEITEM: + { + int i = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED); + if (iInternalDefault == i) + CheckDlgButton(hwnd, IDC_DEFAULTSCHEME, BST_CHECKED); + else + CheckDlgButton(hwnd, IDC_DEFAULTSCHEME, BST_UNCHECKED); + DialogEnableWindow(hwnd, IDC_DEFAULTSCHEME, i != -1); + DialogEnableWindow(hwnd, IDOK, i != -1); + } + break; } - break; } } - } - return TRUE; case WM_COMMAND: - - switch(LOWORD(wParam)) { - + switch (LOWORD(wParam)) { case IDC_DEFAULTSCHEME: - if (IsDlgButtonChecked(hwnd,IDC_DEFAULTSCHEME) == BST_CHECKED) - iInternalDefault = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); + if (IsDlgButtonChecked(hwnd, IDC_DEFAULTSCHEME) == BST_CHECKED) + iInternalDefault = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED); else iInternalDefault = 0; break; @@ -6379,13 +6516,12 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR case IDOK: { LVITEM lvi; - lvi.mask = LVIF_PARAM; - lvi.iItem = ListView_GetNextItem(hwndLV,-1,LVNI_ALL | LVNI_SELECTED); - if (ListView_GetItem(hwndLV,&lvi)) { + lvi.iItem = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED); + if (ListView_GetItem(hwndLV, &lvi)) { g_pLexCurrent = (PEDITLEXER)lvi.lParam; g_iDefaultLexer = iInternalDefault; - g_bAutoSelect = (IsDlgButtonChecked(hwnd,IDC_AUTOSELECT) == BST_CHECKED) ? 1 : 0; + g_bAutoSelect = (IsDlgButtonChecked(hwnd, IDC_AUTOSELECT) == BST_CHECKED) ? 1 : 0; EndDialog(hwnd,IDOK); } } @@ -6393,17 +6529,14 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR case IDCANCEL: - EndDialog(hwnd,IDCANCEL); + EndDialog(hwnd, IDCANCEL); break; - } - + } // switch() + } // WM_COMMAND return TRUE; - } - return FALSE; - } @@ -6414,10 +6547,10 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR void Style_SelectLexerDlg(HWND hwnd) { if (IDOK == ThemedDialogBoxParam(g_hInstance, - MAKEINTRESOURCE(IDD_STYLESELECT), - GetParent(hwnd),Style_SelectLexerDlgProc,0)) + MAKEINTRESOURCE(IDD_STYLESELECT), + GetParent(hwnd), Style_SelectLexerDlgProc, 0)) - Style_SetLexer(hwnd,g_pLexCurrent); + Style_SetLexer(hwnd, g_pLexCurrent); } // End of Styles.c diff --git a/src/Styles.h b/src/Styles.h index 6b9eb1afc..adef1450d 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -87,16 +87,16 @@ void Style_SetDefaultFont(HWND,BOOL); void Style_ToggleUse2ndDefault(HWND); BOOL Style_GetUse2ndDefault(); BOOL Style_SetUse2ndDefault(int); // in:BOOL -int Style_GetBaseFontSize(HWND); -int Style_SetBaseFontSize(HWND,int); -int Style_GetCurrentFontSize(HWND); -int Style_SetCurrentFontSize(HWND, int); +float Style_GetBaseFontSize(HWND); +float Style_SetBaseFontSize(HWND,float); +float Style_GetCurrentFontSize(HWND); +float Style_SetCurrentFontSize(HWND,float); void Style_SetIndentGuides(HWND,BOOL); BOOL Style_GetOpenDlgFilterStr(LPWSTR,int); BOOL Style_StrGetFont(LPCWSTR,LPWSTR,int); BOOL Style_StrGetFontQuality(LPCWSTR,LPWSTR,int); BOOL Style_StrGetCharSet(LPCWSTR,int*); -BOOL Style_StrGetSize(LPCWSTR,int*); +BOOL Style_StrGetSize(LPCWSTR,float*); BOOL Style_StrGetSizeStr(LPCWSTR,LPWSTR,int); BOOL Style_StrGetColor(BOOL,LPCWSTR, COLORREF*); BOOL Style_StrGetCase(LPCWSTR,int*); @@ -112,7 +112,7 @@ int Style_GetLexerIconId(PEDITLEXER); BOOL Style_HasLexerForExt(LPCWSTR); HTREEITEM Style_AddLexerToTreeView(HWND,PEDITLEXER); INT_PTR CALLBACK Styles_ConfigDlgProc(HWND,UINT,WPARAM,LPARAM); -void Style_ConfigDlg(HWND); +HWND Style_CustomizeSchemesDlg(HWND); INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND,UINT,WPARAM,LPARAM); void Style_SelectLexerDlg(HWND); int Style_GetHotspotStyleID(); diff --git a/src/resource.h b/src/resource.h index 5e611296e..08ac6820e 100644 --- a/src/resource.h +++ b/src/resource.h @@ -135,6 +135,7 @@ #define IDC_CHECK_OCC 231 #define IDC_PRINTER 232 #define IDC_USEASREADINGFALLBACK 233 +#define IDR_ACCCUSTOMSCHEMES 234 #define IDACC_FIND 302 #define IDACC_REPLACE 303 #define IDACC_SAVEPOS 304 @@ -145,8 +146,11 @@ #define IDACC_SAVEFIND 309 #define IDACC_SELTONEXT 310 #define IDACC_SELTOPREV 311 +#define IDACC_VIEWSCHEMECONFIG 312 +#define IDACC_PREVIEW 313 #define IDC_NFOASOEM 400 #define IDC_COMPILER 401 +#define IDC_SETCURLEXERTV 402 #define IDD_READPW 501 #define IDC_CHECK1 502 #define IDC_EDIT1 503 @@ -447,6 +451,7 @@ #define IDT_FILE_LAUNCH 40724 #define IDS_SAVEPOS 40800 #define IDS_RESETPOS 40801 +#define IDS_PREVIEW 40802 #define IDS_ERR_LOADFILE 50000 #define IDS_ERR_SAVEFILE 50001 #define IDS_ERR_BROWSE 50002