cosmetics
This commit is contained in:
parent
1ddfffa843
commit
88339bf3f2
5 changed files with 9 additions and 9 deletions
2
main.go
2
main.go
|
|
@ -244,7 +244,7 @@ func main() {
|
||||||
}
|
}
|
||||||
url := fmt.Sprintf("%s://%s/#%s\n", scheme, domain, secret)
|
url := fmt.Sprintf("%s://%s/#%s\n", scheme, domain, secret)
|
||||||
readyMsg := "ready: " + url
|
readyMsg := "ready: " + url
|
||||||
qrCode, _ := GenerateQRCode(url, terminalSupportsColor(os.Stderr.Fd()))
|
qrCode, _ := GenerateQRCode(url, TerminalSupportsColor(os.Stderr.Fd()))
|
||||||
readyMsg += qrCode
|
readyMsg += qrCode
|
||||||
if !tls {
|
if !tls {
|
||||||
readyMsg += ("" +
|
readyMsg += ("" +
|
||||||
|
|
|
||||||
4
qr.go
4
qr.go
|
|
@ -33,7 +33,7 @@ func qrCodeToString(bits [][]bool, colorize bool) string {
|
||||||
s := ""
|
s := ""
|
||||||
for y := -1; y < len(bits); y += 2 {
|
for y := -1; y < len(bits); y += 2 {
|
||||||
if colorize {
|
if colorize {
|
||||||
s += terminalForegroundWhite + terminalBackgroundBlack
|
s += TerminalForegroundWhite + TerminalBackgroundBlack
|
||||||
}
|
}
|
||||||
for x := range bits[0] {
|
for x := range bits[0] {
|
||||||
upper := false
|
upper := false
|
||||||
|
|
@ -55,7 +55,7 @@ func qrCodeToString(bits [][]bool, colorize bool) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if colorize {
|
if colorize {
|
||||||
s += terminalForegroundReset + terminalBackgroundReset
|
s += TerminalForegroundReset + TerminalBackgroundReset
|
||||||
}
|
}
|
||||||
s += "\n"
|
s += "\n"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
terminalForegroundWhite string = "\033[37m"
|
TerminalForegroundWhite string = "\033[37m"
|
||||||
terminalForegroundReset string = "\033[39m"
|
TerminalForegroundReset string = "\033[39m"
|
||||||
terminalBackgroundBlack string = "\033[40m"
|
TerminalBackgroundBlack string = "\033[40m"
|
||||||
terminalBackgroundReset string = "\033[49m"
|
TerminalBackgroundReset string = "\033[49m"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,6 @@ package main
|
||||||
// #include <unistd.h>
|
// #include <unistd.h>
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
func terminalSupportsColor(fd uintptr) bool {
|
func TerminalSupportsColor(fd uintptr) bool {
|
||||||
return C.isatty(C.int(fd)) != 0
|
return C.isatty(C.int(fd)) != 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ var (
|
||||||
setConsoleModeProc = kernel32DLL.NewProc("SetConsoleMode")
|
setConsoleModeProc = kernel32DLL.NewProc("SetConsoleMode")
|
||||||
)
|
)
|
||||||
|
|
||||||
func terminalSupportsColor(fd uintptr) bool {
|
func TerminalSupportsColor(fd uintptr) bool {
|
||||||
r, _, _ := setConsoleModeProc.Call(fd, uintptr(enableProcessedOuput|
|
r, _, _ := setConsoleModeProc.Call(fd, uintptr(enableProcessedOuput|
|
||||||
enableWrapAtEolOutput|enableVirtualTerminalProcessing))
|
enableWrapAtEolOutput|enableVirtualTerminalProcessing))
|
||||||
return r != 0
|
return r != 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue