Skip to content

Commit

Permalink
Add scheme menu for Shell script and M4 macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Sep 9, 2018
1 parent e84c5c9 commit 5c2f5c2
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 80 deletions.
Binary file modified Notepad2.ini
Binary file not shown.
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* AutoIt Script
* AWK
* GNU AWK
* Bash Script, [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#shell-script)
* Windows Batch Script, [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#batch)
* .NET IL
* CMake, [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#cmake)
Expand Down Expand Up @@ -87,6 +86,9 @@
* Windows Rescouce Script
* Ruby, [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#ruby)
* Scala Script
* Shell Script
* Bash, [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#shell-script)
* M4 Macro, limited support
* Android Dalvik Smali, [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#android-smali)
* javap
* Jasmin
Expand Down
6 changes: 5 additions & 1 deletion src/EditAutoC.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,9 +1165,13 @@ void EditToggleCommentLine(HWND hwnd) {
EditToggleLineComments(hwnd, L"#", FALSE);
EndWaitCursor();
break;
case SCLEX_BASH:
BeginWaitCursor();
EditToggleLineComments(hwnd, ((np2LexLangIndex == IDM_LANG_M4)? L"dnl " : L"#"), FALSE);
EndWaitCursor();
break;
case SCLEX_PERL:
case SCLEX_CONF:
case SCLEX_BASH:
case SCLEX_TCL:
case SCLEX_POWERSHELL:
case SCLEX_CMAKE:
Expand Down
44 changes: 5 additions & 39 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2382,28 +2382,7 @@ void MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) {
i = i || StrNotEmpty(szIniFile2);
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGSNOW, i);

i = np2LexLangIndex;
if (i == 0) {
switch (pLexCurrent->rid) {
case NP2LEX_DEFAULT:
i = IDM_LANG_DEFAULT;
break;
case NP2LEX_HTML:
i = IDM_LANG_WEB;
break;
case NP2LEX_XML:
i = IDM_LANG_XML;
break;
}
}
//if (i >= IDM_LANG_DEFAULT)
// CheckMenuRadioItem(hmenu, IDM_LANG_DEFAULT, IDM_LANG_NULL, i, MF_BYCOMMAND);
for (i2 = IDM_LANG_DEFAULT; i2 < IDM_LANG_NULL; i2++) {
CheckCmd(hmenu, i2, FALSE);
}
if (i >= IDM_LANG_DEFAULT) {
CheckCmd(hmenu, i, TRUE);
}
Style_UpdateSchemeMenu(hmenu);
}

//=============================================================================
Expand Down Expand Up @@ -4402,30 +4381,15 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
}
break;

//case CMD_LEXDEFAULT:
case IDM_LANG_DEFAULT:
np2LexLangIndex = 0;
Style_SetDefaultLexer(hwndEdit);
break;

case IDM_LANG_APACHE:
np2LexLangIndex = LOWORD(wParam);
Style_SetConfLexer(hwndEdit);
break;

//case CMD_LEXHTML:
case IDM_LANG_WEB:
case IDM_LANG_PHP:
case IDM_LANG_JSP:
case IDM_LANG_ASPX_CS:
case IDM_LANG_ASPX_VB:
case IDM_LANG_ASP_VBS:
case IDM_LANG_ASP_JS:
np2LexLangIndex = (LOWORD(wParam) - IDM_LANG_WEB <= 0) ? 0 : LOWORD(wParam);
Style_SetHTMLLexer(hwndEdit);
break;

//case CMD_LEXXML:
case IDM_LANG_XML:
case IDM_LANG_XSD:
case IDM_LANG_XSLT:
Expand Down Expand Up @@ -4455,8 +4419,10 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
case IDM_LANG_ANDROID_MANIFEST:
case IDM_LANG_ANDROID_LAYOUT:
case IDM_LANG_SVG:
np2LexLangIndex = (LOWORD(wParam) - IDM_LANG_XML <= 0) ? 0 : LOWORD(wParam);
Style_SetXMLLexer(hwndEdit);

case IDM_LANG_BASH:
case IDM_LANG_M4:
Style_SetLexerByLangIndex(hwndEdit, LOWORD(wParam));
break;

case CMD_TIMESTAMPS: {
Expand Down
5 changes: 5 additions & 0 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ BEGIN
MENUITEM "ASP (V&BScript)", IDM_LANG_ASP_VBS
MENUITEM "ASP (J&Script)", IDM_LANG_ASP_JS
END
POPUP "Shell Script"
BEGIN
MENUITEM "Shell Script", IDM_LANG_BASH
MENUITEM "M4 Macro", IDM_LANG_M4
END
// "&SQL Dialect"
POPUP "&XML Document"
BEGIN
Expand Down
129 changes: 96 additions & 33 deletions src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,13 @@ void Style_GetCurrentLexerName(LPWSTR lpszName, int cchName) {
lang = L"SVG Document";
break;

case IDM_LANG_BASH:
lang = L"Shell Script";
break;
case IDM_LANG_M4:
lang = L"M4 Macro";
break;

default:
break;
}
Expand Down Expand Up @@ -1610,6 +1617,10 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch, BOOL bCheckNames) {
lexMatlab.rid = NP2LEX_SCILAB;
return (&lexMatlab);
}
if (StrCaseEqual(L"m4", lpszMatch)) {
np2LexLangIndex = IDM_LANG_M4;
return (&lexBash);
}
if (bAutoSelect && StrCaseEqual(L"m", lpszMatch)) {
PEDITLEXER lex = Style_DetectObjCAndMatlab();
if (lex != NULL) {
Expand Down Expand Up @@ -1864,45 +1875,97 @@ void Style_SetLexerFromName(HWND hwnd, LPCWSTR lpszFile, LPCWSTR lpszName) {
}
}

//=============================================================================
//
// Style_SetDefaultLexer()
//
void Style_SetDefaultLexer(HWND hwnd) {
np2LexLangIndex = 0;
Style_SetLexer(hwnd, pLexArray[0]);
}
void Style_SetLexerByLangIndex(HWND hwnd, int lang) {
np2LexLangIndex = lang;

//=============================================================================
//
// Style_SetConfLexer()
//
void Style_SetConfLexer(HWND hwnd) {
Style_SetLexer(hwnd, &lexCONF);
}
switch (lang) {
case IDM_LANG_DEFAULT:
Style_SetLexer(hwnd, &lexDefault);
break;

//=============================================================================
//
// Style_SetHTMLLexer()
//
void Style_SetHTMLLexer(HWND hwnd) {
//Style_SetLexer(hwnd, Style_MatchLexer(L"Web Source Code", TRUE));
if (np2LexLangIndex == 0) {
np2LexLangIndex = Style_GetDocTypeLanguage();
case IDM_LANG_APACHE:
Style_SetLexer(hwnd, &lexCONF);
break;

case IDM_LANG_WEB:
case IDM_LANG_PHP:
case IDM_LANG_JSP:
case IDM_LANG_ASPX_CS:
case IDM_LANG_ASPX_VB:
case IDM_LANG_ASP_VBS:
case IDM_LANG_ASP_JS:
if (lang == IDM_LANG_WEB) {
np2LexLangIndex = Style_GetDocTypeLanguage();
}
Style_SetLexer(hwnd, &lexHTML);
break;

case IDM_LANG_XML:
case IDM_LANG_XSD:
case IDM_LANG_XSLT:
case IDM_LANG_DTD:

case IDM_LANG_ANT_BUILD:
case IDM_LANG_MAVEN_POM:
case IDM_LANG_MAVEN_SETTINGS:
case IDM_LANG_IVY_MODULE:
case IDM_LANG_IVY_SETTINGS:
case IDM_LANG_PMD_RULESET:
case IDM_LANG_CHECKSTYLE:

case IDM_LANG_TOMCAT:
case IDM_LANG_WEB_JAVA:
case IDM_LANG_STRUTS:
case IDM_LANG_HIB_CFG:
case IDM_LANG_HIB_MAP:
case IDM_LANG_SPRING_BEANS:
case IDM_LANG_JBOSS:

case IDM_LANG_WEB_NET:
case IDM_LANG_RESX:
case IDM_LANG_XAML:

case IDM_LANG_PROPERTY_LIST:
case IDM_LANG_ANDROID_MANIFEST:
case IDM_LANG_ANDROID_LAYOUT:
case IDM_LANG_SVG:
if (lang == IDM_LANG_XML) {
np2LexLangIndex = Style_GetDocTypeLanguage();
}
Style_SetLexer(hwnd, &lexXML);
break;

case IDM_LANG_BASH:
case IDM_LANG_M4:
Style_SetLexer(hwnd, &lexBash);
break;
}
Style_SetLexer(hwnd, &lexHTML);
}

//=============================================================================
//
// Style_SetXMLLexer()
//
void Style_SetXMLLexer(HWND hwnd) {
//Style_SetLexer(hwnd, Style_MatchLexer(L"XML Document", TRUE));
if (np2LexLangIndex == 0) {
np2LexLangIndex = Style_GetDocTypeLanguage();
void Style_UpdateSchemeMenu(HMENU hmenu) {
int lang = np2LexLangIndex;
if (lang == 0) {
switch (pLexCurrent->rid) {
case NP2LEX_DEFAULT:
lang = IDM_LANG_DEFAULT;
break;
case NP2LEX_HTML:
lang = IDM_LANG_WEB;
break;
case NP2LEX_XML:
lang = IDM_LANG_XML;
break;
case NP2LEX_BASH:
lang = IDM_LANG_BASH;
break;
}
}
for (int i = IDM_LANG_DEFAULT; i < IDM_LANG_NULL; i++) {
CheckCmd(hmenu, i, FALSE);
}
if (lang >= IDM_LANG_DEFAULT) {
CheckCmd(hmenu, lang, TRUE);
}
Style_SetLexer(hwnd, &lexXML);
}

//=============================================================================
Expand Down
6 changes: 2 additions & 4 deletions src/Styles.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ int Style_GetDocTypeLanguage();
void Style_UpdateLexerKeywords(PEDITLEXER pLexNew);
void Style_UpdateLexerKeywordAttr(PEDITLEXER pLexNew);
void Style_GetCurrentLexerName(LPWSTR lpszName, int cchName);
void Style_SetDefaultLexer(HWND hwnd);
void Style_SetConfLexer(HWND hwnd);
void Style_SetHTMLLexer(HWND hwnd);
void Style_SetXMLLexer(HWND hwnd);
void Style_SetLexerByLangIndex(HWND hwnd, int lang);
void Style_UpdateSchemeMenu(HMENU hmenu);

void Style_SetDefaultFont(HWND hwnd);
void Style_SetIndentGuides(HWND hwnd, BOOL bShow);
Expand Down
3 changes: 3 additions & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@
#define IDM_LANG_ASP_VBS 41006
#define IDM_LANG_ASP_JS 41007

#define IDM_LANG_BASH 41008
#define IDM_LANG_M4 41009

#define IDM_LANG_XML 41010
#define IDM_LANG_XSD 41011
#define IDM_LANG_XSLT 41012
Expand Down
4 changes: 2 additions & 2 deletions version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ git clone https://github.com/XhmikosR/notepad2-mod.git
Scintilla
hg clone http://hg.code.sf.net/p/scintilla/code scintilla
4.1.1
2018-09-06 7081:892c361b3969
2018-09-09 7084:cd27559c2a65

SciTE
hg clone http://hg.code.sf.net/p/scintilla/scite
4.1.1
2018-09-05 5082:b31d06a739da
2018-09-09 5083:a986ffda8eee

Notepad++
https://github.com/notepad-plus-plus/notepad-plus-plus.git

0 comments on commit 5c2f5c2

Please sign in to comment.