html

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

gomuks - A terminal Matrix client written in Go. Copyright (C) 2020 Tulir Asokan

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

From https://github.com/golang/image/blob/master/colornames/colornames.go

Index

Constants

View Source
const BlockQuoteChar = '>'
View Source
const HorizontalLineChar = '━'
View Source
const TabLength = 4

Variables

View Source
var BlockTags = []string{"p", "h1", "h2", "h3", "h4", "h5", "h6", "ol", "ul", "li", "pre", "blockquote", "div", "hr", "table"}

Functions

func AdjustStyleBackgroundColor

func AdjustStyleBackgroundColor(color tcell.Color) func(tcell.Style) tcell.Style

func AdjustStyleBold

func AdjustStyleBold(style tcell.Style) tcell.Style

func AdjustStyleItalic

func AdjustStyleItalic(style tcell.Style) tcell.Style

func AdjustStyleStrikethrough

func AdjustStyleStrikethrough(style tcell.Style) tcell.Style

func AdjustStyleTextColor

func AdjustStyleTextColor(color tcell.Color) func(tcell.Style) tcell.Style

func AdjustStyleUnderline

func AdjustStyleUnderline(style tcell.Style) tcell.Style

Types

type AdjustStyleFunc

type AdjustStyleFunc func(tcell.Style) tcell.Style

AdjustStyleFunc is a lambda function type to edit an existing tcell Style.

type BaseEntity

type BaseEntity struct {
	// The HTML tag of this entity.
	Tag string
	// Style for this entity.
	Style tcell.Style
	// Whether or not this is a block-type entity.
	Block bool
	// Height to use for entity if both text and children are empty.
	DefaultHeight int
	// contains filtered or unexported fields
}

func (*BaseEntity) AdjustStyle

func (be *BaseEntity) AdjustStyle(fn AdjustStyleFunc) Entity

AdjustStyle changes the style of this text entity.

func (*BaseEntity) CalculateBuffer

func (be *BaseEntity) CalculateBuffer(width, startX int, bare bool) int

CalculateBuffer prepares this entity for rendering with the given parameters.

func (*BaseEntity) Clone

func (be *BaseEntity) Clone() Entity

Clone creates a copy of this base entity.

func (*BaseEntity) Draw

func (be *BaseEntity) Draw(screen mauview.Screen)

func (*BaseEntity) GetTag

func (be *BaseEntity) GetTag() string

GetTag returns the HTML tag of this entity.

func (*BaseEntity) Height

func (be *BaseEntity) Height() int

Height returns the render height of this entity.

func (*BaseEntity) IsBlock

func (be *BaseEntity) IsBlock() bool

IsBlock returns whether or not this is a block-type entity.

func (*BaseEntity) PlainText

func (be *BaseEntity) PlainText() string

func (*BaseEntity) String

func (be *BaseEntity) String() string

String returns a textual representation of this BaseEntity struct.

type BlockquoteEntity

type BlockquoteEntity struct {
	*ContainerEntity
}

func NewBlockquoteEntity

func NewBlockquoteEntity(children []Entity) *BlockquoteEntity

func (*BlockquoteEntity) AdjustStyle

func (be *BlockquoteEntity) AdjustStyle(fn AdjustStyleFunc) Entity

func (*BlockquoteEntity) Clone

func (be *BlockquoteEntity) Clone() Entity

func (*BlockquoteEntity) Draw

func (be *BlockquoteEntity) Draw(screen mauview.Screen)

func (*BlockquoteEntity) PlainText

func (be *BlockquoteEntity) PlainText() string

func (*BlockquoteEntity) String

func (be *BlockquoteEntity) String() string

type BreakEntity

type BreakEntity struct {
	*BaseEntity
}

func NewBreakEntity

func NewBreakEntity() *BreakEntity

func (*BreakEntity) AdjustStyle

func (be *BreakEntity) AdjustStyle(fn AdjustStyleFunc) Entity

AdjustStyle changes the style of this text entity.

func (*BreakEntity) Clone

func (be *BreakEntity) Clone() Entity

func (*BreakEntity) Draw

func (be *BreakEntity) Draw(screen mauview.Screen)

func (*BreakEntity) PlainText

func (be *BreakEntity) PlainText() string

func (*BreakEntity) String

func (be *BreakEntity) String() string

type CodeBlockEntity

type CodeBlockEntity struct {
	*ContainerEntity
	Background tcell.Style
}

func NewCodeBlockEntity

func NewCodeBlockEntity(children []Entity, background tcell.Style) *CodeBlockEntity

func (*CodeBlockEntity) AdjustStyle

func (ce *CodeBlockEntity) AdjustStyle(fn AdjustStyleFunc) Entity

