diff options
Diffstat (limited to 'src/c_fuzz.go')
-rw-r--r-- | src/c_fuzz.go | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/c_fuzz.go b/src/c_fuzz.go index fb230e1..5dd7880 100644 --- a/src/c_fuzz.go +++ b/src/c_fuzz.go @@ -91,25 +91,37 @@ func c_fuzz_find_item(str_out string, litems *ItemsList) (*ItemsNode) { return nil } -func c_fuzz(data *HardData, ui *HardUI) { - if err := ui.s.Suspend(); err != nil { - c_error_mode("screen", err, ui) - return +func c_fuzz(data *HardData, ui *HardUI) (bool) { + if ui.s != nil { + if err := ui.s.Suspend(); err != nil { + c_error_mode("screen", err, ui) + return false + } } - search := exec.Command("fzf") + search := exec.Command(data.opts.Fuzzer) stdin, stdout := c_fuzz_init_pipes(ui, search) if stdin == nil || stdout == nil { - return + return false } if err := search.Start(); err != nil { - c_error_mode("fzf", err, ui) - c_resume_or_die(ui) - return + if ui.s != nil { + c_error_mode("fuzzy finder", err, ui) + c_resume_or_die(ui) + return false + } else { + c_die("fuzzy finder", err) + } } go func() { defer stdin.Close() for ptr := data.litems.head; ptr != nil; ptr = ptr.next { if ptr.is_dir() == true { + // } else if data.litems.curr.Dirs != nil && + // data.folds[data.litems.curr.Dirs] == nil { + // e_fold_dir(data, data.litems.curr) + // } else { + // e_unfold_dir(data, data.litems.curr) + // } continue } io.WriteString(stdin, ptr.path()[1:] + ptr.Host.Name + "\n") @@ -117,17 +129,25 @@ func c_fuzz(data *HardData, ui *HardUI) { }() output, err := io.ReadAll(stdout) if err != nil { - ui.s.Fini() + if ui.s != nil { + ui.s.Fini() + } c_die("search stdout", err) } str_out := strings.TrimSuffix(string(output), "\n") - c_resume_or_die(ui) + if ui.s != nil { + c_resume_or_die(ui) + } if len(str_out) > 0 { item := c_fuzz_find_item(str_out, data.litems) if item == nil { - c_error_mode("item not found", nil, ui) - return + if ui.s != nil { + c_error_mode("item not found", nil, ui) + } + return false } data.litems.curr = item + return true } + return false } |