mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-04 10:57:50 +08:00
23 lines
421 B
Go
23 lines
421 B
Go
package sys
|
|
|
|
/*
|
|
#include <termios.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
void getwinsize(int fd, int *row, int *col) {
|
|
struct winsize wsz;
|
|
ioctl(fd, TIOCGWINSZ, &wsz);
|
|
*row = wsz.ws_row;
|
|
*col = wsz.ws_col;
|
|
}
|
|
*/
|
|
import "C"
|
|
|
|
// GetWinsize queries the size of the terminal referenced by the given file
|
|
// descriptor.
|
|
func GetWinsize(fd int) (row, col int) {
|
|
var r, c C.int
|
|
C.getwinsize(C.int(fd), &r, &c)
|
|
return int(r), int(c)
|
|
}
|