From 0791079e13ab2f6d39bd7bc0dc656d948c4db556 Mon Sep 17 00:00:00 2001 From: makeworld Date: Wed, 1 Jul 2020 20:37:34 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Wrap=20new=20tab=20text=20-=20fi?= =?UTF-8?q?xes=20#31?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- display/display.go | 11 +++++++---- display/help.go | 1 + display/private.go | 4 +--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/display/display.go b/display/display.go index abf7ca1..8ac2812 100644 --- a/display/display.go +++ b/display/display.go @@ -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() diff --git a/display/help.go b/display/help.go index caaaedc..eb6f816 100644 --- a/display/help.go +++ b/display/help.go @@ -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 diff --git a/display/private.go b/display/private.go index f144f09..d6c92af 100644 --- a/display/private.go +++ b/display/private.go @@ -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