Skip to content

Commit ecef75a

Browse files
committed
Fix webspace console on Windows
1 parent 3a9e2b4 commit ecef75a

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ VERSION := latest
55
default: bin/netsoc
66

77
bin/netsoc:
8-
CGO_ENALBED=0 go build $(GOFLAGS) -ldflags "-X github.com/netsoc/cli/version.Version=$(VERSION) $(GOLDFLAGS)" -o bin/netsoc ./cmd/netsoc
8+
CGO_ENABLED=0 go build $(GOFLAGS) -ldflags "-X github.com/netsoc/cli/version.Version=$(VERSION) $(GOLDFLAGS)" -o bin/netsoc ./cmd/netsoc
99

1010
dev:
1111
cat tools.go | sed -nr 's|^\t_ "(.+)"$$|\1|p' | xargs -tI % go get %

pkg/cmd/webspace/console.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func consoleRun(opts consoleOptions) error {
6060

6161
stdin := int(os.Stdin.Fd())
6262

63-
w, h, err := terminal.GetSize(stdin)
63+
w, h, err := util.GetTerminalSize(stdin)
6464
if err != nil {
6565
return fmt.Errorf("failed to get terminal size: %w", err)
6666
}

pkg/util/console_unix.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ func ResizeListener(sizeChan chan ConsoleSize, stop chan struct{}) {
3232
}
3333
}
3434
}
35+
36+
// GetTerminalSize returns the dimensions of a TTY (lines x cols)
37+
func GetTerminalSize(fd int) (int, int, error) {
38+
return terminal.GetSize(fd)
39+
}

pkg/util/console_windows.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,26 @@
22

33
package util
44

5-
// ResizeListener on windows does nothing
5+
//import (
6+
// "os"
7+
//
8+
// "github.com/TheTitanrain/w32"
9+
//)
10+
11+
// ResizeListener on Windows does nothing
612
func ResizeListener(sizeChan chan ConsoleSize, stop chan struct{}) {}
13+
14+
// TODO: do this properly
15+
// GetTerminalSize on Windows does nothing (Windows bad)
16+
func GetTerminalSize(fd int) (int, int, error) {
17+
//stdout := w32.HANDLE(os.Stdout.Fd())
18+
//info := w32.GetConsoleScreenBufferInfo(stdout)
19+
20+
//lines := info.SrWindow.Bottom - info.SrWindow.Top + 1
21+
//cols := info.SrWindow.Right - info.SrWindow.Left + 1
22+
//cols := info.DwSize.X
23+
//lines := info.DwSize.Y
24+
25+
//return int(cols), int(lines), nil
26+
return 80, 24, nil
27+
}

0 commit comments

Comments
 (0)