Documentation ¶
Overview ¶
The render package defines interfaces and functions to stylize a View's contents with colours, fonts and other metadata.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColourScheme ¶
type ColourScheme interface { // Takes a ViewRegions pointer as input and uses the data contained in it // to determine the Flavour it should be rendered with. Spice(*ViewRegions) Flavour }
type Flavour ¶
type Flavour struct { Background Colour Foreground Colour Font Font Flags ViewRegionFlags }
The Flavour struct contains the specific settings used to style a particular Region.
type FontMeasurement ¶
type FontMeasurement struct {
Width, Height int
}
type FontMetrics ¶
type FontMetrics interface {
Measure(Font, []rune) FontMeasurement
}
type Recipe ¶
The Recipe type groups text.RegionSets by their Flavour. The idea is to allow large groups of text be rendered as a single batch without any state changes inbetween the batches.
func Transform ¶
func Transform(scheme ColourScheme, data ViewRegionMap, viewport text.Region) Recipe
Transform takes a ColourScheme, a ViewRegionMap and a viewport as input.
The viewport would be the text.Region of the current buffer that is visible to the user and any ViewRegions outside of this area are not forwarded for further processing.
The remaining ViewRegions are then passed on to the ColourScheme for determining the exact Flavour for which that RegionSet should be styled, adding Regions of the same Flavour to the same RegionSet.
Typically there are more ViewRegions available in a text buffer than there are unique Flavours in a ColourScheme, so this operation can be viewed as reducing the number of state changes required to display the text to the user.
The final output, the Recipe, contains a mapping of all unique Flavours and that Flavour's associated RegionSet.
func (Recipe) Transcribe ¶
func (r Recipe) Transcribe() (ret TranscribedRecipe)
Transcribing the Recipe creates a linear step-by-step representation of it, which might or might not make it easier for Renderers to work with.
type RenderUnit ¶
A RenderUnit is just a Flavour and an associated Region.
type TranscribedRecipe ¶
type TranscribedRecipe []RenderUnit
A TranscribedRecipe is a linear (in text.Regions) representation of a Recipe
func (*TranscribedRecipe) Len ¶
func (r *TranscribedRecipe) Len() int
Just used to satisfy the sort.Interface interface, typically not used otherwise.
func (*TranscribedRecipe) Less ¶
func (r *TranscribedRecipe) Less(i, j int) bool
Just used to satisfy the sort.Interface interface, typically not used otherwise.
func (*TranscribedRecipe) Swap ¶
func (r *TranscribedRecipe) Swap(i, j int)
Just used to satisfy the sort.Interface interface, typically not used otherwise.
type ViewRegionFlags ¶
type ViewRegionFlags int
const ( DRAW_EMPTY ViewRegionFlags = (1 << iota) HIDE_ON_MINIMAP DRAW_EMPTY_AS_OVERWRITE DRAW_NO_FILL DRAW_NO_OUTLINE DRAW_SOLID_UNDERLINE DRAW_STIPPLED_UNDERLINE DRAW_SQUIGGLY_UNDERLINE PERSISTENT HIDDEN FOREGROUND SELECTION HIGHLIGHT DRAW_TEXT DEFAULT ViewRegionFlags = 0 )
type ViewRegionMap ¶
type ViewRegionMap map[string]ViewRegions
func (*ViewRegionMap) Cull ¶
func (vrm *ViewRegionMap) Cull(viewport text.Region)
type ViewRegions ¶
type ViewRegions struct { Regions text.RegionSet Scope string Icon string Flags ViewRegionFlags }
func (*ViewRegions) Clone ¶
func (vr *ViewRegions) Clone() ViewRegions
func (*ViewRegions) Cull ¶
func (vr *ViewRegions) Cull(viewport text.Region)