Fix panic with vi in busybox
Following bugs are fixed: 1.Handle out of bound cursor movements: vi in busybox sets cursor to (999,999) expecting it to be set to right, bottom correctly. 2.Correctly determine redirected non-terminal file. Signed-off-by: Sachin Joshi <sachin_jayant_joshi@hotmail.com>
This commit is contained in:
parent
27c2a55648
commit
7fc3c0ba26
1 changed files with 14 additions and 0 deletions
|
@ -265,6 +265,10 @@ func StdStreams() (stdOut io.Writer, stdErr io.Writer, stdIn io.ReadCloser) {
|
||||||
func GetHandleInfo(in interface{}) (uintptr, bool) {
|
func GetHandleInfo(in interface{}) (uintptr, bool) {
|
||||||
var inFd uintptr
|
var inFd uintptr
|
||||||
var isTerminalIn bool
|
var isTerminalIn bool
|
||||||
|
if file, ok := in.(*os.File); ok {
|
||||||
|
inFd = file.Fd()
|
||||||
|
isTerminalIn = IsTerminal(inFd)
|
||||||
|
}
|
||||||
if tr, ok := in.(*terminalReader); ok {
|
if tr, ok := in.(*terminalReader); ok {
|
||||||
if file, ok := tr.wrappedReader.(*os.File); ok {
|
if file, ok := tr.wrappedReader.(*os.File); ok {
|
||||||
inFd = file.Fd()
|
inFd = file.Fd()
|
||||||
|
@ -678,14 +682,24 @@ func (term *WindowsTerminal) HandleOutputCommand(fd uintptr, command []byte) (n
|
||||||
// [line;columnf
|
// [line;columnf
|
||||||
// Moves the cursor to the specified position (coordinates).
|
// Moves the cursor to the specified position (coordinates).
|
||||||
// If you do not specify a position, the cursor moves to the home position at the upper-left corner of the screen (line 0, column 0).
|
// If you do not specify a position, the cursor moves to the home position at the upper-left corner of the screen (line 0, column 0).
|
||||||
|
screenBufferInfo, err := GetConsoleScreenBufferInfo(uintptr(handle))
|
||||||
|
if err != nil {
|
||||||
|
return len(command), err
|
||||||
|
}
|
||||||
line, err := parseInt16OrDefault(parsedCommand.getParam(0), 1)
|
line, err := parseInt16OrDefault(parsedCommand.getParam(0), 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return len(command), err
|
return len(command), err
|
||||||
}
|
}
|
||||||
|
if line > int16(screenBufferInfo.Window.Bottom) {
|
||||||
|
line = int16(screenBufferInfo.Window.Bottom)
|
||||||
|
}
|
||||||
column, err := parseInt16OrDefault(parsedCommand.getParam(1), 1)
|
column, err := parseInt16OrDefault(parsedCommand.getParam(1), 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return len(command), err
|
return len(command), err
|
||||||
}
|
}
|
||||||
|
if column > int16(screenBufferInfo.Window.Right) {
|
||||||
|
column = int16(screenBufferInfo.Window.Right)
|
||||||
|
}
|
||||||
// The numbers are not 0 based, but 1 based
|
// The numbers are not 0 based, but 1 based
|
||||||
r, err = setConsoleCursorPosition(uintptr(handle), false, int16(column-1), int16(line-1))
|
r, err = setConsoleCursorPosition(uintptr(handle), false, int16(column-1), int16(line-1))
|
||||||
if !r {
|
if !r {
|
||||||
|
|
Loading…
Reference in a new issue