Debian Codegraph @

ui/messages/html/entity.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 // gomuks - A terminal Matrix client written in Go.
2 // Copyright (C) 2020 Tulir Asokan
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
13 //
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17 package html
18
19 import (
20 "go.mau.fi/mauview"
•21 "github.com/gdamore/tcell/v2"
22 )
23
24 // AdjustStyleFunc is a lambda function type to edit an existing tcell Style.
25 type AdjustStyleFunc func(tcell.Style) tcell.Style
26
27 type AdjustStyleReason int
28
29 const (
30 AdjustStyleReasonNormal AdjustStyleReason = iota
31 AdjustStyleReasonHideSpoiler
32 )
33
34 type DrawContext struct {
35 IsSelected bool
36 BareMessages bool
37 }
38
39 type Entity interface {
40 // AdjustStyle recursively changes the style of the entity and all its children.
41 AdjustStyle(AdjustStyleFunc, AdjustStyleReason) Entity
42 // Draw draws the entity onto the given mauview Screen.
43 Draw(screen mauview.Screen, ctx DrawContext)
44 // IsBlock returns whether or not it's a block-type entity.
45 IsBlock() bool
46 // GetTag returns the HTML tag of the entity.
47 GetTag() string
48 // PlainText returns the plaintext content in the entity and all its children.
49 PlainText() string
50 // String returns a string representation of the entity struct.
51 String() string
52 // Clone creates a deep copy of the entity.
53 Clone() Entity
54
55 // Height returns the render height of the entity.
56 Height() int
57 // CalculateBuffer prepares the entity and all its children for rendering with the given parameters
58 CalculateBuffer(width, startX int, ctx DrawContext) int
59
60 getStartX() int
61
62 IsEmpty() bool
63 }