mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Extract a renderLines function
We'll make some changes to how the display strings are rendered, so it helps to have this code only once. This also fixes the problem that contexts using refreshViewportOnChange weren't able to use column alignments so far. We didn't need this yet, but it's just nice if everything works. :)
This commit is contained in:
parent
061bfce835
commit
473d989cde
1 changed files with 12 additions and 10 deletions
|
@ -57,10 +57,19 @@ func (self *ListContextTrait) FocusLine() {
|
|||
}
|
||||
}
|
||||
|
||||
func (self *ListContextTrait) renderLines(startIdx int, endIdx int) string {
|
||||
var columnAlignments []utils.Alignment
|
||||
if self.getColumnAlignments != nil {
|
||||
columnAlignments = self.getColumnAlignments()
|
||||
}
|
||||
return utils.RenderDisplayStrings(
|
||||
self.getDisplayStrings(startIdx, endIdx),
|
||||
columnAlignments)
|
||||
}
|
||||
|
||||
func (self *ListContextTrait) refreshViewport() {
|
||||
startIdx, length := self.GetViewTrait().ViewPortYBounds()
|
||||
displayStrings := self.getDisplayStrings(startIdx, startIdx+length)
|
||||
content := utils.RenderDisplayStrings(displayStrings, nil)
|
||||
content := self.renderLines(startIdx, startIdx+length)
|
||||
self.GetViewTrait().SetViewPortContent(content)
|
||||
}
|
||||
|
||||
|
@ -93,14 +102,7 @@ func (self *ListContextTrait) HandleFocusLost(opts types.OnFocusLostOpts) error
|
|||
// OnFocus assumes that the content of the context has already been rendered to the view. OnRender is the function which actually renders the content to the view
|
||||
func (self *ListContextTrait) HandleRender() error {
|
||||
self.list.RefreshSelectedIdx()
|
||||
var columnAlignments []utils.Alignment
|
||||
if self.getColumnAlignments != nil {
|
||||
columnAlignments = self.getColumnAlignments()
|
||||
}
|
||||
content := utils.RenderDisplayStrings(
|
||||
self.getDisplayStrings(0, self.list.Len()),
|
||||
columnAlignments,
|
||||
)
|
||||
content := self.renderLines(0, self.list.Len())
|
||||
self.GetViewTrait().SetContent(content)
|
||||
self.c.Render()
|
||||
self.setFooter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue