aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2006-12-26 19:59:58 +0000
committerDavid <david@xagasoft.com>2006-12-26 19:59:58 +0000
commit36242ee4f2c24352c547d266a311305007111ac9 (patch)
tree62c82e6180aff763793f9eeb39775ab84d8fe76b /src
parente7c032338901274425b8d87a527d6aee57711745 (diff)
downloadbuild-36242ee4f2c24352c547d266a311305007111ac9.tar.gz
build-36242ee4f2c24352c547d266a311305007111ac9.tar.bz2
build-36242ee4f2c24352c547d266a311305007111ac9.tar.xz
build-36242ee4f2c24352c547d266a311305007111ac9.zip
david - woops, forgot to add
Diffstat (limited to '')
-rw-r--r--src/viewercolorpct.cpp129
-rw-r--r--src/viewercolorpct.h49
2 files changed, 178 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
diff --git a/src/viewercolorpct.h b/src/viewercolorpct.h
new file mode 100644
index 0000000..dc810c1
--- /dev/null
+++ b/src/viewercolorpct.h
@@ -0,0 +1,49 @@
1#ifndef VIEWER_COLOR_PCT_H
2#define VIEWER_COLOR_PCT_H
3
4#include <stdint.h>
5#include <list>
6#include "viewer.h"
7
8class ViewerColorPct : public Viewer
9{
10public:
11 ViewerColorPct();
12 virtual ~ViewerColorPct();
13
14 virtual void beginCommand( Action::eAction nAct, const std::string &sTarget );
15 virtual void endCommand();
16
17 virtual void beginRequiresCheck( bool bCached, const std::string &sName );
18 virtual void endRequiresCheck();
19 virtual void beginPerform( Perform *pPerform );
20 virtual void endPerform();
21 virtual void beginPerforms( int nCount );
22
23 virtual void skipRequiresCheck( bool bCached, const std::string &sName );
24 virtual void skipPerform( Perform *pPerform );
25
26 virtual void beginAction( const std::string &sName, int nCommands );
27
28 virtual void endAction();
29
30 void printPerform(const char *sRule, const char *sTarget);
31 void printHead();
32 void indent();
33
34private:
35 int iTC, iCC;
36
37 bool bRunClean;
38 typedef struct
39 {
40 int nLevel;
41 bool bCmdClean;
42 std::string sTarget;
43 int iTP, iCP;
44 } Cmd;
45 typedef std::list<Cmd> CmdStack;
46 CmdStack sCmd;
47};
48
49#endif