Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: GitHub noreply@github.com Date: Wed, 15 Jan 2025 14:12:18 UTC Commit: 89c036a98d419b543d9f506524cf2eaf81ca6c6b https://github.com/geany/geany/commit/89c036a98d419b543d9f506524cf2eaf81ca6c...
Log Message: ----------- Merge pull request #3934 from techee/toml
Add TOML support
Modified Paths: -------------- ctags/parsers/iniconf.c data/Makefile.am data/filedefs/filetypes.toml data/filetype_extensions.conf meson.build scintilla/Makefile.am scintilla/lexilla/lexers/LexTOML.cxx scintilla/lexilla/src/Lexilla.cxx scintilla/scintilla_changes.patch src/filetypes.c src/filetypes.h src/highlighting.c src/highlightingmappings.h
Modified: ctags/parsers/iniconf.c 10 lines changed, 7 insertions(+), 3 deletions(-) =================================================================== @@ -32,10 +32,13 @@ #include "subparser.h" #include "vstring.h"
+#define TOML_QUOTED_KEY_CHAR(c) ( (c) == '"' || (c) == ''' ) + static bool isIdentifier (int c) { - /* allow whitespace within keys and sections */ - return (bool)(isalnum (c) || isspace (c) || c == '_'); + /* allow whitespace within keys and sections */ + return (bool)(isalnum (c) || isspace (c) || c == '_' || c == '-' || c == '.' + || TOML_QUOTED_KEY_CHAR(c)); }
static bool isValue (int c) @@ -130,7 +133,8 @@ static void findIniconfTags (void) if (*cp == '[') { ++cp; - while (*cp != '\0' && *cp != ']') + /* look for the final ] to support TOML [[arrays.of.tables]] */ + while (*cp != '\0' && (*cp != ']' || *(cp+1) == ']')) { vStringPut (name, *cp); ++cp;
Modified: data/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -81,6 +81,7 @@ filetypes_dist = \ filedefs/filetypes.SystemVerilog.conf \ filedefs/filetypes.TypeScript.conf \ filedefs/filetypes.tcl \ + filedefs/filetypes.toml \ filedefs/filetypes.txt2tags \ filedefs/filetypes.vala \ filedefs/filetypes.verilog \
Modified: data/filedefs/filetypes.toml 57 lines changed, 57 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,57 @@ +# For complete documentation of this file, please see Geany's main documentation +[styling] +# Edit these in the colorscheme .conf file instead +default=default +comment=comment +identifier=identifier_1 +keyword=keyword_1 +number=number_1 +table=tag +key=attribute +error=error +operator=operator +stringsq=string_1 +stringdq=string_1 +triplestringsq=string_1 +triplestringdq=string_1 +escapechar=string_2 +datetime=number_2 + +[keywords] +# all items must be in one line +keywords=true false inf nan + +[lexer_properties] + +[settings] +# default extension used when saving files +extension=toml + +# MIME type +mime_type=application/toml + +# these characters define word boundaries when making selections and searching +# using word matching options +#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + +# single comments, like # in this file +comment_single=# +# multiline comments +#comment_open= +#comment_close= + +# set to false if a comment character/string should start at column 0 of a line, true uses any +# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d +# #command_example(); +# setting to false would generate this +# # command_example(); +# This setting works only for single line comments +comment_use_indent=true + +# context action command (please see Geany's main documentation for details) +context_action_cmd= + +[indentation] +#width=4 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +#type=1
Modified: data/filetype_extensions.conf 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -79,6 +79,7 @@ SQL=*.sql; Swift=*.swift; SystemVerilog=*.sv;*.svh; Tcl=*.tcl;*.tk;*.wish;*.exp; +TOML=*.toml; Txt2tags=*.t2t; TypeScript=*.ts;*.cts;*.mts;*.tsx; Vala=*.vala;*.vapi;
Modified: meson.build 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -290,6 +290,7 @@ lexilla = static_library('lexilla', 'scintilla/lexilla/lexers/LexSmalltalk.cxx', 'scintilla/lexilla/lexers/LexSQL.cxx', 'scintilla/lexilla/lexers/LexTCL.cxx', + 'scintilla/lexilla/lexers/LexTOML.cxx', 'scintilla/lexilla/lexers/LexTxt2tags.cxx', 'scintilla/lexilla/lexers/LexVerilog.cxx', 'scintilla/lexilla/lexers/LexVHDL.cxx',
Modified: scintilla/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -60,6 +60,7 @@ lexilla/lexers/LexRust.cxx \ lexilla/lexers/LexSmalltalk.cxx \ lexilla/lexers/LexSQL.cxx \ lexilla/lexers/LexTCL.cxx \ +lexilla/lexers/LexTOML.cxx \ lexilla/lexers/LexTxt2tags.cxx \ lexilla/lexers/LexVHDL.cxx \ lexilla/lexers/LexVerilog.cxx \
Modified: scintilla/lexilla/lexers/LexTOML.cxx 482 lines changed, 482 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,482 @@ +// Scintilla source code edit control +/** @file LexTOML.cxx + ** Lexer for TOML language. + **/ +// Based on Zufu Liu's Notepad4 TOML lexer +// Modified for Scintilla by Jiri Techet, 2024 +// The License.txt file describes the conditions under which this software may be distributed. + +#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 "LexerModule.h" + +using namespace Lexilla; + +namespace { +// Use an unnamed namespace to protect the functions and classes from name conflicts + +constexpr bool IsEOLChar(int ch) noexcept { + return ch == '\r' || ch == '\n'; +} + +constexpr bool IsIdentifierChar(int ch) noexcept { + return IsAlphaNumeric(ch) || ch == '_'; +} + +constexpr bool IsNumberContinue(int chPrev, int ch, int chNext) noexcept { + return ((ch == '+' || ch == '-') && (chPrev == 'e' || chPrev == 'E')) + || (ch == '.' && chNext != '.'); +} + +constexpr bool IsDecimalNumber(int chPrev, int ch, int chNext) noexcept { + return IsIdentifierChar(ch) || IsNumberContinue(chPrev, ch, chNext); +} + +constexpr bool IsISODateTime(int ch, int chNext) noexcept { + return ((ch == '+' || ch == '-' || ch == ':' || ch == '.') && IsADigit(chNext)) + || (ch == ' ' && (chNext == '+' || chNext == '-' || IsADigit(chNext))); +} + +struct EscapeSequence { + int outerState = SCE_TOML_DEFAULT; + int digitsLeft = 0; + + // highlight any character as escape sequence. + bool resetEscapeState(int state, int chNext) noexcept { + if (IsEOLChar(chNext)) { + return false; + } + outerState = state; + digitsLeft = 1; + if (chNext == 'x') { + digitsLeft = 3; + } else if (chNext == 'u') { + digitsLeft = 5; + } else if (chNext == 'U') { + digitsLeft = 9; + } + return true; + } + bool atEscapeEnd(int ch) noexcept { + --digitsLeft; + return digitsLeft <= 0 || !IsAHeXDigit(ch); + } +}; + +constexpr bool IsTripleString(int state) noexcept { + return state == SCE_TOML_TRIPLE_STRING_SQ || state == SCE_TOML_TRIPLE_STRING_DQ; +} + +constexpr bool IsDoubleQuoted(int state) noexcept { + return state == SCE_TOML_STRING_DQ || state == SCE_TOML_TRIPLE_STRING_DQ; +} + +constexpr int GetStringQuote(int state) noexcept { + return IsDoubleQuoted(state) ? '"' : '''; +} + +constexpr bool IsTOMLOperator(int ch) noexcept { + return AnyOf(ch, '[', ']', '{', '}', ',', '=', '.', '+', '-'); +} + +constexpr bool IsTOMLUnquotedKey(int ch) noexcept { + return IsIdentifierChar(ch) || ch == '-'; +} + +constexpr bool IsWhiteSpace(int ch) noexcept { + return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); +} + +int GetLineNextChar(StyleContext& sc) { + if (!IsWhiteSpace(sc.ch)) { + return sc.ch; + } + if (static_cast<Sci_Position>(sc.currentPos) + 1 == sc.lineStartNext) { + return '\0'; + } + if (!IsWhiteSpace(sc.chNext)) { + return sc.chNext; + } + for (Sci_Position pos = 2; pos < sc.lineStartNext; pos++) { + const unsigned char chPos = sc.GetRelative(pos); + if (!IsWhiteSpace(chPos)) { + return chPos; + } + } + return '\0'; +} + +bool IsTOMLKey(StyleContext& sc, int braceCount, const WordList *kwList) { + if (braceCount) { + const int chNext = GetLineNextChar(sc); + if (chNext == '=' || chNext == '.' || chNext == '-') { + sc.ChangeState(SCE_TOML_KEY); + return true; + } + } + if (sc.state == SCE_TOML_IDENTIFIER) { + char s[8]; + sc.GetCurrentLowered(s, sizeof(s)); +#if defined(__clang__) + __builtin_assume(kwList != nullptr); // suppress [clang-analyzer-core.CallAndMessage] +#endif + if (kwList->InList(s)) { + sc.ChangeState(SCE_TOML_KEYWORD); + } + } + sc.SetState(SCE_TOML_DEFAULT); + return false; +} + +enum class TOMLLineType { + None = 0, + Table, + CommentLine, +}; + +enum class TOMLKeyState { + Unquoted = 0, + Literal, // single-quoted + Quoted, // double-quoted + End, +}; + +void ColouriseTOMLDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, WordList *keywordLists[], Accessor &styler) { + int visibleChars = 0; + int chPrevNonWhite = 0; + int tableLevel = 0; + int braceCount = 0; + TOMLLineType lineType = TOMLLineType::None; + TOMLKeyState keyState = TOMLKeyState::Unquoted; + EscapeSequence escSeq; + + StyleContext sc(startPos, lengthDoc, initStyle, styler); + if (sc.currentLine > 0) { + const int lineState = styler.GetLineState(sc.currentLine - 1); + /* + 2: lineType + 8: tableLevel + 8: braceCount + */ + braceCount = (lineState >> 10) & 0xff; + } + + while (sc.More()) { + switch (sc.state) { + case SCE_TOML_OPERATOR: + sc.SetState(SCE_TOML_DEFAULT); + break; + + case SCE_TOML_NUMBER: + if (!IsDecimalNumber(sc.chPrev, sc.ch, sc.chNext)) { + if (IsISODateTime(sc.ch, sc.chNext)) { + sc.ChangeState(SCE_TOML_DATETIME); + } else if (IsTOMLKey(sc, braceCount, nullptr)) { + keyState = TOMLKeyState::Unquoted; + continue; + } + } + break; + + case SCE_TOML_DATETIME: + if (!(IsIdentifierChar(sc.ch) || IsISODateTime(sc.ch, sc.chNext))) { + if (IsTOMLKey(sc, braceCount, nullptr)) { + keyState = TOMLKeyState::Unquoted; + continue; + } + } + break; + + case SCE_TOML_IDENTIFIER: + if (!IsIdentifierChar(sc.ch)) { + if (IsTOMLKey(sc, braceCount, keywordLists[0])) { + keyState = TOMLKeyState::Unquoted; + continue; + } + } + break; + + case SCE_TOML_TABLE: + case SCE_TOML_KEY: + if (sc.atLineStart) { + sc.SetState(SCE_TOML_DEFAULT); + } else { + switch (keyState) { + case TOMLKeyState::Literal: + if (sc.ch == ''') { + keyState = TOMLKeyState::Unquoted; + sc.Forward(); + } + break; + case TOMLKeyState::Quoted: + if (sc.ch == '\') { + sc.Forward(); + } else if (sc.ch == '"') { + keyState = TOMLKeyState::Unquoted; + sc.Forward(); + } + break; + default: + break; + } + if (keyState == TOMLKeyState::Unquoted) { + if (sc.ch == ''') { + keyState = TOMLKeyState::Literal; + } else if (sc.ch == '"') { + keyState = TOMLKeyState::Quoted; + } else if (sc.ch == '.') { + if (sc.state == SCE_TOML_TABLE) { + ++tableLevel; + } else { + chPrevNonWhite = '.'; + sc.SetState(SCE_TOML_OPERATOR); + sc.ForwardSetState(SCE_TOML_KEY); + // TODO: skip space after dot + continue; + } + } else if (sc.state == SCE_TOML_TABLE && sc.ch == ']') { + keyState = TOMLKeyState::End; + sc.Forward(); + if (sc.ch == ']') { + sc.Forward(); + } + const int chNext = GetLineNextChar(sc); + if (chNext == '#') { + sc.SetState(SCE_TOML_DEFAULT); + } + } else if (sc.state == SCE_TOML_KEY && !IsTOMLUnquotedKey(sc.ch)) { + const int chNext = GetLineNextChar(sc); + if (chNext == '=' || (chNext != '.' && chPrevNonWhite != '.')) { + keyState = TOMLKeyState::End; + sc.SetState(SCE_TOML_DEFAULT); + } + } + } + } + break; + + case SCE_TOML_STRING_SQ: + case SCE_TOML_STRING_DQ: + case SCE_TOML_TRIPLE_STRING_SQ: + case SCE_TOML_TRIPLE_STRING_DQ: + if (sc.atLineStart && !IsTripleString(sc.state)) { + sc.SetState(SCE_TOML_DEFAULT); + } else if (sc.ch == '\' && IsDoubleQuoted(sc.state)) { + if (escSeq.resetEscapeState(sc.state, sc.chNext)) { + sc.SetState(SCE_TOML_ESCAPECHAR); + sc.Forward(); + } + } else if (sc.ch == GetStringQuote(sc.state) && + (!IsTripleString(sc.state) || (sc.Match(IsDoubleQuoted(sc.state) ? R"(""")" : R"(''')")))) { + while (sc.ch == sc.chNext) { + sc.Forward(); + } + sc.Forward(); + if (!IsTripleString(sc.state) && IsTOMLKey(sc, braceCount, nullptr)) { + keyState = TOMLKeyState::Unquoted; + continue; + } + sc.SetState(SCE_TOML_DEFAULT); + } + break; + + case SCE_TOML_ESCAPECHAR: + if (escSeq.atEscapeEnd(sc.ch)) { + sc.SetState(escSeq.outerState); + continue; + } + break; + + case SCE_TOML_ERROR: + if (sc.atLineStart) { + sc.SetState(SCE_TOML_DEFAULT); + } else if (sc.ch == '#') { + sc.SetState(SCE_TOML_COMMENT); + } + break; + + case SCE_TOML_COMMENT: + if (sc.atLineStart) { + sc.SetState(SCE_TOML_DEFAULT); + } + break; + } + + if (sc.state == SCE_TOML_DEFAULT) { + if (sc.ch == '#') { + sc.SetState(SCE_TOML_COMMENT); + if (visibleChars == 0) { + lineType = TOMLLineType::CommentLine; + } + } else if (visibleChars == 0 && braceCount == 0) { + if (sc.ch == '[') { + tableLevel = 0; + sc.SetState(SCE_TOML_TABLE); + if (sc.chNext == '[') { + sc.Forward(); + } + keyState = TOMLKeyState::Unquoted; + lineType = TOMLLineType::Table; + } else if (sc.ch == ''' || sc.ch == '"') { + keyState = (sc.ch == ''')? TOMLKeyState::Literal : TOMLKeyState::Quoted; + sc.SetState(SCE_TOML_KEY); + } else if (IsTOMLUnquotedKey(sc.ch)) { + keyState = TOMLKeyState::Unquoted; + sc.SetState(SCE_TOML_KEY); + } else if (!isspacechar(sc.ch)) { + // each line must be: key = value + sc.SetState(SCE_TOML_ERROR); + } + } else { + if (sc.ch == ''') { + if (sc.Match(R"(''')")) { + sc.SetState(SCE_TOML_TRIPLE_STRING_SQ); + sc.Forward(2); + } else { + sc.SetState(SCE_TOML_STRING_SQ); + } + } else if (sc.ch == '"') { + if (sc.Match(R"(""")")) { + sc.SetState(SCE_TOML_TRIPLE_STRING_DQ); + sc.Forward(2); + } else { + sc.SetState(SCE_TOML_STRING_DQ); + } + } else if (IsADigit(sc.ch)) { + sc.SetState(SCE_TOML_NUMBER); + } else if (IsLowerCase(sc.ch)) { + sc.SetState(SCE_TOML_IDENTIFIER); + } else if (IsTOMLOperator(sc.ch)) { + sc.SetState(SCE_TOML_OPERATOR); + if (sc.ch == '[' || sc.ch == '{') { + ++braceCount; + } else if (sc.ch == ']' || sc.ch == '}') { + if (braceCount > 0) { + --braceCount; + } + } + } else if (braceCount && IsTOMLUnquotedKey(sc.ch)) { + // Inline Table + keyState = TOMLKeyState::Unquoted; + sc.SetState(SCE_TOML_KEY); + } + } + } + + if (!isspacechar(sc.ch)) { + chPrevNonWhite = sc.ch; + ++visibleChars; + } + if (sc.atLineEnd) { + const int lineState = (tableLevel << 2) | (braceCount << 10) | static_cast<int>(lineType); + styler.SetLineState(sc.currentLine, lineState); + lineType = TOMLLineType::None; + visibleChars = 0; + chPrevNonWhite = 0; + tableLevel = 0; + keyState = TOMLKeyState::Unquoted; + } + sc.Forward(); + } + + sc.Complete(); +} + +constexpr TOMLLineType GetLineType(int lineState) noexcept { + return static_cast<TOMLLineType>(lineState & 3); +} + +constexpr int GetTableLevel(int lineState) noexcept { + return (lineState >> 2) & 0xff; +} + +// code folding based on LexProps +void FoldTOMLDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int /*initStyle*/, WordList *[] /*keywordLists*/, Accessor &styler) { + const Sci_Position endPos = startPos + lengthDoc; + const Sci_Position maxLines = styler.GetLine((endPos == styler.Length()) ? endPos : endPos - 1); + + Sci_Position lineCurrent = styler.GetLine(startPos); + + int prevLevel = SC_FOLDLEVELBASE; + TOMLLineType prevType = TOMLLineType::None; + TOMLLineType prev2Type = TOMLLineType::None; + if (lineCurrent > 0) { + prevLevel = styler.LevelAt(lineCurrent - 1); + prevType = GetLineType(styler.GetLineState(lineCurrent - 1)); + if (lineCurrent >= 2) { + prev2Type = GetLineType(styler.GetLineState(lineCurrent - 2)); + } + } + + bool commentHead = (prevType == TOMLLineType::CommentLine) && (prevLevel & SC_FOLDLEVELHEADERFLAG); + while (lineCurrent <= maxLines) { + int nextLevel; + const int lineState = styler.GetLineState(lineCurrent); + const TOMLLineType lineType = GetLineType(lineState); + + if (lineType == TOMLLineType::CommentLine) { + if (prevLevel & SC_FOLDLEVELHEADERFLAG) { + nextLevel = (prevLevel & SC_FOLDLEVELNUMBERMASK) + 1; + } else { + nextLevel = prevLevel; + } + commentHead = prevType != TOMLLineType::CommentLine; + nextLevel |= commentHead ? SC_FOLDLEVELHEADERFLAG : 0; + } else { + if (lineType == TOMLLineType::Table) { + nextLevel = SC_FOLDLEVELBASE + GetTableLevel(lineState); + if ((prevType == TOMLLineType::CommentLine) && prevLevel <= nextLevel) { + // comment above nested table + commentHead = true; + prevLevel = nextLevel - 1; + } else if ((prevType == TOMLLineType::Table) && (prevLevel & SC_FOLDLEVELNUMBERMASK) >= nextLevel) { + commentHead = true; // empty table + } + nextLevel |= SC_FOLDLEVELHEADERFLAG; + } else { + if (commentHead) { + nextLevel = prevLevel & SC_FOLDLEVELNUMBERMASK; + } else if (prevLevel & SC_FOLDLEVELHEADERFLAG) { + nextLevel = (prevLevel & SC_FOLDLEVELNUMBERMASK) + 1; + } else if ((prevType == TOMLLineType::CommentLine) && (prev2Type == TOMLLineType::CommentLine)) { + nextLevel = prevLevel - 1; + } else { + nextLevel = prevLevel; + } + } + + if (commentHead) { + commentHead = false; + styler.SetLevel(lineCurrent - 1, prevLevel & SC_FOLDLEVELNUMBERMASK); + } + } + + styler.SetLevel(lineCurrent, nextLevel); + prevLevel = nextLevel; + prev2Type = prevType; + prevType = lineType; + lineCurrent++; + } +} + +} // unnamed namespace end + +static const char *const tomlWordListDesc[] = { + "Keywords", + 0 +}; + +extern const LexerModule lmTOML(SCLEX_TOML, ColouriseTOMLDoc, "toml", FoldTOMLDoc, tomlWordListDesc);
Modified: scintilla/lexilla/src/Lexilla.cxx 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -225,6 +225,7 @@ static void AddGeanyLexers() &lmSmalltalk, &lmSQL, &lmTCL, + &lmTOML, &lmTxt2tags, &lmVerilog, &lmVHDL,
Modified: scintilla/scintilla_changes.patch 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -62,7 +62,7 @@ diff --git scintilla/lexilla/src/Lexilla.cxx scintilla/lexilla/src/Lexilla.cxx index cd4b23617..af4a73db4 100644 --- scintilla/lexilla/src/Lexilla.cxx +++ scintilla/lexilla/src/Lexilla.cxx -@@ -167,8 +167,75 @@ +@@ -167,8 +167,76 @@
CatalogueModules catalogueLexilla;
@@ -119,6 +119,7 @@ index cd4b23617..af4a73db4 100644 + &lmSmalltalk, + &lmSQL, + &lmTCL, ++ &lmTOML, + &lmTxt2tags, + &lmVerilog, + &lmVHDL,
Modified: src/filetypes.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -215,6 +215,7 @@ static void init_builtin_filetypes(void) FT_INIT( ZIG, NONE, "Zig", NULL ); FT_INIT( DART, NONE, "Dart", NULL ); FT_INIT( NIX, NONE, "Nix", NULL ); + FT_INIT( TOML, CONF, "TOML", NULL ); }
Modified: src/filetypes.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -116,6 +116,7 @@ typedef enum GEANY_FILETYPES_ZIG, GEANY_FILETYPES_DART, GEANY_FILETYPES_NIX, + GEANY_FILETYPES_TOML, /* ^ append items here */ GEANY_MAX_BUILT_IN_FILETYPES /* Don't use this, use filetypes_array->len instead */ }
Modified: src/highlighting.c 31 lines changed, 21 insertions(+), 10 deletions(-) =================================================================== @@ -1055,6 +1055,7 @@ void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co init_styleset_case(SMALLTALK); init_styleset_case(SQL); init_styleset_case(TCL); + init_styleset_case(TOML); init_styleset_case(TXT2TAGS); init_styleset_case(VHDL); init_styleset_case(VERILOG); @@ -1154,6 +1155,7 @@ void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft) styleset_case(SMALLTALK); styleset_case(SQL); styleset_case(TCL); + styleset_case(TOML); styleset_case(TXT2TAGS); styleset_case(VHDL); styleset_case(VERILOG); @@ -1675,16 +1677,11 @@ gboolean highlighting_is_string_style(gint lexer, gint style) style == SCE_VISUALPROLOG_EMBEDDED || style == SCE_VISUALPROLOG_PLACEHOLDER);
- case SCLEX_BATCH: - case SCLEX_DIFF: - case SCLEX_LATEX: - case SCLEX_MAKEFILE: - case SCLEX_MARKDOWN: - case SCLEX_PROPERTIES: - case SCLEX_TXT2TAGS: - case SCLEX_YAML: - /* there is no string type in those lexers, listing here just for completeness */ - return FALSE; + case SCLEX_TOML: + return (style == SCE_TOML_STRING_SQ || + style == SCE_TOML_STRING_DQ || + style == SCE_TOML_TRIPLE_STRING_SQ || + style == SCE_TOML_TRIPLE_STRING_DQ);
case SCLEX_AU3: return (style == SCE_AU3_STRING); @@ -1716,6 +1713,17 @@ gboolean highlighting_is_string_style(gint lexer, gint style) return (style == SCE_NIX_STRING || style == SCE_NIX_STRING_MULTILINE || style == SCE_NIX_ESCAPECHAR); + + case SCLEX_BATCH: + case SCLEX_DIFF: + case SCLEX_LATEX: + case SCLEX_MAKEFILE: + case SCLEX_MARKDOWN: + case SCLEX_PROPERTIES: + case SCLEX_TXT2TAGS: + case SCLEX_YAML: + /* there is no string type in those lexers, listing here just for completeness */ + return FALSE; } return FALSE; } @@ -1983,6 +1991,9 @@ gboolean highlighting_is_comment_style(gint lexer, gint style) case SCLEX_NIX: return (style == SCE_NIX_COMMENTLINE || style == SCE_NIX_COMMENTBLOCK); + + case SCLEX_TOML: + return (style == SCE_TOML_COMMENT); } return FALSE; }
Modified: src/highlightingmappings.h 27 lines changed, 27 insertions(+), 0 deletions(-) =================================================================== @@ -1828,6 +1828,33 @@ static const HLKeyword highlighting_keywords_TCL[] = #define highlighting_properties_TCL EMPTY_PROPERTIES
+/* TOML */ +#define highlighting_lexer_TOML SCLEX_TOML +static const HLStyle highlighting_styles_TOML[] = +{ + { SCE_TOML_DEFAULT, "default", FALSE }, + { SCE_TOML_COMMENT, "comment", FALSE }, + { SCE_TOML_IDENTIFIER, "identifier", FALSE }, + { SCE_TOML_KEYWORD, "keyword", FALSE }, + { SCE_TOML_NUMBER, "number", FALSE }, + { SCE_TOML_TABLE, "table", FALSE }, + { SCE_TOML_KEY, "key", FALSE }, + { SCE_TOML_ERROR, "error", FALSE }, + { SCE_TOML_OPERATOR, "operator", FALSE }, + { SCE_TOML_STRING_SQ, "stringsq", FALSE }, + { SCE_TOML_STRING_DQ, "stringdq", FALSE }, + { SCE_TOML_TRIPLE_STRING_SQ, "triplestringsq", FALSE }, + { SCE_TOML_TRIPLE_STRING_DQ, "triplestringdq", FALSE }, + { SCE_TOML_ESCAPECHAR, "escapechar", FALSE }, + { SCE_TOML_DATETIME, "datetime", FALSE }, +}; +static const HLKeyword highlighting_keywords_TOML[] = +{ + { 0, "keywords", FALSE } +}; +#define highlighting_properties_TOML EMPTY_PROPERTIES + + /* Txt2Tags */ #define highlighting_lexer_TXT2TAGS SCLEX_TXT2TAGS static const HLStyle highlighting_styles_TXT2TAGS[] =
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).