@@ -322,8 +322,14 @@ func (m *model) promptModalRender() string {
322322}
323323
324324func (m * model ) helpMenuRender () string {
325- maxKeyLength := 0
325+ r := ui .HelpMenuRenderer (m .helpMenu .height , m .helpMenu .width )
326+ m .helpMenu .searchBar .Width = m .helpMenu .width - 3 // 2 for border, 1 for padding
327+ r .AddLines (" " + m .helpMenu .searchBar .View ())
328+ r .AddLines ("" ) // one-line separation between searchbar and content
326329
330+ // TODO : This computation should not happen at render time. Move this to update
331+ // TODO : Move these computations to a utility function
332+ maxKeyLength := 0
327333 for _ , data := range m .helpMenu .filteredData {
328334 totalKeyLen := 0
329335 for _ , key := range data .hotkey {
@@ -354,22 +360,12 @@ func (m *model) helpMenuRender() string {
354360 }
355361
356362 renderHotkeyLength := m .getRenderHotkeyLengthHelpmenuModal ()
357- helpMenuContent := m .getHelpMenuContent (renderHotkeyLength , valueLength )
358- searchBarStyle := m .helpMenu .searchBar .TextStyle .
359- // Add one space of padding to the left
360- PaddingLeft (1 ).
361- // Add a one-line margin at the bottom
362- MarginBottom (1 )
363-
364- searchBar := searchBarStyle .Render (m .helpMenu .searchBar .View ())
365- m .helpMenu .searchBar .Width = m .helpMenu .width - 2
366-
367- helpMenuContent = lipgloss .JoinVertical (lipgloss .Left , searchBar , helpMenuContent )
368- bottomBorder := common .GenerateFooterBorder (fmt .Sprintf ("%s/%s" ,
369- strconv .Itoa (m .helpMenu .cursor + 1 - cursorBeenTitleCount ),
370- strconv .Itoa (len (m .helpMenu .filteredData )- totalTitleCount )), m .helpMenu .width - 2 )
363+ m .getHelpMenuContent (r , renderHotkeyLength , valueLength )
371364
372- return common .HelpMenuModalBorderStyle (m .helpMenu .height , m .helpMenu .width , bottomBorder ).Render (helpMenuContent )
365+ r .SetBorderInfoItems (fmt .Sprintf ("%s/%s" ,
366+ strconv .Itoa (m .helpMenu .cursor + 1 - cursorBeenTitleCount ),
367+ strconv .Itoa (len (m .helpMenu .filteredData )- totalTitleCount )))
368+ return r .Render ()
373369}
374370
375371func (m * model ) getRenderHotkeyLengthHelpmenuModal () int {
@@ -393,15 +389,10 @@ func (m *model) getRenderHotkeyLengthHelpmenuModal() int {
393389 return renderHotkeyLength
394390}
395391
396- func (m * model ) getHelpMenuContent (renderHotkeyLength int , valueLength int ) string {
397- helpMenuContent := ""
392+ func (m * model ) getHelpMenuContent (r * rendering.Renderer , renderHotkeyLength int , valueLength int ) {
398393 for i := m .helpMenu .renderIndex ; i < m .helpMenu .height + m .helpMenu .renderIndex && i < len (m .helpMenu .filteredData ); i ++ {
399- if i != m .helpMenu .renderIndex {
400- helpMenuContent += "\n "
401- }
402-
403394 if m .helpMenu .filteredData [i ].subTitle != "" {
404- helpMenuContent += common .HelpMenuTitleStyle .Render (" " + m .helpMenu .filteredData [i ].subTitle )
395+ r . AddLines ( common .HelpMenuTitleStyle .Render (" " + m .helpMenu .filteredData [i ].subTitle ) )
405396 continue
406397 }
407398
@@ -419,10 +410,9 @@ func (m *model) getHelpMenuContent(renderHotkeyLength int, valueLength int) stri
419410 if m .helpMenu .cursor == i {
420411 cursor = common .FilePanelCursorStyle .Render (icon .Cursor + " " )
421412 }
422- helpMenuContent += cursor + common .ModalStyle .Render (fmt .Sprintf ("%*s%s" , renderHotkeyLength ,
423- common .HelpMenuHotkeyStyle .Render (hotkey + " " ), common .ModalStyle .Render (description )))
413+ r . AddLines ( cursor + common .ModalStyle .Render (fmt .Sprintf ("%*s%s" , renderHotkeyLength ,
414+ common .HelpMenuHotkeyStyle .Render (hotkey + " " ), common .ModalStyle .Render (description ))))
424415 }
425- return helpMenuContent
426416}
427417
428418func (m * model ) sortOptionsRender () string {
0 commit comments