Skip to content

Commit

Permalink
Support SCSS, Less and HSS, fix issue #65.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Sep 9, 2018
1 parent 32a7535 commit ced11b9
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 1 deletion.
Binary file modified Notepad2.ini
Binary file not shown.
2 changes: 1 addition & 1 deletion src/EditLexers/stlCSS.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static KEYWORDLIST Keywords_CSS = {{
, "", "", "", "", "", "", ""
}};

EDITLEXER lexCSS = { SCLEX_CSS, NP2LEX_CSS, L"CSS Style Sheet", L"css", L"", &Keywords_CSS,
EDITLEXER lexCSS = { SCLEX_CSS, NP2LEX_CSS, L"CSS Style Sheet", L"css; scss; less; hss", L"", &Keywords_CSS,
{
{ STYLE_DEFAULT, NP2STYLE_Default, L"Default", L"", L"" },
//{ SCE_CSS_DEFAULT, L"Default", L"", L"" },
Expand Down
5 changes: 5 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4426,6 +4426,11 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
case IDM_LANG_MATLAB:
case IDM_LANG_OCTAVE:
case IDM_LANG_SCILAB:

case IDM_LANG_CSS:
case IDM_LANG_SCSS:
case IDM_LANG_LESS:
case IDM_LANG_HSS:
Style_SetLexerByLangIndex(hwndEdit, LOWORD(wParam));
break;

Expand Down
7 changes: 7 additions & 0 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,13 @@ BEGIN
MENUITEM "&Customize Schemes...\tCtrl+F12", IDM_VIEW_SCHEMECONFIG
MENUITEM SEPARATOR
MENUITEM "Default &Text", IDM_LANG_DEFAULT
POPUP "CSS Style Sheet"
BEGIN
MENUITEM "CSS", IDM_LANG_CSS
MENUITEM "Sassy CSS", IDM_LANG_SCSS
MENUITEM "Less CSS", IDM_LANG_LESS
MENUITEM "HSS", IDM_LANG_HSS
END
POPUP "&Web Source Code"
BEGIN
MENUITEM "&Web Source Code", IDM_LANG_WEB
Expand Down
42 changes: 42 additions & 0 deletions src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,12 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
SciCall_SetProperty("fold.hypertext.comment", "1");
SciCall_SetProperty("fold.hypertext.heredoc", "1");
break;

case NP2LEX_CSS:
SciCall_SetProperty("lexer.css.scss.language", ((np2LexLangIndex == IDM_LANG_SCSS)? "1" : "0"));
SciCall_SetProperty("lexer.css.less.language", ((np2LexLangIndex == IDM_LANG_LESS)? "1" : "0"));
SciCall_SetProperty("lexer.css.hss.language", ((np2LexLangIndex == IDM_LANG_HSS)? "1" : "0"));
break;
}

Style_UpdateLexerKeywords(pLexNew);
Expand Down Expand Up @@ -1545,6 +1551,19 @@ void Style_GetCurrentLexerName(LPWSTR lpszName, int cchName) {
lang = L"Scilab Code";
break;

case IDM_LANG_CSS:
lang = L"CSS Style Sheet";
break;
case IDM_LANG_SCSS:
lang = L"Sassy CSS";
break;
case IDM_LANG_LESS:
lang = L"Less CSS";
break;
case IDM_LANG_HSS:
lang = L"HSS";
break;

default:
break;
}
Expand Down Expand Up @@ -1635,6 +1654,18 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch, BOOL bCheckNames) {
np2LexLangIndex = IDM_LANG_M4;
return (&lexBash);
}
if (StrCaseEqual(L"scss", lpszMatch)) {
np2LexLangIndex = IDM_LANG_SCSS;
return (&lexCSS);
}
if (StrCaseEqual(L"less", lpszMatch)) {
np2LexLangIndex = IDM_LANG_LESS;
return (&lexCSS);
}
if (StrCaseEqual(L"hss", lpszMatch)) {
np2LexLangIndex = IDM_LANG_HSS;
return (&lexCSS);
}
if (bAutoSelect && StrCaseEqual(L"m", lpszMatch)) {
PEDITLEXER lex = Style_DetectObjCAndMatlab();
if (lex != NULL) {
Expand Down Expand Up @@ -1966,6 +1997,13 @@ void Style_SetLexerByLangIndex(HWND hwnd, int lang) {
lexMatlab.rid = NP2LEX_SCILAB;
Style_SetLexer(hwnd, &lexMatlab);
break;

case IDM_LANG_CSS:
case IDM_LANG_SCSS:
case IDM_LANG_LESS:
case IDM_LANG_HSS:
Style_SetLexer(hwnd, &lexCSS);
break;
}
}

Expand Down Expand Up @@ -1994,7 +2032,11 @@ void Style_UpdateSchemeMenu(HMENU hmenu) {
case NP2LEX_SCILAB:
lang = IDM_LANG_SCILAB;
break;
case NP2LEX_CSS:
lang = IDM_LANG_CSS;
break;
}
np2LexLangIndex = lang;
}
for (int i = IDM_LANG_DEFAULT; i < IDM_LANG_NULL; i++) {
CheckCmd(hmenu, i, FALSE);
Expand Down
5 changes: 5 additions & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@
#define IDM_LANG_OCTAVE 41015
#define IDM_LANG_SCILAB 41016

#define IDM_LANG_CSS 41017
#define IDM_LANG_SCSS 41018
#define IDM_LANG_LESS 41019
#define IDM_LANG_HSS 41020

#define IDM_LANG_ANT_BUILD 41021
#define IDM_LANG_MAVEN_POM 41022
#define IDM_LANG_MAVEN_SETTINGS 41023
Expand Down

0 comments on commit ced11b9

Please sign in to comment.