2323import os
2424import sys
2525
26- import ctypes . util
26+ import ctypes
2727import types
2828from dataclasses import dataclass
2929from ctypes .wintypes import (
3737 WCHAR ,
3838 SHORT ,
3939)
40- from ctypes import POINTER , Union
40+ from ctypes import Structure , POINTER , Union
4141from typing import TYPE_CHECKING
4242
4343from _colorize import ANSIColors
@@ -723,25 +723,28 @@ def repaint(self) -> None:
723723
724724
725725# Windows interop
726- @ctypes .util .struct
727- class CONSOLE_SCREEN_BUFFER_INFO :
728- dwSize : _COORD
729- dwCursorPosition : _COORD
730- wAttributes : WORD
731- srWindow : SMALL_RECT
732- dwMaximumWindowSize : _COORD
726+ class CONSOLE_SCREEN_BUFFER_INFO (Structure ):
727+ _fields_ = [
728+ ("dwSize" , _COORD ),
729+ ("dwCursorPosition" , _COORD ),
730+ ("wAttributes" , WORD ),
731+ ("srWindow" , SMALL_RECT ),
732+ ("dwMaximumWindowSize" , _COORD ),
733+ ]
733734
734735
735- @ctypes .util .struct
736- class CONSOLE_CURSOR_INFO :
737- dwSize : DWORD
738- bVisible : BOOL
736+ class CONSOLE_CURSOR_INFO (Structure ):
737+ _fields_ = [
738+ ("dwSize" , DWORD ),
739+ ("bVisible" , BOOL ),
740+ ]
739741
740742
741- @ctypes .util .struct
742- class CHAR_INFO :
743- UnicodeChar : WCHAR
744- Attributes : WORD
743+ class CHAR_INFO (Structure ):
744+ _fields_ = [
745+ ("UnicodeChar" , WCHAR ),
746+ ("Attributes" , WORD ),
747+ ]
745748
746749
747750class Char (Union ):
@@ -751,19 +754,19 @@ class Char(Union):
751754 ]
752755
753756
754- @ctypes .util .struct
755- class KeyEvent :
756- bKeyDown : BOOL
757- wRepeatCount : WORD
758- wVirtualKeyCode : WORD
759- wVirtualScanCode : WORD
760- uChar : Char
761- dwControlKeyState : DWORD
757+ class KeyEvent (ctypes .Structure ):
758+ _fields_ = [
759+ ("bKeyDown" , BOOL ),
760+ ("wRepeatCount" , WORD ),
761+ ("wVirtualKeyCode" , WORD ),
762+ ("wVirtualScanCode" , WORD ),
763+ ("uChar" , Char ),
764+ ("dwControlKeyState" , DWORD ),
765+ ]
762766
763767
764- @ctypes .util .struct
765- class WindowsBufferSizeEvent :
766- dwSize : _COORD
768+ class WindowsBufferSizeEvent (ctypes .Structure ):
769+ _fields_ = [("dwSize" , _COORD )]
767770
768771
769772class ConsoleEvent (ctypes .Union ):
@@ -773,10 +776,8 @@ class ConsoleEvent(ctypes.Union):
773776 ]
774777
775778
776- @ctypes .util .struct
777- class INPUT_RECORD :
778- EventType : WORD
779- Event : ConsoleEvent
779+ class INPUT_RECORD (Structure ):
780+ _fields_ = [("EventType" , WORD ), ("Event" , ConsoleEvent )]
780781
781782
782783KEY_EVENT = 0x01
0 commit comments