summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-13 15:12:52 -0500
committerDrew DeVault <sir@cmpwn.com>2019-01-13 15:12:52 -0500
commit60284850f22624a03996e882fcfd6aeb2af88b93 (patch)
treeccaef66a4e3628fc26df758e9380a2b4ef15db47
parent3157897c1a20e5638feaf56e753b7886bc4ba267 (diff)
downloadaerc-60284850f22624a03996e882fcfd6aeb2af88b93.tar.gz
Render selected list item differently
-rw-r--r--lib/ui/list.go1
-rw-r--r--widgets/directories.go10
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/ui/list.go b/lib/ui/list.go
index 58f304f..9caae20 100644
--- a/lib/ui/list.go
+++ b/lib/ui/list.go
@@ -88,6 +88,7 @@ func (list *List) Select(index int) {
 		panic(fmt.Errorf("Attempted to select unknown child"))
 	}
 	list.selected = index
+	list.Items[list.selected].invalid = true
 	list.Invalidate()
 }
 
diff --git a/widgets/directories.go b/widgets/directories.go
index ff2f6f5..d765ac2 100644
--- a/widgets/directories.go
+++ b/widgets/directories.go
@@ -53,6 +53,7 @@ func (dirlist *DirectoryList) UpdateList() {
 					return strings.Compare(string(a), string(b)) > 0
 				})
 				dirlist.dirs.Set(dirs)
+				dirlist.dirs.Select(0)
 			}
 		})
 }
@@ -84,7 +85,10 @@ func (d directoryEntry) Draw(ctx *ui.Context) {
 }
 
 func (d directoryEntry) DrawWithSelected(ctx *ui.Context, selected bool) {
-	// TODO: distinguish the selected item
-	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
-	ctx.Printf(0, 0, tcell.StyleDefault, "%s", d)
+	style := tcell.StyleDefault
+	if selected {
+		style = style.Background(tcell.ColorWhite).Foreground(tcell.ColorBlack)
+	}
+	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style)
+	ctx.Printf(0, 0, style, "%s", d)
 }