Add filetype ActionScript (patch by Chris Macksey, thanks).

Update type keywords only for real C-like languages.
Fix wrong sorting of Assembler and Ada filetypes.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3624 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2009-03-13 09:58:27 +00:00
parent 7246f992d3
commit 4122c1b138
16 changed files with 260 additions and 8 deletions

View File

@ -1,3 +1,15 @@
2009-03-10 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* data/filetype_extensions.conf, data/filetypes.actionscript,
src/about.c, src/document.c, src/filetypes.c, src/filetypes.h,
src/highlighting.c, src/plugindata.h, src/symbols.c,
tagmanager/Makefile.am, tagmanager/actionscript.c,
tagmanager/makefile.win32, tagmanager/parsers.h, THANKS, wscript:
Add filetype ActionScript (patch by Chris Macksey, thanks).
Update type keywords only for real C-like languages.
Fix wrong sorting of Assembler and Ada filetypes.
2009-03-05 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/notebook.c:

1
THANKS
View File

@ -61,6 +61,7 @@ Tyler Mulligan <tyler(at)doknowevil(dot)net> - Close All toolbar icon
Philipp Gildein <philipp(at)gildein(dot)com> - Ada filetype patch
Thomas Martitz <thomas47(at)arcor(dot)de> - Multiple %cursor% wildcards in Snippets patch
David Gleich <dgleich(at)stanford(dot)edu> - Send Selection to Terminal patch
Chris Macksey <cmacksey(at)users(dot)sourceforge(dot)net> - ActionScript filetype patch
Translators:
------------

View File

@ -17,6 +17,7 @@ FreeBasic=*.bas;*.bi;
GLSL=*.glsl;*.frag;*.vert;
Haskell=*.hs;*.lhs;
Haxe=*.hx;
ActionScript=*.as;
Java=*.java;*.jsp;
Pascal=*.pas;*.pp;*.inc;*.dpr;*.dpk;
Vala=*.vala;*.vapi;

View File

