From 27ff6e75360f99e6a1736803ab6d1e9a5973bc97 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Mon, 29 Aug 2022 22:05:54 -0700 Subject: [PATCH] For directories in preview column, dim cursor When preview is on and consists of a directory listing, make the cursor in there dimmer to emphasize it's not active. This makes it visually obvious which cursor is active at all times, without having to read the path. The active cursor is now always the rightmost bright one, regardless of whether the `preview` option is on or off. See screenshots in the pull request. Before this, I noticed that I often open a file by accident because I got confused which of the three cursors on the screen is the active one. In the future, I also hope this dimming could be used to show when an lf window loses focus, based on @laktak's implementation of focus tracking in https://github.com/gokcehan/lf/pull/861. --- ui.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui.go b/ui.go index e2872352..1793e9c8 100644 --- a/ui.go +++ b/ui.go @@ -324,7 +324,7 @@ func fileInfo(f *file, d *dir) string { return info } -func (win *win) printDir(screen tcell.Screen, dir *dir, selections map[string]int, saves map[string]bool, tags map[string]string, colors styleMap, icons iconMap) { +func (win *win) printDir(screen tcell.Screen, dir *dir, selections map[string]int, saves map[string]bool, tags map[string]string, colors styleMap, icons iconMap, dim_cursor bool) { if win.w < 5 || dir == nil { return } @@ -403,6 +403,9 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, selections map[string]in if i == dir.pos { st = st.Reverse(true) + if dim_cursor { + st = st.Foreground(tcell.ColorGrey) + } } var s []rune @@ -855,7 +858,7 @@ func (ui *ui) draw(nav *nav) { doff := len(nav.dirs) - length for i := 0; i < length; i++ { - ui.wins[woff+i].printDir(ui.screen, nav.dirs[doff+i], nav.selections, nav.saves, nav.tags, ui.styles, ui.icons) + ui.wins[woff+i].printDir(ui.screen, nav.dirs[doff+i], nav.selections, nav.saves, nav.tags, ui.styles, ui.icons, false) } switch ui.cmdPrefix { @@ -889,7 +892,7 @@ func (ui *ui) draw(nav *nav) { preview := ui.wins[len(ui.wins)-1] if curr.IsDir() { - preview.printDir(ui.screen, ui.dirPrev, nav.selections, nav.saves, nav.tags, ui.styles, ui.icons) + preview.printDir(ui.screen, ui.dirPrev, nav.selections, nav.saves, nav.tags, ui.styles, ui.icons, true) } else if curr.Mode().IsRegular() { preview.printReg(ui.screen, ui.regPrev) }