2 #include "../Basics/utils.hpp"
3 #include "../Instancing/Instance.hpp"
11 current( &this->root )
18 Node * node =
new Node( this->current, node_name, box_style );
19 this->current->children.push_back( node );
25 if( !this->current->parent )
32 this->current = this->current->parent;
41 this->draw_node_children( style, target, &this->root );
50 this->current = &this->root;
51 this->root.children.clear();
56 if( this->current == &this->root )
64 this->current->separators.insert( this->current->lines.size() - 1 );
69 if( this->current == &this->root )
75 this->current->lines.push_back( std::string( prefix ) + std::string( line ) + std::string( postfix ) );
78 void TreeDebugView::draw_node_children( Style style,
TextDebugView * target, Node * node )
80 std::vector< const char * > c;
144 const int link_line = 0;
145 const int link_nonlast = 1;
146 const int link_last = 2;
148 const int hor_lhalf = 4;
149 const int hor_rhalf = 5;
150 const int hor_linkout = 6;
152 const int vert_linkin = 8;
159 for(
size_t ci = 0; ci < node->children.size(); ci++ )
162 Node * ch = node->children[ ci ];
163 bool last = ci == node->children.size() - 1;
189 size_t inner_width = 0;
190 for( std::string
const & l : ch->lines )
191 inner_width = std::max( inner_width,
utf8_size( l ) );
192 inner_width = std::max( inner_width,
utf8_size( ch->name ) + 6 );
195 if( node != &this->root )
196 target->
out() <<
" "<<c[ link_line ];
197 if( ch->name.size() )
198 target->
out() <<c[ corner_tl ]<<c[ hor ]<<c[ hor ]<<c[ hor_lhalf ]<< ch->name <<c[ hor_rhalf ]<<c[ hor ]<<c[ hor ];
200 target->
out() <<c[ corner_tl ]<<c[ hor ]<<c[ hor ]<<c[ hor ]<<c[ hor ]<<c[ hor ]<<c[ hor ];
201 for(
size_t i =
utf8_size( ch->name ) + 6; i < inner_width ; i++ )
202 target->
out() << c[ hor ];
203 target->
out() << c[ corner_tr ] << std::endl;
206 if( node != &this->root )
209 target->
out() <<
" "<<c[ link_last ]<<c[ vert_linkin ];
211 target->
out() <<
" "<<c[ link_nonlast ]<<c[ vert_linkin ];
215 target->
out() << c[ vert ];
218 if( ch->lines.size() )
220 target->
out() << ch->lines[ 0 ];
221 for(
size_t i =
utf8_size( ch->lines[ 0 ] ); i < inner_width; i++ )
222 target->
out() <<
" ";
223 target->
out() << c[ vert ] << std::endl;
227 for(
size_t i = 0; i < inner_width; i++ )
228 target->
out() <<
" ";
229 target->
out() << c[ vert ] << std::endl;
233 if( node != &this->root )
238 target->
prefix_push( ( std::string(
" " ) + c[ link_line ] ).c_str() );
242 if( ch->separators.count( 0 ) )
244 target->
out() << c[ vert ];
245 for(
size_t j = 0; j < inner_width; j++ )
246 target->
out() << c[ hor ];
247 target->
out() << c[ vert ] << std::endl;
253 for(
size_t i = 1; i < ch->lines.size(); i++ )
255 target->
out() << c[ vert ] << ch->lines[ i ];
256 for(
size_t j =
utf8_size( ch->lines[ i ] ); j < inner_width; j++ )
257 target->
out() <<
" ";
258 target->
out() << c[ vert ] << std::endl;
261 if( ch->separators.count( i ) && i < ch->lines.size() - 1 )
263 target->
out() << c[ vert ];
264 for(
size_t j = 0; j < inner_width; j++ )
265 target->
out() << c[ hor ];
266 target->
out() << c[ vert ] << std::endl;
271 if( ch->children.size() )
272 target->
out() <<c[ corner_bl ]<<c[ hor_linkout ];
274 target->
out() <<c[ corner_bl ]<<c[ hor ];
275 for(
size_t i = 1; i < inner_width; i++ )
276 target->
out() << c[ hor ];
277 target->
out() << c[ corner_br ] << std::endl;
280 this->draw_node_children( style, target, ch );
284 if( node != &this->root )