console.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package winapi
  2. import (
  3. "unsafe"
  4. "golang.org/x/sys/windows"
  5. )
  6. const PSEUDOCONSOLE_INHERIT_CURSOR = 0x1
  7. // CreatePseudoConsole creates a windows pseudo console.
  8. func CreatePseudoConsole(size windows.Coord, hInput windows.Handle, hOutput windows.Handle, dwFlags uint32, hpcon *windows.Handle) error {
  9. // We need this wrapper as the function takes a COORD struct and not a pointer to one, so we need to cast to something beforehand.
  10. return createPseudoConsole(*((*uint32)(unsafe.Pointer(&size))), hInput, hOutput, 0, hpcon)
  11. }
  12. // ResizePseudoConsole resizes the internal buffers of the pseudo console to the width and height specified in `size`.
  13. func ResizePseudoConsole(hpcon windows.Handle, size windows.Coord) error {
  14. // We need this wrapper as the function takes a COORD struct and not a pointer to one, so we need to cast to something beforehand.
  15. return resizePseudoConsole(hpcon, *((*uint32)(unsafe.Pointer(&size))))
  16. }
  17. // HRESULT WINAPI CreatePseudoConsole(
  18. // _In_ COORD size,
  19. // _In_ HANDLE hInput,
  20. // _In_ HANDLE hOutput,
  21. // _In_ DWORD dwFlags,
  22. // _Out_ HPCON* phPC
  23. // );
  24. //
  25. //sys createPseudoConsole(size uint32, hInput windows.Handle, hOutput windows.Handle, dwFlags uint32, hpcon *windows.Handle) (hr error) = kernel32.CreatePseudoConsole
  26. // void WINAPI ClosePseudoConsole(
  27. // _In_ HPCON hPC
  28. // );
  29. //
  30. //sys ClosePseudoConsole(hpc windows.Handle) = kernel32.ClosePseudoConsole
  31. // HRESULT WINAPI ResizePseudoConsole(
  32. // _In_ HPCON hPC ,
  33. // _In_ COORD size
  34. // );
  35. //
  36. //sys resizePseudoConsole(hPc windows.Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole