(outputCh chan []byte, output io.Writer)
| 23 | } |
| 24 | |
| 25 | func AdaptOutputChToStream(outputCh chan []byte, output io.Writer) error { |
| 26 | drain := false |
| 27 | defer func() { |
| 28 | if drain { |
| 29 | utilfn.DrainChannelSafe(outputCh, "AdaptOutputChToStream") |
| 30 | } |
| 31 | }() |
| 32 | for msg := range outputCh { |
| 33 | if _, err := output.Write(msg); err != nil { |
| 34 | drain = true |
| 35 | return fmt.Errorf("error writing to output (AdaptOutputChToStream): %w", err) |
| 36 | } |
| 37 | // write trailing newline |
| 38 | if _, err := output.Write([]byte{'\n'}); err != nil { |
| 39 | drain = true |
| 40 | return fmt.Errorf("error writing trailing newline to output (AdaptOutputChToStream): %w", err) |
| 41 | } |
| 42 | } |
| 43 | return nil |
| 44 | } |
| 45 | |
| 46 | func AdaptMsgChToPty(outputCh chan []byte, oscEsc string, output io.Writer) error { |
| 47 | if len(oscEsc) != 5 { |
no test coverage detected