CTTL on
SourceForge |
Download
Latest |
Documentation
Index |
Library
News |
CVS
Repository |
Other
Links |
Simple program that uses CTTL node objects to navigate the lines inside user input text.
// sample code: line_navigate.cpp #include <iostream> #include "cttl/cttl.h" int main() { using cttl::input; using cttl::node; using cttl::edge; // one\r\ntwo // 0123 4 567890 // B E B E // 1 1 2 2 input<> inp( "one\r\ntwo" ); node<> B1( new_node( inp ) ); node<> B2( new_node( inp ) ); node<> E1( new_node( inp ) ); node<> E2( new_node( inp ) ); B1.go_line_home( 1 ); B2.go_line_home( 2 ); E1.go_line_end( 1 ); E2.go_line_end( 2 ); // show results: std::cout << "line 1 [" << B1.offset() << '-' << E1.offset() << ") /" << ( B1 + E1 ).text() << '/' << std::endl; std::cout << "line 2 [" << B2.offset() << '-' << E2.offset() << ") /" << ( B2 + E2 ).text() << '/' << std::endl; /* program output: line 1 [0-3) /one/ line 2 [5-8) /two/ */ return 0; }
line 1 [0-3) /one/ line 2 [5-8) /two/
Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.