From 1a5016cf91d605bb69020859270c8501186087f9 Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 28 Apr 2007 18:46:16 +0000 Subject: Added an std::ostream, mpr_stream, to the message.h interface. The usage is along the lines of: mpr_stream << setchan(MSGCH_PROMPT) << "this will be output to prompt" << i << "/" << j << std::endl; This is very hacky at the moment, but at least it's much more type-safe than mprf()... git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1389 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/message.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'crawl-ref/source/message.h') diff --git a/crawl-ref/source/message.h b/crawl-ref/source/message.h index 3fcf7d881e..96a2094f40 100644 --- a/crawl-ref/source/message.h +++ b/crawl-ref/source/message.h @@ -15,6 +15,7 @@ #define MESSAGE_H #include +#include #include "externs.h" @@ -105,4 +106,34 @@ std::string get_last_messages(int mcount); int channel_to_colour( int channel, int param = 0 ); +struct setchan +{ + setchan(msg_channel_type chan); + msg_channel_type m_chan; +}; + +struct setparam +{ + setparam(int param); + int m_param; +}; + +std::ostream& operator<<(std::ostream& os, const setchan& sc); +std::ostream& operator<<(std::ostream& os, const setparam& sp); + +class mpr_stream_buf : public std::streambuf +{ +public: + mpr_stream_buf(); +protected: + int overflow(int c); +private: + static const int INTERNAL_LENGTH = 500; + char internal_buf[500]; // if your terminal is wider than this, too bad + int internal_count; +}; + +extern std::ostream mpr_stream; + + #endif -- cgit v1.2.3-54-g00ecf