~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to libraries/Win32/System/Win32/Console.hsc

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-----------------------------------------------------------------------------
 
2
-- |
 
3
-- Module      :  System.Win32.Console
 
4
-- Copyright   :  (c) University of Glasgow 2006
 
5
-- License     :  BSD-style (see the file LICENSE)
 
6
--
 
7
-- Maintainer  :  Esa Ilari Vuokko <ei@vuokko.info>
 
8
-- Stability   :  provisional
 
9
-- Portability :  portable
 
10
--
 
11
-- A collection of FFI declarations for interfacing with Win32 Console API
 
12
--
 
13
-----------------------------------------------------------------------------
 
14
 
 
15
module System.Win32.Console (
 
16
        -- * Console code pages
 
17
        getConsoleCP,
 
18
        setConsoleCP,
 
19
        getConsoleOutputCP,
 
20
        setConsoleOutputCP,
 
21
        -- * Ctrl events
 
22
        CtrlEvent, cTRL_C_EVENT, cTRL_BREAK_EVENT,
 
23
        generateConsoleCtrlEvent
 
24
  ) where
 
25
 
 
26
import System.Win32.Types
 
27
 
 
28
foreign import stdcall unsafe "windows.h GetConsoleCP"
 
29
        getConsoleCP :: IO UINT
 
30
 
 
31
foreign import stdcall unsafe "windows.h SetConsoleCP"
 
32
        setConsoleCP :: UINT -> IO ()
 
33
 
 
34
foreign import stdcall unsafe "windows.h GetConsoleOutputCP"
 
35
        getConsoleOutputCP :: IO UINT
 
36
 
 
37
foreign import stdcall unsafe "windows.h SetConsoleOutputCP"
 
38
        setConsoleOutputCP :: UINT -> IO ()
 
39
 
 
40
type CtrlEvent = DWORD
 
41
#{enum CtrlEvent,
 
42
    , cTRL_C_EVENT      = 0
 
43
    , cTRL_BREAK_EVENT  = 1
 
44
    }
 
45
 
 
46
generateConsoleCtrlEvent :: CtrlEvent -> DWORD -> IO ()
 
47
generateConsoleCtrlEvent e p
 
48
    = failIfFalse_
 
49
        "generateConsoleCtrlEvent"
 
50
        $ c_GenerateConsoleCtrlEvent e p
 
51
 
 
52
foreign import stdcall safe "windows.h GenerateConsoleCtrlEvent"
 
53
    c_GenerateConsoleCtrlEvent :: CtrlEvent -> DWORD -> IO BOOL
 
54
 
 
55
-- ToDo: lots more