Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/CodeLite/Notepad4.project
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<File Name="../../scintilla/lexers/LexDiff.cxx"/>
<File Name="../../scintilla/lexers/LexFortran.cxx"/>
<File Name="../../scintilla/lexers/LexFSharp.cxx"/>
<File Name="../../scintilla/lexers/LexGeogebra.cxx"/>
<File Name="../../scintilla/lexers/LexGN.cxx"/>
<File Name="../../scintilla/lexers/LexGo.cxx"/>
<File Name="../../scintilla/lexers/LexGraphViz.cxx"/>
Expand Down Expand Up @@ -229,6 +230,7 @@
<File Name="../../src/EditLexers/stlDefault.cpp"/>
<File Name="../../src/EditLexers/stlFortran.cpp"/>
<File Name="../../src/EditLexers/stlFSharp.cpp"/>
<File Name="../../src/EditLexers/stlGeogebra.cpp"/>
<File Name="../../src/EditLexers/stlGN.cpp"/>
<File Name="../../src/EditLexers/stlGo.cpp"/>
<File Name="../../src/EditLexers/stlGradle.cpp"/>
Expand Down
2 changes: 2 additions & 0 deletions build/VisualStudio/Notepad4.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@
<ClCompile Include="..\..\scintilla\lexers\LexDiff.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexFortran.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexFSharp.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexGeogebra.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexGN.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexGo.cxx" />
<ClCompile Include="..\..\scintilla\lexers\LexGraphViz.cxx" />
Expand Down Expand Up @@ -609,6 +610,7 @@
<ClCompile Include="..\..\src\EditLexers\stlDefault.cpp" />
<ClCompile Include="..\..\src\EditLexers\stlFortran.cpp" />
<ClCompile Include="..\..\src\EditLexers\stlFSharp.cpp" />
<ClCompile Include="..\..\src\EditLexers\stlGeogebra.cpp" />
<ClCompile Include="..\..\src\EditLexers\stlGo.cpp" />
<ClCompile Include="..\..\src\EditLexers\stlGN.cpp" />
<ClCompile Include="..\..\src\EditLexers\stlGradle.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions build/VisualStudio/Notepad4.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<ClCompile Include="..\..\scintilla\lexers\LexFSharp.cxx">
<Filter>Scintilla\lexers</Filter>
</ClCompile>
<ClCompile Include="..\..\scintilla\lexers\LexGeogebra.cxx">
<Filter>Scintilla\lexers</Filter>
</ClCompile>
<ClCompile Include="..\..\scintilla\lexers\LexGN.cxx">
<Filter>Scintilla\lexers</Filter>
</ClCompile>
Expand Down Expand Up @@ -498,6 +501,9 @@
<ClCompile Include="..\..\src\EditLexers\stlFSharp.cpp">
<Filter>Source Files\EditLexers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\EditLexers\stlGeogebra.cpp">
<Filter>Source Files\EditLexers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\EditLexers\stlGo.cpp">
<Filter>Source Files\EditLexers</Filter>
</ClCompile>
Expand Down
11 changes: 11 additions & 0 deletions scintilla/include/SciLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
#define SCLEX_MATHEMATICA 225
#define SCLEX_WINHEX 226
#define SCLEX_CANGJIE 227
#define SCLEX_GEOGEBRA 228
#define SCLEX_AUTOMATIC 1000
#define SCE_PY_DEFAULT 0
#define SCE_PY_COMMENTLINE 1
Expand Down Expand Up @@ -1904,4 +1905,14 @@
#define SCE_CANGJIE_ENUM 29
#define SCE_CANGJIE_FUNCTION_DEFINITION 30
#define SCE_CANGJIE_FUNCTION 31
#define SCE_GGB_DEFAULT 0
#define SCE_GGB_COMMENTLINE 1
#define SCE_GGB_TASKMARKER 2
#define SCE_GGB_OPERATOR 3
#define SCE_GGB_NUMBER 4
#define SCE_GGB_IDENTIFIER 5
#define SCE_GGB_WORD 6
#define SCE_GGB_CONSTANT 7
#define SCE_GGB_INNERFUNCTION 8
#define SCE_GGB_FUNCTION 9
/* --Autogenerated -- end of section automatically generated from SciLexer.iface */
13 changes: 13 additions & 0 deletions scintilla/include/SciLexer.iface
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ val SCLEX_CSV=223
val SCLEX_MATHEMATICA=225
val SCLEX_WINHEX=226
val SCLEX_CANGJIE=227
val SCLEX_GEOGEBRA=228

# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
Expand Down Expand Up @@ -3221,3 +3222,15 @@ val SCE_CANGJIE_INTERFACE=
val SCE_CANGJIE_ENUM=
val SCE_CANGJIE_FUNCTION_DEFINITION=
val SCE_CANGJIE_FUNCTION=
# Lexical states for SCLEX_GEOGEGRA
lex Geogebra=SCLEX_GEOGEGRA SCE_GGB_
val SCE_GGB_DEFAULT=
val SCE_GGB_COMMENTLINE=
val SCE_GGB_TASKMARKER=
val SCE_GGB_OPERATOR=
val SCE_GGB_NUMBER=
val SCE_GGB_IDENTIFIER=
val SCE_GGB_WORD=
val SCE_GGB_CONSTANT=
val SCE_GGB_INNERFUNCTION=
val SCE_GGB_FUNCTION=
138 changes: 138 additions & 0 deletions scintilla/lexers/LexGeogebra.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// This file is part of Notepad4.
// See License.txt for details about distribution and modification.
//! Lexer for Geogebra Script.

#include <cassert>
#include <cstring>

#include <string>
#include <string_view>

#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"

#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "StringUtils.h"
#include "LexerModule.h"

using namespace Lexilla;

namespace {

//KeywordIndex++Autogenerated -- start of section automatically generated
enum {
KeywordIndex_Operator = 0,
KeywordIndex_Constant = 1,
KeywordIndex_Innerfunction = 2,
KeywordIndex_Function = 3,
MaxKeywordSize = 32,
};
//KeywordIndex--Autogenerated -- end of section automatically generated

enum class KeywordType {
None = SCE_GGB_DEFAULT,
Return = 0x40,
};

constexpr bool IsSpaceEquiv(int state) noexcept {
return state <= SCE_GGB_TASKMARKER;
}

void ColouriseGgbDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, LexerWordList keywordLists, Accessor &styler) {
int lineStateLineType = 0;

KeywordType kwType = KeywordType::None;

int visibleChars = 0;
int chPrevNonWhite = 0;

StyleContext sc(startPos, lengthDoc, initStyle, styler);

while (sc.More()) {
switch (sc.state) {
case SCE_GGB_OPERATOR:
sc.SetState(SCE_GGB_DEFAULT);
break;

case SCE_GGB_NUMBER:
if (!IsNumberStart(sc.ch, sc.chNext)) {
sc.SetState(SCE_GGB_DEFAULT);
}
break;

case SCE_GGB_COMMENTLINE:
if (sc.atLineStart) {
sc.SetState(SCE_GGB_DEFAULT);
}
break;
case SCE_GGB_IDENTIFIER:
if (!IsAlphaNumeric(sc.ch)) {
char s[MaxKeywordSize];
sc.GetCurrent(s, sizeof(s));
if (keywordLists[KeywordIndex_Operator].InList(s)) {
sc.ChangeState(SCE_GGB_OPERATOR);
} else if (keywordLists[KeywordIndex_Constant].InList(s)) {
sc.ChangeState(SCE_GGB_CONSTANT);
} else if (keywordLists[KeywordIndex_Innerfunction].InList(s)) {
sc.ChangeState(SCE_GGB_INNERFUNCTION);
} else if (keywordLists[KeywordIndex_Function].InList(s)) {
sc.ChangeState(SCE_GGB_FUNCTION);
}
sc.SetState(SCE_GGB_DEFAULT);
}
break;
}


if (sc.state == SCE_GGB_DEFAULT) {
if (sc.ch == '#') {
sc.SetState(SCE_GGB_COMMENTLINE);
if (visibleChars == 0) {
lineStateLineType = SimpleLineStateMaskLineComment;
}
} else if (IsADigit(sc.ch)) {
sc.SetState(SCE_GGB_NUMBER);
} else if (IsIdentifierStart(sc.ch)) {
sc.SetState(SCE_GGB_IDENTIFIER);
} else if (IsAGraphic(sc.ch) && !(sc.ch == '\\' || sc.ch == '`')) {
sc.SetState(SCE_GGB_OPERATOR);
}
}

if (!isspacechar(sc.ch)) {
visibleChars++;
if (!IsSpaceEquiv(sc.state)) {
chPrevNonWhite = sc.ch;
}
}


if (sc.atLineEnd) {
styler.SetLineState(sc.currentLine, lineStateLineType);
lineStateLineType = 0;
visibleChars = 0;
kwType = KeywordType::None;
}
sc.Forward();
}

sc.Complete();
}

