For Development HEAD DRAFTSearch (procedure/syntax/module):

12.39 os.windows - Windowsのサポート

Module: os.windows

This module is only available on Windows-native Gauche, and provides Windows-specific procedures. You can check gauche.os.windows feature with cond-expand macro (see 機能条件式) to conditionalize windows-specific code.

(cond-expand
  [gauche.os.windows
   (use os.windows)
   ... Windows-specific code ...]
  [else
   ... Unix code ...])

Currently there aren’t enough procedures provided here, but eventually we want to support simple scripting on Windows.

Unless otherwise noted, when Windows API returns an error value, a <system-error> condition is thrown.


12.39.1 Windows dialogs

Currenly we only have MessageBox API.

Function: sys-message-box window message :optional caption flags

{os.windows} Calls Windows MessageBox API. The window argument should be a handle for a window, or #f; at the moment we don’t provide any API that retrieves window handles, so you should always pass #f here. The message argument takes a string for the content of the message box. Optional caption argument takes a string to be used in the window title.

The flags argument is an integer; it should be logior of values from one or more of the following groups. See the Windows reference manual for the details.

Buttons

MB_ABORTRETRYIGNORE, MB_CANCELTRYCONTINUE, MB_HELP, MB_OK (default), MB_OKCANCEL, MB_RETRYCANCEL, MB_YESNO, MB_YESNOCANCEL

Icon

Default is no icon. Possible values: MB_ICONEXCLAMATION, MB_ICONWARNING, MB_ICONINFORMATION, MB_ICONASTERISK, MB_ICONQUESTION, MB_ICONSTOP, MB_ICONERROR, MB_ICONHAND

Default button

MB_DEFBUTTON1 (default), MB_DEFBUTTON2, MB_DEFBUTTON3, MB_DEFBUTTON4

Modality

MB_APPLMODAL (default), MB_SYSTEMMODAL, MB_TASKMODAL

Other options

MB_DEFAULT_DESKTOP_ONLY, MB_RIGHT, MB_RTLREADING, MB_SETFOREGROUND, MB_TOPMOST, MB_SERVICE_NOTIFICATION

Return value is one of the following integer constants, indicating which button is pressed: IDABORT, IDCANCEL, IDCONTINUE, IDIGNORE, IDNO, IDOK, IDRETRY, IDTRYAGAIN, or IDYES


12.39.2 Windows console API

Most of these procedures corresponds to Windows Console API one-to-one. See the Windows reference for the detail description of what each API does.

Attaching and detaching

Function: sys-alloc-console
Function: sys-free-console

[Windows] {os.windows} Calls AllocConsole and FreeConsole, respectively.

Function: sys-generate-console-ctrl-event event pgid

[Windows] {os.windows} Calls GenerateConsoleCtrlEvent. For event argument, the constants CTRL_C_EVENT and CTRL_BREAK_EVENT are available.

Constant: CTRL_C_EVENT
Constant: CTRL_BREAK_EVENT

[Windows] {os.windows} Constants to be used for event argument of sys-generate-console above.

Console codepage

Function: sys-get-console-cp
Function: sys-get-console-output-cp
Function: sys-set-console-cp codepage
Function: sys-set-console-output-cp codepage

[Windows] {os.windows} Call GetConsoleCP, GetConsoleOutputCP, SetConsoleCP, and SetConsoleOutputCP, respectively. Setter procedures returns an undefined value.

Console cursor

Function: sys-get-console-cursor-info handle
Function: sys-set-console-cursor-info handle size visible

[Windows] {os.windows} Call GetConsoleCursorInfo and SetConsoleCursorInfo, respectively. Handle is a handle to the console screen buffer. The getter returns two values, size (the integer percentage of the character cell that is filled by the cursor, between 1 and 100), and a boolean visible flag. The setter takes a handle to the console screen buffer, integer size percentage, and boolean visible flag. It returns an undefined value.

Function: sys-set-console-cursor-position handle x y

[Windows] {os.windows} Calls SetConsoleCursorPosition. Handle is a handle to the console screen buffer. X and y are cursor coordinates in character position, where (0, 0) is the upper-left corner of the console screen buffer. It returns an undefined value.

To get the current cursor position, you can use sys-get-console-screen-buffer-info.

Console mode

Function: sys-get-console-mode handle
Function: sys-set-console-mode handle mode

[Windows] {os.windows}

Constant: ENABLE_LINE_INPUT
Constant: ENABLE_ECHO_INPUT
Constant: ENABLE_PROCESSED_INPUT
Constant: ENABLE_WINDOW_INPUT
Constant: ENABLE_MOUSE_INPUT
Constant: ENABLE_PROCESSED_OUTPUT
Constant: ENABLE_WRAP_AT_EOL_OUTPUT

