winpty

package module
v0.0.0-...-bff8ba1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

Go-WinPTY

GoLang Wrapper for WinPTY.dll

Small wrapper around the WinPTY DLL.

This, for example, should allow a Go app to serve up a Windows "cmd" or "powershell" prompt via WebSocket to xterm.js

Currently requires winpty.dll and winpty-agent.exe to be in the same directory as the compiled Go executable.

These are best obtained from the GitHub releases page, in the msvc2015 package.

The error handling needs a bit of work currently though!

Documentation

Index

Constants

View Source
const (
	WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN            = 1
	WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION = 0x8
)

Variables

This section is empty.

Functions

func GetErrorMessage

func GetErrorMessage(ptr uintptr) string

func UTF16PtrFromStringArray

func UTF16PtrFromStringArray(s []string) (*uint16, error)

func UTF16PtrToString

func UTF16PtrToString(p *uint16) string

Types

type Options

type Options struct {
	// DLLPrefix is the path to winpty.dll and winpty-agent.exe
	DLLPrefix string

	// AppName sets the title of the console
	AppName string

	// Command is the full command to launch
	Command string

	// Dir sets the current working directory for the command
	Dir string

	// Env sets the environment variables. Use the format VAR=VAL.
	Env []string

	// Flags to pass to agent config creation
	Flags uint32

	// Initial size for Columns and Rows
	InitialCols uint32
	InitialRows uint32
}

type WinPTY

type WinPTY struct {
	StdIn  *os.File
	StdOut *os.File
	// contains filtered or unexported fields
}

func Open

func Open(dllPrefix, cmd string) (*WinPTY, error)

accepts path to command to execute, then arguments. returns WinPTY object pointer, error. remember to call Close on WinPTY object when done.

func OpenDefault

func OpenDefault(dllPrefix, cmd string) (*WinPTY, error)

the same as open, but uses defaults for Env & Dir

func OpenWithOptions

func OpenWithOptions(options Options) (*WinPTY, error)

func (*WinPTY) Close

func (obj *WinPTY) Close()

func (*WinPTY) GetProcHandle

func (obj *WinPTY) GetProcHandle() uintptr

func (*WinPTY) SetSize

func (obj *WinPTY) SetSize(ws_col, ws_row uint32)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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