1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 04:32:55 +00:00

proper console display (move code out of conky.cc)

This commit is contained in:
François Revol 2018-10-19 02:30:31 +02:00
parent e4b05557fa
commit 1c5198bccd
3 changed files with 17 additions and 11 deletions

View File

@ -201,8 +201,6 @@ int top_cpu, top_mem, top_time;
int top_io;
#endif
int top_running;
static conky::simple_config_setting<bool> extra_newline("extra_newline", false,
false);
/* Update interval */
conky::range_config_setting<double> update_interval(
@ -1075,15 +1073,6 @@ static void draw_string(const char *s) {
#ifdef BUILD_X11
width_of_s = get_string_width(s);
#endif /* BUILD_X11 */
if (out_to_stdout.get(*state) && draw_mode == FG) {
printf("%s\n", s);
if (extra_newline.get(*state)) { fputc('\n', stdout); }
fflush(stdout); /* output immediately, don't buffer */
}
if (out_to_stderr.get(*state) && draw_mode == FG) {
fprintf(stderr, "%s\n", s);
fflush(stderr); /* output immediately, don't buffer */
}
if (draw_mode == FG && (overwrite_fpointer != nullptr)) {
fprintf(overwrite_fpointer, "%s\n", s);
}

View File

@ -34,6 +34,9 @@
#include <sstream>
#include <unordered_map>
static conky::simple_config_setting<bool> extra_newline("extra_newline", false,
false);
namespace conky {
namespace {
@ -63,4 +66,16 @@ bool display_output_console::initialize() { return true; }
bool display_output_console::shutdown() { return true; }
void display_output_console::draw_string(const char *s, int w) {
if (out_to_stdout.get(*state)) {
printf("%s\n", s);
if (extra_newline.get(*state)) { fputc('\n', stdout); }
fflush(stdout); /* output immediately, don't buffer */
}
if (out_to_stderr.get(*state)) {
fprintf(stderr, "%s\n", s);
fflush(stderr); /* output immediately, don't buffer */
}
}
} // namespace conky

View File

@ -47,6 +47,8 @@ class display_output_console : public display_output_base {
virtual bool initialize();
virtual bool shutdown();
virtual void draw_string(const char *s, int w);
// console-specific
};