Changeset 122


Ignore:
Timestamp:
Feb 28, 2007, 12:08:40 AM (17 years ago)
Author:
NoWest
Message:

コンソール関連APIを全て実装

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/api_console.sbp

    r119 r122  
    33#ifndef _INC_CONSOLE
    44#define _INC_CONSOLE
    5 
    6 'console text color
    7 Const FOREGROUND_BLUE =      &H0001
    8 Const FOREGROUND_GREEN =     &H0002
    9 Const FOREGROUND_RED =       &H0004
    10 Const FOREGROUND_INTENSITY = &H0008
    11 Const BACKGROUND_BLUE =      &H0010
    12 Const BACKGROUND_GREEN =     &H0020
    13 Const BACKGROUND_RED =       &H0040
    14 Const BACKGROUND_INTENSITY = &H0080
    155
    166Type COORD
     
    188    Y As Integer
    199End Type
    20 
    21 
     10TypeDef PCOORD = *COORD
     11
     12Type SMALL_RECT
     13    Left As Integer
     14    Top As Integer
     15    Right As Integer
     16    Bottom As Integer
     17End Type
     18TypeDef PSMALL_RECT = *SMALL_RECT
     19
     20Type KEY_EVENT_RECORD
     21    bKeyDown As BOOL
     22    wRepeatCount As Word
     23    wVirtualKeyCode As Word
     24    wVirtualScanCode As Word
     25    uChar As WCHAR
     26    dwControlKeyState As DWord
     27End Type
     28TypeDef PKEY_EVENT_RECORD = *KEY_EVENT_RECORD
     29
     30Const RIGHT_ALT_PRESSED = &H0001
     31Const LEFT_ALT_PRESSED = &H0002
     32Const RIGHT_CTRL_PRESSED = &H0004
     33Const LEFT_CTRL_PRESSED = &H0008
     34Const SHIFT_PRESSED = &H0010
     35Const NUMLOCK_ON = &H0020
     36Const SCROLLLOCK_ON = &H0040
     37Const CAPSLOCK_ON = &H0080
     38Const ENHANCED_KEY = &H0100
     39Const NLS_DBCSCHAR = &H00010000
     40Const NLS_ALPHANUMERIC = &H00000000
     41Const NLS_KATAKANA = &H00020000
     42Const NLS_HIRAGANA = &H00040000
     43Const NLS_ROMAN = &H00400000
     44Const NLS_IME_CONVERSION = &H00800000
     45Const NLS_IME_DISABLE = &H20000000
     46
     47Type MOUSE_EVENT_RECORD
     48    dwMousePosition As COORD
     49    dwButtonState As DWord
     50    dwControlKeyState As DWord
     51    dwEventFlags As DWord
     52End Type
     53TypeDef PMOUSE_EVENT_RECORD = *MOUSE_EVENT_RECORD
     54
     55Const FROM_LEFT_1ST_BUTTON_PRESSED = &H0001
     56Const RIGHTMOST_BUTTON_PRESSED = &H0002
     57Const FROM_LEFT_2ND_BUTTON_PRESSED = &H0004
     58Const FROM_LEFT_3RD_BUTTON_PRESSED = &H0008
     59Const FROM_LEFT_4TH_BUTTON_PRESSED = &H0010
     60
     61Const MOUSE_MOVED = &H0001
     62Const DOUBLE_CLICK = &H0002
     63Const MOUSE_WHEELED = &H0004
     64
     65Type WINDOW_BUFFER_SIZE_RECORD
     66    dwSize As COORD
     67End Type
     68TypeDef PWINDOW_BUFFER_SIZE_RECORD = *WINDOW_BUFFER_SIZE_RECORD
     69
     70Type MENU_EVENT_RECORD
     71    dwCommandId As DWord
     72End Type
     73TypeDef PMENU_EVENT_RECORD = *MENU_EVENT_RECORD
     74
     75Type FOCUS_EVENT_RECORD
     76    bSetFocus As BOOL
     77End Type
     78TypeDef PFOCUS_EVENT_RECORD = *FOCUS_EVENT_RECORD
     79
     80Type INPUT_RECORD
     81    EventType As Word
     82'   Union Event
     83        KeyEvent As KEY_EVENT_RECORD
     84'       MouseEvent As MOUSE_EVENT_RECORD
     85'       WindowBufferSizeEvent As WINDOW_BUFFER_SIZE_RECORD
     86'       MenuEvent As MENU_EVENT_RECORD
     87'       FocusEvent As FOCUS_EVENT_RECORD
     88'   End Union
     89End Type
     90TypeDef PINPUT_RECORD = *INPUT_RECORD
     91
     92Const KEY_EVENT                = &H0001
     93Const MOUSE_EVENT              = &H0002
     94Const WINDOW_BUFFER_SIZE_EVENT = &H0004
     95Const MENU_EVENT               = &H0008
     96Const FOCUS_EVENT              = &H0010
     97
     98Type CHAR_INFO
     99'   Union Char
     100'       UnicodeChar As Word
     101        AsciiChar[1] As SByte
     102'   End Union
     103    Attributes As Word
     104End Type
     105TypeDef PCHAR_INFO = *CHAR_INFO
     106
     107Const FOREGROUND_BLUE            = &H0001
     108Const FOREGROUND_GREEN           = &H0002
     109Const FOREGROUND_RED             = &H0004
     110Const FOREGROUND_INTENSITY       = &H0008
     111Const BACKGROUND_BLUE            = &H0010
     112Const BACKGROUND_GREEN           = &H0020
     113Const BACKGROUND_RED             = &H0040
     114Const BACKGROUND_INTENSITY       = &H0080
     115Const COMMON_LVB_LEADING_BYTE    = &H0100
     116Const COMMON_LVB_TRAILING_BYTE   = &H0200
     117Const COMMON_LVB_GRID_HORIZONTAL = &H0400
     118Const COMMON_LVB_GRID_LVERTICAL  = &H0800
     119Const COMMON_LVB_GRID_RVERTICAL  = &H1000
     120Const COMMON_LVB_REVERSE_VIDEO   = &H4000
     121Const COMMON_LVB_UNDERSCORE      = &H8000
     122Const COMMON_LVB_SBCSDBCS        = &H0300
     123
     124Type CONSOLE_SCREEN_BUFFER_INFO
     125    dwSize As COORD
     126    dwCursorPosition As COORD
     127    wAttributes As Word
     128    srWindow As SMALL_RECT
     129    dwMaximumWindowSize As COORD
     130End Type
     131TypeDef PCONSOLE_SCREEN_BUFFER_INFO = *CONSOLE_SCREEN_BUFFER_INFO
     132
     133Type CONSOLE_CURSOR_INFO
     134    dwSize As DWord
     135    bVisible As BOOL
     136End Type
     137TypeDef PCONSOLE_CURSOR_INFO = *CONSOLE_CURSOR_INFO
     138
     139TypeDef PHANDLER_ROUTINE = *Function(CtrlType As DWord) As BOOL
     140
     141Const CTRL_C_EVENT        = 0
     142Const CTRL_BREAK_EVENT    = 1
     143Const CTRL_CLOSE_EVENT    = 2
     144Const CTRL_LOGOFF_EVENT   = 5
     145Const CTRL_SHUTDOWN_EVENT = 6
     146
     147Const ENABLE_PROCESSED_INPUT    = &H0001
     148Const ENABLE_LINE_INPUT         = &H0002
     149Const ENABLE_ECHO_INPUT         = &H0004
     150Const ENABLE_WINDOW_INPUT       = &H0008
     151Const ENABLE_MOUSE_INPUT        = &H0010
     152Const ENABLE_PROCESSED_OUTPUT   = &H0001
     153Const ENABLE_WRAP_AT_EOL_OUTPUT = &H0002
     154
     155Declare Function PeekConsoleInput Lib "kernel32" Alias "PeekConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
     156Declare Function ReadConsoleInput Lib "kernel32" Alias "ReadConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
     157Declare Function WriteConsoleInput Lib "kernel32" Alias "WriteConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsWritten As DWord) As BOOL
     158Declare Function ReadConsoleOutput Lib "kernel32" Alias "ReadConsoleOutputA" (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpReadRegion As SMALL_RECT) As BOOL
     159Declare Function WriteConsoleOutput Lib "kernel32" Alias "WriteConsoleOutputA" (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpWriteRegion As SMALL_RECT) As BOOL
     160Declare Function ReadConsoleOutputCharacter Lib "kernel32" Alias "ReadConsoleOutputCharacterA" (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfCharsRead As DWord) As BOOL
     161Declare Function ReadConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfAttrsRead As DWord) As BOOL
     162Declare Function WriteConsoleOutputCharacter Lib "kernel32" Alias "WriteConsoleOutputCharacterA" (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
     163Declare Function WriteConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
     164Declare Function FillConsoleOutputCharacter Lib "kernel32" Alias "FillConsoleOutputCharacterA" (hConsoleOutput As HANDLE, cCharacter As Char, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
     165Declare Function FillConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttribute As Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
     166Declare Function GetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, ByRef lpMode As DWord) As BOOL
     167Declare Function GetNumberOfConsoleInputEvents Lib "kernel32" (hConsoleInput As HANDLE, ByRef lpNumberOfEvents As DWord) As BOOL
     168Declare Function GetConsoleScreenBufferInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleScreenBufferInfo As CONSOLE_SCREEN_BUFFER_INFO) As BOOL
     169Declare Function GetLargestConsoleWindowSize Lib "kernel32" (hConsoleOutput As HANDLE) As DWord
     170Declare Function GetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
     171Declare Function GetNumberOfConsoleMouseButtons Lib "kernel32" (ByRef lpNumberOfMouseButtons As DWord) As BOOL
     172Declare Function SetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, dwMode As DWord) As BOOL
     173Declare Function SetConsoleActiveScreenBuffer Lib "kernel32" (hConsoleOutput As HANDLE) As BOOL
     174Declare Function FlushConsoleInputBuffer Lib "kernel32" (hConsoleInput As HANDLE) As BOOL
     175Declare Function SetConsoleScreenBufferSize Lib "kernel32" (hConsoleOutput As HANDLE, dwSize As DWord) As BOOL
     176Declare Function SetConsoleCursorPosition Lib "kernel32" (hConsoleOutput As HANDLE, dwCursorPosition As DWord) As BOOL
     177Declare Function SetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
     178Declare Function ScrollConsoleScreenBuffer Lib "kernel32" Alias "ScrollConsoleScreenBufferA" (hConsoleOutput As HANDLE, ByRef lpScrollRectangle As SMALL_RECT, lpClipRectangle As *SMALL_RECT, ByRef dwDestinationOrigin As COORD, lpFill As *CHAR_INFO) As BOOL
     179Declare Function SetConsoleWindowInfo Lib "kernel32" (hConsoleOutput As HANDLE, bAbsolute As BOOL, ByRef lpConsoleWindow As SMALL_RECT) As BOOL
     180Declare Function SetConsoleTextAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttributes As Word) As BOOL
     181Declare Function SetConsoleCtrlHandler Lib "kernel32" (HandlerRoutine As PHANDLER_ROUTINE, Add As BOOL) As BOOL
     182Declare Function GenerateConsoleCtrlEvent Lib "kernel32" (dwCtrlEvent As DWord, dwProcessGroupId As DWord) As BOOL
    22183Declare Function AllocConsole Lib "kernel32" () As BOOL
    23184Declare Function FreeConsole Lib "kernel32" () As BOOL
    24 
    25 Declare Function SetConsoleCursorPosition Lib "kernel32" (hConsoleOutput As HANDLE, dwCursorPosition As DWord) As BOOL
    26 
    27 Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (hConsoleInput As HANDLE, pBuffer As VoidPtr, nNumberOfCharsToRead As DWord, ByRef NumberOfCharsRead As DWord, pReserved As VoidPtr) As BOOL
    28 Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (hConsoleOutput As HANDLE, pBuffer As VoidPtr, nNumberOfCharsToWrite As DWord, ByRef NumberOfCharsWritten As DWord, pReserved As VoidPtr) As BOOL
    29 
    30 Declare Function CreateConsoleScreenBuffer Lib "kernel32" (dwDesiredAccess As DWord, dwShareMode As DWord, pSecurityAttributes As *SECURITY_ATTRIBUTES, dwFlags As DWord, pScreenBufferData As VoidPtr) As HANDLE
    31 
    32 Declare Function SetConsoleActiveScreenBuffer Lib "kernel32" (hConsoleOutput As HANDLE) As BOOL
     185Declare Function GetConsoleTitle Lib "kernel32" Alias "GetConsoleTitleA" (lpConsoleTitle As LPSTR, nSize As DWord) As DWord
     186Declare Function SetConsoleTitle Lib "kernel32" Alias "SetConsoleTitleA" (lpConsoleTitle As LPSTR) As BOOL
     187Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (hConsoleInput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToRead As DWord, ByRef lpNumberOfCharsRead As DWord, lpReserved As VoidPtr) As BOOL
     188Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (hConsoleOutput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToWrite As DWord, ByRef lpNumberOfCharsWritten As DWord, lpReserved As VoidPtr) As BOOL
     189
     190Const CONSOLE_TEXTMODE_BUFFER = 1
     191
     192Declare Function CreateConsoleScreenBuffer Lib "kernel32" (dwDesiredAccess As DWord, dwShareMode As DWord, lpSecurityAttributes As *SECURITY_ATTRIBUTES, dwFlags As DWord, lpScreenBufferData As VoidPtr) As HANDLE
     193Declare Function GetConsoleCP Lib "kernel32" () As DWord
     194Declare Function SetConsoleCP Lib "kernel32" (wCodePageID As DWord) As BOOL
     195Declare Function GetConsoleOutputCP Lib "kernel32" () As DWord
     196Declare Function SetConsoleOutputCP Lib "kernel32" (wCodePageID As DWord) As BOOL
     197
     198
    33199
    34200#endif '_INC_CONSOLE
Note: See TracChangeset for help on using the changeset viewer.