@@ -54,8 +54,7 @@ Boolean drawTree( TOutlineViewer *beingDrawn, TNode* cur, int level,
54
54
{
55
55
TDrawBuffer &dBuf = *pdBuf;
56
56
ushort color;
57
- char s[256 ];
58
- char * graph;
57
+ int x;
59
58
60
59
if (position >= beingDrawn->delta .y )
61
60
{
@@ -69,23 +68,18 @@ Boolean drawTree( TOutlineViewer *beingDrawn, TNode* cur, int level,
69
68
else
70
69
color = beingDrawn->getColor (0x0401 );
71
70
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 )
78
71
{
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));
82
82
}
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 );
89
83
beingDrawn->writeLine (0 , position-beingDrawn->delta .y ,
90
84
beingDrawn->size .x , 1 , dBuf);
91
85
auxPos = position;
@@ -461,13 +455,13 @@ void TOutlineViewer::handleEvent(TEvent& event)
461
455
if (dragged < 2 && (cur = firstThat (isFocused)))
462
456
{
463
457
graph = getGraph (focLevel,focLines,focFlags);
464
- if (mouse.x < strlen (graph) )
458
+ if (mouse.x < strwidth (graph) )
465
459
{
466
- adjust (cur, ! isExpanded (cur) ? True:False );
460
+ adjust (cur, !isExpanded (cur));
467
461
update ();
468
462
drawView ();
469
463
}
470
- delete graph;
464
+ delete[] graph;
471
465
}
472
466
}
473
467
@@ -560,7 +554,7 @@ static Boolean countNode(TOutlineViewer* beingCounted, TNode* p, int level,
560
554
561
555
updateCount++;
562
556
graph = beingCounted->getGraph (level, lines, flags);
563
- len = strlen (beingCounted->getText (p)) + strlen (graph);
557
+ len = strwidth (beingCounted->getText (p)) + strwidth (graph);
564
558
if (updateMaxX < len)
565
559
updateMaxX = len;
566
560
delete graph;
0 commit comments