mirror of
https://github.com/makew0rld/amfora.git
synced 2024-11-03 02:37:23 -05:00
🐛 Wrap new tab text - fixes #31
This commit is contained in:
parent
85e2191a9a
commit
0791079e13
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user