1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-12-04 14:46:29 -05:00

Possibly improve resize logic perf

This commit is contained in:
makeworld 2022-04-25 20:34:04 -04:00
parent 946b3f5bc0
commit bc81281c84

View File

@ -82,23 +82,18 @@ func Init(version, commit, builtBy string) {
termH = height termH = height
// Make sure the current tab content is reformatted when the terminal size changes // Make sure the current tab content is reformatted when the terminal size changes
go func(t *tab) { for i := range tabs {
reformatMu.Lock() // Only allow one reformat job at a time // Overwrite all tabs with a new, differently sized, left margin
for i := range tabs { browser.AddTab(
// Overwrite all tabs with a new, differently sized, left margin strconv.Itoa(i),
browser.AddTab( tabs[i].label(),
strconv.Itoa(i), makeContentLayout(tabs[i].view, leftMargin()),
tabs[i].label(), )
makeContentLayout(tabs[i].view, leftMargin()), if tabs[i] == tabs[curTab] {
) // Reformat page ASAP, in the middle of loop
if tabs[i] == t { reformatPageAndSetView(tabs[curTab], tabs[curTab].page)
// Reformat page ASAP, in the middle of loop
reformatPageAndSetView(t, t.page)
}
} }
App.Draw() }
reformatMu.Unlock()
}(tabs[curTab])
}) })
panels.AddPanel(PanelBrowser, browser, true, true) panels.AddPanel(PanelBrowser, browser, true, true)