Skip to content

Commit

Permalink
Add scheme menus to enable JSX/TSX for untitled JavaScript/TypeScript…
Browse files Browse the repository at this point in the history
… file.
  • Loading branch information
zufuliu committed Aug 5, 2023
1 parent f73819d commit a264811
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 8 deletions.
7 changes: 7 additions & 0 deletions locale/de/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "&Less Style Sheet", IDM_LEXER_LESS
MENUITEM "&HSS Style Sheet", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "&Web Source Code"
BEGIN
MENUITEM "&Web Source Code", IDM_LEXER_WEB
Expand Down
8 changes: 8 additions & 0 deletions locale/fr-FR/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "&Less Style Sheet", IDM_LEXER_LESS
MENUITEM "&HSS Style Sheet", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "Code source Web "
BEGIN
MENUITEM "Code source Web", IDM_LEXER_WEB
Expand Down Expand Up @@ -714,6 +721,7 @@ BEGIN
BEGIN
MENUITEM "Encodage standard", IDM_EDIT_BASE64_ENCODE
MENUITEM "Encodage sans risque des URL", IDM_EDIT_BASE64_SAFE_ENCODE
MENUITEM "Encode as HTML Embedded &Image", IDM_EDIT_BASE64_HTML_EMBEDDED_IMAGE
MENUITEM "&Décoder", IDM_EDIT_BASE64_DECODE
MENUITEM "Decoder (forme hexadécimale)", IDM_EDIT_BASE64_DECODE_AS_HEX
END
Expand Down
7 changes: 7 additions & 0 deletions locale/it/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "Foglio di stile &Less", IDM_LEXER_LESS
MENUITEM "Foglio di stile &HSS", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "Codice Sorgente &Web"
BEGIN
MENUITEM "Codice Sorgente &Web", IDM_LEXER_WEB
Expand Down
7 changes: 7 additions & 0 deletions locale/ja/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "Less スタイルシート(&L)", IDM_LEXER_LESS
MENUITEM "HSS スタイルシート(&H)", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "Webソースコード(&W)"
BEGIN
MENUITEM "&Web ソースコード", IDM_LEXER_WEB
Expand Down
8 changes: 8 additions & 0 deletions locale/ko/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "Less 스타일 시트(&L)", IDM_LEXER_LESS
MENUITEM "HSS 스타일 시트(&H)", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "웹 소스 코드(&W)"
BEGIN
MENUITEM "웹 소스코드(&W)", IDM_LEXER_WEB
Expand Down Expand Up @@ -2121,3 +2128,4 @@ END
#include "../../src/Notepad2.ver"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

