comparison druntime/src/compiler/dmd/util/console.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
1 /**
2 * The console module contains some simple routines for console output.
3 *
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
6 * Authors: Sean Kelly
7 *
8 * Copyright Sean Kelly 2005 - 2009.
9 * Distributed under the Boost Software License, Version 1.0.
10 * (See accompanying file LICENSE_1_0.txt or copy at
11 * http://www.boost.org/LICENSE_1_0.txt)
12 */
13 module rt.util.console;
14
15
16 private
17 {
18 version (Windows)
19 {
20 import core.sys.windows.windows;
21 }
22 else version( Posix )
23 {
24 import core.sys.posix.unistd;
25 }
26 import rt.util.string;
27 }
28
29
30 struct Console
31 {
32 Console opCall( in char[] val )
33 {
34 version( Windows )
35 {
36 uint count = void;
37 WriteFile( GetStdHandle( 0xfffffff5 ), val.ptr, val.length, &count, null );
38 }
39 else version( Posix )
40 {
41 write( 2, val.ptr, val.length );
42 }
43 return this;
44 }
45
46
47 Console opCall( uint val )
48 {
49 char[10] tmp = void;
50 return opCall( tmp.intToString( val ) );
51 }
52 }
53
54 __gshared Console console;