@@ -240,12 +240,6 @@ class messaget
240
240
return *this ;
241
241
}
242
242
243
- // for feeding in manipulator functions such as eom
244
- mstreamt &operator << (mstreamt &(*func)(mstreamt &))
245
- {
246
- return func (*this );
247
- }
248
-
249
243
private:
250
244
void assign_from (const mstreamt &other)
251
245
{
@@ -259,7 +253,13 @@ class messaget
259
253
260
254
// Feeding 'eom' into the stream triggers
261
255
// the printing of the message
262
- static mstreamt &eom (mstreamt &m)
256
+ class eomt
257
+ {
258
+ };
259
+
260
+ static eomt eom;
261
+
262
+ friend mstreamt &operator <<(mstreamt &m, eomt)
263
263
{
264
264
if (m.message .message_handler )
265
265
{
@@ -275,55 +275,64 @@ class messaget
275
275
return m;
276
276
}
277
277
278
- // in lieu of std::endl
279
- static mstreamt &endl (mstreamt &m)
278
+ class commandt
280
279
{
281
- static_cast <std::ostream &>(m) << std::endl;
282
- return m;
280
+ public:
281
+ commandt (unsigned _command) : command(_command)
282
+ {
283
+ }
284
+
285
+ unsigned command;
286
+ };
287
+
288
+ // / feed a command into an mstreamt
289
+ friend mstreamt &operator <<(mstreamt &m, const commandt &c)
290
+ {
291
+ if (m.message .message_handler )
292
+ return m << m.message .message_handler ->command (c.command );
293
+ else
294
+ return m;
283
295
}
284
296
285
297
// / \brief Create an ECMA-48 SGR (Select Graphic Rendition) command.
286
- std::string command (unsigned c) const
298
+ static commandt command (unsigned c)
287
299
{
288
- if (message_handler)
289
- return message_handler->command (c);
290
- else
291
- return std::string ();
300
+ return commandt (c);
292
301
}
293
302
294
303
// / return to default formatting,
295
304
// / as defined by the terminal
296
- std::string reset () const
305
+ static commandt reset ()
297
306
{
298
307
return command (0 );
299
308
}
300
309
301
310
// / render text with red foreground color
302
- std::string red () const
311
+ static commandt red ()
303
312
{
304
313
return command (31 );
305
314
}
306
315
307
316
// / render text with green foreground color
308
- std::string green () const
317
+ static commandt green ()
309
318
{
310
319
return command (32 );
311
320
}
312
321
313
322
// / render text with yellow foreground color
314
- std::string yellow () const
323
+ static commandt yellow ()
315
324
{
316
325
return command (33 );
317
326
}
318
327
319
328
// / render text with blue foreground color
320
- std::string blue () const
329
+ static commandt blue ()
321
330
{
322
331
return command (34 );
323
332
}
324
333
325
334
// / render text with bold font
326
- std::string bold () const
335
+ static commandt bold ()
327
336
{
328
337
return command (1 );
329
338
}
0 commit comments