7 changes: 7 additions & 0 deletions locale/pt-BR/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "&Less Style Sheet", IDM_LEXER_LESS
MENUITEM "&HSS Style Sheet", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "&Web Source Code"
BEGIN
MENUITEM "&Web Source Code", IDM_LEXER_WEB
Expand Down
7 changes: 7 additions & 0 deletions locale/zh-Hans/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "Less 样式表(&L)", IDM_LEXER_LESS
MENUITEM "HSS 样式表(&H)", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "Web 源代码(&W)"
BEGIN
MENUITEM "Web 源代码(&W)", IDM_LEXER_WEB
Expand Down
7 changes: 7 additions & 0 deletions locale/zh-Hant/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "Less 樣式表(&L)", IDM_LEXER_LESS
MENUITEM "HSS 樣式表(&H)", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "&Web 原始碼"
BEGIN
MENUITEM "&Web 原始碼", IDM_LEXER_WEB
Expand Down
5 changes: 5 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4695,6 +4695,11 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
case IDM_LEXER_SCSS:
case IDM_LEXER_LESS:
case IDM_LEXER_HSS:
// JavaScript
case IDM_LEXER_JAVASCRIPT:
case IDM_LEXER_JAVASCRIPT_JSX:
case IDM_LEXER_TYPESCRIPT:
case IDM_LEXER_TYPESCRIPT_TSX:
// Web Source Code
case IDM_LEXER_WEB:
case IDM_LEXER_PHP:
Expand Down
7 changes: 7 additions & 0 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ BEGIN
MENUITEM "&Less Style Sheet", IDM_LEXER_LESS
MENUITEM "&HSS Style Sheet", IDM_LEXER_HSS
END
POPUP "&JavaScript"
BEGIN
MENUITEM "&JavaScript", IDM_LEXER_JAVASCRIPT
MENUITEM "Java&Script JSX", IDM_LEXER_JAVASCRIPT_JSX
MENUITEM "&TypeScript", IDM_LEXER_TYPESCRIPT
MENUITEM "TypeScript TS&X", IDM_LEXER_TYPESCRIPT_TSX
END
POPUP "&Web Source Code"
BEGIN
MENUITEM "&Web Source Code", IDM_LEXER_WEB
Expand Down
47 changes: 39 additions & 8 deletions src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,12 +1425,9 @@ void Style_SetLexer(PEDITLEXER pLexNew, BOOL bLexerChanged) {
dialect = iCsvOption;
break;

case NP2LEX_JAVASCRIPT:
case NP2LEX_TYPESCRIPT: {
LPCWSTR lpszExt = PathFindExtension(szCurFile);
if (StrNotEmpty(lpszExt) && (StrCaseEqual(lpszExt, L".jsx") || StrCaseEqual(lpszExt, L".tsx"))) {
dialect = 1;
}
case NP2LEX_JAVASCRIPT: {
NP2_static_assert(IDM_LEXER_JAVASCRIPT_JSX - IDM_LEXER_JAVASCRIPT == 1);
dialect = np2LexLangIndex - IDM_LEXER_JAVASCRIPT;
} break;

case NP2LEX_MARKDOWN: {
Expand All @@ -1445,11 +1442,16 @@ void Style_SetLexer(PEDITLEXER pLexNew, BOOL bLexerChanged) {
dialect = np2LexLangIndex - IDM_LEXER_MATLAB;
} break;

// see LexCPP.cxx
case NP2LEX_RESOURCESCRIPT:
dialect = 1;
dialect = 1; // see LexCPP.cxx
break;

case NP2LEX_TYPESCRIPT: {
NP2_static_assert(IDM_LEXER_TYPESCRIPT_TSX - IDM_LEXER_TYPESCRIPT == 1);
dialect = np2LexLangIndex - IDM_LEXER_TYPESCRIPT;
} break;
}

if (dialect > 0) {
char lang[4];
if (dialect < 10) {
Expand Down Expand Up @@ -2298,12 +2300,24 @@ static void Style_UpdateLexerLang(PEDITLEXER pLex, LPCWSTR lpszExt, LPCWSTR lpsz
}
break;

case NP2LEX_JAVASCRIPT:
if (StrCaseEqual(L"jsx", lpszExt)) {
np2LexLangIndex = IDM_LEXER_JAVASCRIPT_JSX;
}
break;

case NP2LEX_MATLAB:
if (StrCaseEqual(L"sce", lpszExt) || StrCaseEqual(L"sci", lpszExt)) {
np2LexLangIndex = IDM_LEXER_SCILAB;
}
break;

case NP2LEX_TYPESCRIPT:
if (StrCaseEqual(L"tsx", lpszExt)) {
np2LexLangIndex = IDM_LEXER_TYPESCRIPT_TSX;
}
break;

case NP2LEX_XML:
if (StrCaseEqual(L"xml", lpszExt)) {
np2LexLangIndex = Style_GetDocTypeLanguage();
Expand Down Expand Up @@ -2702,6 +2716,16 @@ void Style_SetLexerByLangIndex(int lang) {
pLex = &lexCSS;
break;

// JavaScript
case IDM_LEXER_JAVASCRIPT:
case IDM_LEXER_JAVASCRIPT_JSX:
pLex = &lexJavaScript;
break;
case IDM_LEXER_TYPESCRIPT:
case IDM_LEXER_TYPESCRIPT_TSX:
pLex = &lexTypeScript;
break;

// Web Source Code
case IDM_LEXER_WEB:
case IDM_LEXER_JSP:
Expand Down Expand Up @@ -2788,6 +2812,13 @@ void Style_UpdateSchemeMenu(HMENU hmenu) {
case NP2LEX_CSS:
lang = IDM_LEXER_CSS;
break;
// JavaScript
case NP2LEX_JAVASCRIPT:
lang = IDM_LEXER_JAVASCRIPT;
break;
case NP2LEX_TYPESCRIPT:
lang = IDM_LEXER_TYPESCRIPT;
break;
// Web Source Code
case NP2LEX_HTML:
lang = IDM_LEXER_WEB;
Expand Down

0 comments on commit a264811

Please sign in to comment.