mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 22:27:13 +09:00
If stdout is a pipe, output to the pipe
If you run micro as `micro | cat` for example, micro will disallow you from saving the file, and when you quit the buffer, the contents will be sent to the pipe. This allows one to use micro as part of an interactive unix pipeline. Closes #1524
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -34,6 +35,9 @@ var (
|
||||
// FakeCursor is used to disable the terminal cursor and have micro
|
||||
// draw its own (enabled for windows consoles where the cursor is slow)
|
||||
FakeCursor = false
|
||||
|
||||
// Stdout is a buffer that is written to stdout when micro closes
|
||||
Stdout *bytes.Buffer
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -46,6 +50,7 @@ func init() {
|
||||
if runtime.GOOS == "windows" {
|
||||
FakeCursor = true
|
||||
}
|
||||
Stdout = new(bytes.Buffer)
|
||||
}
|
||||
|
||||
// SliceEnd returns a byte slice where the index is a rune index
|
||||
|
||||
Reference in New Issue
Block a user