Skip to content

Commit

Permalink
Highlight ninja file.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Sep 28, 2018
1 parent 224a301 commit 9d4efb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
* gmake
* Borland bmake
* qmake (syntax highlighting only)
* ninja (syntax highlighting only)
* MATLAB, [Screenshots](https://github.com/zufuliu/notepad2/wiki/Screenshots#matlab-octave)
* Octave
* Scilab
Expand Down
10 changes: 8 additions & 2 deletions scintilla/lexers/LexMakefile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using namespace Scintilla;
#define MAKE_TYPE_NMAKE 1
#define MAKE_TYPE_BMAKE 2
#define MAKE_TYPE_QMAKE 3
#define MAKE_TYPE_NINJA 4
static constexpr bool IsMakeOp(int ch, int chNext) noexcept {
return ch == '=' || ch == ':' || ch == '{' || ch == '}' || ch == '(' || ch == ')' || ch == ','
|| ch == '$' || ch == '@' || ch == '%' || ch == '<' || ch == '?' || ch == '^'
Expand All @@ -30,8 +31,10 @@ static constexpr bool IsMakeOp(int ch, int chNext) noexcept {

#define MAX_WORD_LENGTH 15
static void ColouriseMakeDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, LexerWordList keywordLists, Accessor &styler) {
const WordList &keywordsGP = *keywordLists[0]; // gnu make Preprocessor
const WordList &keywordsDP2 = *keywordLists[6];
const WordList &keywordsGP = *keywordLists[0]; // gnu make Preprocessor
const WordList &keywordsDP2 = *keywordLists[6]; // bmake
const WordList &keywordsNinja = *keywordLists[7]; // ninja

int state = initStyle;
int ch = 0, chNext = styler[startPos];
styler.StartAt(startPos);
Expand Down Expand Up @@ -80,6 +83,9 @@ static void ColouriseMakeDoc(Sci_PositionU startPos, Sci_Position length, int in
if (keywordsGP.InList(buf)) { // gmake
styler.ColourTo(i - 1, SCE_MAKE_PREPROCESSOR);
makeType = MAKE_TYPE_GMAKE;
} else if (keywordsNinja.InList(buf)) { // ninja
styler.ColourTo(i - 1, SCE_MAKE_PREPROCESSOR);
makeType = MAKE_TYPE_NINJA;
} else {
Sci_Position pos = i;
while (IsASpace(styler.SafeGetCharAt(pos++)));
Expand Down
7 changes: 5 additions & 2 deletions src/EditLexers/stlMake.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ static KEYWORDLIST Keywords_MAK = {{
, // 6 bmake
"in defined empty exists "

, "", ""
, // 7 ninja
"rule build default "

, ""

, "", "", "", "", "", "", ""
}};


EDITLEXER lexMake = { SCLEX_MAKEFILE, NP2LEX_MAKE, EDITLEXER_HOLE(L"Makefile"), L"mak; make; mk; dsp; dsw; am; pro; pri; gmk", &Keywords_MAK,
EDITLEXER lexMake = { SCLEX_MAKEFILE, NP2LEX_MAKE, EDITLEXER_HOLE(L"Makefile"), L"mak; make; mk; dsp; dsw; am; pro; pri; gmk; ninja", &Keywords_MAK,
{
EDITSTYLE_DEFAULT,
{ SCE_MAKE_COMMENT, NP2STYLE_Comment, EDITSTYLE_HOLE(L"Comment"), L"fore:#008000" },
Expand Down

0 comments on commit 9d4efb2

Please sign in to comment.