aboutsummaryrefslogtreecommitdiff
path: root/src/viewerpercent.cpp
blob: 0b0344b4dc6c0b9a192bb76752cf4669901d0df8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "viewerpercent.h"
#include "perform.h"

ViewerPercent::ViewerPercent() :
	nWidth( 25 )
{
}

ViewerPercent::~ViewerPercent()
{
}
	
void ViewerPercent::beginTarget( const char *sName, const char *sType, const char *sOperation, int nPerforms )
{
	printf("--- %s ---\n", sName );
	nMax = nPerforms;
	nCount = 0;
	nLastLen = 0;
}

void ViewerPercent::endTarget()
{
	printf("\n\n");
}

void ViewerPercent::beginPerform( Perform *pPerf )
{
	sTarget = pPerf->getTarget();
}

void ViewerPercent::beginExecute()
{
}

void ViewerPercent::endPerform()
{
	nCount++;

	int nPer = (nCount*nWidth)/nMax;
	fputc( '[', stdout );
	for( int j = 0; j < nPer; j++ )
		fputc('=', stdout );
	for( int j = nPer; j < nWidth; j++ )
		fputc(' ', stdout );
	//fputc(']', stdout );

	printf("] %s", sTarget.getString() );

	int diff = nLastLen-sTarget;
	for( int j = 0; j < diff; j++ )
		fputc(' ', stdout );

	nLastLen = sTarget;

	fputc('\r', stdout );
	fflush( stdout );
}