Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
create secman iostrams tty_size functions, update modules
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Mar 9, 2022
1 parent c9fd569 commit 9de9380
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ require (
github.com/muesli/reflow v0.3.0
github.com/spf13/cobra v1.3.0
github.com/tidwall/gjson v1.14.0
golang.org/x/sys v0.0.0-20211210111614-af8b64212486
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
)

require (
Expand All @@ -31,7 +33,5 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
)
23 changes: 23 additions & 0 deletions ios/tty_size.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//go:build !windows
// +build !windows

package ios

import (
"os"

"golang.org/x/term"
)

// ttySize measures the size of the controlling terminal for the current process
func ttySize() (int, int, error) {
f, err := os.Open("/dev/tty")

if err != nil {
return -1, -1, err
}

defer f.Close()

return term.GetSize(int(f.Fd()))
}
19 changes: 19 additions & 0 deletions ios/tty_size_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ios

import (
"os"

"golang.org/x/term"
)

func ttySize() (int, int, error) {
f, err := os.Open("CONOUT$")

if err != nil {
return -1, -1, err
}

defer f.Close()

return term.GetSize(int(f.Fd()))
}

0 comments on commit 9de9380

Please sign in to comment.