only draw ui when the output pauses in shell-pipe
This commit is contained in:
1 parent
6193885a55
commit
8229d972b9
1 file changed
+27
-8
@@ -335,15 +335,34 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
||||
app.ui.cmdPrefix = ">"
|
||||
|
||||
reader := bufio.NewReader(out)
|
||||
for {
|
||||
b, err := reader.ReadByte()
|
||||
if err == io.EOF {
|
||||
break
|
||||
bytes := make(chan byte, 1000)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
b, err := reader.ReadByte()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
bytes <- b
|
||||
}
|
||||
app.cmdOutBuf = append(app.cmdOutBuf, b)
|
||||
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
|
||||
if b == '\n' || b == '\r' {
|
||||
app.cmdOutBuf = nil
|
||||
close(bytes)
|
||||
}()
|
||||
|
||||
loop:
|
||||
for {
|
||||
select {
|
||||
case b, ok := <-bytes:
|
||||
switch {
|
||||
case !ok:
|
||||
break loop
|
||||
case b == '\n' || b == '\r':
|
||||
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
|
||||
app.cmdOutBuf = nil
|
||||
default:
|
||||
app.cmdOutBuf = append(app.cmdOutBuf, b)
|
||||
}
|
||||
default:
|
||||
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user