Code refactoring for merging

- license header in new files
- changed "powerline" into "powerline-right"
- added braces around one-liners
- small fixes concerning whitespace
This commit is contained in:
Michał Goliński 2016-04-14 12:18:10 +02:00
parent e9a3726de7
commit bac831cd69
6 changed files with 58 additions and 10 deletions

@ -118,7 +118,7 @@ The full usage::
Prints this help message
--colors
Use tmux colors in output
--powerline
--powerline-right
Use powerline symbols throughout the output, DO NOT reset background color at the end, enables --colors
-i <value>, --interval <value>
Set tmux status refresh interval in seconds. Default: 1 second

@ -78,11 +78,15 @@ std::string load_string( bool use_colors, bool use_powerline )
if( use_colors )
{
if( use_powerline )
{
ss << ' ';
}
else
{
ss << "#[fg=default,bg=default]";
}
}
}
return ss.str();
}

@ -67,10 +67,14 @@ std::string cpu_string( unsigned int cpu_usage_delay, unsigned int graph_lines,
if( use_colors )
{
if( use_powerline )
{
oss << ' ';
}
else
{
oss << "#[fg=default,bg=default]";
}
}
return oss.str();
}
@ -88,7 +92,7 @@ void print_help()
<< "-c, --colors\n"
<< "--colors\n"
<< "\tUse tmux colors in output\n"
<< "-p, --powerline\n"
<< "-p, --powerline-right\n"
<< "\tUse powerline symbols throughout the output, DO NOT reset background color at the end, enables --colors\n"
<< "-i <value>, --interval <value>\n"
<< "\tSet tmux status refresh interval in seconds. Default: 1 second\n"
@ -115,7 +119,7 @@ int main( int argc, char** argv )
// otherwise it's a value to set the variable *flag points to
{ "help", no_argument, NULL, 'h' },
{ "colors", no_argument, NULL, 'c' },
{ "powerline", no_argument, NULL, 'p' },
{ "powerline-right", no_argument, NULL, 'p' },
{ "interval", required_argument, NULL, 'i' },
{ "graph-lines", required_argument, NULL, 'g' },
{ "mem-mode", required_argument, NULL, 'm' },
@ -135,7 +139,7 @@ int main( int argc, char** argv )
case 'c': // --colors
use_colors = true;
break;
case 'p': // --powerline
case 'p': // --powerline-right
use_colors = true;
use_powerline = true;
break;

@ -1,3 +1,21 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2016 Michał Goliński
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "powerline.h"
#include <cstring>
@ -19,9 +37,13 @@ const char * bg2fg(const char s[])
void powerline(std::ostringstream &oss, const char s[], bool use_powerline)
{
if( use_powerline )
{
oss << bg2fg(s)
<< PWL_RIGHT_FILLED
<< s << ' ';
}
else
{
oss << s;
}
}

@ -1,3 +1,21 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2016 Michał Goliński
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef POWERLINE_H
#define POWERLINE_H