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:
parent
e9a3726de7
commit
bac831cd69
@ -80,7 +80,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# set common source files
|
# set common source files
|
||||||
set(COMMON_SOURCES "common/main.cc" "common/memory.cc" "common/graph.cc""common/powerline.cc")
|
set(COMMON_SOURCES "common/main.cc" "common/memory.cc" "common/graph.cc" "common/powerline.cc")
|
||||||
|
|
||||||
# add binary tree so we find version.h
|
# add binary tree so we find version.h
|
||||||
include_directories("${PROJECT_BINARY_DIR}")
|
include_directories("${PROJECT_BINARY_DIR}")
|
||||||
|
@ -118,7 +118,7 @@ The full usage::
|
|||||||
Prints this help message
|
Prints this help message
|
||||||
--colors
|
--colors
|
||||||
Use tmux colors in output
|
Use tmux colors in output
|
||||||
--powerline
|
--powerline-right
|
||||||
Use powerline symbols throughout the output, DO NOT reset background color at the end, enables --colors
|
Use powerline symbols throughout the output, DO NOT reset background color at the end, enables --colors
|
||||||
-i <value>, --interval <value>
|
-i <value>, --interval <value>
|
||||||
Set tmux status refresh interval in seconds. Default: 1 second
|
Set tmux status refresh interval in seconds. Default: 1 second
|
||||||
|
@ -77,10 +77,14 @@ std::string load_string( bool use_colors, bool use_powerline )
|
|||||||
|
|
||||||
if( use_colors )
|
if( use_colors )
|
||||||
{
|
{
|
||||||
if(use_powerline)
|
if( use_powerline )
|
||||||
|
{
|
||||||
ss << ' ';
|
ss << ' ';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ss << "#[fg=default,bg=default]";
|
ss << "#[fg=default,bg=default]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,13 @@ std::string cpu_string( unsigned int cpu_usage_delay, unsigned int graph_lines,
|
|||||||
if( use_colors )
|
if( use_colors )
|
||||||
{
|
{
|
||||||
if( use_powerline )
|
if( use_powerline )
|
||||||
|
{
|
||||||
oss << ' ';
|
oss << ' ';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
oss << "#[fg=default,bg=default]";
|
oss << "#[fg=default,bg=default]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oss.str();
|
return oss.str();
|
||||||
@ -88,7 +92,7 @@ void print_help()
|
|||||||
<< "-c, --colors\n"
|
<< "-c, --colors\n"
|
||||||
<< "--colors\n"
|
<< "--colors\n"
|
||||||
<< "\tUse tmux colors in output\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"
|
<< "\tUse powerline symbols throughout the output, DO NOT reset background color at the end, enables --colors\n"
|
||||||
<< "-i <value>, --interval <value>\n"
|
<< "-i <value>, --interval <value>\n"
|
||||||
<< "\tSet tmux status refresh interval in seconds. Default: 1 second\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
|
// otherwise it's a value to set the variable *flag points to
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ "colors", no_argument, NULL, 'c' },
|
{ "colors", no_argument, NULL, 'c' },
|
||||||
{ "powerline", no_argument, NULL, 'p' },
|
{ "powerline-right", no_argument, NULL, 'p' },
|
||||||
{ "interval", required_argument, NULL, 'i' },
|
{ "interval", required_argument, NULL, 'i' },
|
||||||
{ "graph-lines", required_argument, NULL, 'g' },
|
{ "graph-lines", required_argument, NULL, 'g' },
|
||||||
{ "mem-mode", required_argument, NULL, 'm' },
|
{ "mem-mode", required_argument, NULL, 'm' },
|
||||||
@ -135,7 +139,7 @@ int main( int argc, char** argv )
|
|||||||
case 'c': // --colors
|
case 'c': // --colors
|
||||||
use_colors = true;
|
use_colors = true;
|
||||||
break;
|
break;
|
||||||
case 'p': // --powerline
|
case 'p': // --powerline-right
|
||||||
use_colors = true;
|
use_colors = true;
|
||||||
use_powerline = true;
|
use_powerline = true;
|
||||||
break;
|
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 "powerline.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -18,10 +36,14 @@ const char * bg2fg(const char s[])
|
|||||||
|
|
||||||
void powerline(std::ostringstream &oss, const char s[], bool use_powerline)
|
void powerline(std::ostringstream &oss, const char s[], bool use_powerline)
|
||||||
{
|
{
|
||||||
if (use_powerline)
|
if( use_powerline )
|
||||||
oss << bg2fg(s)
|
{
|
||||||
<< PWL_RIGHT_FILLED
|
oss << bg2fg(s)
|
||||||
<< s << ' ';
|
<< PWL_RIGHT_FILLED
|
||||||
|
<< s << ' ';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
oss << s;
|
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
|
#ifndef POWERLINE_H
|
||||||
#define POWERLINE_H
|
#define POWERLINE_H
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user