Add --no-clear option
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent 337cdbb · Browse files · 4 files·+30 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+30 added−10 removed
- other:+30 added−10 removed
Provenance
- Commit
53348fe- Tree
f1fd030- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
337cdbb
4 files changed+30 added−10 removed
modified:man/man1/fzf.1+6 added
337 unmodified lines338 .TP339 .B "--print0"340 Print output delimited by ASCII NUL characters instead of newline characters341 .TP342+.B "--no-clear"343+Do not clear finder interface on exit. If fzf was started in full screen mode,344+it will not switch back to the original screen, so you'll have to manually run345+\fBtput rmcup\fR to return. This option can be used to avoid flickering of the346+screen when your application needs to start fzf multiple times in order.347+.TP348 .B "--sync"349 Synchronous search for multi-staged filtering. If specified, fzf will launch350 ncurses finder only after the input stream is complete.351 226 unmodified linesmodified:src/tui/light.go+16 added-8 removed
72 unmodified lines73 type LightRenderer struct {74 theme *ColorTheme75 mouse bool76 forceBlack bool77+ clearOnExit bool78 prevDownTime time.Time79 clickY []int80 ttyin *os.File81 buffer []byte24 unmodified lines106 tabstop int107 bg Color108 }109 109-func NewLightRenderer(theme *ColorTheme, forceBlack bool, mouse bool, tabstop int, maxHeightFunc func(int) int) Renderer {110+func NewLightRenderer(theme *ColorTheme, forceBlack bool, mouse bool, tabstop int, clearOnExit bool, maxHeightFunc func(int) int) Renderer {111 r := LightRenderer{112 theme: theme,113 forceBlack: forceBlack,114 mouse: mouse,115+ clearOnExit: clearOnExit,116 ttyin: openTtyIn(),117 yoffset: 0,118 tabstop: tabstop,119 fullscreen: false,452 unmodified lines572 }573 574 func (r *LightRenderer) Close() {575 // r.csi("u")576+ if r.clearOnExit {574- if r.fullscreen {575- r.rmcup()576- } else {577- r.origin()578- if r.upOneLine {579- r.csi("A")577+ if r.fullscreen {578+ r.rmcup()579+ } else {580+ r.origin()581+ if r.upOneLine {582+ r.csi("A")583+ }584+ r.csi("J")585 }586+ } else if r.fullscreen {581- r.csi("J")587+ r.csi("G")588+ } else {589+ r.move(r.height, 0)590 }591 if r.mouse {592 r.csi("?1000l")593 }292 unmodified linesmodified:src/options.go+6 added
184 unmodified lines185 HeaderLines int186 Margin [4]sizeSpec187 Bordered bool188 Tabstop int189+ ClearOnExit bool190 Version bool191 }192 193 func defaultOptions() *Options {40 unmodified lines234 Header: make([]string, 0),235 HeaderLines: 0,236 Margin: defaultMargin(),237 Tabstop: 8,238+ ClearOnExit: true,239 Version: false}240 }241 242 func help(code int) {857 unmodified lines1100 opts.Margin = parseMargin(1101 nextString(allArgs, &i, "margin required (TRBL / TB,RL / T,RL,B / T,R,B,L)"))1102 case "--tabstop":1103 opts.Tabstop = nextInt(allArgs, &i, "tab stop required")1104+ case "--clear":1105+ opts.ClearOnExit = true1106+ case "--no-clear":1107+ opts.ClearOnExit = false1108 case "--version":1109 opts.Version = true1110 default:1111 if match, value := optString(arg, "--algo="); match {131 unmodified linesmodified:src/terminal.go+2 added-2 removed
314 unmodified lines315 effectiveMinHeight += 2316 }317 return util.Min(termHeight, util.Max(maxHeight, effectiveMinHeight))318 }319- renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, maxHeightFunc)319+ renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, opts.ClearOnExit, maxHeightFunc)320 } else if tui.HasFullscreenRenderer() {321 renderer = tui.NewFullscreenRenderer(opts.Theme, opts.Black, opts.Mouse)322 } else {323- renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop,323+ renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, opts.ClearOnExit,324 func(h int) int { return h })325 }326 wordRubout := "[^[:alnum:]][[:alnum:]]"327 wordNext := "[[:alnum:]][^[:alnum:]]|(.$)"1460 unmodified lines