Render selected list item differently
This commit is contained in:
parent
3157897c1a
commit
60284850f2
2 changed files with 8 additions and 3 deletions
|
@ -88,6 +88,7 @@ func (list *List) Select(index int) {
|
||||||
panic(fmt.Errorf("Attempted to select unknown child"))
|
panic(fmt.Errorf("Attempted to select unknown child"))
|
||||||
}
|
}
|
||||||
list.selected = index
|
list.selected = index
|
||||||
|
list.Items[list.selected].invalid = true
|
||||||
list.Invalidate()
|
list.Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ func (dirlist *DirectoryList) UpdateList() {
|
||||||
return strings.Compare(string(a), string(b)) > 0
|
return strings.Compare(string(a), string(b)) > 0
|
||||||
})
|
})
|
||||||
dirlist.dirs.Set(dirs)
|
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) {
|
func (d directoryEntry) DrawWithSelected(ctx *ui.Context, selected bool) {
|
||||||
// TODO: distinguish the selected item
|
style := tcell.StyleDefault
|
||||||
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
|
if selected {
|
||||||
ctx.Printf(0, 0, tcell.StyleDefault, "%s", d)
|
style = style.Background(tcell.ColorWhite).Foreground(tcell.ColorBlack)
|
||||||
|
}
|
||||||
|
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style)
|
||||||
|
ctx.Printf(0, 0, style, "%s", d)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue