mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-28 13:00:45 +00:00
proper console display (move code out of conky.cc)
This commit is contained in:
parent
e4b05557fa
commit
1c5198bccd
11
src/conky.cc
11
src/conky.cc
@ -201,8 +201,6 @@ int top_cpu, top_mem, top_time;
|
|||||||
int top_io;
|
int top_io;
|
||||||
#endif
|
#endif
|
||||||
int top_running;
|
int top_running;
|
||||||
static conky::simple_config_setting<bool> extra_newline("extra_newline", false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
/* Update interval */
|
/* Update interval */
|
||||||
conky::range_config_setting<double> update_interval(
|
conky::range_config_setting<double> update_interval(
|
||||||
@ -1075,15 +1073,6 @@ static void draw_string(const char *s) {
|
|||||||
#ifdef BUILD_X11
|
#ifdef BUILD_X11
|
||||||
width_of_s = get_string_width(s);
|
width_of_s = get_string_width(s);
|
||||||
#endif /* BUILD_X11 */
|
#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)) {
|
if (draw_mode == FG && (overwrite_fpointer != nullptr)) {
|
||||||
fprintf(overwrite_fpointer, "%s\n", s);
|
fprintf(overwrite_fpointer, "%s\n", s);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
static conky::simple_config_setting<bool> extra_newline("extra_newline", false,
|
||||||
|
false);
|
||||||
|
|
||||||
namespace conky {
|
namespace conky {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -63,4 +66,16 @@ bool display_output_console::initialize() { return true; }
|
|||||||
|
|
||||||
bool display_output_console::shutdown() { 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
|
} // namespace conky
|
||||||
|
@ -47,6 +47,8 @@ class display_output_console : public display_output_base {
|
|||||||
virtual bool initialize();
|
virtual bool initialize();
|
||||||
virtual bool shutdown();
|
virtual bool shutdown();
|
||||||
|
|
||||||
|
virtual void draw_string(const char *s, int w);
|
||||||
|
|
||||||
// console-specific
|
// console-specific
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user