struct FoldLineState {
int lineComment;
int moduleImport;
constexpr explicit FoldLineState(int lineState) noexcept:
lineComment(lineState & SimpleLineStateMaskLineComment),
moduleImport((lineState >> 1) & 1) {
}
};

}

extern const LexerModule lmGeogebra(SCLEX_GEOGEBRA, ColouriseGgbDoc, "Geogebra", FoldSimpleDoc);
2 changes: 2 additions & 0 deletions scintilla/lexlib/LexerModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ extern const LexerModule lmDiff;
extern const LexerModule lmDLang;
extern const LexerModule lmFortran;
extern const LexerModule lmFSharp;
extern const LexerModule lmGeogebra;
extern const LexerModule lmGN;
extern const LexerModule lmGo;
extern const LexerModule lmGraphViz;
Expand Down Expand Up @@ -135,6 +136,7 @@ const LexerModule * const lexerCatalogue[] = {
&lmDLang,
&lmFortran,
&lmFSharp,
&lmGeogebra,
&lmGN,
&lmGo,
&lmGraphViz,
Expand Down
5 changes: 5 additions & 0 deletions src/EditAutoC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ enum {
DartKeywordIndex_Metadata = 4,
FSharpKeywordIndex_Preprocessor = 2,
FSharpKeywordIndex_CommentTag = 4,
GeogebraKeywordIndex_Operator = 0,
GeogebraKeywordIndex_Constant = 1,
GeogebraKeywordIndex_Function = 3,
GraphVizKeywordIndex_HtmlLabel = 1,
GroovyKeywordIndex_Annotation = 7,
GroovyKeywordIndex_GroovyDoc = 9,
Expand Down Expand Up @@ -2494,6 +2497,7 @@ void EditToggleCommentLine(bool alternative) noexcept {
case NP2LEX_CMAKE:
case NP2LEX_COFFEESCRIPT:
case NP2LEX_CONFIG:
case NP2LEX_GEOGEBRA:
case NP2LEX_GN:
case NP2LEX_JAMFILE:
case NP2LEX_JULIA:
Expand Down Expand Up @@ -2943,6 +2947,7 @@ void InitAutoCompletionCache(LPCEDITLEXER pLex) noexcept {
case NP2LEX_BATCH:
case NP2LEX_BLOCKDIAG:
case NP2LEX_CSV:
case NP2LEX_GEOGEBRA:
case NP2LEX_GRAPHVIZ:
case NP2LEX_LISP:
case NP2LEX_SMALI:
Expand Down
2 changes: 2 additions & 0 deletions src/EditLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ using LPCEDITLEXER = const EDITLEXER *;
#define NP2LEX_REGISTRY 63093 // SCLEX_REGISTRY Registry File
#define NP2LEX_COFFEESCRIPT 63094 // SCLEX_COFFEESCRIPT CoffeeScript
#define NP2LEX_AUTOHOTKEY 63095 // SCLEX_AUTOHOTKEY AutoHotkey Script
#define NP2LEX_GEOGEBRA 63096 // NP2LEX_GEOGEBRA Geogebra Script


// special lexers
#define NP2LEX_ANSI 63196 // SCLEX_NULL ANSI Art
Expand Down
Loading
Loading