lazy drawing in shell-pipe commands
This commit is contained in:
parent
ce5c5845e7
commit
654a14ea7d
14
app.go
14
app.go
@ -445,17 +445,25 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
app.ui.cmdPrefix = ">"
|
app.ui.cmdPrefix = ">"
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
eol := false
|
||||||
reader := bufio.NewReader(out)
|
reader := bufio.NewReader(out)
|
||||||
for {
|
for {
|
||||||
b, err := reader.ReadByte()
|
b, err := reader.ReadByte()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
app.cmdOutBuf = append(app.cmdOutBuf, b)
|
if eol {
|
||||||
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
|
eol = false
|
||||||
if b == '\n' || b == '\r' {
|
|
||||||
app.cmdOutBuf = nil
|
app.cmdOutBuf = nil
|
||||||
}
|
}
|
||||||
|
app.cmdOutBuf = append(app.cmdOutBuf, b)
|
||||||
|
if b == '\n' || b == '\r' {
|
||||||
|
eol = true
|
||||||
|
}
|
||||||
|
if reader.Buffered() > 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cmd.Wait(); err != nil {
|
if err := cmd.Wait(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user