diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2017-07-18 20:50:38 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-07-18 21:10:49 +0900 |
commit | 6b5886c034800c46d25a02c8b91c2797ec5fb6d6 (patch) | |
tree | 1dedf6690a05413e88e6acd17685c17a88a9f028 /src | |
parent | 7727ad43afb57cb325439590a9a6bad94601a720 (diff) |
Adjust --no-clear option for repetitive relaunching
Related: https://gist.github.com/junegunn/4963bab6ace453f7f529d2d0e01b1d85
Close #974
Diffstat (limited to 'src')
-rw-r--r-- | src/terminal.go | 24 | ||||
-rw-r--r-- | src/tui/light.go | 20 |
2 files changed, 28 insertions, 16 deletions
diff --git a/src/terminal.go b/src/terminal.go index d4f4c854..2863f1a5 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -87,6 +87,7 @@ type Terminal struct { margin [4]sizeSpec strong tui.Attr bordered bool + cleanExit bool border tui.Window window tui.Window pborder tui.Window @@ -366,6 +367,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { history: opts.History, margin: opts.Margin, bordered: opts.Bordered, + cleanExit: opts.ClearOnExit, strong: strongAttr, cycle: opts.Cycle, header: header, @@ -1341,7 +1343,14 @@ func (t *Terminal) Loop() { }() } - exit := func(code int) { + exit := func(code int, printQuery bool) { + if !t.cleanExit && t.fullscreen && t.inlineInfo { + t.placeCursor() + } + t.tui.Close() + if printQuery { + t.printer(string(t.input)) + } if code <= exitNoMatch && t.history != nil { t.history.append(string(t.input)) } @@ -1389,11 +1398,11 @@ func (t *Terminal) Loop() { case reqRedraw: t.redraw() case reqClose: - t.tui.Close() if t.output() { - exit(exitOk) + exit(exitOk, false) + } else { + exit(exitNoMatch, false) } - exit(exitNoMatch) case reqPreviewDisplay: t.previewer.text = value.(string) t.previewer.lines = strings.Count(t.previewer.text, "\n") @@ -1402,12 +1411,9 @@ func (t *Terminal) Loop() { case reqPreviewRefresh: t.printPreview() case reqPrintQuery: - t.tui.Close() - t.printer(string(t.input)) - exit(exitOk) + exit(exitOk, true) case reqQuit: - t.tui.Close() - exit(exitInterrupt) + exit(exitInterrupt, false) } } t.placeCursor() diff --git a/src/tui/light.go b/src/tui/light.go index c19c8dca..5159aafe 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -182,10 +182,18 @@ func (r *LightRenderer) Init() { if r.fullscreen { r.smcup() } else { - r.csi("J") + // We assume that --no-clear is used for repetitive relaunching of fzf. + // So we do not clear the lower bottom of the screen. + if r.clearOnExit { + r.csi("J") + } y, x := r.findOffset() r.mouse = r.mouse && y >= 0 - if x > 0 { + // When --no-clear is used for repetitive relaunching, there is a small + // time frame between fzf processes where the user keystrokes are not + // captured by either of fzf process which can cause x offset to be + // increased and we're left with unwanted extra new line. + if x > 0 && r.clearOnExit { r.upOneLine = true r.makeSpace() } @@ -200,7 +208,7 @@ func (r *LightRenderer) Init() { r.csi(fmt.Sprintf("%dA", r.MaxY()-1)) r.csi("G") r.csi("K") - // r.csi("s") + r.csi("s") if !r.fullscreen && r.mouse { r.yoffset, _ = r.findOffset() } @@ -586,10 +594,8 @@ func (r *LightRenderer) Close() { } r.csi("J") } - } else if r.fullscreen { - r.csi("G") - } else { - r.move(r.height, 0) + } else if !r.fullscreen { + r.csi("u") } if r.mouse { r.csi("?1000l") |