renderer

package
v0.0.0-...-e184c4b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package renderer provides functions to convert various data into a cview primitive. Example objects include a Gemini response, and an error.

Rendered lines always end with \r\n, in an effort to be Window compatible.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadEncoding = errors.New("unsupported encoding")
View Source
var ErrBadMediatype = errors.New("displayable mediatype is not handled in the code, implementation error")
View Source
var ErrCantDisplay = errors.New("invalid content for a page")
View Source
var ErrTimedOut = errors.New("page download timed out")
View Source
var ErrTooLarge = errors.New("page content would be too large")
View Source
var TermColor string

Terminal color information, set during display initialization by display/display.go

Functions

func CanDisplay

func CanDisplay(res *gemini.Response) bool

CanDisplay returns true if the response is supported by Amfora for displaying on the screen. It also doubles as a function to detect whether something can be stored in a Page struct.

func MakePage

func MakePage(url string, res *gemini.Response, width int, proxied bool) (*structs.Page, error)

MakePage creates a formatted, rendered Page from the given network response and params. You must set the Page.Width value yourself.

func RenderANSI

func RenderANSI(s string) string

RenderANSI renders plain text pages containing ANSI codes. Practically, it is used for the text/x-ansi.

func RenderGemini

func RenderGemini(s string, width int, proxied bool) (string, []string)

RenderGemini converts text/gemini into a cview displayable format. It also returns a slice of link URLs.

width is the number of columns to wrap to. leftMargin is the number of blank spaces to prepend to each line.

proxied is whether the request is through the gemini:// scheme. If it's not a gemini:// page, set this to true.

func RenderPlainText

func RenderPlainText(s string) string

RenderPlainText should be used to format plain text pages.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL