Skip to content

Commit

Permalink
Fix windows build using github.com/kopoli/go-terminal-size
Browse files Browse the repository at this point in the history
https: //pkg.go.dev/github.com/kopoli/go-terminal-size
Co-Authored-By: Refaktor <1375005+refaktor@users.noreply.github.com>
  • Loading branch information
stefanb and refaktor committed Jul 23, 2024
1 parent 8675fba commit fb304ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
github.com/gobwas/ws v1.4.0
github.com/gorilla/sessions v1.2.2
github.com/jinzhu/copier v0.4.0
github.com/kopoli/go-terminal-size v0.0.0-20170219200355-5c97524c8b54
github.com/labstack/echo v3.3.10+incompatible
github.com/lib/pq v1.10.9
github.com/mattn/go-runewidth v0.0.15
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kopoli/go-terminal-size v0.0.0-20170219200355-5c97524c8b54 h1:0SMHxjkLKNawqUjjnMlCtEdj6uWZjv0+qDZ3F6GOADI=
github.com/kopoli/go-terminal-size v0.0.0-20170219200355-5c97524c8b54/go.mod h1:bm7MVZZvHQBfqHG5X59jrRE/3ak6HvK+/Zb6aZhLR2s=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down
22 changes: 7 additions & 15 deletions util/getcolumns_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@
package util

import (
"syscall"
"unsafe"
tsize "github.com/kopoli/go-terminal-size"
)

type winSize struct {
row, col uint16
xpixel, ypixel uint16
}

func GetTerminalColumns() int {
var ws winSize
// TODO -- MOVE THIS OUTSIDE ... in case of native use this, in case of browser check how we can get the numer of columns
ok, _, _ := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdout),
syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws)))
if int(ok) < 0 {
return 50
var s tsize.Size

s, err := tsize.GetSize()
if err == nil {
return s.Width
}
columns := int(ws.col)
return columns
return 50
}

0 comments on commit fb304ee

Please sign in to comment.