cosmetics

This commit is contained in:
Unrud 2018-09-30 00:26:33 +02:00
parent 1ddfffa843
commit 88339bf3f2
5 changed files with 9 additions and 9 deletions

View file

@ -244,7 +244,7 @@ func main() {
}
url := fmt.Sprintf("%s://%s/#%s\n", scheme, domain, secret)
readyMsg := "ready: " + url
qrCode, _ := GenerateQRCode(url, terminalSupportsColor(os.Stderr.Fd()))
qrCode, _ := GenerateQRCode(url, TerminalSupportsColor(os.Stderr.Fd()))
readyMsg += qrCode
if !tls {
readyMsg += ("" +

4
qr.go
View file

@ -33,7 +33,7 @@ func qrCodeToString(bits [][]bool, colorize bool) string {
s := ""
for y := -1; y < len(bits); y += 2 {
if colorize {
s += terminalForegroundWhite + terminalBackgroundBlack
s += TerminalForegroundWhite + TerminalBackgroundBlack
}
for x := range bits[0] {
upper := false
@ -55,7 +55,7 @@ func qrCodeToString(bits [][]bool, colorize bool) string {
}
}
if colorize {
s += terminalForegroundReset + terminalBackgroundReset
s += TerminalForegroundReset + TerminalBackgroundReset
}
s += "\n"
}

View file

@ -20,8 +20,8 @@
package main
const (
terminalForegroundWhite string = "\033[37m"
terminalForegroundReset string = "\033[39m"
terminalBackgroundBlack string = "\033[40m"
terminalBackgroundReset string = "\033[49m"
TerminalForegroundWhite string = "\033[37m"
TerminalForegroundReset string = "\033[39m"
TerminalBackgroundBlack string = "\033[40m"
TerminalBackgroundReset string = "\033[49m"
)

View file

@ -24,6 +24,6 @@ package main
// #include <unistd.h>
import "C"
func terminalSupportsColor(fd uintptr) bool {
func TerminalSupportsColor(fd uintptr) bool {
return C.isatty(C.int(fd)) != 0
}

View file

@ -32,7 +32,7 @@ var (
setConsoleModeProc = kernel32DLL.NewProc("SetConsoleMode")
)
func terminalSupportsColor(fd uintptr) bool {
func TerminalSupportsColor(fd uintptr) bool {
r, _, _ := setConsoleModeProc.Call(fd, uintptr(enableProcessedOuput|
enableWrapAtEolOutput|enableVirtualTerminalProcessing))
return r != 0