render

package
v0.0.0-...-d18bf32 Latest Latest
Warning

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

Go to latest
Published: May 12, 2014 License: BSD-2-Clause Imports: 3 Imported by: 0

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 Colour

type Colour color.RGBA

Colour represented by a underlying color.RGBA structure

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 Font

type Font struct {
	Name  string
	Size  float64
	Style FontStyle
}

type FontMeasurement

type FontMeasurement struct {
	Width, Height int
}

type FontMetrics

type FontMetrics interface {
	Measure(Font, []rune) FontMeasurement
}

type FontStyle

type FontStyle int
const (
	Italic FontStyle = (1 << iota)
	Bold
	Underline
)

type Recipe

type Recipe map[Flavour]text.RegionSet

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

type RenderUnit struct {
	Flavour Flavour
	Region  text.Region
}

A RenderUnit is just a Flavour and an associated Region.

type Renderer

type Renderer interface {
	// Renders the given Recipe
	Render(Recipe)
}

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)

Jump to

Keyboard shortcuts

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