-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. 修复windows不兼容问题 Signed-off-by: 孙林耀 <[email protected]>
- Loading branch information
1 parent
753c8bc
commit 8e7c2e3
Showing
6 changed files
with
43 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.3.2 | ||
0.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build darwin || linux | ||
|
||
package term | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
func terminalWidth() (int, error) { | ||
type window struct { | ||
Row uint16 | ||
Col uint16 | ||
Xpixel uint16 | ||
Ypixel uint16 | ||
} | ||
w := new(window) | ||
tio := syscall.TIOCGWINSZ | ||
res, _, err := syscall.Syscall(syscall.SYS_IOCTL, | ||
uintptr(syscall.Stdin), | ||
uintptr(tio), | ||
uintptr(unsafe.Pointer(w)), | ||
) | ||
if int(res) == -1 { | ||
return 0, err | ||
} | ||
return int(w.Col), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package term | ||
|
||
func terminalWidth() (int, error) { | ||
return 50, nil | ||
} |