Set terminal title
This commit is contained in:
parent
1e46a174aa
commit
390827829a
4 changed files with 28 additions and 6 deletions
4
main.go
4
main.go
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 Unrud <unrud@outlook.com>
|
* Copyright (c) 2018-2019 Unrud <unrud@outlook.com>
|
||||||
*
|
*
|
||||||
* This file is part of Remote-Touchpad.
|
* This file is part of Remote-Touchpad.
|
||||||
*
|
*
|
||||||
|
|
@ -46,6 +46,7 @@ const (
|
||||||
challengeLength int = 8
|
challengeLength int = 8
|
||||||
defaultBind string = ":0"
|
defaultBind string = ":0"
|
||||||
version string = "0.0.13"
|
version string = "0.0.13"
|
||||||
|
pretty_app_name string = "Remote Touchpad"
|
||||||
)
|
)
|
||||||
|
|
||||||
func processCommand(backend Backend, command string) error {
|
func processCommand(backend Backend, command string) error {
|
||||||
|
|
@ -139,6 +140,7 @@ func secureRandBase64(length int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
TerminalSetTitle(pretty_app_name)
|
||||||
var bind, certFile, keyFile, secret string
|
var bind, certFile, keyFile, secret string
|
||||||
var showVersion bool
|
var showVersion bool
|
||||||
parseFlags := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
parseFlags := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// +build !windows
|
// +build !windows
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 Unrud <unrud@outlook.com>
|
* Copyright (c) 2018-2019 Unrud <unrud@outlook.com>
|
||||||
*
|
*
|
||||||
* This file is part of Remote-Touchpad.
|
* This file is part of Remote-Touchpad.
|
||||||
*
|
*
|
||||||
|
|
@ -23,7 +23,17 @@ package main
|
||||||
|
|
||||||
// #include <unistd.h>
|
// #include <unistd.h>
|
||||||
import "C"
|
import "C"
|
||||||
|
import "os"
|
||||||
|
|
||||||
func TerminalSupportsColor(fd uintptr) bool {
|
func TerminalSupportsColor(fd uintptr) bool {
|
||||||
return C.isatty(C.int(fd)) != 0
|
return C.isatty(C.int(fd)) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TerminalSetTitle(title string) bool {
|
||||||
|
if C.isatty(C.int(os.Stdout.Fd())) != 0 {
|
||||||
|
os.Stdout.Write([]byte("\x1b]2;" + title + "\x07"))
|
||||||
|
os.Stdout.Sync()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 Unrud <unrud@outlook.com>
|
* Copyright (c) 2018-2019 Unrud <unrud@outlook.com>
|
||||||
*
|
*
|
||||||
* This file is part of Remote-Touchpad.
|
* This file is part of Remote-Touchpad.
|
||||||
*
|
*
|
||||||
|
|
@ -19,7 +19,10 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "syscall"
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
enableProcessedOuput uint32 = 0x1
|
enableProcessedOuput uint32 = 0x1
|
||||||
|
|
@ -28,8 +31,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
|
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
|
||||||
setConsoleModeProc = kernel32DLL.NewProc("SetConsoleMode")
|
setConsoleModeProc = kernel32DLL.NewProc("SetConsoleMode")
|
||||||
|
setConsoleTitleProc = kernel32DLL.NewProc("SetConsoleTitleW")
|
||||||
)
|
)
|
||||||
|
|
||||||
func TerminalSupportsColor(fd uintptr) bool {
|
func TerminalSupportsColor(fd uintptr) bool {
|
||||||
|
|
@ -37,3 +41,9 @@ func TerminalSupportsColor(fd uintptr) bool {
|
||||||
enableWrapAtEolOutput|enableVirtualTerminalProcessing))
|
enableWrapAtEolOutput|enableVirtualTerminalProcessing))
|
||||||
return r != 0
|
return r != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TerminalSetTitle(title string) bool {
|
||||||
|
r, _, _ := setConsoleTitleProc.Call(
|
||||||
|
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))))
|
||||||
|
return r != 0
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue