~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/sdk/wxscintilla/src/scintilla/src/LexMetapost.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
// File: LexMetapost.cxx - general context conformant metapost coloring scheme
4
4
// Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com
5
5
// Version: September 28, 2003
 
6
// Modified by instanton: July 10, 2007
 
7
// Folding based on keywordlists[]
6
8
 
7
9
// Copyright: 1998-2003 by Neil Hodgson <neilh@scintilla.org>
8
10
// The License.txt file describes the conditions under which this software may be distributed.
25
27
#include "SciLexer.h"
26
28
#include "StyleContext.h"
27
29
 
 
30
#ifdef SCI_NAMESPACE
 
31
using namespace Scintilla;
 
32
#endif
 
33
 
28
34
// val SCE_METAPOST_DEFAULT = 0
29
35
// val SCE_METAPOST_SPECIAL = 1
30
36
// val SCE_METAPOST_GROUP = 2
317
323
        0
318
324
} ;
319
325
 
320
 
LexerModule lmMETAPOST(SCLEX_METAPOST, ColouriseMETAPOSTDoc, "metapost", 0, metapostWordListDesc);
 
326
static int classifyFoldPointMetapost(const char* s,WordList *keywordlists[]) {
 
327
        WordList& keywordsStart=*keywordlists[3];
 
328
        WordList& keywordsStop1=*keywordlists[4];
 
329
        
 
330
        if (keywordsStart.InList(s)) {return 1;}
 
331
        else if (keywordsStop1.InList(s)) {return -1;}
 
332
        return 0;
 
333
        
 
334
}
 
335
 
 
336
static int ParseMetapostWord(unsigned int pos, Accessor &styler, char *word)
 
337
{
 
338
  int length=0;
 
339
  char ch=styler.SafeGetCharAt(pos);
 
340
  *word=0;
 
341
 
 
342
  while(isMETAPOSTidentifier(ch) && isalpha(ch) && length<100){
 
343
          word[length]=ch;
 
344
          length++;
 
345
          ch=styler.SafeGetCharAt(pos+length);
 
346
  }
 
347
  word[length]=0;   
 
348
  return length;
 
349
}
 
350
 
 
351
static void FoldMetapostDoc(unsigned int startPos, int length, int, WordList *keywordlists[], Accessor &styler) 
 
352
{
 
353
        bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
 
354
        unsigned int endPos = startPos+length;
 
355
        int visibleChars=0;
 
356
        int lineCurrent=styler.GetLine(startPos);
 
357
        int levelPrev=styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
 
358
        int levelCurrent=levelPrev;
 
359
        char chNext=styler[startPos];
 
360
        
 
361
        char buffer[100]="";
 
362
        
 
363
        for (unsigned int i=startPos; i < endPos; i++) {
 
364
                char ch=chNext;
 
365
                chNext=styler.SafeGetCharAt(i+1);
 
366
                char chPrev=styler.SafeGetCharAt(i-1);
 
367
                bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
 
368
 
 
369
                if(i==0 || chPrev == '\r' || chPrev=='\n'|| chPrev==' '|| chPrev=='(' || chPrev=='$')
 
370
                {
 
371
            ParseMetapostWord(i, styler, buffer);
 
372
                        levelCurrent += classifyFoldPointMetapost(buffer,keywordlists);
 
373
                }
 
374
                
 
375
                if (atEOL) {
 
376
                        int lev = levelPrev;
 
377
                        if (visibleChars == 0 && foldCompact)
 
378
                                lev |= SC_FOLDLEVELWHITEFLAG;
 
379
                        if ((levelCurrent > levelPrev) && (visibleChars > 0))
 
380
                                lev |= SC_FOLDLEVELHEADERFLAG;
 
381
                        if (lev != styler.LevelAt(lineCurrent)) {
 
382
                                styler.SetLevel(lineCurrent, lev);
 
383
                        }
 
384
                        lineCurrent++;
 
385
                        levelPrev = levelCurrent;
 
386
                        visibleChars = 0;
 
387
                }
 
388
 
 
389
                if (!isspacechar(ch))
 
390
                        visibleChars++;
 
391
        }
 
392
        // Fill in the real level of the next line, keeping the current flags as they will be filled in later
 
393
        int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
 
394
        styler.SetLevel(lineCurrent, levelPrev | flagsNext);
 
395
 
 
396
}
 
397
 
 
398
 
 
399
LexerModule lmMETAPOST(SCLEX_METAPOST, ColouriseMETAPOSTDoc, "metapost", FoldMetapostDoc, metapostWordListDesc);