🐛 Wrap new tab text - fixes #31

This commit is contained in:
makeworld 2020-07-01 20:37:34 -04:00
parent 85e2191a9a
commit 0791079e13
3 changed files with 9 additions and 7 deletions

View File

@ -69,6 +69,10 @@ var layout = cview.NewFlex().
AddItem(nil, 1, 1, false). // One line of empty space before bottomBar
AddItem(bottomBar, 1, 1, false)
var renderedNewTabContent string
var newTabLinks []string
var newTabPage structs.Page
var App = cview.NewApplication().
EnableMouse(false).
SetRoot(layout, true).
@ -81,15 +85,14 @@ var App = cview.NewApplication().
// XXX: This is hacky but works. The biggest issue is that there will sometimes be a tiny flash
// of the old not shifted tab on startup.
if tabMap[curTab] == &newTabPage {
renderedNewTabContent, _ = renderer.RenderGemini(newTabContent, textWidth())
newTabPage.Content = renderedNewTabContent
newTabPage.LeftMargin = 0
setLeftMargin(tabMap[curTab])
tabViews[curTab].SetText(tabMap[curTab].Content)
}
})
var renderedNewTabContent string
var newTabLinks []string
var newTabPage structs.Page
func Init() {
tabRow.SetChangedFunc(func() {
App.Draw()

View File

@ -32,6 +32,7 @@ Ctrl-T|New tab, or if a link is selected,
|this will open the link in a new tab.
Ctrl-W|Close tab. For now, only the right-most tab can be closed.
Ctrl-R, R|Reload a page, discarding the cached version.
|This can also be used if you resize your terminal.
Ctrl-B|View bookmarks
Ctrl-D|Add, change, or remove a bookmark for the current page.
q, Ctrl-Q, Ctrl-C|Quit

View File

@ -176,9 +176,7 @@ func setLeftMargin(p *structs.Page) {
// Old margin needs to be removed, new one added
lines := strings.Split(p.Content, "\n")
for i := range lines {
if lines[i] != "" {
shifted += strings.Repeat(" ", lM) + lines[i][p.LeftMargin:] + "\n"
}
shifted += strings.Repeat(" ", lM) + lines[i][p.LeftMargin:] + "\n"
}
}
p.Content = shifted