Home | Modules | Class Hierarchy | Alphabetical List | Compound List | Related Pages

# Code Samples

## Basic library usage

To parse text you must create:
  - Class, acting as source of text lines (implements LineSource interface).
  - ParserFactory instance, which stores all global parse data and structures.
  - BaseEditor class for each editor (or your colorized object).

        // Source file text lines store.
        TextLinesStore textLinesStore;
        textLinesStore.loadFile(inputFileName, inputEncoding, true);
        // parsers factory
        ParserFactory pf(catalogPath);
        // Base editor to make primary parse
        BaseEditor baseEditor(&pf, &textLinesStore);
        baseEditor.setRegionMapper(&DString("rgb"), &DString("default"));
        baseEditor.setFileType(DString("cpp"));
        // Initial line count notify
        baseEditor.lineCountEvent(textLinesStore.getLineCount());
        // Iterate over text lines
        for(int idx = 0; idx < textLinesStore.getLineCount(); idx++){
          LineRegions *lr = baseEditor.getLineRegions(idx);
          // Iterate over line regions
          for(LineRegions *next = lr; next != null; lr = lr->next){
            // work with this region:
            //   next->start
            //   next->end
            //   next->region
            StyledRegion *sr = next->styled();
            // colors:
            //   sr->fore, sr->back
          };
        };

Colorer-take5 Library. Copyright © 1999-2006 Igor Russkih.
Generated at Fri Nov 24 17:13:14 2006 by doxygen 1.4.6.