I'm afraid I'm not used to mailing-lists, especially when using the digest 
version. I've posted my response without the subject, so I copy it again here.

I'm sending also the patch, this time it's the full version with the 
tagmanager/txt2tags.c file correctly included.


>I'm just wondering whether it isn't possible to extend the Markdown
>parser to parse txt2tags files as well. 

it's problably possible because the txt2tags tags don't interfere with the 
markdown for this part. But...

>This way we wouldn't need to
>add yet another filetype in Geany.

yet the extension for txt2tags files is different. And in case I or someone 
manage to write the scintilla lexer, the rest of the txt2tags syntax would 
interfere with the markdown one.

>Your patch doesn't list any changes to Scintilla code,

I didn't include it, maybe I could have done it (without the scintilla lexer)? 
I'm still not satisfied with my scintilla lexer, because I managed only to 
highlight the tags and not the text. I'll propose it in a later revision.

Besides, the first time I inserted my changes, I did it on the released version 
0.18, so I had to do it again with the svn version later.



      
Index: src/filetypes.c
===================================================================
--- src/filetypes.c	(révision 4137)
+++ src/filetypes.c	(copie de travail)
@@ -375,6 +375,17 @@
 	ft->comment_open = NULL;
 	ft->comment_close = NULL;
 	ft->group = GEANY_FILETYPE_GROUP_MISC;
+	
+#define TXT2TAGS
+	ft = filetypes[GEANY_FILETYPES_TXT2TAGS];
+	ft->lang = 37;
+	ft->name = g_strdup("Txt2tags");
+	filetype_make_title(ft, TITLE_SOURCE_FILE);
+	ft->extension = g_strdup("t2t");
+	ft->pattern = utils_strv_new("*.t2t", "*.txt2tags", NULL);
+	ft->comment_open = NULL;
+	ft->comment_close = NULL;
+	ft->group = GEANY_FILETYPE_GROUP_MISC;
 
 #define SH
 	ft = filetypes[GEANY_FILETYPES_SH];
Index: src/filetypes.h
===================================================================
--- src/filetypes.h	(révision 4137)
+++ src/filetypes.h	(copie de travail)
@@ -78,6 +78,7 @@
 	GEANY_FILETYPES_ADA,
 	GEANY_FILETYPES_CMAKE,
 	GEANY_FILETYPES_MARKDOWN,
+	GEANY_FILETYPES_TXT2TAGS,
 	/* ^ append items here */
 	GEANY_MAX_BUILT_IN_FILETYPES	/* Don't use this, use filetypes_array->len instead */
 }
Index: tagmanager/parsers.h
===================================================================
--- tagmanager/parsers.h	(révision 4137)
+++ tagmanager/parsers.h	(copie de travail)
@@ -51,7 +51,8 @@
     ValaParser, \
     ActionScriptParser, \
     NsisParser, \
-    MarkdownParser
+    MarkdownParser, \
+    Txt2tagsParser
 /*
 langType of each parser
  0	CParser
@@ -91,6 +92,7 @@
 34  ActionScriptParser
 35  NsisParser
 36  MarkdownParser
+37  Txt2tagsParser
 */
 #endif	/* _PARSERS_H */
 
Index: tagmanager/makefile.win32
===================================================================
--- tagmanager/makefile.win32	(révision 4137)
+++ tagmanager/makefile.win32	(copie de travail)
@@ -43,7 +43,7 @@
 actionscript.o nsis.o \
 haskell.o haxe.o html.o python.o lregex.o rest.o sh.o ctags.o entry.o get.o keyword.o nestlevel.o \
 options.o \
-parse.o basic.o read.o sort.o strlist.o latex.o markdown.o matlab.o docbook.o tcl.o ruby.o asm.o sql.o css.o \
+parse.o basic.o read.o sort.o strlist.o latex.o markdown.o matlab.o docbook.o tcl.o ruby.o asm.o sql.o text2tags.o css.o \
 vstring.o regex.o tm_workspace.o tm_work_object.o tm_source_file.o tm_project.o tm_tag.o \
 tm_symbol.o tm_file_entry.o tm_tagmanager.o
 	$(AR) rc $@ $^
