MCPcopy
hub / github.com/junegunn/fzf / Run

Function Run

src/core.go:55–644  ·  view source on GitHub ↗

Run starts fzf

(opts *Options)

Source from the content-addressed store, hash-verified

53
54// Run starts fzf
55func Run(opts *Options) (int, error) {
56 if opts.Filter == nil {
57 if opts.useTmux() {
58 return runTmux(os.Args, opts)
59 }
60 if opts.useZellij() {
61 return runZellij(os.Args, opts)
62 }
63
64 if needWinpty(opts) {
65 return runWinpty(os.Args, opts)
66 }
67 }
68
69 if err := postProcessOptions(opts); err != nil {
70 return ExitError, err
71 }
72
73 defer util.RunAtExitFuncs()
74
75 // Output channel given
76 if opts.Output != nil {
77 opts.Printer = func(str string) {
78 opts.Output <- str
79 }
80 }
81
82 sort := opts.Sort > 0
83 sortCriteria = opts.Criteria
84
85 // Event channel
86 eventBox := util.NewEventBox()
87
88 // ANSI code processor
89 ansiProcessor := func(data []byte) (util.Chars, *[]ansiOffset) {
90 return util.ToChars(data), nil
91 }
92
93 var lineAnsiState, prevLineAnsiState *ansiState
94 if opts.Ansi {
95 ansiProcessor = func(data []byte) (util.Chars, *[]ansiOffset) {
96 prevLineAnsiState = lineAnsiState
97 trimmed, offsets, newState := extractColor(byteString(data), lineAnsiState, nil)
98 lineAnsiState = newState
99
100 // Full line background is found. Add a special marker.
101 if offsets != nil && newState != nil && len(*offsets) > 0 && newState.lbg >= 0 {
102 marker := (*offsets)[len(*offsets)-1]
103 marker.offset[0] = marker.offset[1]
104 marker.color.bg = newState.lbg
105 marker.color.attr = marker.color.attr | tui.FullBg
106 newOffsets := append(*offsets, marker)
107 offsets = &newOffsets
108
109 // Reset the full-line background color
110 lineAnsiState.lbg = -1
111 }
112 return util.ToChars(stringBytes(trimmed)), offsets

Callers

nothing calls this directly

Calls 15

environMethod · 0.95
PushMethod · 0.95
ReadSourceMethod · 0.95
IndexMethod · 0.95
UnwatchMethod · 0.95
WaitForMethod · 0.95
SnapshotMethod · 0.95
ClearMethod · 0.95
scanMethod · 0.95
LoopMethod · 0.95
StopMethod · 0.95

Tested by

no test coverage detected