Add new filetype 'Matlab' (closes #1938631, patch by Roland Baudin, thanks).
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3190 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
8bf87e009c
commit
474a0b4410
1
THANKS
1
THANKS
@ -50,6 +50,7 @@ Timothy Boronczyk <tboronczyk(at)gmail(dot)com> - scroll_stop_at_last_line GUI p
|
||||
Jason Oster <parasytic(at)users(dot)sourceforge(dot)net> - various patches
|
||||
Andrew Rowland <weibullguy(at)charter(dot)net> - R filetype patch
|
||||
Bronisław Białek <after89(at)gmail(dot)com> - CSS parser update
|
||||
Roland Baudin <roland(dot)baudin(at)thalesaleniaspace(dot)com> - Matlab filetype patch
|
||||
|
||||
Translators:
|
||||
------------
|
||||
|
@ -23,6 +23,7 @@ Ferite=*.fe;
|
||||
Javascript=*.js;
|
||||
Lua=*.lua;
|
||||
Make=*.mak;*.mk;GNUmakefile;makefile;Makefile;makefile.*;Makefile.*;
|
||||
Matlab=*.m;
|
||||
O-Matrix=*.oms;
|
||||
Perl=*.pl;*.perl;*.pm;*.agi;*.pod;
|
||||
PHP=*.php;*.php3;*.php4;*.php5;*.phtml;
|
||||
|
38
data/filetypes.matlab
Normal file
38
data/filetypes.matlab
Normal file
@ -0,0 +1,38 @@
|
||||
# For complete documentation of this file, please see Geany's main documentation
|
||||
[styling]
|
||||
# foreground;background;bold;italic
|
||||
default=0x000000;0xffffff;false;false
|
||||
comment=0x808080;0xffffff;false;false
|
||||
command=0x111199;0xffffff;true;false
|
||||
number=0x007f00;0xffffff;false;false
|
||||
keyword=0x001a7f;0xffffff;true;false
|
||||
string=0xff901e;0xffffff;false;false
|
||||
operator=0x301010;0xffffff;false;false
|
||||
identifier=0x000000;0xffffff;false;false
|
||||
doublequotedstring=0xff901e;0xffffff;false;false
|
||||
|
||||
[keywords]
|
||||
# all items must be in one line
|
||||
primary=break case catch continue else elseif end for function global if otherwise persistent return switch try while
|
||||
|
||||
[settings]
|
||||
# default extension used when saving files
|
||||
#extension=m
|
||||
|
||||
# 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=
|
@ -160,6 +160,7 @@ int Scintilla_LinkLexers() {
|
||||
LINK_LEXER(lmLatex);
|
||||
LINK_LEXER(lmLua);
|
||||
LINK_LEXER(lmMake);
|
||||
LINK_LEXER(lmMatlab);
|
||||
LINK_LEXER(lmNncrontab);
|
||||
LINK_LEXER(lmNull);
|
||||
LINK_LEXER(lmOMS);
|
||||
|
236
scintilla/LexMatlab.cxx
Normal file
236
scintilla/LexMatlab.cxx
Normal file
@ -0,0 +1,236 @@
|
||||
// Scintilla source code edit control
|
||||
/** @file LexMatlab.cxx
|
||||
** Lexer for Matlab.
|
||||
** Written by José Fonseca
|
||||
**
|
||||
** Changes by Christoph Dalitz 2003/12/04:
|
||||
** - added support for Octave
|
||||
** - Strings can now be included both in single or double quotes
|
||||
**/
|
||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// 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 bool IsMatlabCommentChar(int c) {
|
||||
return (c == '%') ;
|
||||
}
|
||||
|
||||
static bool IsOctaveCommentChar(int c) {
|
||||
return (c == '%' || c == '#') ;
|
||||
}
|
||||
|
||||
static bool IsMatlabComment(Accessor &styler, int pos, int len) {
|
||||
return len > 0 && IsMatlabCommentChar(styler[pos]) ;
|
||||
}
|
||||
|
||||
static bool IsOctaveComment(Accessor &styler, int pos, int len) {
|
||||
return len > 0 && IsOctaveCommentChar(styler[pos]) ;
|
||||
}
|
||||
|
||||
static inline bool IsAWordChar(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static inline bool IsAWordStart(const int ch) {
|
||||
return (ch < 0x80) && (isalnum(ch) || ch == '_');
|
||||
}
|
||||
|
||||
static void ColouriseMatlabOctaveDoc(
|
||||
unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler,
|
||||
bool (*IsCommentChar)(int)) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
|
||||
styler.StartAt(startPos);
|
||||
|
||||
bool transpose = false;
|
||||
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
for (; sc.More(); sc.Forward()) {
|
||||
|
||||
if (sc.state == SCE_MATLAB_OPERATOR) {
|
||||
if (sc.chPrev == '.') {
|
||||
if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') {
|
||||
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = false;
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = true;
|
||||
} else {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
}
|
||||
} else {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_KEYWORD) {
|
||||
if (!isalnum(sc.ch) && sc.ch != '_') {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (keywords.InList(s)) {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = false;
|
||||
} else {
|
||||
sc.ChangeState(SCE_MATLAB_IDENTIFIER);
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = true;
|
||||
}
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_NUMBER) {
|
||||
if (!isdigit(sc.ch) && sc.ch != '.'
|
||||
&& !(sc.ch == 'e' || sc.ch == 'E')
|
||||
&& !((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E'))) {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = true;
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_STRING) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_DOUBLEQUOTESTRING) {
|
||||
if (sc.ch == '\\') {
|
||||
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_MATLAB_COMMENT || sc.state == SCE_MATLAB_COMMAND) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||
transpose = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (sc.state == SCE_MATLAB_DEFAULT) {
|
||||
if (IsCommentChar(sc.ch)) {
|
||||
sc.SetState(SCE_MATLAB_COMMENT);
|
||||
} else if (sc.ch == '!' && sc.chNext != '=' ) {
|
||||
sc.SetState(SCE_MATLAB_COMMAND);
|
||||
} else if (sc.ch == '\'') {
|
||||
if (transpose) {
|
||||
sc.SetState(SCE_MATLAB_OPERATOR);
|
||||
} else {
|
||||
sc.SetState(SCE_MATLAB_STRING);
|
||||
}
|
||||
} else if (sc.ch == '"') {
|
||||
sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING);
|
||||
} else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) {
|
||||
sc.SetState(SCE_MATLAB_NUMBER);
|
||||
} else if (isalpha(sc.ch)) {
|
||||
sc.SetState(SCE_MATLAB_KEYWORD);
|
||||
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '\\') {
|
||||
if (sc.ch == ')' || sc.ch == ']') {
|
||||
transpose = true;
|
||||
} else {
|
||||
transpose = false;
|
||||
}
|
||||
sc.SetState(SCE_MATLAB_OPERATOR);
|
||||
} else {
|
||||
transpose = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar);
|
||||
}
|
||||
|
||||
static void ColouriseOctaveDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar);
|
||||
}
|
||||
|
||||
static void FoldMatlabOctaveDoc(unsigned int startPos, int length, int,
|
||||
WordList *[], Accessor &styler,
|
||||
bool (*IsComment)(Accessor&, int, int)) {
|
||||
|
||||
int endPos = startPos + length;
|
||||
|
||||
// Backtrack to previous line in case need to fix its fold status
|
||||
int lineCurrent = styler.GetLine(startPos);
|
||||
if (startPos > 0) {
|
||||
if (lineCurrent > 0) {
|
||||
lineCurrent--;
|
||||
startPos = styler.LineStart(lineCurrent);
|
||||
}
|
||||
}
|
||||
int spaceFlags = 0;
|
||||
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsComment);
|
||||
char chNext = styler[startPos];
|
||||
for (int i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
|
||||
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) {
|
||||
int lev = indentCurrent;
|
||||
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsComment);
|
||||
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||
// Only non whitespace lines can be headers
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
|
||||
// Line after is blank so check the next - maybe should continue further?
|
||||
int spaceFlags2 = 0;
|
||||
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsComment);
|
||||
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
|
||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
indentCurrent = indentNext;
|
||||
styler.SetLevel(lineCurrent, lev);
|
||||
lineCurrent++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FoldMatlabDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabComment);
|
||||
}
|
||||
|
||||
static void FoldOctaveDoc(unsigned int startPos, int length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveComment);
|
||||
}
|
||||
|
||||
static const char * const matlabWordListDesc[] = {
|
||||
"Keywords",
|
||||
0
|
||||
};
|
||||
|
||||
static const char * const octaveWordListDesc[] = {
|
||||
"Keywords",
|
||||
0
|
||||
};
|
||||
|
||||
LexerModule lmMatlab(SCLEX_MATLAB, ColouriseMatlabDoc, "matlab", FoldMatlabDoc, matlabWordListDesc);
|
||||
|
||||
LexerModule lmOctave(SCLEX_OCTAVE, ColouriseOctaveDoc, "octave", FoldOctaveDoc, octaveWordListDesc);
|
@ -19,6 +19,7 @@ LexHaskell.cxx \
|
||||
LexHTML.cxx \
|
||||
LexLua.cxx \
|
||||
LexOMS.cxx \
|
||||
LexMatlab.cxx \
|
||||
LexOthers.cxx \
|
||||
LexPascal.cxx \
|
||||
LexPerl.cxx \
|
||||
|
@ -61,7 +61,7 @@ MARSHALLER=scintilla-marshal.o
|
||||
#**LEXOBJS=\\\n\(\*.o \)
|
||||
LEXOBJS=\
|
||||
LexBash.o LexAsm.o LexCSS.o LexCPP.o LexCrontab.o LexHTML.o LexOthers.o LexPascal.o \
|
||||
LexPerl.o LexPython.o LexSQL.o LexCaml.o LexOMS.o LexTCL.o LexRuby.o LexFortran.o LexVHDL.o \
|
||||
LexPerl.o LexPython.o LexSQL.o LexCaml.o LexOMS.o LexTCL.o LexRuby.o LexFortran.o LexVHDL.o LexMatlab.o \
|
||||
LexD.o LexLua.o LexHaskell.o LexBasic.o LexR.o
|
||||
#--Autogenerated -- end of automatically generated section
|
||||
|
||||
|
@ -2763,6 +2763,10 @@ static gboolean is_string_style(gint lexer, gint style)
|
||||
case SCLEX_FREEBASIC:
|
||||
return (style == SCE_B_STRING);
|
||||
|
||||
case SCLEX_MATLAB:
|
||||
return (style == SCE_MATLAB_STRING ||
|
||||
style == SCE_MATLAB_DOUBLEQUOTESTRING);
|
||||
|
||||
case SCLEX_HTML:
|
||||
return (style == SCE_HPHP_SIMPLESTRING ||
|
||||
style == SCE_HPHP_HSTRING || /* HSTRING is a heredoc */
|
||||
@ -2846,6 +2850,9 @@ static gboolean is_comment_style(gint lexer, gint style)
|
||||
style == SCE_TCL_COMMENT_BOX ||
|
||||
style == SCE_TCL_BLOCK_COMMENT);
|
||||
|
||||
case SCLEX_MATLAB:
|
||||
return (style == SCE_MATLAB_COMMENT);
|
||||
|
||||
case SCLEX_LUA:
|
||||
return (style == SCE_LUA_COMMENT ||
|
||||
style == SCE_LUA_COMMENTLINE ||
|
||||
@ -4095,6 +4102,7 @@ void editor_set_indentation_guides(GeanyEditor *editor)
|
||||
case SCLEX_FREEBASIC:
|
||||
case SCLEX_D:
|
||||
case SCLEX_OMS:
|
||||
case SCLEX_MATLAB:
|
||||
mode = SC_IV_LOOKBOTH;
|
||||
break;
|
||||
|
||||
|
@ -495,6 +495,17 @@ static void init_builtin_filetypes(void)
|
||||
ft->comment_close = NULL;
|
||||
ft->group = GEANY_FILETYPE_GROUP_MISC;
|
||||
|
||||
#define MATLAB
|
||||
ft = filetypes[GEANY_FILETYPES_MATLAB];
|
||||
ft->lang = 32;
|
||||
ft->name = g_strdup("Matlab");
|
||||
ft->title = g_strdup_printf(_("%s source file"), "Matlab");
|
||||
ft->extension = g_strdup("m");
|
||||
ft->pattern = utils_strv_new("*.m", NULL);
|
||||
ft->comment_open = g_strdup("%");
|
||||
ft->comment_close = NULL;
|
||||
ft->group = GEANY_FILETYPE_GROUP_SCRIPT;
|
||||
|
||||
#define ALL
|
||||
ft = filetypes[GEANY_FILETYPES_NONE];
|
||||
ft->lang = -2;
|
||||
|
@ -57,6 +57,7 @@ typedef enum
|
||||
GEANY_FILETYPES_JS,
|
||||
GEANY_FILETYPES_LUA,
|
||||
GEANY_FILETYPES_MAKE,
|
||||
GEANY_FILETYPES_MATLAB,
|
||||
GEANY_FILETYPES_OMS,
|
||||
GEANY_FILETYPES_PERL,
|
||||
GEANY_FILETYPES_PHP,
|
||||
|
@ -2579,6 +2579,52 @@ static void styleset_tcl(ScintillaObject *sci)
|
||||
set_sci_style(sci, SCE_TCL_WORD5, GEANY_FILETYPES_TCL, 15);
|
||||
}
|
||||
|
||||
|
||||
static void styleset_matlab_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
|
||||
{
|
||||
new_style_array(GEANY_FILETYPES_MATLAB, 9);
|
||||
get_keyfile_hex(config, config_home, "styling", "default", "0x000000", "0xffffff", "false", &style_sets[GEANY_FILETYPES_MATLAB].styling[0]);
|
||||
get_keyfile_hex(config, config_home, "styling", "comment", "0x808080", "0xffffff", "false", &style_sets[GEANY_FILETYPES_MATLAB].styling[1]);
|
||||
get_keyfile_hex(config, config_home, "styling", "command", "0x111199", "0xffffff", "true", &style_sets[GEANY_FILETYPES_MATLAB].styling[2]);
|
||||
get_keyfile_hex(config, config_home, "styling", "number", "0x007f00", "0xffffff", "false", &style_sets[GEANY_FILETYPES_MATLAB].styling[3]);
|
||||
get_keyfile_hex(config, config_home, "styling", "keyword", "0x001a7f", "0xffffff", "true", &style_sets[GEANY_FILETYPES_MATLAB].styling[4]);
|
||||
get_keyfile_hex(config, config_home, "styling", "string", "0xff901e", "0xffffff", "false", &style_sets[GEANY_FILETYPES_MATLAB].styling[5]);
|
||||
get_keyfile_hex(config, config_home, "styling", "operator", "0x301010", "0xffffff", "false", &style_sets[GEANY_FILETYPES_MATLAB].styling[6]);
|
||||
get_keyfile_hex(config, config_home, "styling", "identifier", "0x000000", "0xffffff", "false", &style_sets[GEANY_FILETYPES_MATLAB].styling[7]);
|
||||
get_keyfile_hex(config, config_home, "styling", "doublequotedstring", "0xff901e", "0xffffff", "false", &style_sets[GEANY_FILETYPES_MATLAB].styling[8]);
|
||||
|
||||
style_sets[GEANY_FILETYPES_MATLAB].keywords = g_new(gchar*, 2);
|
||||
get_keyfile_keywords(config, config_home, "keywords", "primary", GEANY_FILETYPES_MATLAB, 0, "break case catch continue else elseif end for function global if otherwise persistent return switch try while");
|
||||
style_sets[GEANY_FILETYPES_MATLAB].keywords[1] = NULL;
|
||||
|
||||
get_keyfile_wordchars(config, config_home,
|
||||
&style_sets[GEANY_FILETYPES_MATLAB].wordchars);
|
||||
}
|
||||
|
||||
|
||||
static void styleset_matlab(ScintillaObject *sci)
|
||||
{
|
||||
const filetype_id ft_id = GEANY_FILETYPES_MATLAB;
|
||||
|
||||
styleset_common(sci);
|
||||
|
||||
apply_filetype_properties(sci, SCLEX_MATLAB, ft_id);
|
||||
|
||||
SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t) style_sets[GEANY_FILETYPES_MATLAB].keywords[0]);
|
||||
|
||||
set_sci_style(sci, STYLE_DEFAULT, GEANY_FILETYPES_MATLAB, 0);
|
||||
set_sci_style(sci, SCE_MATLAB_DEFAULT, GEANY_FILETYPES_MATLAB, 0);
|
||||
set_sci_style(sci, SCE_MATLAB_COMMENT, GEANY_FILETYPES_MATLAB, 1);
|
||||
set_sci_style(sci, SCE_MATLAB_COMMAND, GEANY_FILETYPES_MATLAB, 2);
|
||||
set_sci_style(sci, SCE_MATLAB_NUMBER, GEANY_FILETYPES_MATLAB, 3);
|
||||
set_sci_style(sci, SCE_MATLAB_KEYWORD, GEANY_FILETYPES_MATLAB, 4);
|
||||
set_sci_style(sci, SCE_MATLAB_STRING, GEANY_FILETYPES_MATLAB, 5);
|
||||
set_sci_style(sci, SCE_MATLAB_OPERATOR, GEANY_FILETYPES_MATLAB, 6);
|
||||
set_sci_style(sci, SCE_MATLAB_IDENTIFIER, GEANY_FILETYPES_MATLAB, 7);
|
||||
set_sci_style(sci, SCE_MATLAB_DOUBLEQUOTESTRING, GEANY_FILETYPES_MATLAB, 8);
|
||||
}
|
||||
|
||||
|
||||
static void styleset_d_init(gint ft_id, GKeyFile *config, GKeyFile *config_home)
|
||||
{
|
||||
new_style_array(GEANY_FILETYPES_D, 18);
|
||||
@ -3087,6 +3133,7 @@ void highlighting_init_styles(gint filetype_idx, GKeyFile *config, GKeyFile *con
|
||||
init_styleset_case(GEANY_FILETYPES_LATEX, latex);
|
||||
init_styleset_case(GEANY_FILETYPES_LUA, lua);
|
||||
init_styleset_case(GEANY_FILETYPES_MAKE, makefile);
|
||||
init_styleset_case(GEANY_FILETYPES_MATLAB, matlab);
|
||||
init_styleset_case(GEANY_FILETYPES_OMS, oms);
|
||||
init_styleset_case(GEANY_FILETYPES_PASCAL, pascal);
|
||||
init_styleset_case(GEANY_FILETYPES_PERL, perl);
|
||||
@ -3143,6 +3190,7 @@ void highlighting_set_styles(ScintillaObject *sci, gint filetype_idx)
|
||||
styleset_case(GEANY_FILETYPES_LATEX, latex);
|
||||
styleset_case(GEANY_FILETYPES_LUA, lua);
|
||||
styleset_case(GEANY_FILETYPES_MAKE, makefile);
|
||||
styleset_case(GEANY_FILETYPES_MATLAB, matlab);
|
||||
styleset_case(GEANY_FILETYPES_OMS, oms);
|
||||
styleset_case(GEANY_FILETYPES_PASCAL, pascal);
|
||||
styleset_case(GEANY_FILETYPES_PERL, perl);
|
||||
|
@ -41,13 +41,13 @@
|
||||
enum {
|
||||
/** The Application Programming Interface (API) version, incremented
|
||||
* whenever any plugin data types are modified or appended to. */
|
||||
GEANY_API_VERSION = 104,
|
||||
GEANY_API_VERSION = 105,
|
||||
|
||||
/** 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 = 47
|
||||
GEANY_ABI_VERSION = 48
|
||||
};
|
||||
|
||||
/** Check the plugin can be loaded by Geany.
|
||||
|
@ -623,6 +623,14 @@ static void init_tag_list(GeanyDocument *doc)
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
case GEANY_FILETYPES_MATLAB:
|
||||
{
|
||||
tag_list_add_groups(tag_store,
|
||||
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
||||
&(tv_iters.tag_struct), _("Structures"), "classviewer-struct",
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
case GEANY_FILETYPES_PERL:
|
||||
{
|
||||
tag_list_add_groups(tag_store,
|
||||
|
@ -548,6 +548,7 @@ static gchar *make_comment_block(const gchar *comment_text, gint filetype_idx, g
|
||||
}
|
||||
|
||||
case GEANY_FILETYPES_LATEX:
|
||||
case GEANY_FILETYPES_MATLAB:
|
||||
{
|
||||
line_prefix = "%";
|
||||
break;
|
||||
|
@ -49,6 +49,7 @@ libtagmanager_a_SOURCES =\
|
||||
asm.c\
|
||||
latex.c\
|
||||
lregex.c\
|
||||
matlab.c\
|
||||
pascal.c\
|
||||
perl.c\
|
||||
rest.c\
|
||||
|
@ -41,7 +41,7 @@ clean:
|
||||
|
||||
$(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 \
|
||||
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 docbook.o tcl.o ruby.o asm.o sql.o css.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 \
|
||||
tm_symbol.o tm_file_entry.o tm_tagmanager.o
|
||||
$(AR) rc $@ $^
|
||||
|
150
tagmanager/matlab.c
Normal file
150
tagmanager/matlab.c
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2000-2001, Darren Hiebert
|
||||
*
|
||||
* 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 Matlab scripts.
|
||||
* The tags 'function' and 'struct' are parsed.
|
||||
* Author Roland Baudin <roland65@free.fr>
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
*/
|
||||
#include "general.h" /* must always come first */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "parse.h"
|
||||
#include "read.h"
|
||||
#include "vstring.h"
|
||||
|
||||
/*
|
||||
* DATA DEFINITIONS
|
||||
*/
|
||||
typedef enum {
|
||||
K_FUNCTION,
|
||||
K_STRUCT
|
||||
} MatlabKind;
|
||||
|
||||
static kindOption MatlabKinds [] = {
|
||||
{ TRUE, 'f', "function", "Functions" },
|
||||
{ TRUE, 's', "struct", "Structures" },
|
||||
};
|
||||
|
||||
/*
|
||||
* FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
static void findMatlabTags (void)
|
||||
{
|
||||
vString *name = vStringNew ();
|
||||
const unsigned char *line;
|
||||
const unsigned char *p;
|
||||
|
||||
while ((line = fileReadLine ()) != NULL)
|
||||
{
|
||||
int i, ic;
|
||||
|
||||
if (line [0] == '\0' || line [0] == '%')
|
||||
continue;
|
||||
|
||||
/* search if the line has a comment */
|
||||
for (ic = 0 ; line [ic] != '\0' && line [ic]!='%' ; ++ic)
|
||||
;
|
||||
|
||||
/* function tag */
|
||||
|
||||
/* read first word */
|
||||
for (i = 0 ; line [i] != '\0' && ! isspace (line [i]) ; ++i)
|
||||
;
|
||||
|
||||
if (strncmp ((const char *) line, "function", (size_t) 8) == 0)
|
||||
{
|
||||
const unsigned char *cp = line + i;
|
||||
const unsigned char *ptr = cp;
|
||||
boolean eq=FALSE;
|
||||
|
||||
while (isspace ((int) *cp))
|
||||
++cp;
|
||||
|
||||
/* search for '=' character in the line */
|
||||
while (*ptr != '\0')
|
||||
{
|
||||
if (*ptr == '=')
|
||||
{
|
||||
eq=TRUE;
|
||||
break;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* '=' was found => get the right most part of the line after '=' and before '%' */
|
||||
if (eq)
|
||||
{
|
||||
ptr++;
|
||||
while (isspace ((int) *ptr))
|
||||
++ptr;
|
||||
|
||||
while (*ptr != '\0' && *ptr != '%')
|
||||
{
|
||||
vStringPut (name, (int) *ptr);
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* '=' was not found => get the right most part of the line after
|
||||
* 'function' and before '%' */
|
||||
else
|
||||
{
|
||||
while (*cp != '\0' && *cp != '%')
|
||||
{
|
||||
vStringPut (name, (int) *cp);
|
||||
++cp;
|
||||
}
|
||||
}
|
||||
|
||||
vStringTerminate (name);
|
||||
makeSimpleTag (name, MatlabKinds, K_FUNCTION);
|
||||
vStringClear (name);
|
||||
}
|
||||
|
||||
/* struct tag */
|
||||
|
||||
/* search if the line contains the keyword 'struct' */
|
||||
p=(const unsigned char*) strstr ((const char*) line, "struct");
|
||||
|
||||
/* and avoid the part after the '%' if any */
|
||||
if ( p != NULL && ic>0 && p < line+ic)
|
||||
{
|
||||
const unsigned char *cp = line;
|
||||
|
||||
/* get the left most part of the line before '=' */
|
||||
while (*cp != '\0' && !isspace(*cp) && *cp != '=' )
|
||||
{
|
||||
vStringPut (name, (int) *cp);
|
||||
++cp;
|
||||
}
|
||||
|
||||
vStringTerminate (name);
|
||||
makeSimpleTag (name, MatlabKinds, K_STRUCT);
|
||||
vStringClear (name);
|
||||
}
|
||||
}
|
||||
vStringDelete (name);
|
||||
}
|
||||
|
||||
extern parserDefinition* MatlabParser (void)
|
||||
{
|
||||
static const char *const extensions [] = { "m", NULL };
|
||||
parserDefinition* def = parserNew ("Matlab");
|
||||
def->kinds = MatlabKinds;
|
||||
def->kindCount = KIND_COUNT (MatlabKinds);
|
||||
def->extensions = extensions;
|
||||
def->parser = findMatlabTags;
|
||||
return def;
|
||||
}
|
||||
|
||||
/* vi:set tabstop=8 shiftwidth=4: */
|
@ -46,7 +46,8 @@
|
||||
RestParser, \
|
||||
HtmlParser, \
|
||||
F77Parser, \
|
||||
GLSLParser
|
||||
GLSLParser, \
|
||||
MatlabParser
|
||||
|
||||
/*
|
||||
langType of each parser
|
||||
@ -82,6 +83,7 @@ langType of each parser
|
||||
29 HtmlParser
|
||||
30 F77Parser
|
||||
31 GLSLParser
|
||||
32 MatlabParser
|
||||
*/
|
||||
#endif /* _PARSERS_H */
|
||||
|
||||
|
5
wscript
5
wscript
@ -56,7 +56,8 @@ tagmanager_sources = [
|
||||
'tagmanager/docbook.c', 'tagmanager/entry.c', 'tagmanager/fortran.c', 'tagmanager/get.c',
|
||||
'tagmanager/haskell.c', 'tagmanager/haxe.c', 'tagmanager/html.c', 'tagmanager/js.c',
|
||||
'tagmanager/keyword.c', 'tagmanager/latex.c', 'tagmanager/lregex.c', 'tagmanager/lua.c',
|
||||
'tagmanager/make.c', 'tagmanager/options.c', 'tagmanager/parse.c', 'tagmanager/pascal.c',
|
||||
'tagmanager/make.c', 'tagmanager/matlab.c', 'tagmanager/options.c', 'tagmanager/parse.c',
|
||||
'tagmanager/pascal.c',
|
||||
'tagmanager/perl.c', 'tagmanager/php.c', 'tagmanager/python.c', 'tagmanager/read.c',
|
||||
'tagmanager/rest.c', 'tagmanager/ruby.c', 'tagmanager/sh.c', 'tagmanager/sort.c',
|
||||
'tagmanager/sql.c', 'tagmanager/strlist.c', 'tagmanager/tcl.c', 'tagmanager/tm_file_entry.c',
|
||||
@ -75,7 +76,7 @@ scintilla_sources = [
|
||||
'scintilla/LexFortran.cxx', 'scintilla/LexHaskell.cxx', 'scintilla/LexHTML.cxx',
|
||||
'scintilla/LexLua.cxx', 'scintilla/LexOMS.cxx', 'scintilla/LexOthers.cxx',
|
||||
'scintilla/LexPascal.cxx', 'scintilla/LexPerl.cxx', 'scintilla/LexPython.cxx',
|
||||
'scintilla/LexR.cxx',
|
||||
'scintilla/LexR.cxx', 'scintilla/LexMatlab.cxx',
|
||||
'scintilla/LexRuby.cxx', 'scintilla/LexSQL.cxx', 'scintilla/LexTCL.cxx',
|
||||
'scintilla/LexVHDL.cxx', 'scintilla/LineMarker.cxx', 'scintilla/PlatGTK.cxx',
|
||||
'scintilla/PositionCache.cxx', 'scintilla/PropSet.cxx', 'scintilla/RESearch.cxx',
|
||||
|
Loading…
x
Reference in New Issue
Block a user