Skip to content
Myr

Add --no-hscroll option to disable horizontal scroll

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

Close #193

authored by Junegunn Choi · committed by Junegunn Choi · parent 3e1e75f · Browse files · 4 files+50 added−20 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+50 added−20 removed

  • other:+50 added−20 removed

4 files+50 added−20 removed

modified:man/man1/fzf.1+3 added
87 unmodified lines
88.TP89.B "--reverse"90Reverse orientation91.TP92.B "--no-hscroll"93Disable horizontal scroll94.TP95.BI "--prompt=" "STR"96Input prompt (default: '> ')97.SS Scripting98.TP
108 unmodified lines
modified:src/util/util.go+8 added
17 unmodified lines
18 }19 return max20}2122// Max32 returns the smallest 32-bit integer23func Min32(first int32, second int32) int32 {24 if first <= second {25 return first26 }27 return second28}2930// Max32 returns the largest 32-bit integer31func Max32(first int32, second int32) int32 {32 if first > second {33 return first
46 unmodified lines
modified:src/options.go+7 added
36 unmodified lines
37 +c, --no-color Disable colors38 +2, --no-256 Disable 256-color39 --black Use black background40 --reverse Reverse orientation41 --no-hscroll Disable horizontal scroll42 --prompt=STR Input prompt (default: '> ')4344 Scripting45 -q, --query=STR Start the finder with the given query
47 unmodified lines
93 Color bool94 Color256 bool95 Black bool96 Reverse bool97 Hscroll bool98 Prompt string99 Query string100 Select1 bool101 Exit0 bool
20 unmodified lines
122 Color: true,123 Color256: strings.Contains(os.Getenv("TERM"), "256"),124 Black: false,125 Reverse: false,126 Hscroll: true,127 Prompt: "> ",128 Query: "",129 Select1: false,130 Exit0: false,
175 unmodified lines
306 case "--reverse":307 opts.Reverse = true308 case "--no-reverse":309 opts.Reverse = false310 case "--hscroll":311 opts.Hscroll = true312 case "--no-hscroll":313 opts.Hscroll = false314 case "-1", "--select-1":315 opts.Select1 = true316 case "+1", "--no-select-1":317 opts.Select1 = false
67 unmodified lines
modified:src/terminal.go+32 added-20 removed
20 unmodified lines
21// Terminal represents terminal input/output22type Terminal struct {23 prompt string24 reverse bool25 hscroll bool26 cx int27 cy int28 offset int29 yanked []rune
58 unmodified lines
88 input := []rune(opts.Query)89 return &Terminal{90 prompt: opts.Prompt,91 reverse: opts.Reverse,92 hscroll: opts.Hscroll,93 cx: len(input),94 cy: 0,95 offset: 0,96 yanked: []rune{},
222 unmodified lines
319 }320 return runes, trimmed321}322321func (*Terminal) printHighlighted(item *Item, bold bool, col1 int, col2 int, current bool) {323func (t *Terminal) printHighlighted(item *Item, bold bool, col1 int, col2 int, current bool) {324 var maxe int32325 for _, offset := range item.offsets {326 if offset[1] > maxe {327 maxe = offset[1]
5 unmodified lines
333 offsets := item.colorOffsets(col2, bold, current)334 maxWidth := C.MaxX() - 3335 fullWidth := displayWidth(text)336 if fullWidth > maxWidth {335 // Stri..336 matchEndWidth := displayWidth(text[:maxe])337 if matchEndWidth <= maxWidth-2 {338 text, _ = trimRight(text, maxWidth-2)339 text = append(text, []rune("..")...)340 } else {337 if t.hscroll {338 // Stri..339 matchEndWidth := displayWidth(text[:maxe])340 if matchEndWidth <= maxWidth-2 {341 text, _ = trimRight(text, maxWidth-2)342 text = append(text, []rune("..")...)343 } else {344 // Stri..342 if matchEndWidth < fullWidth-2 {343 text = append(text[:maxe], []rune("..")...)345 if matchEndWidth < fullWidth-2 {346 text = append(text[:maxe], []rune("..")...)347 }348 // ..ri..349 var diff int32350 text, diff = trimLeft(text, maxWidth-2)351352 // Transform offsets353 for idx, offset := range offsets {354 b, e := offset.offset[0], offset.offset[1]355 b += 2 - diff356 e += 2 - diff357 b = util.Max32(b, 2)358 offsets[idx].offset[0] = b359 offsets[idx].offset[1] = util.Max32(b, e)360 }361 text = append([]rune(".."), text...)362 }345 // ..ri..346 var diff int32347 text, diff = trimLeft(text, maxWidth-2)363 } else {364 text, _ = trimRight(text, maxWidth-2)365 text = append(text, []rune("..")...)366349 // Transform offsets367 for idx, offset := range offsets {351 b, e := offset.offset[0], offset.offset[1]352 b += 2 - diff353 e += 2 - diff354 b = util.Max32(b, 2)355 offsets[idx].offset[0] = b356 offsets[idx].offset[1] = util.Max32(b, e)368 offsets[idx].offset[0] = util.Min32(offset.offset[0], int32(maxWidth-2))369 offsets[idx].offset[1] = util.Min32(offset.offset[1], int32(maxWidth))370 }358 text = append([]rune(".."), text...)371 }372 }373374 var index int32
387 unmodified lines