Index: tagmanager/txt2tags.c
===================================================================
--- tagmanager/txt2tags.c	(révision 0)
+++ tagmanager/txt2tags.c	(révision 0)
@@ -0,0 +1,132 @@
+/*
+*   Copyright (c) 2009, Eric Forgeot
+*
+*   Based on work by Jon Strait
+*
+*   This source code is released for free distribution under the terms of the
+*   GNU General Public License.
+*
+*   This module contains functions for generating tags for Txt2tags files.
+*/
+
+/*
+*   INCLUDE FILES
+*/
+#include "general.h"	/* must always come first */
+
+#include <ctype.h>
+#include <string.h>
+
+#include "parse.h"
+#include "read.h"
+#include "vstring.h"
+
+/*
+*   DATA DEFINITIONS
+*/
+
+static kindOption Txt2tagsKinds[] = {
+	{ TRUE, 'v', "variable", "sections" },
+	{ TRUE, 's', "struct",  "header1"}
+};
+
+/*
+*   FUNCTION DEFINITIONS
+*/
+
+/* checks if str is all the same character */
+static boolean issame(const char *str)
+{
+	char first = *str;
+
+	while (*(++str))
+	{
+		if (*str && *str != first)
+			return FALSE;
+	}
+	return TRUE;
+}
+
+
+static void makeTxt2tagsTag (const vString* const name, boolean name_before)
+{
+	tagEntryInfo e;
+	initTagEntry (&e, vStringValue(name));
+
+	if (name_before)
+		e.lineNumber--;	/* we want the line before the underline chars */
+	e.kindName = "variable";
+	e.kind = 'v';
+
+	makeTagEntry(&e);
+}
+
+static void makeTxt2tagsTag2 (const vString* const name, boolean name_before)
+{
+	tagEntryInfo e;
+	initTagEntry (&e, vStringValue(name));
+
+	if (name_before)
+		e.lineNumber--;	
+	e.kindName = "struct";
+	e.kind = 's';
+
+	makeTagEntry(&e);
+}
+
+static void findTxt2tagsTags (void)
+{
+	vString *name = vStringNew();
+	const unsigned char *line;
+
+	while ((line = fileReadLine()) != NULL)
+	{
+		int name_len = vStringLength(name);
+
+		/* underlines must be the same length or more */
+		/*if (name_len > 0 &&	(line[0] == '=' || line[0] == '-') && issame((const char*) line))
+		{
+			makeTxt2tagsTag(name, TRUE);
+		}*/
+		if (line[0] == '=') {
+// 			vStringClear(name);
+			vStringCatS(name, (const char *) line);
+			vStringTerminate(name);
+			makeTxt2tagsTag(name, FALSE);
+		}
+		/*else if (line[0] == "=") {
+			vStringClear(name);
+			vStringCatS(name, (const char *) line);
+			vStringTerminate(name);
+			makeTxt2tagsTag(name, FALSE);
+		}*/
+		else if (line[0] == '°') {
+			/*vStringClear(name);*/
+			vStringCatS(name, (const char *) line);
+			vStringTerminate(name);
+			makeTxt2tagsTag2(name, FALSE);
+		}
+		else {
+			vStringClear (name);
+			if (! isspace(*line))
+				vStringCatS(name, (const char*) line);
+			vStringTerminate(name);
+		}
+	}
+	vStringDelete (name);
+}
+
+extern parserDefinition* Txt2tagsParser (void)
+{
+	static const char *const patterns [] = { "*.t2t", NULL };
+	static const char *const extensions [] = { "t2t", NULL };
+	parserDefinition* const def = parserNew ("Txt2tags");
+
+	def->kinds = Txt2tagsKinds;
+	def->kindCount = KIND_COUNT (Txt2tagsKinds);
+	def->patterns = patterns;
+	def->extensions = extensions;
+	def->parser = findTxt2tagsTags;
+	return def;
+}
+
Index: tagmanager/Makefile.am
===================================================================
--- tagmanager/Makefile.am	(révision 4137)
+++ tagmanager/Makefile.am	(copie de travail)
@@ -61,6 +61,7 @@
 	python.c\
 	tcl.c\
 	sh.c\
+	txt2tags.c\
 	vhdl.c\
 	actionscript.c\
 	nsis.c\
Index: data/filetype_extensions.conf
===================================================================
--- data/filetype_extensions.conf	(révision 4137)
+++ data/filetype_extensions.conf	(copie de travail)
@@ -43,6 +43,7 @@
 Po=*.po;*.pot;
 LaTeX=*.tex;*.sty;*.idx;*.ltx;
 reStructuredText=*.rest;*.reST;*.rst;
+txt2tags=*.t2t;
 SQL=*.sql;
 YAML=*.yaml;*.yml;
 None=*;
_______________________________________________
Geany-devel mailing list
Geany-devel@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to