mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
fix: set title
This commit is contained in:
parent
84115a7316
commit
ba0e471a19
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
|
|
||||||
@ -12,6 +13,25 @@ import (
|
|||||||
"github.com/FloatTech/ZeroBot-Plugin/kanban"
|
"github.com/FloatTech/ZeroBot-Plugin/kanban"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
//go:linkname golang.org/x/sys/windows.modkernel32 modkernel32
|
||||||
|
modkernel32 *windows.LazyDLL
|
||||||
|
procSetConsoleTitle = modkernel32.NewProc("SetConsoleTitle")
|
||||||
|
)
|
||||||
|
|
||||||
|
func setConsoleTitle(title string) (err error) {
|
||||||
|
var p0 *uint16
|
||||||
|
p0, err = syscall.UTF16PtrFromString(title)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r1, _, e1 := syscall.Syscall(procSetConsoleTitle.Addr(), 1, uintptr(unsafe.Pointer(p0)), 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
stdin := windows.Handle(os.Stdin.Fd())
|
stdin := windows.Handle(os.Stdin.Fd())
|
||||||
|
|
||||||
@ -54,7 +74,7 @@ func init() {
|
|||||||
// windows 带颜色 log 自定义格式
|
// windows 带颜色 log 自定义格式
|
||||||
logrus.SetFormatter(&LogFormat{})
|
logrus.SetFormatter(&LogFormat{})
|
||||||
|
|
||||||
err = windows.SetConsoleTitle("ZeroBot-Blugin " + kanban.Version + " " + kanban.Copyright)
|
err = setConsoleTitle("ZeroBot-Blugin " + kanban.Version + " " + kanban.Copyright)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user