here is a new patch, with a better support for most of the syntax.
The main problem (which can be also found in the Markdown lexer), is when using
symbols similar to the one used for --strike-- for example, it will interfere
with the rest of the document. At least the coloration shouldn't last after the
end of the current line, but I didn't manage to get it this way.
Index: scintilla/LexTxt2tags.cxx
===================================================================
--- scintilla/LexTxt2tags.cxx (révision 0)
+++ scintilla/LexTxt2tags.cxx (révision 0)
@@ -0,0 +1,400 @@
+/******************************************************************
+ * LexTxt2tags.cxx
+ *
+ * A simple Txt2tags lexer for scintilla.
+ *
+ *
+ * Adapted by Eric Forgeot
+ * Based on the LexMarkdown.cxx by Jon Strait - [email protected]
+ *
+ * The License.txt file describes the conditions under which this
+ * software may be distributed.
+ *
+ *****************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+
+
+static inline bool IsNewline(const int ch) {
+ return (ch == '\n' || ch == '\r');
+}
+
+// True if can follow ch down to the end with possibly trailing whitespace
+static bool FollowToLineEnd(const int ch, const int state, const unsigned int endPos, StyleContext &sc) {
+ unsigned int i = 0;
+ while (sc.GetRelative(++i) == ch)
+ ;
+ // Skip over whitespace
+ while (IsASpaceOrTab(sc.GetRelative(i)) && sc.currentPos + i < endPos)
+ ++i;
+ if (IsNewline(sc.GetRelative(i)) || sc.currentPos + i == endPos) {
+ sc.Forward(i);
+ sc.ChangeState(state);
+ sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+ return true;
+ }
+ else return false;
+}
+
+// Set the state on text section from current to length characters,
+// then set the rest until the newline to default, except for any characters matching token
+static void SetStateAndZoom(const int state, const int length, const int token, StyleContext &sc) {
+ sc.SetState(state);
+ sc.Forward(length);
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ sc.Forward();
+ bool started = false;
+ while (sc.More() && !IsNewline(sc.ch)) {
+ if (sc.ch == token && !started) {
+ sc.SetState(state);
+ started = true;
+ }
+ else if (sc.ch != token) {
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ started = false;
+ }
+ sc.Forward();
+ }
+ sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+}
+
+// Does the previous line have more than spaces and tabs?
+static bool HasPrevLineContent(StyleContext &sc) {
+ int i = 0;
+ // Go back to the previous newline
+ while ((--i + sc.currentPos) && !IsNewline(sc.GetRelative(i)))
+ ;
+ while (--i + sc.currentPos) {
+ if (IsNewline(sc.GetRelative(i)))
+ break;
+ if (!IsASpaceOrTab(sc.GetRelative(i)))
+ return true;
+ }
+ return false;
+}
+
+static bool IsValidHrule(const unsigned int endPos, StyleContext &sc) {
+ int c, count = 1;
+ unsigned int i = 0;
+ while (++i) {
+ c = sc.GetRelative(i);
+ if (c == sc.ch)
+ ++count;
+ // hit a terminating character
+ else if (!IsASpaceOrTab(c) || sc.currentPos + i == endPos) {
+ // Are we a valid HRULE
+ if ((IsNewline(c) || sc.currentPos + i == endPos) &&
+ count >= 3 && !HasPrevLineContent(sc)) {
+ sc.SetState(SCE_TXT2TAGS_HRULE);
+ sc.Forward(i);
+ sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+ return true;
+ }
+ else {
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ return false;
+ }
+ }
+ }
+ return false;
+}
+
+static void ColorizeTxt2tagsDoc(unsigned int startPos, int length, int initStyle,
+ WordList **, Accessor &styler) {
+ unsigned int endPos = startPos + length;
+ int precharCount = 0;
+ // Don't advance on a new loop iteration and retry at the same position.
+ // Useful in the corner case of having to start at the beginning file position
+ // in the default state.
+ bool freezeCursor = false;
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ while (sc.More()) {
+ // Skip past escaped characters
+ if (sc.ch == '\\') {
+ sc.Forward();
+ continue;
+ }
+
+ // A blockquotes resets the line semantics
+ if (sc.state == SCE_TXT2TAGS_BLOCKQUOTE)
+ sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+
+ // A comment colors the whole line
+ if (sc.state == SCE_TXT2TAGS_COMMENT){
+ FollowToLineEnd('%', SCE_TXT2TAGS_COMMENT, endPos, sc);
+ }
+ // Conditional state-based actions
+ if (sc.state == SCE_TXT2TAGS_CODE2) {
+ if (sc.Match("``") && sc.GetRelative(-2) != ' ') {
+ sc.Forward(2);
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ }
+ else if (sc.state == SCE_TXT2TAGS_CODE) {
+ if (sc.ch == '`' && sc.chPrev != ' ')
+ sc.ForwardSetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ // Strong
+ else if (sc.state == SCE_TXT2TAGS_STRONG1) {
+ if (sc.Match("**") && sc.chPrev != ' ') {
+ sc.Forward(2);
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ }
+ // Emphasis
+ else if (sc.state == SCE_TXT2TAGS_EM1) {
+ if (sc.Match("//") && sc.chPrev != ' ') {
+ sc.Forward(2);
+ sc.ForwardSetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ }
+ // Underline
+ else if (sc.state == SCE_TXT2TAGS_EM2) {
+ if (sc.Match("__") && sc.chPrev != ' ') {
+ sc.Forward(2);
+ sc.ForwardSetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ }
+ else if (sc.state == SCE_TXT2TAGS_CODEBK) {
+ if (sc.atLineStart && sc.Match("~~~")) {
+ int i = 1;
+ while (!IsNewline(sc.GetRelative(i)) && sc.currentPos + i < endPos)
+ i++;
+ sc.Forward(i);
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ }
+ else if (sc.state == SCE_TXT2TAGS_STRIKEOUT) {
+ if (sc.Match("--") && sc.ch != ' ' && sc.chPrev != ' ') {
+ sc.Forward(2);
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ }
+ else if (sc.state == SCE_TXT2TAGS_LINE_BEGIN) {
+ // Header
+ if (sc.Match("======"))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER6, 6, '=', sc);
+ else if (sc.Match("====="))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER5, 5, '=', sc);
+ else if (sc.Match("===="))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER4, 4, '=', sc);
+ else if (sc.Match("==="))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER3, 3, '=', sc);
+ else if (sc.Match("=="))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER2, 2, '=', sc);
+ else if (sc.Match("=")) {
+ // Catch the special case of an unordered list
+ if (sc.chNext == '.' && IsASpaceOrTab(sc.GetRelative(2))) {
+ precharCount = 0;
+ sc.SetState(SCE_TXT2TAGS_PRECHAR);
+ }
+ else
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER1, 1, '=', sc);
+ }
+ // Numbered title
+ if (sc.Match("++++++"))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER6, 6, '+', sc);
+ else if (sc.Match("+++++"))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER5, 5, '+', sc);
+ else if (sc.Match("++++"))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER4, 4, '+', sc);
+ else if (sc.Match("+++"))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER3, 3, '+', sc);
+ else if (sc.Match("++"))
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER2, 2, '+', sc);
+ else if (sc.Match("+")) {
+ // Catch the special case of an unordered list
+ if (sc.chNext == '.' && IsASpaceOrTab(sc.GetRelative(2))) {
+ precharCount = 0;
+ sc.SetState(SCE_TXT2TAGS_PRECHAR);
+ }
+ else
+ SetStateAndZoom(SCE_TXT2TAGS_HEADER1, 1, '+', sc);
+ }
+ // Code block
+ else if (sc.Match("```")) {
+ if (!HasPrevLineContent(sc))
+ sc.SetState(SCE_TXT2TAGS_CODEBK);
+ else
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ }
+
+ else if (sc.ch == '=') {
+ if (HasPrevLineContent(sc) && FollowToLineEnd('=', SCE_TXT2TAGS_HEADER1, endPos, sc))
+ ;
+ else
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ // Comment
+ else if (sc.ch == '%') {
+ sc.SetState(SCE_TXT2TAGS_COMMENT);
+ }
+ // list
+ else if (sc.ch == '-') {
+ if (HasPrevLineContent(sc) && FollowToLineEnd('-', SCE_TXT2TAGS_HEADER2, endPos, sc))
+ ;
+ else {
+ precharCount = 0;
+ sc.SetState(SCE_TXT2TAGS_PRECHAR);
+ }
+ }
+ else if (IsNewline(sc.ch))
+ sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+ else {
+ precharCount = 0;
+ sc.SetState(SCE_TXT2TAGS_PRECHAR);
+ }
+ }
+
+ // The header lasts until the newline
+ else if (sc.state == SCE_TXT2TAGS_HEADER1 || sc.state == SCE_TXT2TAGS_HEADER2 ||
+ sc.state == SCE_TXT2TAGS_HEADER3 || sc.state == SCE_TXT2TAGS_HEADER4 ||
+ sc.state == SCE_TXT2TAGS_HEADER5 || sc.state == SCE_TXT2TAGS_HEADER6) {
+ if (IsNewline(sc.ch))
+ sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+ }
+
+ // New state only within the initial whitespace
+ if (sc.state == SCE_TXT2TAGS_PRECHAR) {
+ // Blockquote
+ if (sc.ch == '>' && precharCount < 5)
+ sc.SetState(SCE_TXT2TAGS_BLOCKQUOTE);
+ /*
+ // Begin of code block
+ else if (!HasPrevLineContent(sc) && (sc.chPrev == '\t' || precharCount >= 4))
+ sc.SetState(SCE_TXT2TAGS_CODEBK);
+ */
+ // HRule - Total of three or more hyphens, asterisks, or underscores
+ // on a line by themselves
+ else if ((sc.ch == '-') && IsValidHrule(endPos, sc))
+ ;
+ // Unordered list
+ else if ((sc.ch == '-') && IsASpaceOrTab(sc.chNext)) {
+ sc.SetState(SCE_TXT2TAGS_ULIST_ITEM);
+ sc.ForwardSetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ // Ordered list
+ else if (IsADigit(sc.ch)) {
+ int digitCount = 0;
+ while (IsADigit(sc.GetRelative(++digitCount)))
+ ;
+ if (sc.GetRelative(digitCount) == '.' &&
+ IsASpaceOrTab(sc.GetRelative(digitCount + 1))) {
+ sc.SetState(SCE_TXT2TAGS_OLIST_ITEM);
+ sc.Forward(digitCount + 1);
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ }
+ // Alternate Ordered list
+ else if (sc.ch == '+' && sc.chNext == '.' && IsASpaceOrTab(sc.GetRelative(2))) {
+ sc.SetState(SCE_TXT2TAGS_OLIST_ITEM);
+ sc.Forward(2);
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ else if (sc.ch != ' ' || precharCount > 2)
+ sc.SetState(SCE_TXT2TAGS_DEFAULT);
+ else
+ ++precharCount;
+ }
+
+ // New state anywhere in doc
+ if (sc.state == SCE_TXT2TAGS_DEFAULT) {
+ if (sc.atLineStart && sc.ch == '#') {
+ sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+ freezeCursor = true;
+ }
+ // Links and Images
+ if (sc.Match("![") || sc.ch == '[') {
+ int i = 0, j = 0, k = 0;
+ int len = endPos - sc.currentPos;
+ while (i < len && (sc.GetRelative(++i) != ']' || sc.GetRelative(i - 1) == '\\'))
+ ;
+ if (sc.GetRelative(i) == ']') {
+ j = i;
+ if (sc.GetRelative(++i) == '(') {
+ while (i < len && (sc.GetRelative(++i) != ')' || sc.GetRelative(i - 1) == '\\'))
+ ;
+ if (sc.GetRelative(i) == ')')
+ k = i;
+ }
+ else if (sc.GetRelative(i) == '[' || sc.GetRelative(++i) == '[') {
+ while (i < len && (sc.GetRelative(++i) != ']' || sc.GetRelative(i - 1) == '\\'))
+ ;
+ if (sc.GetRelative(i) == ']')
+ k = i;
+ }
+ }
+ // At least a link text
+ if (j) {
+ sc.SetState(SCE_TXT2TAGS_LINK);
+ sc.Forward(j);
+ // Also has a URL or reference portion
+ if (k)
+ sc.Forward(k - j);
+ sc.ForwardSetState(SCE_TXT2TAGS_DEFAULT);
+ }
+ }
+ // Code - also a special case for alternate inside spacing
+ if (sc.Match("``") && sc.GetRelative(3) != ' ') {
+ sc.SetState(SCE_TXT2TAGS_CODE2);
+ sc.Forward();
+ }
+ else if (sc.ch == '`' && sc.chNext != ' ') {
+ sc.SetState(SCE_TXT2TAGS_CODE);
+ }
+ // Strong
+ else if (sc.Match("**") && sc.GetRelative(2) != ' ') {
+ sc.SetState(SCE_TXT2TAGS_STRONG1);
+ sc.Forward();
+ }
+ // Emphasis
+ else if (sc.Match("//") && sc.GetRelative(2) != ' ') {
+ sc.SetState(SCE_TXT2TAGS_EM1);
+ sc.Forward();
+ }
+ else if (sc.Match("__") && sc.GetRelative(2) != ' ') {
+ sc.SetState(SCE_TXT2TAGS_EM2);
+ sc.Forward();
+ }
+ // Strikeout
+ else if (sc.Match("--") && sc.GetRelative(2) != ' ') {
+ //FollowToLineEnd('-', SCE_TXT2TAGS_STRIKEOUT, endPos, sc);
+ //SetStateAndZoom(SCE_TXT2TAGS_STRIKEOUT, 1, '-', sc);
+ sc.SetState(SCE_TXT2TAGS_STRIKEOUT);
+ sc.Forward();
+ // if (IsNewline(sc.ch))
+ // sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+ }
+ // Beginning of line
+ else if (IsNewline(sc.ch))
+ sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
+ }
+ // Advance if not holding back the cursor for this iteration.
+ if (!freezeCursor)
+ sc.Forward();
+ freezeCursor = false;
+ }
+ sc.Complete();
+}
+
+LexerModule lmTxt2tags(SCLEX_TXT2TAGS, ColorizeTxt2tagsDoc, "txt2tags");
Index: scintilla/makefile.win32
===================================================================
--- scintilla/makefile.win32 (révision 5053)
+++ scintilla/makefile.win32 (copie de travail)
@@ -61,7 +61,7 @@
#**LEXOBJS=\\\n\(\*.o \)
LEXOBJS=\
LexAda.o LexBash.o LexAsm.o LexCSS.o LexCPP.o LexHTML.o LexOthers.o LexPascal.o \
-LexPerl.o LexPython.o LexSQL.o LexCaml.o LexTCL.o LexRuby.o LexFortran.o LexVHDL.o LexVerilog.o\
+LexPerl.o LexPython.o LexSQL.o LexCaml.o LexTCL.o LexTxt2tags.o LexRuby.o LexFortran.o LexVHDL.o LexVerilog.o\
LexMarkdown.o LexMatlab.o \
LexD.o LexLua.o LexHaskell.o LexBasic.o LexR.o LexYAML.o LexCmake.o LexNsis.o
#--Autogenerated -- end of automatically generated section
Index: scintilla/include/SciLexer.h
===================================================================
--- scintilla/include/SciLexer.h (révision 5053)
+++ scintilla/include/SciLexer.h (copie de travail)
@@ -111,6 +111,7 @@
#define SCLEX_NIMROD 96
#define SCLEX_SML 97
#define SCLEX_MARKDOWN 98
+#define SCLEX_TXT2TAGS 99
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
@@ -1385,6 +1386,29 @@
#define SCE_MARKDOWN_CODE 19
#define SCE_MARKDOWN_CODE2 20
#define SCE_MARKDOWN_CODEBK 21
+#define SCE_TXT2TAGS_DEFAULT 0
+#define SCE_TXT2TAGS_LINE_BEGIN 1
+#define SCE_TXT2TAGS_STRONG1 2
+#define SCE_TXT2TAGS_STRONG2 3
+#define SCE_TXT2TAGS_EM1 4
+#define SCE_TXT2TAGS_EM2 5
+#define SCE_TXT2TAGS_HEADER1 6
+#define SCE_TXT2TAGS_HEADER2 7
+#define SCE_TXT2TAGS_HEADER3 8
+#define SCE_TXT2TAGS_HEADER4 9
+#define SCE_TXT2TAGS_HEADER5 10
+#define SCE_TXT2TAGS_HEADER6 11
+#define SCE_TXT2TAGS_PRECHAR 12
+#define SCE_TXT2TAGS_ULIST_ITEM 13
+#define SCE_TXT2TAGS_OLIST_ITEM 14
+#define SCE_TXT2TAGS_BLOCKQUOTE 15
+#define SCE_TXT2TAGS_STRIKEOUT 16
+#define SCE_TXT2TAGS_HRULE 17
+#define SCE_TXT2TAGS_LINK 18
+#define SCE_TXT2TAGS_CODE 19
+#define SCE_TXT2TAGS_CODE2 20
+#define SCE_TXT2TAGS_CODEBK 21
+#define SCE_TXT2TAGS_COMMENT 22
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif
Index: scintilla/include/Scintilla.iface
===================================================================
--- scintilla/include/Scintilla.iface (révision 5053)
+++ scintilla/include/Scintilla.iface (copie de travail)
@@ -3752,6 +3752,31 @@
val SCE_MARKDOWN_CODE=19
val SCE_MARKDOWN_CODE2=20
val SCE_MARKDOWN_CODEBK=21
+# Lexical state for SCLEX_TXT2TAGS
+lex Markdown=SCLEX_TXT2TAGS SCE_TXT2TAGS_
+val SCE_TXT2TAGS_DEFAULT=0
+val SCE_TXT2TAGS_LINE_BEGIN=1
+val SCE_TXT2TAGS_STRONG1=2
+val SCE_TXT2TAGS_STRONG2=3
+val SCE_TXT2TAGS_EM1=4
+val SCE_TXT2TAGS_EM2=5
+val SCE_TXT2TAGS_HEADER1=6
+val SCE_TXT2TAGS_HEADER2=7
+val SCE_TXT2TAGS_HEADER3=8
+val SCE_TXT2TAGS_HEADER4=9
+val SCE_TXT2TAGS_HEADER5=10
+val SCE_TXT2TAGS_HEADER6=11
+val SCE_TXT2TAGS_PRECHAR=12
+val SCE_TXT2TAGS_ULIST_ITEM=13
+val SCE_TXT2TAGS_OLIST_ITEM=14
+val SCE_TXT2TAGS_BLOCKQUOTE=15
+val SCE_TXT2TAGS_STRIKEOUT=16
+val SCE_TXT2TAGS_HRULE=17
+val SCE_TXT2TAGS_LINK=18
+val SCE_TXT2TAGS_CODE=19
+val SCE_TXT2TAGS_CODE2=20
+val SCE_TXT2TAGS_CODEBK=21
+val SCE_COMMENT_CODEBK=22
# Events
Index: scintilla/KeyWords.cxx
===================================================================
--- scintilla/KeyWords.cxx (révision 5053)
+++ scintilla/KeyWords.cxx (copie de travail)
@@ -357,6 +357,7 @@
LINK_LEXER(lmRuby);
LINK_LEXER(lmSQL);
LINK_LEXER(lmTCL);
+ LINK_LEXER(lmTxt2tags);
LINK_LEXER(lmVHDL);
LINK_LEXER(lmVerilog);
LINK_LEXER(lmXML);
Index: scintilla/Makefile.am
===================================================================
--- scintilla/Makefile.am (révision 5053)
+++ scintilla/Makefile.am (copie de travail)
@@ -29,6 +29,7 @@
LexR.cxx \
LexRuby.cxx \
LexSQL.cxx \
+LexTxt2tags.cxx \
LexTCL.cxx \
LexVHDL.cxx \
LexVerilog.cxx \
Index: src/highlighting.c
===================================================================
--- src/highlighting.c (révision 5053)
+++ src/highlighting.c (copie de travail)
@@ -2537,7 +2537,65 @@
set_sci_style(sci, SCE_TCL_WORD5, ft_id, 15);
}
+static void styleset_txt2tags_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
+{
+ new_styleset(ft_id, 19);
+ get_keyfile_style(config, config_home, "default", &style_sets[ft_id].styling[0]);
+ get_keyfile_style(config, config_home, "strong", &style_sets[ft_id].styling[1]);
+ get_keyfile_style(config, config_home, "emphasis", &style_sets[ft_id].styling[2]);
+ get_keyfile_style(config, config_home, "header1", &style_sets[ft_id].styling[3]);
+ get_keyfile_style(config, config_home, "header2", &style_sets[ft_id].styling[4]);
+ get_keyfile_style(config, config_home, "header3", &style_sets[ft_id].styling[5]);
+ get_keyfile_style(config, config_home, "header4", &style_sets[ft_id].styling[6]);
+ get_keyfile_style(config, config_home, "header5", &style_sets[ft_id].styling[7]);
+ get_keyfile_style(config, config_home, "header6", &style_sets[ft_id].styling[8]);
+ get_keyfile_style(config, config_home, "ulist_item", &style_sets[ft_id].styling[9]);
+ get_keyfile_style(config, config_home, "olist_item", &style_sets[ft_id].styling[10]);
+ get_keyfile_style(config, config_home, "blockquote", &style_sets[ft_id].styling[11]);
+ get_keyfile_style(config, config_home, "strikeout", &style_sets[ft_id].styling[12]);
+ get_keyfile_style(config, config_home, "hrule", &style_sets[ft_id].styling[13]);
+ get_keyfile_style(config, config_home, "link", &style_sets[ft_id].styling[14]);
+ get_keyfile_style(config, config_home, "code", &style_sets[ft_id].styling[15]);
+ get_keyfile_style(config, config_home, "codebk", &style_sets[ft_id].styling[16]);
+ get_keyfile_style(config, config_home, "underlined", &style_sets[ft_id].styling[17]);
+ get_keyfile_style(config, config_home, "comment", &style_sets[ft_id].styling[18]);
+
+ style_sets[ft_id].keywords = NULL;
+}
+
+
+static void styleset_txt2tags(ScintillaObject *sci, gint ft_id)
+{
+ apply_filetype_properties(sci, SCLEX_TXT2TAGS, ft_id);
+
+ set_sci_style(sci, STYLE_DEFAULT, ft_id, 0);
+ set_sci_style(sci, SCE_TXT2TAGS_DEFAULT, ft_id, 0);
+ set_sci_style(sci, SCE_TXT2TAGS_LINE_BEGIN, ft_id, 0);
+ set_sci_style(sci, SCE_TXT2TAGS_PRECHAR, ft_id, 0);
+ set_sci_style(sci, SCE_TXT2TAGS_STRONG1, ft_id, 1);
+ set_sci_style(sci, SCE_TXT2TAGS_STRONG2, ft_id, 1);
+ set_sci_style(sci, SCE_TXT2TAGS_EM1, ft_id, 2);
+ set_sci_style(sci, SCE_TXT2TAGS_EM2, ft_id, 17);
+ set_sci_style(sci, SCE_TXT2TAGS_HEADER1, ft_id, 3);
+ set_sci_style(sci, SCE_TXT2TAGS_HEADER2, ft_id, 4);
+ set_sci_style(sci, SCE_TXT2TAGS_HEADER3, ft_id, 5);
+ set_sci_style(sci, SCE_TXT2TAGS_HEADER4, ft_id, 6);
+ set_sci_style(sci, SCE_TXT2TAGS_HEADER5, ft_id, 7);
+ set_sci_style(sci, SCE_TXT2TAGS_HEADER6, ft_id, 8);
+ set_sci_style(sci, SCE_TXT2TAGS_ULIST_ITEM, ft_id, 9);
+ set_sci_style(sci, SCE_TXT2TAGS_OLIST_ITEM, ft_id, 10);
+ set_sci_style(sci, SCE_TXT2TAGS_BLOCKQUOTE, ft_id, 11);
+ set_sci_style(sci, SCE_TXT2TAGS_STRIKEOUT, ft_id, 12);
+ set_sci_style(sci, SCE_TXT2TAGS_HRULE, ft_id, 13);
+ set_sci_style(sci, SCE_TXT2TAGS_LINK, ft_id, 14);
+ set_sci_style(sci, SCE_TXT2TAGS_CODE, ft_id, 15);
+ set_sci_style(sci, SCE_TXT2TAGS_CODE2, ft_id, 15);
+ set_sci_style(sci, SCE_TXT2TAGS_CODEBK, ft_id, 16);
+ set_sci_style(sci, SCE_TXT2TAGS_COMMENT, ft_id, 18);
+}
+
+
static void styleset_matlab_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{
new_styleset(ft_id, 9);
@@ -3201,6 +3259,7 @@
init_styleset_case(GEANY_FILETYPES_SH, styleset_sh_init);
init_styleset_case(GEANY_FILETYPES_SQL, styleset_sql_init);
init_styleset_case(GEANY_FILETYPES_TCL, styleset_tcl_init);
+ init_styleset_case(GEANY_FILETYPES_TXT2TAGS, styleset_txt2tags_init);
init_styleset_case(GEANY_FILETYPES_VHDL, styleset_vhdl_init);
init_styleset_case(GEANY_FILETYPES_VERILOG, styleset_verilog_init);
init_styleset_case(GEANY_FILETYPES_XML, styleset_markup_init);
@@ -3269,6 +3328,7 @@
styleset_case(GEANY_FILETYPES_SH, styleset_sh);
styleset_case(GEANY_FILETYPES_SQL, styleset_sql);
styleset_case(GEANY_FILETYPES_TCL, styleset_tcl);
+ styleset_case(GEANY_FILETYPES_TXT2TAGS, styleset_txt2tags);
styleset_case(GEANY_FILETYPES_VHDL, styleset_vhdl);
styleset_case(GEANY_FILETYPES_VERILOG, styleset_verilog);
styleset_case(GEANY_FILETYPES_XML, styleset_xml);
Index: data/filetypes.txt2tags
===================================================================
--- data/filetypes.txt2tags (révision 5053)
+++ data/filetypes.txt2tags (copie de travail)
@@ -1,6 +1,25 @@
# For complete documentation of this file, please see Geany's main documentation
[styling]
-# no syntax highlighting yet
+# foreground;background;bold;italic
+default=0x000000;0xffffff;false;false
+strong=0x00458A;0xffffff;true;false
+emphasis=0x9C0E0E;0xffffff;false;true
+underlined=0x00892B;0xffffff;false;false
+header1=0xE20700;0xffffff;true;false
+header2=0xE20700;0xffffff;true;false
+header3=0xE20700;0xffffff;true;false
+header4=0x0000bb;0xffffff;true;false
+header5=0x0000bb;0xffffff;true;false
+header6=0x0000bb;0xffffff;true;false
+ulist_item=0xee0000;0xffffff;false;false
+olist_item=0xee0000;0xffffff;false;false
+blockquote=0xff0000;0xffffff;false;false
+strikeout=0x644A9B;0xffffff;false;false
+hrule=0xff901e;0xffffff;false;false
+link=0x0000ff;0xffffff;false;true
+code=0x009f00;0xffffff;false;false
+codebk=0x005f00;0xffffff;false;false
+comment=0x888888;0xffffff;false;false
[settings]
# default extension used when saving files
Index: wscript
===================================================================
--- wscript (révision 5053)
+++ wscript (copie de travail)
@@ -92,8 +92,8 @@
'scintilla/LexLua.cxx', 'scintilla/LexMarkdown.cxx', 'scintilla/LexMatlab.cxx',
'scintilla/LexNsis.cxx', 'scintilla/LexOthers.cxx',
'scintilla/LexPascal.cxx', 'scintilla/LexPerl.cxx', 'scintilla/LexPython.cxx',
- 'scintilla/LexR.cxx',
- 'scintilla/LexRuby.cxx', 'scintilla/LexSQL.cxx', 'scintilla/LexTCL.cxx',
+ 'scintilla/LexR.cxx', 'scintilla/LexRuby.cxx', 'scintilla/LexSQL.cxx',
+ 'scintilla/LexTCL.cxx', 'scintilla/LexTxt2tags.cxx',
'scintilla/LexVHDL.cxx', 'scintilla/LexVerilog.cxx', 'scintilla/LexYAML.cxx',
'scintilla/LineMarker.cxx', 'scintilla/PerLine.cxx',
'scintilla/PlatGTK.cxx',
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel