mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
Bring new master content in line with rendering updates
This commit is contained in:
parent
adb7b379cb
commit
08689a400f
@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/makeworld-the-better-one/amfora/bookmarks"
|
||||
"github.com/makeworld-the-better-one/amfora/client"
|
||||
@ -86,13 +86,12 @@ func isStdinEmpty() bool {
|
||||
}
|
||||
|
||||
func renderFromStdin() {
|
||||
stdinTextBuilder := new(strings.Builder)
|
||||
_, err := io.Copy(stdinTextBuilder, os.Stdin)
|
||||
var stdinTextBuilder bytes.Buffer
|
||||
_, err := io.Copy(&stdinTextBuilder, os.Stdin)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error reading from standard input: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
stdinText := stdinTextBuilder.String()
|
||||
display.RenderFromString(stdinText)
|
||||
display.RenderFromBytes(stdinTextBuilder.Bytes())
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/makeworld-the-better-one/amfora/cache"
|
||||
"github.com/makeworld-the-better-one/amfora/config"
|
||||
"github.com/makeworld-the-better-one/amfora/render"
|
||||
"github.com/makeworld-the-better-one/amfora/structs"
|
||||
"github.com/makeworld-the-better-one/go-gemini"
|
||||
"github.com/spf13/viper"
|
||||
@ -522,17 +523,17 @@ func URL(u string) {
|
||||
go t.goURL(fixUserURL(u))
|
||||
}
|
||||
|
||||
func RenderFromString(str string) {
|
||||
func RenderFromBytes(b []byte) {
|
||||
t := tabs[curTab]
|
||||
page, _ := renderPageFromString(str)
|
||||
setPage(t, page)
|
||||
page, _ := renderPageFromBytes(b)
|
||||
t.setPage(page)
|
||||
}
|
||||
|
||||
func renderPageFromString(str string) (*structs.Page, bool) {
|
||||
rendered, links := renderer.RenderGemini(str, textWidth(), false)
|
||||
func renderPageFromBytes(b []byte) (*structs.Page, bool) {
|
||||
rendered, links := render.RenderGemini(b, textWidth(), false)
|
||||
page := &structs.Page{
|
||||
Mediatype: structs.TextGemini,
|
||||
Raw: str,
|
||||
Raw: b,
|
||||
Content: rendered,
|
||||
Links: links,
|
||||
TermWidth: termW,
|
||||
|
@ -430,11 +430,11 @@ func (t *tab) applyAll() {
|
||||
|
||||
// HighlightedURL returns the currently selected URL
|
||||
func (t *tab) HighlightedURL() string {
|
||||
currentSelection := tabs[curTab].view.GetHighlights()
|
||||
currentSelection := t.view.GetHighlights()
|
||||
|
||||
if len(currentSelection) > 0 {
|
||||
linkN, _ := strconv.Atoi(currentSelection[0])
|
||||
selectedURL := tabs[curTab].page.Links[linkN]
|
||||
selectedURL := t.page.Links[linkN]
|
||||
return selectedURL
|
||||
}
|
||||
return ""
|
||||
|
Loading…
Reference in New Issue
Block a user