Documentation ¶
Overview ¶
Package render handles output size constraints and paginated rendering of contents and menus against templates.
Index ¶
- type BrowseConfig
- type BrowseError
- type Menu
- func (m *Menu) GetBrowseConfig() BrowseConfig
- func (m *Menu) GetOutputSize() uint32
- func (m *Menu) Put(selector string, title string) error
- func (m *Menu) Render(idx uint16) (string, error)
- func (m *Menu) ReservedSize() uint16
- func (m *Menu) WithBrowseConfig(cfg BrowseConfig) *Menu
- func (m *Menu) WithOutputSize(outputSize uint16) *Menu
- func (m *Menu) WithPageCount(pageCount uint16) *Menu
- type Page
- func (pg *Page) Map(key string) error
- func (pg *Page) Render(sym string, idx uint16) (string, error)
- func (pg *Page) RenderTemplate(sym string, values map[string]string, idx uint16) (string, error)
- func (pg *Page) Reset()
- func (pg *Page) Sizes() (map[string]uint16, error)
- func (pg *Page) Usage() (uint32, uint32, error)
- func (pg *Page) Val(key string) (string, error)
- func (pg *Page) WithMenu(menu *Menu) *Page
- func (pg *Page) WithSizer(sizer *Sizer) *Page
- type Sizer
- func (szr *Sizer) AddCursor(c uint32)
- func (szr *Sizer) Check(s string) (uint32, bool)
- func (szr *Sizer) GetAt(values map[string]string, idx uint16) (map[string]string, error)
- func (szr *Sizer) MenuSize() uint16
- func (szr *Sizer) Set(key string, size uint16) error
- func (szr *Sizer) Size(s string) (uint16, error)
- func (szr *Sizer) String() string
- func (szr *Sizer) WithMenuSize(menuSize uint16) *Sizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrowseConfig ¶
type BrowseConfig struct { NextAvailable bool NextSelector string NextTitle string PreviousAvailable bool PreviousSelector string PreviousTitle string }
BrowseConfig defines the availability and display parameters for page browsing.
func DefaultBrowseConfig ¶
func DefaultBrowseConfig() BrowseConfig
Default browse settings for convenience.
type BrowseError ¶
BrowseError is raised when browsing outside the page range of a rendered node.
func (*BrowseError) Error ¶
func (err *BrowseError) Error() string
Error implements the Error interface.
type Menu ¶
type Menu struct {
// contains filtered or unexported fields
}
Menu renders menus. May be included in a Page object to render menus for pages.
func (*Menu) GetBrowseConfig ¶
func (m *Menu) GetBrowseConfig() BrowseConfig
GetBrowseConfig returns a copy of the current state of the browse configuration.
func (*Menu) GetOutputSize ¶
GetOutputSize returns the defined heuristic menu size.
func (*Menu) Render ¶
Render returns the full current state of the menu as a string.
After this has been executed, the state of the menu will be empty.
func (*Menu) ReservedSize ¶
ReservedSize returns the maximum render byte size of the menu.
func (*Menu) WithBrowseConfig ¶
func (m *Menu) WithBrowseConfig(cfg BrowseConfig) *Menu
WithBrowseConfig defines the criteria for page browsing.
func (*Menu) WithOutputSize ¶
WithSize defines the maximum byte size of the rendered menu.
func (*Menu) WithPageCount ¶
WithBrowseConfig defines the criteria for page browsing.
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page exectues output rendering into pages constrained by size.
func (*Page) Map ¶
Map marks the given key for retrieval.
After this, Val() will return the value for the key, and Size() will include the value size and limitations in its calculations.
Only one symbol with no size limitation may be mapped at the current level.
func (*Page) Render ¶
Render renders the current mapped content and menu state against the template associated with the symbol.
func (*Page) RenderTemplate ¶
RenderTemplate is an adapter to implement the builtin golang text template renderer as resource.RenderTemplate.
func (*Page) Reset ¶
func (pg *Page) Reset()
Reset prepared the Page object for re-use.
It clears mappings and removes the sink definition.
type Sizer ¶
type Sizer struct {
// contains filtered or unexported fields
}
Sizer splits dynamic contents into individual segments for browseable pages.
func (*Sizer) Check ¶
Check audits whether the rendered string is within the output size constraint of the sizer.
func (*Sizer) GetAt ¶
GetAt the paged symbols for the current page index.
Fails if index requested is out of range.
func (*Sizer) Size ¶
Size gives the byte size of content for a single symbol.
Fails if the symbol has not been registered using Set
func (*Sizer) WithMenuSize ¶
WithMenuSize sets the size of the menu being used in the rendering context.