renderer

package
v0.0.0-...-799e331 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Some extended parser.Expr that are useful to the editor

Index

Constants

View Source
const (
	CONF_RENDER_EMPTY_COMP_EXPR = true // config to enable rendering empty CompositeExpr "{}" as a space
)

Variables

View Source
var VanillaToUnicode = map[parser.LatexCmd]string{}/* 388 elements not displayed */

Functions

func GetVanillaString

func GetVanillaString(cmd parser.LatexCmd) string

func JoinHorizontal

func JoinHorizontal(baseline []int, strs ...string) string

Types

type Cursor

type Cursor struct {
	Symbol string // appearance of the cursor
}

the Cursor object implements a zero-width parser.Literal TODO rn its still a normal character

func (*Cursor) Content

func (c *Cursor) Content() string

func (*Cursor) End

func (c *Cursor) End() parser.Pos

func (*Cursor) Pos

func (c *Cursor) Pos() parser.Pos

func (*Cursor) VisualizeTree

func (c *Cursor) VisualizeTree() string

type LatexCmdInput

type LatexCmdInput struct {
	Text *parser.TextStringWrapper
}

func (*LatexCmdInput) Children

func (x *LatexCmdInput) Children() []parser.Expr

func (*LatexCmdInput) End

func (x *LatexCmdInput) End() parser.Pos

func (*LatexCmdInput) Parameters

func (x *LatexCmdInput) Parameters() int

func (*LatexCmdInput) Pos

func (x *LatexCmdInput) Pos() parser.Pos

func (*LatexCmdInput) SetArg

func (x *LatexCmdInput) SetArg(index int, expr parser.Expr)

func (*LatexCmdInput) VisualizeTree

func (x *LatexCmdInput) VisualizeTree() string

type LatexSourceConfig

type LatexSourceConfig struct {
	UseUnicode bool
}

func (*LatexSourceConfig) ProduceLatex

func (cfg *LatexSourceConfig) ProduceLatex(node parser.Expr) string

possible optimisation: pass the strings.Builder object by reference into the recursive function to avoid multiple Builder instances. Then returning string is no longer needed, we just use the original Builder to get the string instead

type Renderer

type Renderer struct {
	Buffer       string
	LatexTree    parser.FlexContainer
	FocusOn      parser.Container // the container in which the cursor is, a better implementation would be letting Render functions return a 'focused' flag when cursor is found
	HasSelection bool             // whether there is a selection in FocusOn
	Focus        bool             // whether the widget itself is focused
}

func FromFormula

func FromFormula(formula string) *Renderer

func New

func New() Renderer

func (*Renderer) DrawToBuffer

func (r *Renderer) DrawToBuffer(tree parser.Expr)

func (*Renderer) Load

func (r *Renderer) Load(tree parser.FlexContainer)

func (*Renderer) Prerender

func (r *Renderer) Prerender(node parser.Expr) (out string, baseLevel int)

func (*Renderer) PrerenderCmdContainer

func (r *Renderer) PrerenderCmdContainer(node parser.CmdContainer, x int, y int) (output string, baseLine int)

TODO remove

func (*Renderer) PrerenderCmdFrac

func (r *Renderer) PrerenderCmdFrac(node parser.CmdContainer) (output string, newBaseLevel int)

func (*Renderer) PrerenderCmdOverline

func (r *Renderer) PrerenderCmdOverline(node parser.CmdContainer) (output string, baseLevel int)

func (*Renderer) PrerenderCmdSqrt

func (r *Renderer) PrerenderCmdSqrt(node parser.CmdContainer) (output string, baseLevel int)

func (*Renderer) PrerenderCmdUnderline

func (r *Renderer) PrerenderCmdUnderline(node parser.CmdContainer) (output string, baseLevel int)

func (*Renderer) PrerenderFlexContainer

func (r *Renderer) PrerenderFlexContainer(node parser.FlexContainer) (output string, baseLine int)

func (*Renderer) Sync

func (r *Renderer) Sync(focus parser.Container, selected bool)

rerender the latex tree

func (*Renderer) View

func (r *Renderer) View() string

Jump to

Keyboard shortcuts

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