diff --git a/src/Edit.c b/src/Edit.c index 682f78ca3..633525424 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5765,9 +5765,13 @@ void EditUpdateUrlHotspots(HWND hwnd, int startPos, int endPos, BOOL bActiveHots if (iPos < 0) break; // not found + int mlen = end - start; + if ((mlen <= 0) || ((iPos + mlen) > endPos)) + break; // wrong match + // mark this match SciCall_StartStyling(iPos); - SciCall_SetStyling((end - start), iStyle); + SciCall_SetStyling(mlen, iStyle); // next occurrence start = end; diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 1ce9847ee..0664ff9c2 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -12,7 +12,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Englisch (USA) resources +// English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US @@ -309,9 +309,9 @@ BEGIN MENUITEM "Match &Case Sensitive", IDM_VIEW_MARKOCCUR_CASE POPUP "Match &Whole Word Only" BEGIN - MENUITEM "OFF" IDM_VIEW_MARKOCCUR_WNONE - MENUITEM "Match &Selected Word", IDM_VIEW_MARKOCCUR_WORD - MENUITEM "Match &Current Word", IDM_VIEW_MARKOCCUR_CURRENT + MENUITEM "OFF", IDM_VIEW_MARKOCCUR_WNONE + MENUITEM "Match &Selected Word", IDM_VIEW_MARKOCCUR_WORD + MENUITEM "Match &Current Word", IDM_VIEW_MARKOCCUR_CURRENT END END MENUITEM SEPARATOR @@ -817,30 +817,31 @@ BEGIN SCROLLBAR IDC_RESIZEGRIP3,7,117,10,10 END -IDD_STYLECONFIG DIALOGEX 0, 0, 468, 238 +IDD_STYLECONFIG DIALOGEX 0, 0, 467, 254 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Customize Schemes" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "",IDC_STYLELIST,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_SINGLEEXPAND | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,164,224 - LTEXT "",IDC_STYLELABEL,182,144,279,8 - EDITTEXT IDC_STYLEEDIT,182,156,279,12,ES_AUTOHSCROLL - PUSHBUTTON "For&e...",IDC_STYLEFORE,181,174,46,14 - PUSHBUTTON "&Back...",IDC_STYLEBACK,232,174,46,14 - PUSHBUTTON "&Font...",IDC_STYLEFONT,283,174,42,14 - PUSHBUTTON "&Preview",IDC_PREVIEW,330,174,42,14 - PUSHBUTTON "&Reset",IDC_STYLEDEFAULT,377,174,42,14 - PUSHBUTTON "",IDC_PREVSTYLE,426,174,15,14 - PUSHBUTTON "",IDC_NEXTSTYLE,446,174,15,14 - PUSHBUTTON "&Import...",IDC_IMPORT,181,217,50,14 - PUSHBUTTON "E&xport...",IDC_EXPORT,237,217,50,14 - DEFPUSHBUTTON "OK",IDOK,355,217,50,14 - PUSHBUTTON "Cancel",IDCANCEL,411,217,50,14 - GROUPBOX "Info",IDC_STATIC,181,7,280,127 + CONTROL "",IDC_STYLELIST,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_SINGLEEXPAND | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,164,240 + LTEXT "",IDC_STYLELABEL,181,171,279,8 + PUSHBUTTON "For&e...",IDC_STYLEFORE,181,201,46,14 + PUSHBUTTON "&Back...",IDC_STYLEBACK,232,201,46,14 + PUSHBUTTON "&Font...",IDC_STYLEFONT,283,201,42,14 + PUSHBUTTON "&Preview",IDC_PREVIEW,330,201,42,14 + PUSHBUTTON "&Reset",IDC_STYLEDEFAULT,377,201,42,14 + PUSHBUTTON "",IDC_PREVSTYLE,426,201,15,14 + PUSHBUTTON "",IDC_NEXTSTYLE,445,201,15,14 + PUSHBUTTON "&Import...",IDC_IMPORT,181,233,50,14 + PUSHBUTTON "E&xport...",IDC_EXPORT,237,233,50,14 + DEFPUSHBUTTON "OK",IDOK,355,233,50,14 + PUSHBUTTON "Cancel",IDCANCEL,410,233,50,14 + GROUPBOX "Info",IDC_STATIC,180,7,280,127 ICON IDI_STYLES,IDC_STATIC,189,19,20,20 LTEXT "Customize Schemes",IDC_TITLE,220,25,200,12 LTEXT "Filename extensions must be separated by ;\n\nStyle format:\nfont:Name;size:nn;bold;italic;underline;fore:#ffffff;back:#bbbbbb;eolfilled\n\nStyle properties can be copied using copy and paste or drag and drop.\n\nThe ""Preview"" button will not apply any changes.",IDC_STATIC,197,50,252,70 - LTEXT "Associated file&name extensions:|Style &settings:",IDC_STYLELABELS,315,230,152,8,NOT WS_VISIBLE + EDITTEXT IDC_STYLEEDIT,181,183,279,12,ES_AUTOHSCROLL + EDITTEXT IDC_STYLEEDIT_ROOT,181,152,279,12,ES_AUTOHSCROLL + LTEXT "",IDC_STYLELABEL_ROOT,181,141,279,8 END IDD_TABSETTINGS DIALOGEX 0, 0, 174, 90 @@ -1240,9 +1241,9 @@ BEGIN IDD_STYLECONFIG, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 461 + RIGHTMARGIN, 460 TOPMARGIN, 7 - BOTTOMMARGIN, 231 + BOTTOMMARGIN, 247 END IDD_TABSETTINGS, DIALOG @@ -1400,6 +1401,10 @@ END STRINGTABLE BEGIN IDS_PASS_FAILURE "The passphrase is incorrect." +END + +STRINGTABLE +BEGIN IDS_NOPASS "Cancelled - no passphrase." END @@ -1448,7 +1453,6 @@ BEGIN IDT_EDIT_CUT "Cut" IDT_EDIT_COPY "Copy" IDT_EDIT_PASTE "Paste" - IDT_EDIT_CLEAR "Delete" IDT_EDIT_FIND "Find" IDT_EDIT_REPLACE "Replace" IDT_VIEW_WORDWRAP "Word Wrap" @@ -1459,6 +1463,7 @@ BEGIN IDT_FILE_EXIT "Exit" IDT_FILE_SAVEAS "Save As" IDT_FILE_SAVECOPY "Save Copy" + IDT_EDIT_CLEAR "Delete" END STRINGTABLE @@ -1917,12 +1922,12 @@ BEGIN 63265 "2nd Hyperlink Hotspots" END -#endif // Englisch (USA) resources +#endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Deutsch (Schweiz) resources +// German (Switzerland) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DES) LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_SWISS @@ -1951,7 +1956,7 @@ END #endif // APSTUDIO_INVOKED -#endif // Deutsch (Schweiz) resources +#endif // German (Switzerland) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/Styles.c b/src/Styles.c index e4e80b468..5936b5879 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -44,6 +44,7 @@ extern HINSTANCE g_hInstance; extern HWND g_hwndMain; +extern HWND g_hwndEdit; extern int iSciFontQuality; extern const int FontQuality[4]; @@ -3134,6 +3135,9 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { pLexNew = &lexStandard; } + // first set standard lexer's default values + g_pLexCurrent = &lexStandard; + // Lexer SendMessage(hwnd, SCI_SETLEXER, pLexNew->iLexer, 0); @@ -3176,17 +3180,13 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { SendMessage(hwnd, SCI_SETKEYWORDS, i, (LPARAM)pLexNew->pKeyWords->pszKeyWords[i]); } - - // first set standard lexer's default values - g_pLexCurrent = &lexStandard; - - WCHAR* wchStandardStyleStrg = lexStandard.Styles[STDLEXID(STY_DEFAULT)].szValue; - // Clear SendMessage(hwnd, SCI_CLEARDOCUMENTSTYLE, 0, 0); + WCHAR* wchStandardStyleStrg = lexStandard.Styles[STDLEXID(STY_DEFAULT)].szValue; + // Idle Styling (very large text) - //SendMessage(hwnd, SCI_SETIDLESTYLING, SC_IDLESTYLING_ALL, 0); + SendMessage(hwnd, SCI_SETIDLESTYLING, SC_IDLESTYLING_ALL, 0); // Default Values are always set SendMessage(hwnd, SCI_STYLERESETDEFAULT, 0, 0); @@ -3223,7 +3223,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { int iBaseFontSize = INITIAL_BASE_FONT_SIZE; // init Style_StrGetSize(wchStandardStyleStrg, &iBaseFontSize); - Style_SetBaseFontSize(hwnd, iBaseFontSize); // apply + Style_SetBaseFontSize(hwnd, iBaseFontSize); Style_SetCurrentFontSize(hwnd, iBaseFontSize); if (!Style_StrGetCharSet(wchStandardStyleStrg, &iValue)) { @@ -3248,22 +3248,19 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { SendMessage(hwnd, SCI_STYLESETEOLFILLED, STYLE_DEFAULT, (LPARAM)FALSE); - // --- apply default style --- + // --- apply default style --- Style_SetStyles(hwnd, STYLE_DEFAULT, wchStandardStyleStrg); // --- apply current scheme specific settings to default style --- - - // global define current lexer - g_pLexCurrent = pLexNew; - - if (g_pLexCurrent != &lexStandard) + if (pLexNew != &lexStandard) { - WCHAR* wchCurrentLexerStyleStrg = g_pLexCurrent->Styles[STY_DEFAULT].szValue; - // use this font size as new base - Style_StrGetSize(wchCurrentLexerStyleStrg, &iBaseFontSize); - Style_SetCurrentFontSize(hwnd, iBaseFontSize); + WCHAR* wchCurrentLexerStyleStrg = pLexNew->Styles[STY_DEFAULT].szValue; // 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); + Style_SetCurrentFontSize(hwnd, iBaseFontSize); EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_CURRENTSCHEME, TRUE); } else { @@ -3277,7 +3274,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { // -------------------------------------------------------------------------- Style_SetStyles(hwnd, lexStandard.Styles[STDLEXID(STY_MARGIN)].iStyle, - lexStandard.Styles[STDLEXID(STY_MARGIN)].szValue); // linenumber + lexStandard.Styles[STDLEXID(STY_MARGIN)].szValue); // line number if (bUseOldStyleBraceMatching) { Style_SetStyles(hwnd, lexStandard.Styles[STDLEXID(STY_BRACE_OK)].iStyle, @@ -3521,7 +3518,8 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { int iDescent = 0; int iValAdj = min(max(iValue,0),64); if (iValAdj != iValue) - StringCchPrintf(lexStandard.Styles[STDLEXID(STY_X_LN_SPACE)].szValue, COUNTOF(lexStandard.Styles[STDLEXID(STY_X_LN_SPACE)].szValue), L"size:%i", iValAdj); + StringCchPrintf(lexStandard.Styles[STDLEXID(STY_X_LN_SPACE)].szValue, + COUNTOF(lexStandard.Styles[STDLEXID(STY_X_LN_SPACE)].szValue), L"size:%i", iValAdj); if ((iValAdj % 2) != 0) { iAscent++; @@ -3573,58 +3571,60 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { if (SendMessage(hwnd,SCI_GETINDENTATIONGUIDES,0,0) != SC_IV_NONE) Style_SetIndentGuides(hwnd,TRUE); + // here: global define current lexer (used in subsequent calls) + g_pLexCurrent = pLexNew; - if (pLexNew->iLexer != SCLEX_NULL || pLexNew == &lexANSI) + if (g_pLexCurrent->iLexer != SCLEX_NULL || g_pLexCurrent == &lexANSI) { int j; int i = 1; // don't re-apply lexers default style - while (pLexNew->Styles[i].iStyle != -1) + while (g_pLexCurrent->Styles[i].iStyle != -1) { - for (j = 0; j < 4 && (pLexNew->Styles[i].iStyle8[j] != 0 || j == 0); ++j) { - Style_SetStyles(hwnd, pLexNew->Styles[i].iStyle8[j], pLexNew->Styles[i].szValue); + for (j = 0; j < 4 && (g_pLexCurrent->Styles[i].iStyle8[j] != 0 || j == 0); ++j) { + Style_SetStyles(hwnd, g_pLexCurrent->Styles[i].iStyle8[j], g_pLexCurrent->Styles[i].szValue); } - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HPHP_DEFAULT) { + if (g_pLexCurrent->iLexer == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HPHP_DEFAULT) { int iRelated[] = { SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJ_DEFAULT) { + if (g_pLexCurrent->iLexer == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HJ_DEFAULT) { int iRelated[] = { SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD, SCE_HJ_DOUBLESTRING, SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER, SCE_HJ_SYMBOLS }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJA_DEFAULT) { + if (g_pLexCurrent->iLexer == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HJA_DEFAULT) { int iRelated[] = { SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING, SCE_HJA_SINGLESTRING, SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HB_DEFAULT) { + if (g_pLexCurrent->iLexer == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HB_DEFAULT) { int iRelated[] = { SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING, SCE_HB_STRINGEOL, SCE_HB_NUMBER }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HBA_DEFAULT) { + if (g_pLexCurrent->iLexer == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HBA_DEFAULT) { int iRelated[] = { SCE_HBA_COMMENTLINE, SCE_HBA_WORD, SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL, SCE_HBA_NUMBER }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML) && pLexNew->Styles[i].iStyle8[0] == SCE_H_SGML_DEFAULT) { + if ((g_pLexCurrent->iLexer == SCLEX_HTML || g_pLexCurrent->iLexer == SCLEX_XML) && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_SGML_DEFAULT) { int iRelated[] = { SCE_H_SGML_COMMAND, SCE_H_SGML_1ST_PARAM, SCE_H_SGML_DOUBLESTRING, SCE_H_SGML_SIMPLESTRING, SCE_H_SGML_ERROR, SCE_H_SGML_SPECIAL, SCE_H_SGML_ENTITY, SCE_H_SGML_COMMENT, SCE_H_SGML_1ST_PARAM_COMMENT, SCE_H_SGML_BLOCK_DEFAULT }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML) && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) { + if ((g_pLexCurrent->iLexer == SCLEX_HTML || g_pLexCurrent->iLexer == SCLEX_XML) && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_CDATA) { int iRelated[] = { SCE_HP_START, SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING, SCE_HP_CHARACTER, SCE_HP_WORD, SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME, SCE_HP_DEFNAME, SCE_HP_OPERATOR, SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT, @@ -3632,10 +3632,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if (pLexNew->iLexer == SCLEX_XML && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) { + if (g_pLexCurrent->iLexer == SCLEX_XML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_CDATA) { int iRelated[] = { SCE_H_SCRIPT, SCE_H_ASP, SCE_H_ASPAT, SCE_H_QUESTION, SCE_HPHP_DEFAULT, SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, @@ -3654,19 +3654,19 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) { SCE_HPA_STRING, SCE_HPA_CHARACTER, SCE_HPA_WORD, SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if (pLexNew->iLexer == SCLEX_CPP && pLexNew->Styles[i].iStyle8[0] == SCE_C_COMMENT) { + if (g_pLexCurrent->iLexer == SCLEX_CPP && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_C_COMMENT) { int iRelated[] = { SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } - if (pLexNew -> iLexer == SCLEX_SQL && pLexNew->Styles[i].iStyle8[0] == SCE_SQL_COMMENT) { + if (g_pLexCurrent -> iLexer == SCLEX_SQL && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_SQL_COMMENT) { int iRelated[] = { SCE_SQL_COMMENTLINE, SCE_SQL_COMMENTDOC, SCE_SQL_COMMENTLINEDOC, SCE_SQL_COMMENTDOCKEYWORD, SCE_SQL_COMMENTDOCKEYWORDERROR }; for (j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],pLexNew->Styles[i].szValue); + Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue); } i++; } @@ -4158,7 +4158,8 @@ void Style_SetDefaultFont(HWND hwnd, BOOL bGlobalDefault) BOOL bIsCurrentDefault = (pLexer->Styles[iStyle].rid == 63126); //(StringCchCompareIX(pLexer->Styles[iStyle].pszName, L"Default") == 0); - if (Style_SelectFont(hwnd, newStyle, COUNTOF(newStyle), bIsGlobalDefault, bIsCurrentDefault, FALSE, TRUE)) + if (Style_SelectFont(hwnd, newStyle, COUNTOF(newStyle), pLexer->pszName, pLexer->Styles[iStyle].pszName, + bIsGlobalDefault, bIsCurrentDefault, FALSE, TRUE)) { // set new styles to current lexer's default text StringCchCopyW(pLexer->Styles[iStyle].szValue, COUNTOF(pLexer->Styles[iStyle].szValue), newStyle); @@ -4776,15 +4777,9 @@ void Style_CopyStyles_IfNotDefined(LPWSTR lpszStyleSrc, LPWSTR lpszStyleDest, in } - -static const WCHAR* FontSelTitle1 = L"Global Default Font"; -static const WCHAR* FontSelTitle2 = L"Current Scheme's Default Font"; -static const WCHAR* FontSelTitle3 = L"++ Global Default Font ++"; -static const WCHAR* FontSelTitle4 = L"++ Current Scheme's Default Font ++"; - +/// Callback to set the font dialog's title static WCHAR FontSelTitle[128]; -/// Callback to set the font dialog's title static UINT CALLBACK Style_FontDialogHook( HWND hdlg, // handle to the dialog box window UINT uiMsg, // message identifier @@ -4803,7 +4798,7 @@ static UINT CALLBACK Style_FontDialogHook( // // Style_SelectFont() // -BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, +BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerName, LPCWSTR sStyleName, BOOL bGlobalDefaultStyle, BOOL bCurrentDefaultStyle, BOOL bWithEffects, BOOL bPreserveStyles) { @@ -4821,13 +4816,13 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, if (!Style_StrGetCharSet(lpszStyle, &iCharSet)) { iCharSet = iDefaultCharSet; } - - const int iBaseFontSize = (bGlobalDefaultStyle ? INITIAL_BASE_FONT_SIZE : - (bCurrentDefaultStyle ? Style_GetBaseFontSize(hwnd) : Style_GetCurrentFontSize(hwnd))); - + // 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 : + (bCurrentDefaultStyle ? Style_GetBaseFontSize(hwnd) : Style_GetCurrentFontSize(hwnd))); + // Font Height int iFontHeight = 0; int iFontSize = iBaseFontSize; @@ -4883,23 +4878,21 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, if (bGlobalDefaultStyle) { if (bRelFontSize) - StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), - L" +++ Global (%s) %s Font +++", (Style_GetUse2ndDefault() ? L"2nd Scheme" : L"1st Scheme"), lexStandard.pszName); + StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" +++ BASE (%s) +++", sStyleName); else - StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), - L" Global (%s) %s Font", (Style_GetUse2ndDefault() ? L"2nd Scheme" : L"1st Scheme"), lexStandard.pszName); + StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" BASE (%s)", sStyleName); } else if (bCurrentDefaultStyle) { if (bRelFontSize) - StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" +++ Default %s Font +++", g_pLexCurrent->pszName); + StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" +++ %s: %s Style +++", sLexerName, sStyleName); else - StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" Default %s Font", g_pLexCurrent->pszName); + StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" %s: %s Style", sLexerName, sStyleName); } else { if (bRelFontSize) - StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" +++ %s Font +++", g_pLexCurrent->pszName); + StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" +++ Style '%s' (%s) +++", sStyleName, sLexerName); else - StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" %s Font", g_pLexCurrent->pszName); + StringCchPrintfW(FontSelTitle, COUNTOF(FontSelTitle), L" Style '%s' (%s)", sStyleName, sLexerName); } if (bWithEffects) @@ -5157,7 +5150,7 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle) } // Size values are relative to iBaseFontSize - int iValue = (g_pLexCurrent == &lexStandard) ? INITIAL_BASE_FONT_SIZE : Style_GetBaseFontSize(hwnd); + int iValue = (g_pLexCurrent == &lexStandard) ? Style_GetBaseFontSize(hwnd) : Style_GetCurrentFontSize(hwnd); if (Style_StrGetSize(lpszStyle, &iValue)) { SendMessage(hwnd, SCI_STYLESETSIZE, iStyle, (LPARAM)iValue); //or Fractional @@ -5291,7 +5284,6 @@ int Style_GetLexerIconId(PEDITLEXER plex) // HTREEITEM Style_AddLexerToTreeView(HWND hwnd,PEDITLEXER plex) { - int i = 0; WCHAR tch[MIDSZ_BUFFER] = { L'\0' }; HTREEITEM hTreeNode; @@ -5318,6 +5310,7 @@ HTREEITEM Style_AddLexerToTreeView(HWND hwnd,PEDITLEXER plex) //tvis.item.iImage = -1; //tvis.item.iSelectedImage = -1; + int i = 1; // default style is handled separately while (plex->Styles[i].iStyle != -1) { if (GetString(plex->Styles[i].rid,tch,COUNTOF(tch))) @@ -5370,6 +5363,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP static HFONT hFontTitle; static HBRUSH hbrFore; static HBRUSH hbrBack; + static BOOL bIsStyleSelected = FALSE; switch(umsg) { @@ -5401,6 +5395,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP Style_AddLexerToTreeView(hwndTV,pLexArray[i]); } + pCurrentLexer = NULL; pCurrentStyle = NULL; //SetExplorerTheme(hwndTV); @@ -5436,6 +5431,28 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP return FALSE; + #define APPLY_DIALOG_ITEM_TEXT { \ + BOOL bChgNfy = FALSE; \ + WCHAR szBuf[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)]; \ + GetDlgItemText(hwnd, IDC_STYLEEDIT, szBuf, COUNTOF(szBuf)); \ + if (StringCchCompareIXW(szBuf, pCurrentStyle->szValue) != 0) { \ + StringCchCopyW(pCurrentStyle->szValue, COUNTOF(pCurrentStyle->szValue), szBuf); \ + bChgNfy = TRUE; \ + } \ + if (!bIsStyleSelected) { \ + if (!GetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, szBuf, COUNTOF(szBuf))) { \ + StringCchCopy(szBuf, COUNTOF(szBuf), pCurrentLexer->pszDefExt); \ + } \ + if (StringCchCompareIXW(szBuf, pCurrentLexer->szExtensions) != 0) { \ + StringCchCopyW(pCurrentLexer->szExtensions, COUNTOF(pCurrentLexer->szExtensions), szBuf); \ + bChgNfy = TRUE; \ + } \ + } \ + if (bChgNfy && ((pCurrentLexer == &lexStandard) || (pCurrentLexer == g_pLexCurrent))) { \ + Style_SetLexer(g_hwndEdit, g_pLexCurrent); \ + } \ + } + case WM_NOTIFY: if (((LPNMHDR)(lParam))->idFrom == IDC_STYLELIST) @@ -5447,93 +5464,85 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case TVN_SELCHANGED: { - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - - else if (pCurrentLexer) { - WCHAR szBuf[BUFZIZE_STYLE_EXTENTIONS] = { L'\0' }; - if (GetDlgItemText(hwnd, IDC_STYLEEDIT, szBuf, COUNTOF(szBuf))) - StringCchCopy(pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions),szBuf); + if (pCurrentLexer && pCurrentStyle) { + APPLY_DIALOG_ITEM_TEXT; } + WCHAR label[128] = { L'\0' }; + + //DialogEnableWindow(hwnd, IDC_STYLEEDIT, TRUE); + //DialogEnableWindow(hwnd, IDC_STYLEFONT, TRUE); + //DialogEnableWindow(hwnd, IDC_STYLEFORE, TRUE); + //DialogEnableWindow(hwnd, IDC_STYLEBACK, TRUE); + //DialogEnableWindow(hwnd, IDC_STYLEDEFAULT, TRUE); + // a lexer has been selected if (!TreeView_GetParent(hwndTV,lpnmtv->itemNew.hItem)) { - WCHAR wch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; - - GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch)); - if (StrChr(wch,L'|')) *StrChr(wch,L'|') = L'\0'; - - pCurrentStyle = 0; pCurrentLexer = (PEDITLEXER)lpnmtv->itemNew.lParam; + if (pCurrentLexer) { - SetDlgItemText(hwnd,IDC_STYLELABEL,wch); - DialogEnableWindow(hwnd,IDC_STYLEEDIT,TRUE); - DialogEnableWindow(hwnd,IDC_STYLEFONT,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEFORE,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEBACK,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEDEFAULT,TRUE); - //DialogEnableWindow(hwnd,IDC_STYLEBOLD,FALSE); - //DialogEnableWindow(hwnd,IDC_STYLEITALIC,FALSE); - //DialogEnableWindow(hwnd,IDC_STYLEUNDERLINE,FALSE); - //DialogEnableWindow(hwnd,IDC_STYLEEOLFILLED,FALSE); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED); - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); + bIsStyleSelected = FALSE; + SetDlgItemText(hwnd,IDC_STYLELABEL_ROOT, L"Associated filename extensions:"); + DialogEnableWindow(hwnd,IDC_STYLEEDIT_ROOT,TRUE); + SetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, pCurrentLexer->szExtensions); + DialogEnableWindow(hwnd, IDC_STYLEEDIT_ROOT, TRUE); + + if (pCurrentLexer == &lexStandard) { + pCurrentStyle = &(pCurrentLexer->Styles[STDLEXID(STY_DEFAULT)]); + if (!Style_GetUse2ndDefault()) + StringCchCopyW(label, COUNTOF(label), L"BASE (Default Style):"); + else + StringCchCopyW(label, COUNTOF(label), L"BASE (2nd Default Style):"); + } + else { + pCurrentStyle = &(pCurrentLexer->Styles[STY_DEFAULT]); + StringCchPrintfW(label, COUNTOF(label), L"%s: Default style:", pCurrentLexer->pszName); + } + SetDlgItemText(hwnd, IDC_STYLELABEL, label); + SetDlgItemText(hwnd, IDC_STYLEEDIT, pCurrentStyle->szValue); } else { - SetDlgItemText(hwnd,IDC_STYLELABEL,L""); - DialogEnableWindow(hwnd,IDC_STYLEEDIT,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEFONT,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEFORE,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEBACK,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEDEFAULT,FALSE); - //DialogEnableWindow(hwnd,IDC_STYLEBOLD,FALSE); - //DialogEnableWindow(hwnd,IDC_STYLEITALIC,FALSE); - //DialogEnableWindow(hwnd,IDC_STYLEUNDERLINE,FALSE); - //DialogEnableWindow(hwnd,IDC_STYLEEOLFILLED,FALSE); - //CheckDlgButton(hwnd,IDC_STYLEBOLD,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEITALIC,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEUNDERLINE,BST_UNCHECKED); - //CheckDlgButton(hwnd,IDC_STYLEEOLFILLED,BST_UNCHECKED); - SetDlgItemText(hwnd,IDC_STYLEEDIT,L""); + SetDlgItemText(hwnd,IDC_STYLELABEL_ROOT,L""); + DialogEnableWindow(hwnd,IDC_STYLEEDIT_ROOT,FALSE); + SetDlgItemText(hwnd, IDC_STYLELABEL, L""); + DialogEnableWindow(hwnd, IDC_STYLEEDIT, FALSE); } } // a style has been selected else { - WCHAR wch[BUFSIZE_STYLE_VALUE] = { L'\0' }; + if (pCurrentLexer == &lexStandard) { + if (!Style_GetUse2ndDefault()) + StringCchCopyW(label, COUNTOF(label), L"BASE (Default Style):"); + else + StringCchCopyW(label, COUNTOF(label), L"BASE (2nd Default Style):"); + } + else { + StringCchPrintfW(label, COUNTOF(label), L"%s: Default style:", pCurrentLexer->pszName); + } + SetDlgItemText(hwnd, IDC_STYLELABEL_ROOT, label); - GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch)); - if (StrChr(wch,L'|')) *StrChr(wch,L'|') = L'\0'; + int iDSID = Style_GetUse2ndDefault() ? STDLEXID(STY_DEFAULT) : STY_DEFAULT; + SetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, pCurrentLexer->Styles[iDSID].szValue); + DialogEnableWindow(hwnd, IDC_STYLEEDIT_ROOT, FALSE); - - pCurrentLexer = 0; pCurrentStyle = (PEDITSTYLE)lpnmtv->itemNew.lParam; + if (pCurrentStyle) { - SetDlgItemText(hwnd,IDC_STYLELABEL,StrEnd(wch)+1); - DialogEnableWindow(hwnd,IDC_STYLEEDIT,TRUE); - DialogEnableWindow(hwnd,IDC_STYLEFONT,TRUE); - DialogEnableWindow(hwnd,IDC_STYLEFORE,TRUE); - DialogEnableWindow(hwnd,IDC_STYLEBACK,TRUE); - DialogEnableWindow(hwnd,IDC_STYLEDEFAULT,TRUE); - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); + bIsStyleSelected = TRUE; + StringCchPrintfW(label, COUNTOF(label), L"%s's style:", pCurrentStyle->pszName); + SetDlgItemText(hwnd, IDC_STYLELABEL, label); + SetDlgItemText(hwnd, IDC_STYLEEDIT, pCurrentStyle->szValue); } else { - SetDlgItemText(hwnd,IDC_STYLELABEL,L""); - DialogEnableWindow(hwnd,IDC_STYLEEDIT,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEFONT,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEFORE,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEBACK,FALSE); - DialogEnableWindow(hwnd,IDC_STYLEDEFAULT,FALSE); - SetDlgItemText(hwnd,IDC_STYLEEDIT,L""); + SetDlgItemText(hwnd, IDC_STYLELABEL, L""); + DialogEnableWindow(hwnd, IDC_STYLEEDIT, FALSE); } } } @@ -5541,16 +5550,9 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case TVN_BEGINDRAG: { - //HIMAGELIST himl; - - //if (pCurrentStyle) - // GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); TreeView_Select(hwndTV,lpnmtv->itemNew.hItem,TVGN_CARET); - //himl = TreeView_CreateDragImage(hwndTV,lpnmtv->itemNew.hItem); - //ImageList_BeginDrag(himl,0,0,0); - //ImageList_DragEnter(hwndTV,lpnmtv->ptDrag.x,lpnmtv->ptDrag.y); - if (pCurrentStyle) + if (bIsStyleSelected) DestroyCursor(SetCursor(LoadCursor(g_hInstance,MAKEINTRESOURCE(IDC_COPY)))); else DestroyCursor(SetCursor(LoadCursor(NULL,IDC_NO))); @@ -5570,7 +5572,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP HTREEITEM htiTarget; TVHITTESTINFO tvht; - if (fDragging && pCurrentStyle) + if (fDragging && bIsStyleSelected) { LONG xCur = LOWORD(lParam); LONG yCur = HIWORD(lParam); @@ -5603,7 +5605,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case WM_LBUTTONUP: { - if (fDragging) + if (fDragging && bIsStyleSelected) { HTREEITEM htiTarget; @@ -5617,11 +5619,8 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP TreeView_Select(hwndTV,htiTarget,TVGN_CARET); // after select, this is new current item - if (pCurrentStyle) - { - StringCchCopy(pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue),tchCopy); - SetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy); - } + SetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy); + APPLY_DIALOG_ITEM_TEXT; } ReleaseCapture(); DestroyCursor(SetCursor(LoadCursor(NULL,IDC_ARROW))); @@ -5649,41 +5648,6 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP switch(LOWORD(wParam)) { - - case IDC_PREVSTYLE: - if (TreeView_GetSelection(hwndTV)) - TreeView_Select(hwndTV,TreeView_GetPrevVisible(hwndTV, - TreeView_GetSelection(hwndTV)),TVGN_CARET); - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); - break; - - case IDC_NEXTSTYLE: - if (TreeView_GetSelection(hwndTV)) - TreeView_Select(hwndTV,TreeView_GetNextVisible(hwndTV, - TreeView_GetSelection(hwndTV)),TVGN_CARET); - 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)); - - BOOL bIsGlobalDefault = ((pCurrentStyle->rid == 63100) || (pCurrentStyle->rid == 63112)); - //(StringCchCompareIX(pCurrentStyle->pszName, L"Default Style") == 0) || - //(StringCchCompareIX(pCurrentStyle->pszName, L"2nd Default Style") == 0); - - BOOL bIsCurrentDefault = (pCurrentStyle->rid == 63126); - //(StringCchCompareIX(pCurrentStyle->pszName, L"Default") == 0); - - if (Style_SelectFont(hwnd,tch,COUNTOF(tch), bIsGlobalDefault, bIsCurrentDefault, FALSE, TRUE)) { - SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); - } - } - PostMessage(hwnd,WM_NEXTDLGCTL,(WPARAM)(GetDlgItem(hwnd,IDC_STYLEEDIT)),1); - break; - case IDC_STYLEFORE: if (pCurrentStyle) { @@ -5708,16 +5672,32 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP 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)); + + BOOL bIsGlobalDefault = ((pCurrentStyle->rid == 63100) || (pCurrentStyle->rid == 63112)); + //(StringCchCompareIX(pCurrentStyle->pszName, L"Default Style") == 0) || + //(StringCchCompareIX(pCurrentStyle->pszName, L"2nd Default Style") == 0); + + BOOL bIsCurrentDefault = (pCurrentStyle->rid == 63126); + //(StringCchCompareIX(pCurrentStyle->pszName, L"Default") == 0); + + if (Style_SelectFont(hwnd, tch, COUNTOF(tch), pCurrentLexer->pszName, pCurrentStyle->pszName, + bIsGlobalDefault, bIsCurrentDefault, FALSE, TRUE)) { + SetDlgItemText(hwnd, IDC_STYLEEDIT, tch); + } + } + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); + break; + case IDC_STYLEDEFAULT: - if (pCurrentStyle) - { - StringCchCopy(pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue),pCurrentStyle->pszDefault); - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); - } - else if (pCurrentLexer) { - StringCchCopy(pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions),pCurrentLexer->pszDefExt); - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); + 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); break; @@ -5744,61 +5724,48 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP { hwndTV = GetDlgItem(hwnd,IDC_STYLELIST); - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - StringCchCopy(pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions),pCurrentLexer->pszDefExt); - } - if (Style_Import(hwnd)) { - - if (pCurrentStyle) - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue); - else if (pCurrentLexer) - SetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions); - + SetDlgItemText(hwnd, IDC_STYLEEDIT, pCurrentStyle->szValue); + if (!bIsStyleSelected) { + SetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, pCurrentLexer->szExtensions); + } TreeView_Select(hwndTV,TreeView_GetRoot(hwndTV),TVGN_CARET); + Style_SetLexer(g_hwndEdit, g_pLexCurrent); } } break; case IDC_EXPORT: { - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - StringCchCopy(pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions),pCurrentLexer->pszDefExt); - } - + APPLY_DIALOG_ITEM_TEXT; Style_Export(hwnd); } break; case IDC_PREVIEW: { - // Hack from outside - extern HWND g_hwndEdit; - - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - StringCchCopy(pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions),pCurrentLexer->pszDefExt); - } - Style_SetLexer(g_hwndEdit,g_pLexCurrent); - UpdateLineNumberWidth(); + APPLY_DIALOG_ITEM_TEXT; } break; - case IDOK: - if (pCurrentStyle) - GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); - else if (pCurrentLexer) { - if (!GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions))) - StringCchCopy(pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions),pCurrentLexer->pszDefExt); + case IDC_PREVSTYLE: + APPLY_DIALOG_ITEM_TEXT; + if (TreeView_GetSelection(hwndTV)) { + TreeView_Select(hwndTV, TreeView_GetPrevVisible(hwndTV,TreeView_GetSelection(hwndTV)), TVGN_CARET); } + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); + break; + + case IDC_NEXTSTYLE: + APPLY_DIALOG_ITEM_TEXT; + if (TreeView_GetSelection(hwndTV)) { + TreeView_Select(hwndTV, TreeView_GetNextVisible(hwndTV, TreeView_GetSelection(hwndTV)), TVGN_CARET); + } + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); + break; + + case IDOK: + APPLY_DIALOG_ITEM_TEXT; EndDialog(hwnd,IDOK); break; diff --git a/src/Styles.h b/src/Styles.h index bc5a67cea..0e766109f 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -98,7 +98,7 @@ BOOL Style_StrGetCase(LPCWSTR,int*); BOOL Style_StrGetAlpha(LPCWSTR,int*,BOOL); BOOL Style_GetIndicatorType(LPWSTR,int,int*); void Style_CopyStyles_IfNotDefined(LPWSTR, LPWSTR, int); -BOOL Style_SelectFont(HWND,LPWSTR,int,BOOL,BOOL,BOOL,BOOL); +BOOL Style_SelectFont(HWND,LPWSTR,int,LPCWSTR,LPCWSTR,BOOL,BOOL,BOOL,BOOL); BOOL Style_SelectColor(HWND,BOOL,LPWSTR,int,BOOL); void Style_SetStyles(HWND,int,LPCWSTR); void Style_SetFontQuality(HWND,LPCWSTR); diff --git a/src/resource.h b/src/resource.h index 9664c082b..bdc0ea9f1 100644 --- a/src/resource.h +++ b/src/resource.h @@ -1,163 +1,164 @@ //{{NO_DEPENDENCIES}} -// Von Microsoft Visual C++ generierte Includedatei. -// Verwendet durch Notepad3.rc +// Microsoft Visual C++ generated include file. +// Used by Notepad3.rc // #define IDR_RT_MANIFEST 1 #define IDR_MAINWND 100 -#define IDC_FINDTEXT 100 -#define IDC_LINENUM 100 -#define IDC_COMMANDLINE 100 -#define IDD_ABOUT 100 -#define IDC_VERSION 100 -#define IDC_OPENWITHDIR 100 -#define IDC_FILEMRU 100 -#define IDC_STYLELIST 100 -#define IDC_FAVORITESDIR 100 -#define IDC_COLUMNWRAP 100 -#define IDC_INFOBOXICON 100 -#define IDC_COPY 100 -#define IDC_ENCODINGLIST 100 -#define IDC_SEARCHEXE 101 -#define IDR_POPUPMENU 101 -#define IDC_GETOPENWITHDIR 101 -#define IDC_RESIZEGRIP 101 -#define IDD_OPENWITH 101 -#define IDC_REPLACETEXT 101 -#define IDI_RUN 101 -#define IDC_COLNUM 101 -#define IDC_DEFAULTSCHEME 101 -#define IDC_GETFAVORITESDIR 101 -#define IDC_INFOBOXTEXT 101 -#define IDB_OPEN 101 -#define IDR_ACCFINDREPLACE 101 -#define IDC_STYLELABEL 101 -#define IDC_RESIZEGRIP4 101 -#define IDC_NOUNICODEDETECTION 101 -#define IDC_COPYRIGHT 101 -#define IDC_STYLEEDIT 102 -#define IDC_FINDCASE 102 -#define IDC_OPENWITHDESCR 102 -#define IDC_SAVEMRU 102 -#define IDD_RUN 102 -#define IDC_AUTOSELECT 102 -#define IDC_FAVORITESDESCR 102 -#define IDC_INFOBOXCHECK 102 -#define IDC_CONSISTENTEOLS 102 -#define IDB_PREV 102 -#define IDI_STYLES 102 -#define IDC_ASCIIASUTF8 102 -#define IDC_WEBPAGE 102 -#define IDD_DEFENCODING 103 -#define IDC_FINDWORD 103 -#define IDC_RESIZEGRIP3 103 -#define IDB_NEXT 103 -#define IDC_STYLEFORE 103 -#define IDC_AUTOSTRIPBLANKS 103 -#define IDC_ENCODINGFROMFILEVARS 103 -#define IDC_WEBPAGE2 103 -#define IDC_PRESERVECARET 103 -#define IDC_MODWEBPAGE2 104 -#define IDD_ENCODING 104 -#define IDC_MOD_PAGE2 104 -#define IDC_FINDSTART 104 -#define IDB_PICK 104 -#define IDC_STYLEBACK 104 -#define IDC_AUTHORNAME 104 -#define IDC_WEBPAGE4 104 -#define IDC_MODWEBPAGE 105 -#define IDD_RECODE 105 -#define IDC_FINDREGEXP 105 -#define IDC_STYLEFONT 105 -#define IDB_ENCODING 105 -#define IDC_EMAIL 105 -#define IDC_NOTE2WEBPAGE 106 -#define IDD_DEFEOLMODE 106 -#define IDC_FINDTRANSFORMBS 106 -#define IDC_PREVIEW 106 -#define IDC_EMAIL2 106 -#define IDC_NOTE2WEBPAGE2 107 -#define IDD_FAVORITES 107 -#define IDC_NOWRAP 107 -#define IDC_STYLEDEFAULT 107 -#define IDD_ADDTOFAV 108 -#define IDC_PREVSTYLE 108 -#define IDC_FINDCLOSE 108 -#define IDC_EMAIL3 108 -#define IDC_VERSION2 108 -#define IDD_FILEMRU 109 -#define IDC_FINDPREV 109 -#define IDC_NEXTSTYLE 109 -#define IDD_CHANGENOTIFY 110 -#define IDC_IMPORT 110 -#define IDD_MODIFYLINES 111 -#define IDC_EXPORT 111 -#define IDC_MOD_PAGE 112 -#define IDC_REPLACE 112 -#define IDC_TITLE 112 -#define IDD_ALIGN 112 -#define IDC_WEBPAGE3 112 -#define IDD_ENCLOSESELECTION 113 -#define IDC_REPLACEALL 113 -#define IDC_STYLELABELS 113 -#define IDD_INSERTTAG 114 -#define IDC_REPLACEINSEL 114 -#define IDD_SORT 115 -#define IDC_TOGGLEFINDREPLACE 115 -#define IDD_COLUMNWRAP 116 -#define IDD_LINENUM 117 -#define IDD_FIND 118 -#define IDD_REPLACE 119 -#define IDD_STYLESELECT 120 -#define IDD_STYLECONFIG 121 -#define IDD_WORDWRAP 122 -#define IDD_LONGLINES 123 -#define IDD_TABSETTINGS 124 -#define IDD_PAGESETUP 125 -#define IDD_INFOBOX 126 -#define IDD_INFOBOX2 127 -#define IDD_INFOBOX3 128 -#define IDT_TIMER_MRKALL 130 -#define IDC_ALL_OCCURRENCES 131 -#define IDC_MARKALL_OCC 132 -#define IDC_DOT_MATCH_ALL 133 -#define IDT_TIMER_MAIN_MRKALL 134 -#define IDC_MAIN_MARKALL_OCC 135 -#define IDT_TIMER_UPDATE_HOTSPOT 136 -#define IDC_CALL_UPDATE_HOTSPOT 137 -#define IDC_BACKSLASHHELP 151 -#define IDC_REGEXPHELP 152 -#define IDC_WILDCARDHELP 153 -#define IDC_WILDCARDSEARCH 154 -#define IDC_SCI_VERSION 155 -#define IDR_MAINWND2 156 -#define IDC_REMOVE 157 -#define IDC_SWAPSTRG 158 -#define IDC_CHECK_OCC 159 -#define IDACC_FIND 200 -#define IDACC_REPLACE 201 -#define IDACC_SAVEPOS 202 -#define IDACC_RESETPOS 203 -#define IDACC_FINDNEXT 204 -#define IDACC_FINDPREV 205 -#define IDACC_REPLACENEXT 206 -#define IDACC_SAVEFIND 207 -#define IDACC_SELTONEXT 208 -#define IDACC_SELTOPREV 209 -#define IDC_NFOASOEM 300 -#define IDC_COMPILER 301 -#define IDC_COMPILER2 302 -#define IDD_READPW 401 -#define IDC_CHECK1 402 -#define IDC_EDIT1 403 -#define IDC_EDIT2 404 -#define IDC_CHECK2 405 -#define IDC_STATICPW 406 -#define IDC_CHECK3 407 -#define IDM_SETPASS 408 -#define IDD_PASSWORDS 409 -#define IDC_EDIT3 410 -#define IDS_PASS_FAILURE 411 -#define IDS_NOPASS 412 +#define IDC_FINDTEXT 101 +#define IDC_LINENUM 102 +#define IDC_COMMANDLINE 103 +#define IDD_ABOUT 104 +#define IDC_VERSION 105 +#define IDC_OPENWITHDIR 106 +#define IDC_FILEMRU 107 +#define IDC_STYLELIST 108 +#define IDC_FAVORITESDIR 109 +#define IDC_COLUMNWRAP 110 +#define IDC_INFOBOXICON 111 +#define IDC_COPY 112 +#define IDC_ENCODINGLIST 113 +#define IDC_SEARCHEXE 114 +#define IDR_POPUPMENU 115 +#define IDC_GETOPENWITHDIR 116 +#define IDC_RESIZEGRIP 117 +#define IDD_OPENWITH 118 +#define IDC_REPLACETEXT 119 +#define IDI_RUN 120 +#define IDC_COLNUM 121 +#define IDC_DEFAULTSCHEME 122 +#define IDC_GETFAVORITESDIR 123 +#define IDC_INFOBOXTEXT 124 +#define IDB_OPEN 125 +#define IDR_ACCFINDREPLACE 126 +#define IDC_STYLELABEL_ROOT 127 +#define IDC_STYLELABEL 128 +#define IDC_STYLEEDIT_ROOT 129 +#define IDC_STYLEEDIT 130 +#define IDC_STYLEBACK 131 +#define IDC_STYLEFONT 132 +#define IDC_STYLEDEFAULT 133 +#define IDC_PREVIEW 134 +#define IDC_PREVSTYLE 135 +#define IDC_NEXTSTYLE 136 +#define IDC_IMPORT 137 +#define IDC_EXPORT 138 +#define IDC_RESIZEGRIP4 139 +#define IDC_NOUNICODEDETECTION 140 +#define IDC_COPYRIGHT 141 +#define IDC_FINDCASE 142 +#define IDC_OPENWITHDESCR 143 +#define IDC_SAVEMRU 144 +#define IDD_RUN 145 +#define IDC_AUTOSELECT 146 +#define IDC_FAVORITESDESCR 147 +#define IDC_INFOBOXCHECK 148 +#define IDC_CONSISTENTEOLS 149 +#define IDB_PREV 150 +#define IDI_STYLES 151 +#define IDC_ASCIIASUTF8 152 +#define IDC_WEBPAGE 153 +#define IDD_DEFENCODING 154 +#define IDC_FINDWORD 155 +#define IDC_RESIZEGRIP3 156 +#define IDB_NEXT 157 +#define IDC_STYLEFORE 158 +#define IDC_AUTOSTRIPBLANKS 159 +#define IDC_ENCODINGFROMFILEVARS 160 +#define IDC_WEBPAGE2 161 +#define IDC_PRESERVECARET 162 +#define IDC_MODWEBPAGE2 163 +#define IDD_ENCODING 164 +#define IDC_MOD_PAGE2 165 +#define IDC_FINDSTART 166 +#define IDB_PICK 167 +#define IDC_AUTHORNAME 168 +#define IDC_WEBPAGE4 169 +#define IDC_MODWEBPAGE 170 +#define IDD_RECODE 171 +#define IDC_FINDREGEXP 172 +#define IDB_ENCODING 173 +#define IDC_EMAIL 174 +#define IDC_NOTE2WEBPAGE 175 +#define IDD_DEFEOLMODE 176 +#define IDC_FINDTRANSFORMBS 177 +#define IDC_EMAIL2 178 +#define IDC_NOTE2WEBPAGE2 179 +#define IDD_FAVORITES 180 +#define IDC_NOWRAP 181 +#define IDD_ADDTOFAV 182 +#define IDC_FINDCLOSE 183 +#define IDC_EMAIL3 184 +#define IDC_VERSION2 185 +#define IDD_FILEMRU 186 +#define IDC_FINDPREV 187 +#define IDD_CHANGENOTIFY 188 +#define IDD_MODIFYLINES 189 +#define IDC_MOD_PAGE 190 +#define IDC_REPLACE 191 +#define IDC_TITLE 192 +#define IDD_ALIGN 193 +#define IDC_WEBPAGE3 194 +#define IDD_ENCLOSESELECTION 195 +#define IDC_REPLACEALL 196 +#define IDD_INSERTTAG 198 +#define IDC_REPLACEINSEL 199 +#define IDD_SORT 200 +#define IDC_TOGGLEFINDREPLACE 201 +#define IDD_COLUMNWRAP 202 +#define IDD_LINENUM 203 +#define IDD_FIND 204 +#define IDD_REPLACE 205 +#define IDD_STYLESELECT 206 +#define IDD_STYLECONFIG 207 +#define IDD_WORDWRAP 208 +#define IDD_LONGLINES 209 +#define IDD_TABSETTINGS 210 +#define IDD_PAGESETUP 211 +#define IDD_INFOBOX 212 +#define IDD_INFOBOX2 213 +#define IDD_INFOBOX3 214 +#define IDT_TIMER_MRKALL 215 +#define IDC_ALL_OCCURRENCES 216 +#define IDC_MARKALL_OCC 217 +#define IDC_DOT_MATCH_ALL 218 +#define IDT_TIMER_MAIN_MRKALL 219 +#define IDC_MAIN_MARKALL_OCC 220 +#define IDT_TIMER_UPDATE_HOTSPOT 221 +#define IDC_CALL_UPDATE_HOTSPOT 222 +#define IDC_BACKSLASHHELP 223 +#define IDC_REGEXPHELP 224 +#define IDC_WILDCARDHELP 225 +#define IDC_WILDCARDSEARCH 226 +#define IDC_SCI_VERSION 227 +#define IDR_MAINWND2 228 +#define IDC_REMOVE 229 +#define IDC_SWAPSTRG 230 +#define IDC_CHECK_OCC 231 +#define IDACC_FIND 302 +#define IDACC_REPLACE 303 +#define IDACC_SAVEPOS 304 +#define IDACC_RESETPOS 305 +#define IDACC_FINDNEXT 306 +#define IDACC_FINDPREV 307 +#define IDACC_REPLACENEXT 308 +#define IDACC_SAVEFIND 309 +#define IDACC_SELTONEXT 310 +#define IDACC_SELTOPREV 311 +#define IDC_NFOASOEM 400 +#define IDC_COMPILER 401 +#define IDC_COMPILER2 402 +#define IDD_READPW 501 +#define IDC_CHECK1 502 +#define IDC_EDIT1 503 +#define IDC_EDIT2 504 +#define IDC_CHECK2 505 +#define IDC_STATICPW 506 +#define IDC_CHECK3 507 +#define IDM_SETPASS 508 +#define IDD_PASSWORDS 509 +#define IDC_EDIT3 510 +#define IDS_PASS_FAILURE 511 +#define IDS_NOPASS 512 #define IDS_APPTITLE 10000 #define IDS_APPTITLE_ELEVATED 10001 #define IDS_APPTITLE_PASTEBOARD 10002