<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Colorer-take5 Library: Code Samples</title> <link href="../styles/styles.css" rel="stylesheet" type="text/css"> <link href="../styles/doc.css" rel="stylesheet" type="text/css"> <link rel="icon" href="../images/logo-small-api.png"/> </head> <body> <div align='center'> <a href="../index.html">Home</a> | <a href="modules.html">Modules</a> | <a href="hierarchy.html">Class Hierarchy</a> | <a href="classes.html">Alphabetical List</a> | <a href="annotated.html">Compound List</a> | <a href="pages.html">Related Pages</a> </div> <!-- Generated by Doxygen 1.4.6 --> <h1><a class="anchor" name="samples">Code Samples</a></h1><h2><a class="anchor" name="basic"> Basic library usage</a></h2> <dl compact><dt><b>To parse text you must create:</b></dt><dd><ul> <li>Class, acting as source of text lines (implements <a class="el" href="classLineSource.html">LineSource</a> interface).</li><li><a class="el" href="classParserFactory.html">ParserFactory</a> instance, which stores all global parse data and structures.</li><li><a class="el" href="classBaseEditor.html">BaseEditor</a> class for each editor (or your colorized object).</li></ul> </dd></dl> <div class="fragment"><pre class="fragment"> <span class="comment">// Source file text lines store.</span> <a class="code" href="classTextLinesStore.html">TextLinesStore</a> textLinesStore; textLinesStore.<a class="code" href="classTextLinesStore.html#2a6ec3b78f5ec0e1a9ea3e044741a301">loadFile</a>(inputFileName, inputEncoding, <span class="keyword">true</span>); <span class="comment">// parsers factory</span> <a class="code" href="classParserFactory.html">ParserFactory</a> pf(catalogPath); <span class="comment">// Base editor to make primary parse</span> <a class="code" href="classBaseEditor.html">BaseEditor</a> baseEditor(&pf, &textLinesStore); baseEditor.setRegionMapper(&<a class="code" href="classDString.html">DString</a>(<span class="stringliteral">"rgb"</span>), &<a class="code" href="classDString.html">DString</a>(<span class="stringliteral">"default"</span>)); baseEditor.setFileType(<a class="code" href="classDString.html">DString</a>(<span class="stringliteral">"cpp"</span>)); <span class="comment">// Initial line count notify</span> baseEditor.lineCountEvent(textLinesStore.<a class="code" href="classTextLinesStore.html#4e4464b5b1783e37e8cdaad581526fed">getLineCount</a>()); <span class="comment">// Iterate over text lines</span> <span class="keywordflow">for</span>(<span class="keywordtype">int</span> idx = 0; idx < textLinesStore.<a class="code" href="classTextLinesStore.html#4e4464b5b1783e37e8cdaad581526fed">getLineCount</a>(); idx++){ LineRegions *lr = baseEditor.getLineRegions(idx); <span class="comment">// Iterate over line regions</span> <span class="keywordflow">for</span>(LineRegions *next = lr; next != null; lr = lr->next){ <span class="comment">// work with this region:</span> <span class="comment">// next->start</span> <span class="comment">// next->end</span> <span class="comment">// next->region</span> <a class="code" href="classStyledRegion.html">StyledRegion</a> *sr = next->styled(); <span class="comment">// colors:</span> <span class="comment">// sr->fore, sr->back</span> }; }; </pre></div> <br><br> <center><small> Colorer-take5 Library. Copyright © 1999-2006 Igor Russkih.<br> Generated at Fri Nov 24 17:13:14 2006 by doxygen 1.4.6. </small><center> </BODY> </HTML>