]> git.tdb.fi Git - libs/core.git/blob - source/io/console.h
Move files to prepare for assimilation into core
[libs/core.git] / source / io / console.h
1 #ifndef MSP_IO_CONSOLE_H_
2 #define MSP_IO_CONSOLE_H_
3
4 #include "base.h"
5
6 namespace Msp {
7 namespace IO {
8
9 /**
10 Provides access to standard input, output and error streams.  This class can't
11 be instantiated directly - use one of the cin, cout and cerr references
12 instead.
13 */
14 class Console: public Base
15 {
16 private:
17         Handle handle;
18
19         Console(unsigned);
20 public:
21         ~Console();
22
23         virtual void set_block(bool);
24         
25         /** If local echo is enabled, characters will appear on the console as they
26         are typed.  Can only be used on an input Console.  */
27         void set_local_echo(bool);
28
29         /** If line buffering is enabled, input will only be available when a
30         newline is encountered.  On some systems, this may also enable line editing.
31         Can only be used on an input Console.
32         */
33         void set_line_buffer(bool);
34
35         /** Retrieves the size of the Console.  Can only be used on an output
36         Console. */
37         void get_size(unsigned &rows, unsigned &cols);
38
39 protected:
40         virtual unsigned do_write(const char *, unsigned);
41         virtual unsigned do_read(char *, unsigned);
42
43 public:
44         virtual Handle get_event_handle();
45
46         static Console &instance(unsigned);
47 };
48
49 extern Console &cin;
50 extern Console &cout;
51 extern Console &cerr;
52
53 } // namespace IO
54 } // namespace Msp
55
56 #endif