# HG changeset patch # User František Kučera # Date 1473544821 -7200 # Node ID 6e5c4e267ddb1054d9998f014687ed9a8c599bc2 # Parent 584f60104c13b5c74aa82f4a50dfc4bfa6d05f9c c++: some colors + start script diff -r 584f60104c13 -r 6e5c4e267ddb c++/parameter-lister/info/globalcode/parameterLister/TerminalOutputModule.cpp --- a/c++/parameter-lister/info/globalcode/parameterLister/TerminalOutputModule.cpp Sat Sep 10 23:52:37 2016 +0200 +++ b/c++/parameter-lister/info/globalcode/parameterLister/TerminalOutputModule.cpp Sun Sep 11 00:00:21 2016 +0200 @@ -13,13 +13,13 @@ terminalCodes::Modifier fgGreen(terminalCodes::FG_GREEN); terminalCodes::Modifier fgReset(terminalCodes::FG_DEFAULT); - output << fgGreen << "" << fgReset << endl; + output << fgGreen << "terminalOutputModule >>>" << fgReset << endl; for_each(args.begin(), args.end(), [this, &output, command, fgGreen, fgReset](string s) { - output << fgGreen << command << fgReset << ": " << escapeValue(s, true) << endl; + output << fgGreen << colorize(RED, command) << fgReset << ": " << escapeValue(s, true) << endl; }); - output << fgGreen << "" << fgReset << endl; + output << fgGreen << "<<< terminalOutputModule" << fgReset << endl; return 0; } diff -r 584f60104c13 -r 6e5c4e267ddb c++/parameter-lister/info/globalcode/parameterLister/TerminalOutputModule.h --- a/c++/parameter-lister/info/globalcode/parameterLister/TerminalOutputModule.h Sat Sep 10 23:52:37 2016 +0200 +++ b/c++/parameter-lister/info/globalcode/parameterLister/TerminalOutputModule.h Sun Sep 11 00:00:21 2016 +0200 @@ -1,7 +1,8 @@ #ifndef TERMINALOUTPUTMODULE_H -#define TERMINALOUTPUTMODULE_H +#define TERMINALOUTPUTMODULE_H #include +#include #include "OutputModule.h" @@ -9,16 +10,30 @@ namespace globalcode { namespace parameterLister { +using namespace std; + class TerminalOutputModule : public OutputModule { public: - virtual int process(std::ostream &output, std::string &command, std::vector &args); + virtual int process(ostream &output, string &command, vector &args); private: + const int RED = 31; + const int GREEN = 32; + const int BLUE = 34; + + string colorize(int foreground, string text) { + //return "\033[" + "32" + "m" + text + "\033[39m"; + ostringstream fgStream; + fgStream << foreground; + return "\033[" + fgStream.str() + "m" + text + "\033[39m"; + } + + // tabulky: http://www.rubydoc.info/gems/terminal-table/1.4.2/frames }; } } } -#endif /* TERMINALOUTPUTMODULE_H */ +#endif /* TERMINALOUTPUTMODULE_H */ diff -r 584f60104c13 -r 6e5c4e267ddb c++/parameter-lister/start.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c++/parameter-lister/start.sh Sun Sep 11 00:00:21 2016 +0200 @@ -0,0 +1,14 @@ +#!/bin/sh + +# syntax highlight: +# ./start.sh | pygmentize -l xml + +p1="aaa"; +p2="first line +second line +third line"; +p3="a & b >> OMG <<"; + +export PARAMETER_LISTER_OUTPUT="terminal"; + +dist/Debug/GNU-Linux/parameter-lister "$p1" "$p2" "$p3";