func (*CodeBlockEntity) Clone

func (ce *CodeBlockEntity) Clone() Entity

func (*CodeBlockEntity) Draw

func (ce *CodeBlockEntity) Draw(screen mauview.Screen)

type ContainerEntity

type ContainerEntity struct {
	*BaseEntity

	// The children of this container entity.
	Children []Entity
	// Number of cells to indent children.
	Indent int
}

func (*ContainerEntity) AdjustStyle

func (ce *ContainerEntity) AdjustStyle(fn AdjustStyleFunc) Entity

AdjustStyle recursively changes the style of this entity and all its children.

func (*ContainerEntity) CalculateBuffer

func (ce *ContainerEntity) CalculateBuffer(width, startX int, bare bool) int

CalculateBuffer prepares this entity and all its children for rendering with the given parameters

func (*ContainerEntity) Clone

func (ce *ContainerEntity) Clone() Entity

clone creates a deep copy of this base entity.

func (*ContainerEntity) Draw

func (ce *ContainerEntity) Draw(screen mauview.Screen)

Draw draws this entity onto the given mauview Screen.

func (*ContainerEntity) PlainText

func (ce *ContainerEntity) PlainText() string

PlainText returns the plaintext content in this entity and all its children.

func (*ContainerEntity) String

func (ce *ContainerEntity) String() string

String returns a textual representation of this BaseEntity struct.

type Entity

type Entity interface {
	// AdjustStyle recursively changes the style of the entity and all its children.
	AdjustStyle(AdjustStyleFunc) Entity
	// Draw draws the entity onto the given mauview Screen.
	Draw(screen mauview.Screen)
	// IsBlock returns whether or not it's a block-type entity.
	IsBlock() bool
	// GetTag returns the HTML tag of the entity.
	GetTag() string
	// PlainText returns the plaintext content in the entity and all its children.
	PlainText() string
	// String returns a string representation of the entity struct.
	String() string
	// Clone creates a deep copy of the entity.
	Clone() Entity

	// Height returns the render height of the entity.
	Height() int
	// CalculateBuffer prepares the entity and all its children for rendering with the given parameters
	CalculateBuffer(width, startX int, bare bool) int
	// contains filtered or unexported methods
}

func Parse

func Parse(room *rooms.Room, content *event.MessageEventContent, sender id.UserID, senderDisplayname string) Entity

Parse parses a HTML-formatted Matrix event into a UIMessage.

type HorizontalLineEntity

type HorizontalLineEntity struct {
	*BaseEntity
}

func NewHorizontalLineEntity

func NewHorizontalLineEntity() *HorizontalLineEntity

func (*HorizontalLineEntity) AdjustStyle

func (he *HorizontalLineEntity) AdjustStyle(fn AdjustStyleFunc) Entity

func (*HorizontalLineEntity) Clone

func (he *HorizontalLineEntity) Clone() Entity

func (*HorizontalLineEntity) Draw

func (he *HorizontalLineEntity) Draw(screen mauview.Screen)

func (*HorizontalLineEntity) PlainText

func (he *HorizontalLineEntity) PlainText() string

func (*HorizontalLineEntity) String

func (he *HorizontalLineEntity) String() string

type ListEntity

type ListEntity struct {
	*ContainerEntity
	Ordered bool
	Start   int
}

func NewListEntity

func NewListEntity(ordered bool, start int, children []Entity) *ListEntity

func (*ListEntity) AdjustStyle

func (le *ListEntity) AdjustStyle(fn AdjustStyleFunc) Entity

func (*ListEntity) Clone

func (le *ListEntity) Clone() Entity

func (*ListEntity) Draw

func (le *ListEntity) Draw(screen mauview.Screen)

func (*ListEntity) PlainText

func (le *ListEntity) PlainText() string

func (*ListEntity) String

func (le *ListEntity) String() string

type TextEntity

type TextEntity struct {
	*BaseEntity
	// Text in this entity.
	Text string
	// contains filtered or unexported fields
}

func NewTextEntity

func NewTextEntity(text string) *TextEntity

NewTextEntity creates a new text-only Entity.

func (*TextEntity) AdjustStyle

func (te *TextEntity) AdjustStyle(fn AdjustStyleFunc) Entity

func (*TextEntity) CalculateBuffer

func (te *TextEntity) CalculateBuffer(width, startX int, bare bool) int

func (*TextEntity) Clone

func (te *TextEntity) Clone() Entity

func (*TextEntity) Draw

func (te *TextEntity) Draw(screen mauview.Screen)

func (*TextEntity) PlainText

func (te *TextEntity) PlainText() string

func (*TextEntity) String

func (te *TextEntity) String() string

Jump to

Keyboard shortcuts

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