Exemple #1
0
func terminalWidth() (int, error) {
	screenBufInfo := w32.GetConsoleScreenBufferInfo(w32.HANDLE(syscall.Stdout))
	if screenBufInfo == nil {
		return 79, nil
	}
	return int(screenBufInfo.DwSize.X) - 1, nil
}
Exemple #2
0
func SetClipboardText(text string) {
	if !w32.OpenClipboard(w32.HWND(0)) {
		return
	}
	defer w32.CloseClipboard()

	w32.EmptyClipboard()

	tuftlen := uint32(len(text)*2 + 1)
	cptrglob := w32.GlobalAlloc(w32.GMEM_MOVEABLE, tuftlen)

	cptr := unsafe.Pointer(w32.GlobalLock(cptrglob))
	tptr := unsafe.Pointer(syscall.StringToUTF16Ptr(text))
	w32.MoveMemory(cptr, tptr, tuftlen)
	w32.GlobalUnlock(cptrglob)

	w32.SetClipboardData(w32.CF_UNICODETEXT, w32.HANDLE(cptrglob))
}