Wx-Scintilla
view release on metacpan or search on metacpan
wx-scintilla/src/scintilla/src/LexTeX.cxx view on Meta::CPAN
return ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z'));
}
static int ParseTeXCommand(unsigned int pos, Accessor &styler, char *command)
{
int length=0;
char ch=styler.SafeGetCharAt(pos+1);
if(ch==',' || ch==':' || ch==';' || ch=='%'){
command[0]=ch;
command[1]=0;
return 1;
}
// find end
while(isWordChar(ch) && !isNumber(ch) && ch!='_' && ch!='.' && length<100){
command[length]=ch;
length++;
ch=styler.SafeGetCharAt(pos+length+1);
}
command[length]='\0';
if(!length) return 0;
return length+1;
}
static int classifyFoldPointTeXPaired(const char* s) {
int lev=0;
if (!(isdigit(s[0]) || (s[0] == '.'))){
if (strcmp(s, "begin")==0||strcmp(s,"FoldStart")==0||
strcmp(s,"abstract")==0||strcmp(s,"unprotect")==0||
strcmp(s,"title")==0||strncmp(s,"start",5)==0||strncmp(s,"Start",5)==0||
strcmp(s,"documentclass")==0||strncmp(s,"if",2)==0
)
lev=1;
if (strcmp(s, "end")==0||strcmp(s,"FoldStop")==0||
strcmp(s,"maketitle")==0||strcmp(s,"protect")==0||
strncmp(s,"stop",4)==0||strncmp(s,"Stop",4)==0||
strcmp(s,"fi")==0
)
lev=-1;
}
return lev;
}
static int classifyFoldPointTeXUnpaired(const char* s) {
int lev=0;
if (!(isdigit(s[0]) || (s[0] == '.'))){
if (strcmp(s,"part")==0||
strcmp(s,"chapter")==0||
strcmp(s,"section")==0||
strcmp(s,"subsection")==0||
strcmp(s,"subsubsection")==0||
strcmp(s,"CJKfamily")==0||
strcmp(s,"appendix")==0||
strcmp(s,"Topic")==0||strcmp(s,"topic")==0||
strcmp(s,"subject")==0||strcmp(s,"subsubject")==0||
strcmp(s,"def")==0||strcmp(s,"gdef")==0||strcmp(s,"edef")==0||
strcmp(s,"xdef")==0||strcmp(s,"framed")==0||
strcmp(s,"frame")==0||
strcmp(s,"foilhead")==0||strcmp(s,"overlays")==0||strcmp(s,"slide")==0
){
lev=1;
}
}
return lev;
}
static bool IsTeXCommentLine(int line, Accessor &styler) {
int pos = styler.LineStart(line);
int eol_pos = styler.LineStart(line + 1) - 1;
int startpos = pos;
while (startpos<eol_pos){
char ch = styler[startpos];
if (ch!='%' && ch!=' ') return false;
else if (ch=='%') return true;
startpos++;
}
return false;
}
// FoldTeXDoc: borrowed from VisualTeX with modifications
static void FoldTexDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
{
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
unsigned int endPos = startPos+length;
int visibleChars=0;
int lineCurrent=styler.GetLine(startPos);
int levelPrev=styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent=levelPrev;
char chNext=styler[startPos];
char buffer[100]="";
for (unsigned int i=startPos; i < endPos; i++) {
char ch=chNext;
chNext=styler.SafeGetCharAt(i+1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if(ch=='\\') {
ParseTeXCommand(i, styler, buffer);
levelCurrent += classifyFoldPointTeXPaired(buffer)+classifyFoldPointTeXUnpaired(buffer);
}
if (levelCurrent > SC_FOLDLEVELBASE && ((ch == '\r' || ch=='\n') && (chNext == '\\'))) {
ParseTeXCommand(i+1, styler, buffer);
levelCurrent -= classifyFoldPointTeXUnpaired(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);
( run in 0.860 second using v1.01-cache-2.11-cpan-c221a9de4ec )