diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-28 18:46:16 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-28 18:46:16 +0000 |
commit | 1a5016cf91d605bb69020859270c8501186087f9 (patch) | |
tree | b55a6cd74dfc387ee7e955a373f0077f3728cc04 /crawl-ref/source/message.h | |
parent | 0d012087e1d0b1829aed9e2a6be94ed21dccd545 (diff) | |
download | crawl-ref-1a5016cf91d605bb69020859270c8501186087f9.tar.gz crawl-ref-1a5016cf91d605bb69020859270c8501186087f9.zip |
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
Diffstat (limited to 'crawl-ref/source/message.h')
-rw-r--r-- | crawl-ref/source/message.h | 31 |
1 files changed, 31 insertions, 0 deletions
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 <string> +#include <streambuf> #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 |