mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-04 10:57:50 +08:00
improve sys
This commit is contained in:
parent
e70c214c6a
commit
0a53c7f17b
|
@ -330,8 +330,7 @@ func renderNavColumn(nc *navColumn, w, h int) *buffer {
|
|||
// refresh redraws the line editor. The dot is passed as an index into text;
|
||||
// the corresponding position will be calculated.
|
||||
func (w *writer) refresh(es *editorState) error {
|
||||
winsize := sys.GetWinsize(int(w.file.Fd()))
|
||||
width, height := int(winsize.Col), int(winsize.Row)
|
||||
height, width := sys.GetWinsize(int(w.file.Fd()))
|
||||
|
||||
var bufLine, bufMode, bufTips, bufListing, buf *buffer
|
||||
// bufLine
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
echo godef >> /tmp/xiaq
|
||||
go tool cgo -godefs "$1" > "$2"
|
|
@ -1,6 +1,5 @@
|
|||
package sys
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
// +build generate
|
||||
|
||||
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"
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Winsize wraps the C winsize struct and represents the size of a terminal.
|
||||
type Winsize C.struct_winsize
|
||||
|
||||
// GetWinsize queries the size of the terminal referenced by the given file
|
||||
// descriptor.
|
||||
func GetWinsize(fd int) Winsize {
|
||||
var ws Winsize
|
||||
Ioctl(fd, syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws)))
|
||||
return ws
|
||||
func GetWinsize(fd int) (row, col int) {
|
||||
var r, c C.int
|
||||
C.getwinsize(C.int(fd), &r, &c)
|
||||
return int(r), int(c)
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs winsize.go
|
||||
|
||||
package sys
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type Winsize struct {
|
||||
Row uint16
|
||||
Col uint16
|
||||
Xpixel uint16
|
||||
Ypixel uint16
|
||||
}
|
||||
|
||||
func GetWinsize(fd int) Winsize {
|
||||
var ws Winsize
|
||||
Ioctl(fd, syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws)))
|
||||
return ws
|
||||
}
|
Loading…
Reference in New Issue
Block a user