aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2007-07-15 04:59:13 +0000
committernyamatongwe <devnull@localhost>2007-07-15 04:59:13 +0000
commitd53089b9a6b62776dabf882b58246dc527941f04 (patch)
treefac58b77a52628b9a706964658e5fa2d50ae7caf /src
parent272cb46f99debcd764f3a8806d5cf5c64d0b4144 (diff)
downloadscintilla-mirror-d53089b9a6b62776dabf882b58246dc527941f04.tar.gz
Updated metapost folder uses keyword lists for fold strats and ends.
Diffstat (limited to 'src')
-rw-r--r--src/LexMetapost.cxx54
1 files changed, 15 insertions, 39 deletions
diff --git a/src/LexMetapost.cxx b/src/LexMetapost.cxx
index 552d68cb4..6afc9d826 100644
--- a/src/LexMetapost.cxx
+++ b/src/LexMetapost.cxx
@@ -3,8 +3,8 @@
// File: LexMetapost.cxx - general context conformant metapost coloring scheme
// Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com
// Version: September 28, 2003
-// Modified by instanton: June 22, 2007
-// Added folding code
+// Modified by instanton: July 10, 2007
+// Folding based on keywordlists[]
// Copyright: 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
@@ -323,21 +323,14 @@ static const char * const metapostWordListDesc[] = {
0
} ;
-static int classifyFoldPointMetapost(const char* s) {
- int lev=0;
- if (!(isdigit(s[0]) || (s[0] == '.'))){
- if (strcmp(s, "beginfig")==0||strcmp(s,"for")==0||strcmp(s,"verbatimtex")==0||
- strcmp(s,"def")==0||strcmp(s,"vardef")==0||strcmp(s,"begingroup")==0||
- strcmp(s,"btex")==0||strcmp(s,"if")==0
- )
- lev=1;
- if (strcmp(s,"endfig")==0||strcmp(s,"enddef")==0||strcmp(s,"endfor")==0||
- strcmp(s,"endgroup")==0||strcmp(s,"etex")==0||
- strcmp(s,"fi")==0||strcmp(s,"endif")==0
- )
- lev=-1;
- }
- return lev;
+static int classifyFoldPointMetapost(const char* s,WordList *keywordlists[]) {
+ WordList& keywordsStart=*keywordlists[3];
+ WordList& keywordsStop1=*keywordlists[4];
+
+ if (keywordsStart.InList(s)) {return 1;}
+ else if (keywordsStop1.InList(s)) {return -1;}
+ return 0;
+
}
static int ParseMetapostWord(unsigned int pos, Accessor &styler, char *word)
@@ -355,7 +348,7 @@ static int ParseMetapostWord(unsigned int pos, Accessor &styler, char *word)
return length;
}
-static void FoldMetapostDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
+static void FoldMetapostDoc(unsigned int startPos, int length, int, WordList *keywordlists[], Accessor &styler)
{
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
unsigned int endPos = startPos+length;
@@ -370,31 +363,14 @@ static void FoldMetapostDoc(unsigned int startPos, int length, int, WordList *[]
for (unsigned int i=startPos; i < endPos; i++) {
char ch=chNext;
chNext=styler.SafeGetCharAt(i+1);
+ char chPrev=styler.SafeGetCharAt(i-1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+ if(i==0 || chPrev == '\r' || chPrev=='\n'|| chPrev==' '|| chPrev=='(' || chPrev=='$')
+ {
ParseMetapostWord(i, styler, buffer);
- levelCurrent += classifyFoldPointMetapost(buffer);
-
- char chNext2;
- char chNext3;
- char chNext4;
- char chNext5;
- chNext2=styler.SafeGetCharAt(i+2);
- chNext3=styler.SafeGetCharAt(i+3);
- chNext4=styler.SafeGetCharAt(i+4);
- chNext5=styler.SafeGetCharAt(i+5);
-
- bool atenddef =(ch == 'e') && (chNext=='n') &&
- (chNext2=='d')&& (chNext3=='d')&& (chNext4=='e')&& (chNext5=='f');
-
- bool atendfor = (ch == 'e') && (chNext=='n') &&
- (chNext2=='d') && (chNext3=='f') && (chNext4=='o')&& (chNext5=='r');
-
- if(atenddef||atendfor
- ){
- levelCurrent-=1;
+ levelCurrent += classifyFoldPointMetapost(buffer,keywordlists);
}
-
if (atEOL) {
int lev = levelPrev;