mirror of
https://github.com/wassname/pyreadline.git
synced 2026-06-27 16:10:38 +08:00
Changing console.py to be 64-bit compliant
This commit is contained in:
@@ -15,7 +15,7 @@ else:
|
||||
success = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
raise
|
||||
|
||||
if not success:
|
||||
raise ImportError(
|
||||
|
||||
@@ -27,6 +27,7 @@ from pyreadline.console.ansi import AnsiState,AnsiWriter
|
||||
try:
|
||||
from ctypes import *
|
||||
from _ctypes import call_function
|
||||
from ctypes.wintypes import HWND, LPCSTR, UINT, WORD, DWORD, BOOL#, TCHAR
|
||||
except ImportError:
|
||||
raise ImportError(u"You need ctypes to run this code")
|
||||
|
||||
@@ -192,14 +193,13 @@ class Console(object):
|
||||
self.hout = self.GetStdHandle(STD_OUTPUT_HANDLE)
|
||||
|
||||
self.hin = self.GetStdHandle(STD_INPUT_HANDLE)
|
||||
self.inmode = c_int(0)
|
||||
self.inmode = DWORD(0)
|
||||
self.GetConsoleMode(self.hin, byref(self.inmode))
|
||||
self.SetConsoleMode(self.hin, 0xf)
|
||||
info = CONSOLE_SCREEN_BUFFER_INFO()
|
||||
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
|
||||
self.attr = info.wAttributes
|
||||
self.saveattr = info.wAttributes # remember the initial colors
|
||||
|
||||
self.defaultstate = AnsiState()
|
||||
self.defaultstate.winattr = info.wAttributes
|
||||
self.ansiwriter = AnsiWriter(self.defaultstate)
|
||||
@@ -214,6 +214,7 @@ class Console(object):
|
||||
|
||||
self.pythondll = \
|
||||
CDLL(u'python%s%s' % (sys.version[0], sys.version[2]))
|
||||
self.pythondll.PyMem_Malloc.restype = c_size_t
|
||||
self.inputHookPtr = \
|
||||
c_int.from_address(addressof(self.pythondll.PyOS_InputHook)).value
|
||||
setattr(Console, u'PyMem_Malloc', self.pythondll.PyMem_Malloc)
|
||||
@@ -595,8 +596,66 @@ class Console(object):
|
||||
# add the functions from the dll to the class
|
||||
for func in funcs:
|
||||
setattr(Console, func, getattr(windll.kernel32, func))
|
||||
|
||||
windll.kernel32.SetConsoleTitleW.argtypes = [c_wchar_p]
|
||||
windll.kernel32.GetConsoleTitleW.argtypes = [c_wchar_p,c_short]
|
||||
windll.kernel32.GetConsoleTitleW.argtypes = [c_wchar_p, c_short]
|
||||
|
||||
if True:
|
||||
from ctypes.wintypes import HWND, LPCSTR, UINT, WORD, DWORD, BOOL#, TCHAR
|
||||
Console.AllocConsole.restype = BOOL
|
||||
Console.AllocConsole.argtypes = [] #void
|
||||
Console.CreateConsoleScreenBuffer.restype = HWND
|
||||
Console.CreateConsoleScreenBuffer.argtypes = [DWORD, DWORD, HWND, DWORD, HWND] #DWORD, DWORD, SECURITY_ATTRIBUTES*, DWORD, LPVOID
|
||||
Console.FillConsoleOutputAttribute.restype = BOOL
|
||||
Console.FillConsoleOutputAttribute.argtypes = [HWND, WORD, DWORD, c_int, HWND] #HANDLE, WORD, DWORD, COORD, LPDWORD
|
||||
Console.FillConsoleOutputCharacterW.restype = BOOL
|
||||
Console.FillConsoleOutputCharacterW.argtypes = [HWND, c_uint, DWORD, c_int, HWND] #HANDLE, TCHAR, DWORD, COORD, LPDWORD
|
||||
Console.FreeConsole.restype = BOOL
|
||||
Console.FreeConsole.argtypes = [] #void
|
||||
Console.GetConsoleCursorInfo.restype = BOOL
|
||||
Console.GetConsoleCursorInfo.argtypes = [HWND, HWND] #HWND, PCONSOLE_CURSOR_INFO
|
||||
Console.GetConsoleMode.restype = BOOL
|
||||
Console.GetConsoleMode.argtypes = [HWND, HWND] #HWND, LPDWORD
|
||||
Console.GetConsoleScreenBufferInfo.restype = BOOL
|
||||
Console.GetConsoleScreenBufferInfo.argtypes = [HWND, HWND] #HWND, PCONSOLE_SCREEN_BUFFER_INFO
|
||||
Console.GetConsoleTitleW.restype = DWORD
|
||||
Console.GetConsoleTitleW.argtypes = [c_wchar_p, c_short] #LPTSTR , DWORD
|
||||
Console.GetProcAddress.restype = HWND
|
||||
Console.GetProcAddress.argtypes = [HWND, c_char_p] #HMODULE , LPCSTR
|
||||
Console.GetStdHandle.restype = HWND
|
||||
Console.GetStdHandle.argtypes = [DWORD]
|
||||
Console.PeekConsoleInputW.restype = BOOL
|
||||
Console.PeekConsoleInputW.argtypes = [HWND, HWND, DWORD, HWND] #HANDLE, PINPUT_RECORD, DWORD, LPDWORD
|
||||
Console.ReadConsoleInputW.restype = BOOL
|
||||
Console.ReadConsoleInputW.argtypes = [HWND, HWND, DWORD, HWND] #HANDLE, PINPUT_RECORD, DWORD, LPDWORD
|
||||
Console.ScrollConsoleScreenBufferW.restype = BOOL
|
||||
Console.ScrollConsoleScreenBufferW.argtypes = [HWND, HWND, HWND, c_int, HWND] #HANDLE, SMALL_RECT*, SMALL_RECT*, COORD, LPDWORD
|
||||
Console.SetConsoleActiveScreenBuffer.restype = BOOL
|
||||
Console.SetConsoleActiveScreenBuffer.argtypes = [HWND] #HANDLE
|
||||
Console.SetConsoleCursorInfo.restype = BOOL
|
||||
Console.SetConsoleCursorInfo.argtypes = [HWND, HWND] #HANDLE, CONSOLE_CURSOR_INFO*
|
||||
Console.SetConsoleCursorPosition.restype = BOOL
|
||||
Console.SetConsoleCursorPosition.argtypes = [HWND, c_int] #HANDLE, COORD
|
||||
Console.SetConsoleMode.restype = BOOL
|
||||
Console.SetConsoleMode.argtypes = [HWND, DWORD] #HANDLE, DWORD
|
||||
Console.SetConsoleScreenBufferSize.restype = BOOL
|
||||
Console.SetConsoleScreenBufferSize.argtypes = [HWND, c_int] #HANDLE, COORD
|
||||
Console.SetConsoleTextAttribute.restype = BOOL
|
||||
Console.SetConsoleTextAttribute.argtypes = [HWND, c_short] #HANDLE, WORD
|
||||
Console.SetConsoleTitleW.restype = BOOL
|
||||
Console.SetConsoleTitleW.argtypes = [c_wchar_p] #LPCTSTR
|
||||
Console.SetConsoleTitleW.restype = BOOL
|
||||
Console.SetConsoleTitleW.argtypes = [c_wchar_p] #LPCTSTR
|
||||
Console.SetConsoleWindowInfo.restype = BOOL
|
||||
Console.SetConsoleWindowInfo.argtypes = [HWND, BOOL, HWND] #HANDLE, BOOL, SMALL_RECT*
|
||||
Console.WriteConsoleW.restype = BOOL
|
||||
Console.WriteConsoleW.argtypes = [HWND, HWND, DWORD, HWND, HWND] #HANDLE, VOID*, DWORD, LPDWORD, LPVOID
|
||||
Console.WriteConsoleOutputCharacterW.restype = BOOL
|
||||
Console.WriteConsoleOutputCharacterW.argtypes = [HWND, HWND, DWORD, c_int, HWND] #HANDLE, LPCTSTR, DWORD, COORD, LPDWORD
|
||||
Console.WriteFile.restype = BOOL
|
||||
Console.WriteFile.argtypes = [HWND, HWND, DWORD, HWND, HWND] #HANDLE, LPCVOID , DWORD, LPDWORD , LPOVERLAPPED
|
||||
|
||||
|
||||
|
||||
from event import Event
|
||||
|
||||
|
||||
Reference in New Issue
Block a user