diff options
| author | Hiroki Konishi <relastle@gmail.com> | 2020-02-17 10:19:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-17 10:19:03 +0900 |
| commit | 2a60edcd52df0c913ea8a93efec4027b9a758a5b (patch) | |
| tree | 6ff74c8dd9996ad0f5a621c0175ccad18c2b55b4 /src/terminal.go | |
| parent | d61ac32d7b5f1ba0c98c5fff3ec33f76c865e96e (diff) | |
| download | fzf-2a60edcd52df0c913ea8a93efec4027b9a758a5b.tar.gz | |
Make pointer and multi-select marker customizable (#1844)
Add --pointer and --marker option which can provide additional context to the user
Diffstat (limited to 'src/terminal.go')
| -rw-r--r-- | src/terminal.go | 158 |
1 files changed, 85 insertions, 73 deletions
diff --git a/src/terminal.go b/src/terminal.go index e9101a52..bc975546 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -59,72 +59,78 @@ var emptyLine = itemLine{} // Terminal represents terminal input/output type Terminal struct { - initDelay time.Duration - infoStyle infoStyle - spinner []string - prompt string - promptLen int - queryLen [2]int - layout layoutType - fullscreen bool - hscroll bool - hscrollOff int - wordRubout string - wordNext string - cx int - cy int - offset int - xoffset int - yanked []rune - input []rune - multi int - sort bool - toggleSort bool - delimiter Delimiter - expect map[int]string - keymap map[int][]action - pressed string - printQuery bool - history *History - cycle bool - header []string - header0 []string - ansi bool - tabstop int - margin [4]sizeSpec - strong tui.Attr - unicode bool - bordered bool - cleanExit bool - border tui.Window - window tui.Window - pborder tui.Window - pwindow tui.Window - count int - progress int - reading bool - failed *string - jumping jumpMode - jumpLabels string - printer func(string) - printsep string - merger *Merger - selected map[int32]selectedItem - version int64 - reqBox *util.EventBox - preview previewOpts - previewer previewer - previewBox *util.EventBox - eventBox *util.EventBox - mutex sync.Mutex - initFunc func() - prevLines []itemLine - suppress bool - startChan chan bool - killChan chan int - slab *util.Slab - theme *tui.ColorTheme - tui tui.Renderer + initDelay time.Duration + infoStyle infoStyle + spinner []string + prompt string + promptLen int + pointer string + pointerLen int + pointerEmpty string + marker string + markerLen int + markerEmpty string + queryLen [2]int + layout layoutType + fullscreen bool + hscroll bool + hscrollOff int + wordRubout string + wordNext string + cx int + cy int + offset int + xoffset int + yanked []rune + input []rune + multi int + sort bool + toggleSort bool + delimiter Delimiter + expect map[int]string + keymap map[int][]action + pressed string + printQuery bool + history *History + cycle bool + header []string + header0 []string + ansi bool + tabstop int + margin [4]sizeSpec + strong tui.Attr + unicode bool + bordered bool + cleanExit bool + border tui.Window + window tui.Window + pborder tui.Window + pwindow tui.Window + count int + progress int + reading bool + failed *string + jumping jumpMode + jumpLabels string + printer func(string) + printsep string + merger *Merger + selected map[int32]selectedItem + version int64 + reqBox *util.EventBox + preview previewOpts + previewer previewer + previewBox *util.EventBox + eventBox *util.EventBox + mutex sync.Mutex + initFunc func() + prevLines []itemLine + suppress bool + startChan chan bool + killChan chan int + slab *util.Slab + theme *tui.ColorTheme + tui tui.Renderer } type selectedItem struct { @@ -441,6 +447,12 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { tui: renderer, initFunc: func() { renderer.Init() }} t.prompt, t.promptLen = t.processTabs([]rune(opts.Prompt), 0) + t.pointer, t.pointerLen = t.processTabs([]rune(opts.Pointer), 0) + t.marker, t.markerLen = t.processTabs([]rune(opts.Marker), 0) + // Pre-calculated empty pointer and marker signs + t.pointerEmpty = strings.Repeat(" ", t.pointerLen) + t.markerEmpty = strings.Repeat(" ", t.markerLen) + return &t } @@ -852,15 +864,15 @@ func (t *Terminal) printList() { func (t *Terminal) printItem(result Result, line int, i int, current bool) { item := result.item _, selected := t.selected[item.Index()] - label := " " + label := t.pointerEmpty if t.jumping != jumpDisabled { if i < len(t.jumpLabels) { // Striped current = i%2 == 0 - label = t.jumpLabels[i : i+1] + label = t.jumpLabels[i:i+1] + strings.Repeat(" ", t.pointerLen-1) } } else if current { - label = ">" + label = t.pointer } // Avoid unnecessary redraw @@ -879,17 +891,17 @@ func (t *Terminal) printItem(result Result, line int, i int, current bool) { if current { t.window.CPrint(tui.ColCurrentCursor, t.strong, label) if selected { - t.window.CPrint(tui.ColCurrentSelected, t.strong, ">") + t.window.CPrint(tui.ColCurrentSelected, t.strong, t.marker) } else { - t.window.CPrint(tui.ColCurrentSelected, t.strong, " ") + t.window.CPrint(tui.ColCurrentSelected, t.strong, t.markerEmpty) } newLine.width = t.printHighlighted(result, t.strong, tui.ColCurrent, tui.ColCurrentMatch, true, true) } else { t.window.CPrint(tui.ColCursor, t.strong, label) if selected { - t.window.CPrint(tui.ColSelected, t.strong, ">") + t.window.CPrint(tui.ColSelected, t.strong, t.marker) } else { - t.window.Print(" ") + t.window.Print(t.markerEmpty) } newLine.width = t.printHighlighted(result, 0, tui.ColNormal, tui.ColMatch, false, true) } |