@ -0,0 +1,60 @@
# For complete documentation of this file, please see Geany's main documentation
[styling]
# foreground;background;bold;italic
default=0x000000;0xffffff;false;false
comment=0xd00000;0xffffff;false;false
commentline=0xd00000;0xffffff;false;false
commentdoc=0x3f5fbf;0xffffff;false;false
number=0x007f00;0xffffff;false;false
word=0x00007f;0xffffff;true;false
word2=0x991111;0xffffff;true;false
string=0xff901e;0xffffff;false;false
character=0xff901e;0xffffff;false;false
uuid=0x404080;0xffffff;false;false
preprocessor=0x007F7F;0xffffff;false;false
operator=0x301010;0xffffff;false;false
identifier=0x000000;0xffffff;false;false
stringeol=0x000000;0xe0c0e0;false;false
verbatim=0x101030;0xffffff;false;false
regex=0x105090;0xffffff;false;false
commentlinedoc=0x3f5fbf;0xffffff;true;false
commentdockeyword=0x3f5fbf;0xffffff;true;true
commentdockeyworderror=0x3f5fbf;0xffffff;false;false
globalclass=0x0000d0;0xffffff;true;false
[keywords]
# all items must be in one line
primary=break case catch class const continue default do dynamic each else extends false final finally for function get if implements import in include Infinity int interface internal label namespace NaN native new null override package private protected public return set static super switch this throw true try typeof uint undefined var while with void
secondary=arguments decodeURI decodeURIcomponent encodeURI encodeURIcomponent escape isFinite isNaN isXMLName parseFloat parseInt trace unescape
classes=ArgumentError Array Boolean Class Date DefinitionError Error EvalError Function Math NameSpace Null Number Object QName RangeError ReferenceError RegExp SecurityError String SyntaxError TypeError URIError Vector VerifyError XML XMLList
[settings]
# default extension used when saving files
#extension=as
# the following characters are these which a "word" can contains, see documentation
#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
# if only single comment char is supported like # in this file, leave comment_close blank
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=
[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension
# (use only one of it at one time)
compiler=
run_cmd=

View File

@ -79,7 +79,8 @@ static const gint prev_translators_len = G_N_ELEMENTS(prev_translators);
static const gchar *contributors =
"Alexander Rodin, Andrew Rowland, Anh Phạm, blackdog, Bo Lorentsen, Bob Doan, Bronisław Białek, Catalin Marinas, "
"Christoph Berg, Colomban Wendling, Conrad Steenberg, Daniel Richard G., Dave Moore, Dirk Weber, Felipe Pena, François Cami, "
"Chris Macksey, Christoph Berg, Colomban Wendling, Conrad Steenberg, Daniel Richard G., Dave Moore, Dirk Weber, "
"Felipe Pena, François Cami, "
"Giuseppe Torelli, Guillaume de Rorthais, Guillaume Hoffmann, Herbert Voss, Jason Oster, Jean-François Wauthy, Jeff Pohlmeyer, "
"John Gabriele, Josef Whiter, Kevin Ellwood, Kristoffer A. Tjernås, Marko Peric, Matti Mårds, Moritz Barsnick, "
"Peter Strand, Philipp Gildein, Pierre Joye, Rob van der Linde, Robert McGinley, Roland Baudin, S Jagannathan, Saleem Abdulrasool, "

View File

@ -2334,8 +2334,24 @@ static gboolean update_type_keywords(GeanyDocument *doc, gint lang)
gboolean ret = FALSE;
guint n;
const GString *s;
ScintillaObject *sci = doc ? doc->editor->sci : NULL;
ScintillaObject *sci = doc->editor->sci;
g_return_val_if_fail(doc != NULL, FALSE);
switch (FILETYPE_ID(doc->file_type))
{ /* continue working with the following languages, skip on all others */
case GEANY_FILETYPES_C:
case GEANY_FILETYPES_CPP:
case GEANY_FILETYPES_CS:
case GEANY_FILETYPES_D:
case GEANY_FILETYPES_JAVA:
case GEANY_FILETYPES_VALA:
break;
default:
return FALSE;
}
sci = doc->editor->sci;
if (sci != NULL && editor_lexer_get_type_keyword_idx(sci_get_lexer(sci)) == -1)
return FALSE;

View File

@ -472,6 +472,17 @@ static void init_builtin_filetypes(void)
ft->comment_close = NULL;
ft->group = GEANY_FILETYPE_GROUP_COMPILED;
#define ACTIONSCRIPT
ft = filetypes[GEANY_FILETYPES_AS];
ft->lang = 34;
ft->name = g_strdup("ActionScript");
ft->title = g_strdup_printf(_("%s source file"), "Actionscript");
ft->extension = g_strdup("as");
ft->pattern = utils_strv_new("*.as", NULL);
ft->comment_open = g_strdup("//");
ft->comment_close = NULL;
ft->group = GEANY_FILETYPE_GROUP_COMPILED;
#define R
ft = filetypes[GEANY_FILETYPES_R];
ft->lang = 34;

View File

@ -36,8 +36,9 @@
typedef enum
{
/* normally compiled languages */
GEANY_FILETYPES_ASM = 0,
GEANY_FILETYPES_ADA,
GEANY_FILETYPES_ADA = 0,
GEANY_FILETYPES_AS,
GEANY_FILETYPES_ASM,
GEANY_FILETYPES_C,
GEANY_FILETYPES_CPP,
GEANY_FILETYPES_CS,

View File

@ -3236,6 +3236,35 @@ static void styleset_basic(ScintillaObject *sci)
set_sci_style(sci, SCE_B_BINNUMBER, GEANY_FILETYPES_BASIC, 18);
}
static void styleset_actionscript_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{
new_style_array(GEANY_FILETYPES_AS, 20);
styleset_c_like_init(config, config_home, GEANY_FILETYPES_AS);
style_sets[GEANY_FILETYPES_AS].keywords = g_new(gchar *, 4);
get_keyfile_keywords(config, config_home, "keywords", "primary", GEANY_FILETYPES_AS, 0, "");
get_keyfile_keywords(config, config_home, "keywords", "secondary", GEANY_FILETYPES_AS, 1, "");
get_keyfile_keywords(config, config_home, "keywords", "classes", GEANY_FILETYPES_AS, 2, "");
style_sets[GEANY_FILETYPES_AS].keywords[3] = NULL;
get_keyfile_wordchars(config, config_home, &style_sets[GEANY_FILETYPES_AS].wordchars);
}
static void styleset_actionscript(ScintillaObject *sci)
{
apply_filetype_properties(sci, SCLEX_CPP, GEANY_FILETYPES_AS);
SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t) style_sets[GEANY_FILETYPES_AS].keywords[0]);
SSM(sci, SCI_SETKEYWORDS, 1, (sptr_t) style_sets[GEANY_FILETYPES_AS].keywords[2]);
SSM(sci, SCI_SETKEYWORDS, 3, (sptr_t) style_sets[GEANY_FILETYPES_AS].keywords[1]);
styleset_c_like(sci, GEANY_FILETYPES_AS);
}
static void styleset_haxe_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
{
new_style_array(GEANY_FILETYPES_HAXE, 20);
@ -3366,6 +3395,7 @@ void highlighting_init_styles(gint filetype_idx, GKeyFile *config, GKeyFile *con
init_styleset_case(GEANY_FILETYPES_GLSL, glsl);
init_styleset_case(GEANY_FILETYPES_HASKELL, haskell);
init_styleset_case(GEANY_FILETYPES_HAXE, haxe);
init_styleset_case(GEANY_FILETYPES_AS, actionscript);
init_styleset_case(GEANY_FILETYPES_HTML, html);
init_styleset_case(GEANY_FILETYPES_JAVA, java);
init_styleset_case(GEANY_FILETYPES_JS, js);
@ -3427,6 +3457,7 @@ void highlighting_set_styles(ScintillaObject *sci, gint filetype_idx)
styleset_case(GEANY_FILETYPES_GLSL, glsl);
styleset_case(GEANY_FILETYPES_HASKELL, haskell);
styleset_case(GEANY_FILETYPES_HAXE, haxe);
styleset_case(GEANY_FILETYPES_AS, actionscript);
styleset_case(GEANY_FILETYPES_HTML, html);
styleset_case(GEANY_FILETYPES_JAVA, java);
styleset_case(GEANY_FILETYPES_JS, js);

View File

@ -45,13 +45,13 @@
enum {
/** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 133,
GEANY_API_VERSION = 134,
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */
/* This should usually stay the same if fields are only appended, assuming only pointers to
* structs and not structs themselves are declared by plugins. */
GEANY_ABI_VERSION = 58
GEANY_ABI_VERSION = 59
};
/** Check the plugin can be loaded by Geany.

View File

@ -723,6 +723,20 @@ static void add_top_level_items(GeanyDocument *doc)
NULL);
break;
}
case GEANY_FILETYPES_AS:
{
tag_list_add_groups(tag_store,
&(tv_iters.tag_namespace), _("Package"), "classviewer-namespace",
&(tv_iters.tag_struct), _("Interfaces"), "classviewer-struct",
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
&(tv_iters.tag_member), _("Properties"), "classviewer-member",
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
&(tv_iters.tag_macro), _("Constants"), "classviewer-macro",
&(tv_iters.tag_other), _("Other"), "classviewer-other",
NULL);
break;
}
case GEANY_FILETYPES_HAXE:
{
tag_list_add_groups(tag_store,

View File

@ -60,6 +60,7 @@ libtagmanager_a_SOURCES =\
tcl.c\
sh.c\
vhdl.c\
actionscript.c\
ctags.c\
entry.c\
get.c\

99
tagmanager/actionscript.c Normal file
View File

@ -0,0 +1,99 @@
/*
* $Id: actionscript.c,v 1.1 2004/01/03 03:59:19 svoisen Exp $
*
* Original file copyright (c) 2004, Sean Voisen
*
* Modified October 8, 2007 By Mike Fahy (VeryVito) of www.turdhead.com
* - Added initial AS3 support
* - Threw in some "TODO" and "NOTE" bits
*
* Modified October 9, 2007 By Ali Rantakari of hasseg.org:
* - Added more allowed AS3 attribute keywords (override, final, internal
* etc...) for classes, getters & setters, variables
* - Allowed varying versions of "note" and "todo" spellings
* - Allowed points (.) in package names so that they would display the
* whole package name instead of just the first level
* - Added interfaces matching support
* - Reformatted some name parameters:
* - Getters and setters: display either "get" or "set" in front
* of the property name
* - Todos & notes: made the name be the text that comes after the
* "todo" or "note" text
* - Variables: Moved the variable type after the name and separated
* them with " : " according to ActionScript syntax
* Modified March 6, 2009 by Chris Macksey (cmacksey@users.sourceforge.net)
* - Tweaked to work better with Geany
*
* 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 ActionScript language
* files.
*/
/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */
#include "parse.h"
/*
* FUNCTION DEFINITIONS
*
*/
static void installActionScriptRegex (const langType language)
{
/* Functions */
addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal|final|override)( \t)]*function[ \t]+([A-Za-z0-9_]+)[ \t]*\\(([^\\{]*)",
"\\1 (\\2", "f,function,functions,methods", NULL);
/* Getters and setters */
addTagRegex (language, "^[ \t]*[(public|static|internal|final|override)( \t)]*function[ \t]+(set|get)[ \t]+([A-Za-z0-9_]+)[ \t]*\\(",
"\\2 \\1", "f,field,fields", NULL);
/* Variables */
addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal)( \t)]*var[ \t]+([A-Za-z0-9_]+)([ \t]*\\:[ \t]*([A-Za-z0-9_]+))*[ \t]*",
"\\1 \\: \\3", "v,variable,variables", NULL);
/* Constants */
addTagRegex (language, "^[ \t]*[(private|public|static|protected|internal)( \t)]*const[ \t]+([A-Za-z0-9_]+)([ \t]*\\:[ \t]*([A-Za-z0-9_]+))*[ \t]*",
"\\1 : \\3", "m,macro,macros", NULL);
/* Classes */
addTagRegex (language, "^[ \t]*[(private|public|static|dynamic|final|internal)( \t)]*class[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)",
"\\1 (\\2)", "c,class,classes", NULL);
/* Interfaces */
addTagRegex (language, "^[ \t]*[(private|public|static|dynamic|final|internal)( \t)]*interface[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)",
"\\1 (\\2)", "i,interface,interfaces", NULL);
/* Packages */
addTagRegex (language, "^[ \t]*[(private|public|static)( \t)]*package[ \t]+([A-Za-z0-9_.]+)[ \t]*",
"\\1", "p,package", NULL);
/* Notes */
addTagRegex (language, "\\/\\/[ \t]*(NOTE|note|Note)[ \t]*\\:*(.*)",
"\\2", "o,other", NULL);
/* Todos */
addTagRegex (language, "\\/\\/[ \t]*(TODO|todo|ToDo|Todo)[ \t]*\\:*(.*)",
"\\2", "o,other", NULL);
/* Prototypes (Put this in for AS1 compatibility...) */
addTagRegex (language, ".*\\.prototype\\.([A-Za-z0-9 ]+)[ \t]*\\=([ \t]*)function( [ \t]?)*\\(",
"\\1", "p,prototype", NULL);
}
/* Create parser definition stucture */
extern parserDefinition* ActionScriptParser (void)
{
static const char *const extensions [] = { "as", NULL };
parserDefinition *const def = parserNew ("ActionScript");
def->extensions = extensions;
def->initialize = installActionScriptRegex;
def->regex = TRUE;
return def;
}

