Skip to content
Myr

Use alternate screen only when the value of height is 100%

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Do not automatically decide to use alternate screen when the value of height exceeds the height of the terminal. # Use alternate screen fzf fzf --height 100% fzf --no-height # Still use current screen fzf --height 10000

authored by Junegunn Choi · committed by Junegunn Choi · parent 53348fe · Browse files · 2 files+14 added−21 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−21 removed

  • other:+14 added−21 removed

2 files+14 added−21 removed

modified:src/tui/light.go+5 added-14 removed
105 unmodified lines
106 tabstop int107 bg Color108}109110func NewLightRenderer(theme *ColorTheme, forceBlack bool, mouse bool, tabstop int, clearOnExit bool, maxHeightFunc func(int) int) Renderer {110func NewLightRenderer(theme *ColorTheme, forceBlack bool, mouse bool, tabstop int, clearOnExit bool, fullscreen 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,119 fullscreen: fullscreen,120 upOneLine: false,121 maxHeightFunc: maxHeightFunc}122 return &r123}
51 unmodified lines
175 errorExit(err.Error())176 }177 r.origState = origState178 terminal.MakeRaw(fd)179 terminalHeight, capHeight := r.updateTerminalSize()180 if capHeight == terminalHeight {181 r.fullscreen = true182 r.height = terminalHeight183 }179 r.updateTerminalSize()180 initTheme(r.theme, r.defaultTheme(), r.forceBlack)181182 if r.fullscreen {183 r.smcup()
53 unmodified lines
237 }238 return atoi(env, defaultValue)239}240245func (r *LightRenderer) updateTerminalSize() (int, int) {241func (r *LightRenderer) updateTerminalSize() {242 width, height, err := terminal.GetSize(r.fd())243 if err == nil {244 r.width = width249 if r.fullscreen {250 r.height = height251 } else {252 r.height = r.maxHeightFunc(height)245 r.height = r.maxHeightFunc(height)253 }246 } else {247 r.width = getEnv("COLUMNS", defaultWidth)248 r.height = r.maxHeightFunc(getEnv("LINES", defaultHeight))249 }258 return height, r.height250}251252func (r *LightRenderer) getch(nonblock bool) (int, bool) {253 b := make([]byte, 1)
623 unmodified lines
modified:src/terminal.go+9 added-7 removed
293 unmodified lines
294 if !opts.Bold {295 strongAttr = tui.AttrRegular296 }297 var renderer tui.Renderer298 if opts.Height.size > 0 {298 if opts.Height.size == 0 || opts.Height.percent && opts.Height.size == 100 {299 if tui.HasFullscreenRenderer() {300 renderer = tui.NewFullscreenRenderer(opts.Theme, opts.Black, opts.Mouse)301 } else {302 renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, opts.ClearOnExit,303 true, func(h int) int { return h })304 }305 } else {306 maxHeightFunc := func(termHeight int) int {307 var maxHeight int308 if opts.Height.percent {309 maxHeight = util.Max(int(opts.Height.size*float64(termHeight)/100.0), opts.MinHeight)
12 unmodified lines
322 effectiveMinHeight += 2323 }324 return util.Min(termHeight, util.Max(maxHeight, effectiveMinHeight))325 }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, opts.ClearOnExit,324 func(h int) int { return h })326 renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, opts.ClearOnExit, false, maxHeightFunc)327 }328 wordRubout := "[^[:alnum:]][[:alnum:]]"329 wordNext := "[[:alnum:]][^[:alnum:]]|(.$)"330 if opts.FileWord {
1459 unmodified lines