summaryrefslogtreecommitdiff
path: root/src/reader.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.go')
-rw-r--r--src/reader.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/reader.go b/src/reader.go
index 8fa864e7..6092087e 100644
--- a/src/reader.go
+++ b/src/reader.go
@@ -93,11 +93,26 @@ func (r *Reader) restart(command string, environ []string) {
r.fin(success)
}
+func (r *Reader) readChannel(inputChan chan string) bool {
+ for {
+ item, more := <-inputChan
+ if !more {
+ break
+ }
+ if r.pusher([]byte(item)) {
+ atomic.StoreInt32(&r.event, int32(EvtReadNew))
+ }
+ }
+ return true
+}
+
// ReadSource reads data from the default command or from standard input
-func (r *Reader) ReadSource(root string, opts walkerOpts, ignores []string) {
+func (r *Reader) ReadSource(inputChan chan string, root string, opts walkerOpts, ignores []string) {
r.startEventPoller()
var success bool
- if util.IsTty() {
+ if inputChan != nil {
+ success = r.readChannel(inputChan)
+ } else if util.IsTty() {
cmd := os.Getenv("FZF_DEFAULT_COMMAND")
if len(cmd) == 0 {
success = r.readFiles(root, opts, ignores)