View File

@ -40,6 +40,7 @@ clean:
-$(RM) deps.mak *.o $(COMPLIB)
$(COMPLIB): args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o diff.o vhdl.o lua.o js.o \
actionscript.o \
haskell.o haxe.o html.o python.o lregex.o rest.o sh.o ctags.o entry.o get.o keyword.o options.o \
parse.o basic.o read.o sort.o strlist.o latex.o matlab.o docbook.o tcl.o ruby.o asm.o sql.o css.o \
vstring.o regex.o tm_workspace.o tm_work_object.o tm_source_file.o tm_project.o tm_tag.o \

View File

@ -48,7 +48,8 @@
F77Parser, \
GLSLParser, \
MatlabParser, \
ValaParser
ValaParser, \
ActionScriptParser
/*
langType of each parser
@ -86,6 +87,7 @@ langType of each parser
31 GLSLParser
32 MatlabParser
33 ValaParser
34 ActionScriptParser
*/
#endif /* _PARSERS_H */

View File

@ -52,7 +52,8 @@ blddir = '_build_'
tagmanager_sources = [
'tagmanager/args.c', 'tagmanager/asm.c', 'tagmanager/basic.c', 'tagmanager/c.c',
'tagmanager/args.c', 'tagmanager/actionscript.c', 'tagmanager/asm.c',
'tagmanager/basic.c', 'tagmanager/c.c',
'tagmanager/conf.c', 'tagmanager/css.c', 'tagmanager/ctags.c', 'tagmanager/diff.c',
'tagmanager/docbook.c', 'tagmanager/entry.c', 'tagmanager/fortran.c', 'tagmanager/get.c',
'tagmanager/haskell.c', 'tagmanager/haxe.c', 'tagmanager/html.c', 'tagmanager/js.c',