示例#1
0
void
LineRenderer::refresh_tokens( TextLine & line ) { 
	
	if ( AudicleWindow::main()->m_syntax_query->parseLine ( line.str(), tokenized ) ) { 
	//if ( fakeTokenizer( line.str() , tokenized ) ) { 
		line.tokens() = tokenized;
	}
	
	line.dirty() = false;
}
示例#2
0
void
LineRenderer::draw_tokens( TextLine &line ) { 

	char lc = 0;
	int last = 0;
	std::vector<SyntaxToken>::size_type i;
	SyntaxToken tk;

	if ( line.dirty() ) refresh_tokens( line );
	SyntaxTokenList tklist = line.tokens();
	if ( tklist.howmany == 0 ) { draw(line); return; } 

	for ( i = 0 ; i < tklist.howmany ; i++ ) {
		tk = tklist.list[i];
		if ( last != tk.begin ) 
			lc = font->draw_sub( line.substr(last, tk.begin - last ), lc );
		glColor4dv( token_colors[ tk.type ].data() );
		lc = font->draw_sub( tk.token, lc );
		last = tk.end;
	}

}