@@ -54,8 +54,7 @@ Boolean drawTree( TOutlineViewer *beingDrawn, TNode* cur, int level,
5454{
5555 TDrawBuffer &dBuf = *pdBuf;
5656 ushort color;
57- char s[256 ];
58- char * graph;
57+ int x;
5958
6059 if (position >= beingDrawn->delta .y )
6160 {
@@ -69,23 +68,18 @@ Boolean drawTree( TOutlineViewer *beingDrawn, TNode* cur, int level,
6968 else
7069 color = beingDrawn->getColor (0x0401 );
7170 dBuf.moveChar (0 , ' ' , color, beingDrawn->size .x );
72-
73- graph = beingDrawn->getGraph (level, lines, flags);
74- strcpy (s, graph);
75- delete graph;
76-
77- if ( (flags & ovExpanded) == 0 )
7871 {
79- strcat (s, " ~" );
80- strcat (s, beingDrawn->getText (cur));
81- strcat (s, " ~" );
72+ TStringView graph = beingDrawn->getGraph (level, lines, flags);
73+ x = strwidth (graph) - beingDrawn->delta .x ;
74+ if (x > 0 )
75+ dBuf.moveStr (0 , graph, color, (ushort) -1U , beingDrawn->delta .x );
76+ delete graph.data ();
77+ }
78+ {
79+ TStringView text = beingDrawn->getText (cur);
80+ uchar c = (flags & ovExpanded) ? color : (color >> 8 );
81+ dBuf.moveStr (max (0 , x), text, c, (ushort) -1U , max (0 , -x));
8282 }
83- else
84- strcat (s, beingDrawn->getText (cur));
85- if (beingDrawn->delta .x <=strlen (s))
86- dBuf.moveCStr (0 , &s[beingDrawn->delta .x ], color);
87- else
88- dBuf.moveCStr (0 , " " , color );
8983 beingDrawn->writeLine (0 , position-beingDrawn->delta .y ,
9084 beingDrawn->size .x , 1 , dBuf);
9185 auxPos = position;
@@ -461,13 +455,13 @@ void TOutlineViewer::handleEvent(TEvent& event)
461455 if (dragged < 2 && (cur = firstThat (isFocused)))
462456 {
463457 graph = getGraph (focLevel,focLines,focFlags);
464- if (mouse.x < strlen (graph) )
458+ if (mouse.x < strwidth (graph) )
465459 {
466- adjust (cur, ! isExpanded (cur) ? True:False );
460+ adjust (cur, !isExpanded (cur));
467461 update ();
468462 drawView ();
469463 }
470- delete graph;
464+ delete[] graph;
471465 }
472466 }
473467
@@ -560,7 +554,7 @@ static Boolean countNode(TOutlineViewer* beingCounted, TNode* p, int level,
560554
561555 updateCount++;
562556 graph = beingCounted->getGraph (level, lines, flags);
563- len = strlen (beingCounted->getText (p)) + strlen (graph);
557+ len = strwidth (beingCounted->getText (p)) + strwidth (graph);
564558 if (updateMaxX < len)
565559 updateMaxX = len;
566560 delete graph;
0 commit comments