[Windows] {os.windows}

Screen buffer

Function: sys-create-console-screen-buffer desired-access share-mode inheritable

[Windows] {os.windows}

Constant: GENERIC_READ
Constant: GENERIC_WRITE

[Windows] {os.windows}

Constant: FILE_SHARE_READ
Constant: FILE_SHARE_WRITE

[Windows] {os.windows}

Function: sys-set-console-active-screen-buffer handle

[Windows] {os.windows}

Function: sys-scroll-console-screen-buffer handle scroll-rectangle clip-rectangle x y fill

[Windows] {os.windows}

Class: <win:console-screen-buffer-info>

[Windows] {os.windows}

Instance Variable of <win:console-screen-buffer-info>: size.x
Instance Variable of <win:console-screen-buffer-info>: size.y
Instance Variable of <win:console-screen-buffer-info>: cursor-position.x
Instance Variable of <win:console-screen-buffer-info>: cursor-position.y
Instance Variable of <win:console-screen-buffer-info>: attributes
Instance Variable of <win:console-screen-buffer-info>: window.left
Instance Variable of <win:console-screen-buffer-info>: window.top
Instance Variable of <win:console-screen-buffer-info>: window.right
Instance Variable of <win:console-screen-buffer-info>: window.bottom
Instance Variable of <win:console-screen-buffer-info>: maximum-window-size.x
Instance Variable of <win:console-screen-buffer-info>: maximum-window-size.y
Constant: FOREGROUND_BLUE
Constant: FOREGROUND_GREEN
Constant: FOREGROUND_RED
Constant: FOREGROUND_INTENSITY
Constant: BACKGROUND_BLUE
Constant: BACKGROUND_GREEN
Constant: BACKGROUND_RED
Constant: BACKGROUND_INTENSITY

[Windows] {os.windows}

Function: sys-get-console-screen-buffer-info handle

[Windows] {os.windows}

Function: sys-get-largest-console-window-size handle

[Windows] {os.windows}

Function: sys-set-screen-buffer-size handle x y

[Windows] {os.windows}

Console input/output

Class: <win:input-record>

[Windows] {os.windows}

Instance Variable of <win:input-record>: event-type
Instance Variable of <win:input-record>: key.down
Instance Variable of <win:input-record>: key.repeat-count
Instance Variable of <win:input-record>: key.virtual-key-code
Instance Variable of <win:input-record>: key.virtual-scan-code
Instance Variable of <win:input-record>: key.unicode-char
Instance Variable of <win:input-record>: key.ascii-char
Instance Variable of <win:input-record>: key.control-key-state
Instance Variable of <win:input-record>: mouse.x
Instance Variable of <win:input-record>: mouse.y
Instance Variable of <win:input-record>: mouse.button-state
Instance Variable of <win:input-record>: mouse.control-key-state
Instance Variable of <win:input-record>: mouse.event-flags
Instance Variable of <win:input-record>: window-buffer-size.x
Instance Variable of <win:input-record>: window-buffer-size.y
Instance Variable of <win:input-record>: menu.command-id
Instance Variable of <win:input-record>: focus.set-focus
Function: sys-get-number-of-console-input-events handle

[Windows] {os.windows}

Function: sys-get-number-of-console-mouse-buttons

[Windows] {os.windows}

Function: sys-peek-console-input handle
Function: sys-read-console-input handle

[Windows] {os.windows}

Function: sys-read-console handle buf

[Windows] {os.windows}

Function: sys-read-console-output handle buf w h x y region

[Windows] {os.windows}

Function: sys-read-console-output-attribute handle buf x y

[Windows] {os.windows}

Function: sys-read-console-output-character handle len x y

[Windows] {os.windows}

Function: sys-set-console-text-attribute handle attr

[Windows] {os.windows}

Function: sys-set-console-window-info handle absolute window

[Windows] {os.windows}

Function: sys-write-console handle string

[Windows] {os.windows}

Function: sys-write-console-output-character handle string x y

[Windows] {os.windows}

Function: sys-fill-console-output-character handle char len x y

[Windows] {os.windows}

Function: sys-fill-console-output-attribute handle attr len x y

[Windows] {os.windows}

Function: sys-flush-console-input-buffer handle

[Windows] {os.windows}

Function: sys-get-console-title

[Windows] {os.windows}

Function: sys-set-console-title string

[Windows] {os.windows}

Standard handles

Function: sys-get-std-handle which
Function: sys-set-std-handle which handle

[Windows] {os.windows}

Constant: STD_INPUT_HANDLE
Constant: STD_OUTPUT_HANDLE
Constant: STD_ERROR_HANDLE

[Windows] {os.windows}



For Development HEAD DRAFTSearch (procedure/syntax/module):
DRAFT