summaryrefslogtreecommitdiff
path: root/library/ColorText.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-03-14 19:57:29 +0400
committerAlexander Gavrilov2012-03-14 19:57:29 +0400
commit560e977f0589ac1c0feb6ea825d20d351e325826 (patch)
treee32bf2135261fa1e9129fae4c2c7ae068b6ef4cc /library/ColorText.cpp
parentc42e2ff053bc3acbded353112cd6412c8211f279 (diff)
downloaddfhack-560e977f0589ac1c0feb6ea825d20d351e325826.tar.gz
dfhack-560e977f0589ac1c0feb6ea825d20d351e325826.tar.bz2
dfhack-560e977f0589ac1c0feb6ea825d20d351e325826.tar.xz
Implement trivial RPC interface for dfhack via TCP & protobufs.
Use it to make an executable capable of calling commands remotely.
Diffstat (limited to 'library/ColorText.cpp')
-rw-r--r--library/ColorText.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/library/ColorText.cpp b/library/ColorText.cpp
index fa5d57e0..c399504b 100644
--- a/library/ColorText.cpp
+++ b/library/ColorText.cpp
@@ -143,6 +143,16 @@ void color_ostream::reset_color(void)
color(COLOR_RESET);
}
+void color_ostream_wrapper::add_text(color_value, const std::string &text)
+{
+ out << text;
+}
+
+void color_ostream_wrapper::flush_proxy()
+{
+ out << std::flush;
+}
+
void buffered_color_ostream::add_text(color_value color, const std::string &text)
{
if (text.empty())
@@ -165,23 +175,20 @@ void buffered_color_ostream::add_text(color_value color, const std::string &text
void color_ostream_proxy::flush_proxy()
{
- if (!buffer.empty())
+ if (buffer.empty())
+ return;
+
+ if (target)
{
target->begin_batch();
for (auto it = buffer.begin(); it != buffer.end(); ++it)
target->add_text(it->first, it->second);
- buffer.clear();
-
target->end_batch();
}
-}
-color_ostream_proxy::color_ostream_proxy(color_ostream &target)
- : target(&target)
-{
- //
+ buffer.clear();
}
color_ostream_proxy::~color_ostream_proxy()