mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
- Add package/installer.nsi (Full/Server/Client) and toolchain.nsi
- Embed icon.ico (rounded corners) into homed.exe/waiter.exe via .syso
- GUI auto-launches homed.exe from parent dir (Windows only)
- GUI fallback connections.json from app resource dir
- Add initconfig command for config.db seeding
- Replace waiter rawmode* with raw_{unix,windows,other}.go
- Fix .gitignore: /homed instead of homed, add login.json
- Update icon.svg with rounded rect, new mascot.svg
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
var (
|
|
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
|
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
|
procSetConsoleMode = kernel32.NewProc("SetConsoleMode")
|
|
procGetStdHandle = kernel32.NewProc("GetStdHandle")
|
|
)
|
|
|
|
const (
|
|
stdInputHandle = ^uint32(9) + 1 // -10
|
|
enableVirtualTerminalProcessing = 0x0004
|
|
enableProcessedOutput = 0x0001
|
|
enableWrapAtEOLOutput = 0x0002
|
|
disableNewlineAutoReturn = 0x0008
|
|
)
|
|
|
|
func setRawMode(fd int) (func(), error) {
|
|
if fd == 0 {
|
|
fd = int(os.Stdin.Fd())
|
|
}
|
|
if !isTerminal(fd) {
|
|
return func() {}, nil
|
|
}
|
|
// Enable virtual terminal processing for ANSI escape sequences on Windows
|
|
h, _, _ := procGetStdHandle.Call(uintptr(^uint32(10) + 1)) // STD_OUTPUT_HANDLE = -11
|
|
if h != 0 && h != ^uintptr(0) {
|
|
var mode uint32
|
|
procGetConsoleMode.Call(h, uintptr(unsafe.Pointer(&mode)))
|
|
newMode := mode | enableVirtualTerminalProcessing | enableProcessedOutput | enableWrapAtEOLOutput
|
|
procSetConsoleMode.Call(h, uintptr(newMode))
|
|
}
|
|
return func() {}, nil
|
|
}
|
|
|
|
func isTerminal(fd int) bool {
|
|
var mode uint32
|
|
h, _, _ := procGetStdHandle.Call(uintptr(^uint32(10) + 1)) // STD_OUTPUT_HANDLE = -11
|
|
if h == 0 || h == ^uintptr(0) {
|
|
return false
|
|
}
|
|
ret, _, _ := procGetConsoleMode.Call(h, uintptr(unsafe.Pointer(&mode)))
|
|
return ret != 0
|
|
}
|