winpty

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE uintptr = 0x20016
	STILL_ACTIVE                        uint32  = 259
)
View Source
const (
	S_OK uintptr = 0
)

Variables

View Source
var (
	ErrConPtyUnsupported = errors.New("ConPty is not available on this version of Windows")
)

Functions

func CreateConsoleProcessAttachedToPTY

func CreateConsoleProcessAttachedToPTY(hpc windows.Handle, commandLine string, envs []string) (*windows.ProcessInformation, error)

func CreateEnvBlock

func CreateEnvBlock(envv []string) ([]uint16, error)

CreateEnvBlock converts an array of environment strings into the representation required by CreateProcess: a sequence of NUL terminated strings followed by a nil. Last bytes are two UCS-2 NULs, or four NUL bytes. If any string contains a NUL, it returns (nil, EINVAL).

func EnableVirtualTerminalProcessing

func EnableVirtualTerminalProcessing() error

func SetRawMode

func SetRawMode() (inHandle, outHandle windows.Handle)

func Win32ClosePseudoConsole

func Win32ClosePseudoConsole(hPc windows.Handle)

func Win32CreatePseudoConsole

func Win32CreatePseudoConsole(coord *COORD, hIn, hOut windows.Handle) (windows.Handle, error)

func Win32ResizePseudoConsole

func Win32ResizePseudoConsole(hPc windows.Handle, coord *COORD) error

func WinCloseHandles

func WinCloseHandles(handles ...windows.Handle) error

This will only return the first error.

func WinIsConPtyAvailable

func WinIsConPtyAvailable() bool

func WinIsDataAvailable

func WinIsDataAvailable(handle windows.Handle) (bytesAvailable int, err error)

Types

type COORD

type COORD struct {
	X, Y int
}

func WinConsoleScreenSize

func WinConsoleScreenSize() (size *COORD, err error)

func (*COORD) Pack

func (c *COORD) Pack() uintptr

type ConPty

type ConPty struct {
	// contains filtered or unexported fields
}

func Start

func Start(commandLine string, coord *COORD, envs []string) (*ConPty, error)

Start a new process specified in `commandLine` and attach a pseudo console using the Windows ConPty API. If ConPty is not available, ErrConPtyUnsupported will be returned. On successful return, an instance of ConPty is returned. You must call Close() on this to release any resources associated with the process. To get the exit code of the process, you can call Wait().

func (*ConPty) Close

func (cpty *ConPty) Close() error

Close all open handles and terminate the process.

func (*ConPty) Read

func (cpty *ConPty) Read(p []byte) (int, error)

func (*ConPty) Resize

func (cpty *ConPty) Resize(width, height int) error

func (*ConPty) Wait

func (cpty *ConPty) Wait(ctx context.Context) (uint32, error)

Wait for the process to exit and return the exit code. If context is canceled, Wait() will return STILL_ACTIVE and an error indicating the context was canceled.

func (*ConPty) Write

func (cpty *ConPty) Write(p []byte) (int, error)

type HandleWrapper

type HandleWrapper struct {
	// contains filtered or unexported fields
}

func (*HandleWrapper) Close

func (h *HandleWrapper) Close() error

func (*HandleWrapper) GetHandle

func (h *HandleWrapper) GetHandle() windows.Handle

func (*HandleWrapper) Read

func (h *HandleWrapper) Read(p []byte) (int, error)

func (*HandleWrapper) Write

func (h *HandleWrapper) Write(p []byte) (int, error)

type StartupInfoEx

type StartupInfoEx struct {
	// contains filtered or unexported fields
}

func GetStartupInfoExForPTY

func GetStartupInfoExForPTY(hpc windows.Handle) (*StartupInfoEx, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL