aboutsummaryrefslogtreecommitdiff
path: root/src/viewercolorpct.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/viewercolorpct.cpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/src/viewercolorpct.cpp b/src/viewercolorpct.cpp
new file mode 100644
index 0000000..3745a03
--- /dev/null
+++ b/src/viewercolorpct.cpp
@@ -0,0 +1,129 @@
1#include "viewercolorpct.h"
2#include "perform.h"
3#include "plugger.h"
4#include "math.h"
5
6PluginInterface2( colorpct, ViewerColorPct, Viewer, "Mike Buland", 0, 1 );
7
8ViewerColorPct::ViewerColorPct() :
9 bRunClean( true )
10{
11}
12
13ViewerColorPct::~ViewerColorPct()
14{
15}
16
17void ViewerColorPct::beginCommand( Action::eAction nAct, const std::string &sTarget )
18{
19 Cmd cmd;
20 if( sCmd.empty() )
21 cmd.nLevel = 0;
22 else
23 cmd.nLevel = sCmd.front().nLevel+1;
24
25 cmd.bCmdClean = true;
26 cmd.sTarget = sTarget;
27
28 sCmd.push_front( cmd );
29}
30
31void ViewerColorPct::endCommand()
32{
33 if( sCmd.front().bCmdClean == false )
34 printf("\n");
35 sCmd.pop_front();
36 if(sCmd.empty())
37 iCC++;
38}
39
40void ViewerColorPct::indent()
41{
42 if( sCmd.empty() ) return;
43 int jmax = sCmd.front().nLevel;
44 for( int j = 0; j < jmax; j++ )
45 {
46 printf(" ");
47 }
48}
49
50void ViewerColorPct::printHead()
51{
52 if( sCmd.front().bCmdClean == true )
53 {
54 bRunClean = false;
55 sCmd.front().bCmdClean = false;
56 indent();
57 if(sCmd.size() > 1)
58 printf("\033[37;22m--- \033[34m%s\033[37m ---\n\033[0m", sCmd.front().sTarget.c_str() );
59 else
60 printf("\033[37;1m--- [\033[32m%d/%d\033[37m] \033[34m%s\033[37m ---\n\033[0m", iCC, iTC, sCmd.front().sTarget.c_str() );
61 }
62}
63
64void ViewerColorPct::printPerform(const char *sRule, const char *sTarget)
65{
66 int iPct = (int)round(
67 ((double)sCmd.front().iCP/(double)sCmd.front().iTP)*100.0
68 );
69 if(sCmd.size() > 1)
70 printf( "\033[37;22m[\033[32m%3d%%\033[37m] \033[35m%8s\033[37m: %s\n\033[0m", iPct, sRule, sTarget );
71 else
72 printf( "\033[37;1m[\033[32m%3d%%\033[37m] \033[35m%8s\033[37m: %s\n\033[0m", iPct, sRule, sTarget );
73}
74
75void ViewerColorPct::beginRequiresCheck( bool bCached, const std::string &sName )
76{
77 printHead();
78 indent();
79 printPerform("deps", sName.c_str());
80}
81
82void ViewerColorPct::endRequiresCheck()
83{
84 sCmd.front().iCP++;
85}
86
87void ViewerColorPct::skipRequiresCheck( bool bCached, const std::string &sName )
88{
89 sCmd.front().iCP++;
90}
91
92void ViewerColorPct::beginPerform( Perform *pPerform )
93{
94 printHead();
95 indent();
96 printPerform(pPerform->getRule().c_str(), pPerform->getTarget().c_str());
97}
98
99void ViewerColorPct::endPerform()
100{
101 sCmd.front().iCP++;
102}
103
104void ViewerColorPct::skipPerform( Perform *pPerform )
105{
106 sCmd.front().iCP++;
107}
108
109void ViewerColorPct::beginPerforms( int nCount )
110{
111 sCmd.front().iTP = nCount*2;
112 sCmd.front().iCP = 1;
113}
114
115void ViewerColorPct::beginAction( const std::string &sName, int nCommands )
116{
117 iTC = nCommands;
118 iCC = 1;
119}
120
121void ViewerColorPct::endAction()
122{
123 if( bRunClean == true )
124 {
125 printf("Nothing to be done.\n\n");
126 }
127 printf("\033[0m");
128}
129