ui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: AGPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

Package ui contains the main gomuks UI.

Index

Constants

View Source
const (
	SelectReply    SelectReason = "reply to"
	SelectReact                 = "react to"
	SelectRedact                = "redact"
	SelectDownload              = "download"
	SelectOpen                  = "open"
	SelectCopy                  = "copy"
)
View Source
const (
	TimestampSenderGap = 1
	SenderSeparatorGap = 1
	SenderMessageGap   = 3
)
View Source
const (
	UserListBorderWidth   = 1
	UserListWidth         = 20
	StaticHorizontalSpace = UserListBorderWidth + UserListWidth

	TopicBarHeight  = 1
	StatusBarHeight = 1

	MaxInputHeight = 5
)

Constants defining the size of the room view grid.

View Source
const PaddingAtTop = 5
View Source
const WheelScrollOffsetDiff = 3

Variables

View Source
var TagDisplayNameStyle = tcell.StyleDefault.Underline(true).Bold(true)
View Source
var TagRoomCountStyle = tcell.StyleDefault.Italic(true)

Functions

func NewGomuksUI

func NewGomuksUI(gmx ifc.Gomuks) ifc.GomuksUI

func Rand

func Rand(n int) (str string)

Types

type Alias

type Alias struct {
	NewCommand string
}

func (*Alias) Process

func (alias *Alias) Process(cmd *Command) *Command

type Command

type Command struct {
	Handler *CommandProcessor

	Room        *RoomView
	Command     string
	OrigCommand string
	Args        []string
	OrigText    string
	// contains filtered or unexported fields
}

func (*Command) Reply

func (cmd *Command) Reply(message string, args ...interface{})

type CommandHandler

type CommandHandler func(cmd *Command)

type CommandProcessor

type CommandProcessor struct {
	// contains filtered or unexported fields
}

func NewCommandProcessor

func NewCommandProcessor(parent *MainView) *CommandProcessor

func (*CommandProcessor) HandleCommand

func (ch *CommandProcessor) HandleCommand(cmd *Command)

func (*CommandProcessor) ParseCommand

func (ch *CommandProcessor) ParseCommand(roomView *RoomView, text string) *Command

type FuzzySearchModal

type FuzzySearchModal struct {
	mauview.Component
	// contains filtered or unexported fields
}

func NewFuzzySearchModal

func NewFuzzySearchModal(mainView *MainView, width int, height int) *FuzzySearchModal

func (*FuzzySearchModal) Blur

func (fs *FuzzySearchModal) Blur()

func (*FuzzySearchModal) Focus

func (fs *FuzzySearchModal) Focus()

func (*FuzzySearchModal) InitList

func (fs *FuzzySearchModal) InitList(rooms map[id.RoomID]*RoomView)

func (*FuzzySearchModal) OnKeyEvent

func (fs *FuzzySearchModal) OnKeyEvent(event mauview.KeyEvent) bool

type GomuksUI

type GomuksUI struct {
	// contains filtered or unexported fields
}

func (*GomuksUI) Finish

func (ui *GomuksUI) Finish()

func (*GomuksUI) HandleNewPreferences

func (ui *GomuksUI) HandleNewPreferences()

func (*GomuksUI) Init

func (ui *GomuksUI) Init()

func (*GomuksUI) MainView

func (ui *GomuksUI) MainView() ifc.MainView

func (*GomuksUI) NewLoginView

func (ui *GomuksUI) NewLoginView() mauview.Component

func (*GomuksUI) NewMainView

func (ui *GomuksUI) NewMainView() mauview.Component

func (*GomuksUI) OnLogin

func (ui *GomuksUI) OnLogin()

func (*GomuksUI) OnLogout

func (ui *GomuksUI) OnLogout()

func (*GomuksUI) Render

func (ui *GomuksUI) Render()

func (*GomuksUI) SetView

func (ui *GomuksUI) SetView(name View)

func (*GomuksUI) Start

func (ui *GomuksUI) Start() error

func (*GomuksUI) Stop

func (ui *GomuksUI) Stop()

type GradientTable

type GradientTable []struct {
	Col colorful.Color
	Pos float64
}

GradientTable from https://github.com/lucasb-eyer/go-colorful/blob/master/doc/gradientgen/gradientgen.go

func (GradientTable) GetInterpolatedColorFor

func (gt GradientTable) GetInterpolatedColorFor(t float64) colorful.Color

type HideMessage

type HideMessage string

func (HideMessage) Format

func (hm HideMessage) Format(state bool) string

func (HideMessage) Name

func (hm HideMessage) Name() string

type LoginView

type LoginView struct {
	*mauview.Form
	// contains filtered or unexported fields
}

func (*LoginView) Error

func (view *LoginView) Error(err string)

func (*LoginView) Login

func (view *LoginView) Login()

type MainView

type MainView struct {
	// contains filtered or unexported fields
}

func (*MainView) AddRoom

func (view *MainView) AddRoom(room *rooms.Room)

func (*MainView) Blur

func (view *MainView) Blur()

func (*MainView) Bump

func (view *MainView) Bump(room *rooms.Room)

func (*MainView) BumpFocus

func (view *MainView) BumpFocus(roomView *RoomView)

func (*MainView) Draw

func (view *MainView) Draw(screen mauview.Screen)

func (*MainView) Focus

func (view *MainView) Focus()

func (*MainView) GetRoom

func (view *MainView) GetRoom(roomID id.RoomID) ifc.RoomView

func (*MainView) HideModal

func (view *MainView) HideModal()

func (*MainView) InputChanged

func (view *MainView) InputChanged(roomView *RoomView, text string)

func (*MainView) LoadHistory

func (view *MainView) LoadHistory(roomID id.RoomID)

func (*MainView) MarkRead

func (view *MainView) MarkRead(roomView *RoomView)

func (*MainView) NotifyMessage

func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, should pushrules.PushActionArrayShould)

func (*MainView) OnKeyEvent

func (view *MainView) OnKeyEvent(event mauview.KeyEvent) bool

func (*MainView) OnMouseEvent

func (view *MainView) OnMouseEvent(event mauview.MouseEvent) bool

func (*MainView) OnPasteEvent

func (view *MainView) OnPasteEvent(event mauview.PasteEvent) bool

func (*MainView) OpenSyncingModal

func (view *MainView) OpenSyncingModal() ifc.SyncingModal

func (*MainView) RemoveRoom

func (view *MainView) RemoveRoom(room *rooms.Room)

func (*MainView) SetRooms

func (view *MainView) SetRooms(rooms *rooms.RoomCache)

func (*MainView) SetTyping

func (view *MainView) SetTyping(roomID id.RoomID, users []id.UserID)

func (*MainView) ShowBare

func (view *MainView) ShowBare(roomView *RoomView)

func (*MainView) ShowModal

func (view *MainView) ShowModal(modal mauview.Component)

func (*MainView) SwitchRoom

func (view *MainView) SwitchRoom(tag string, room *rooms.Room)

func (*MainView) UpdateTags

func (view *MainView) UpdateTags(room *rooms.Room)

type MemberList

type MemberList struct {
	// contains filtered or unexported fields
}

func NewMemberList

func NewMemberList() *MemberList

func (*MemberList) Draw

func (ml *MemberList) Draw(screen mauview.Screen)

func (*MemberList) Update

func (ml *MemberList) Update(data map[id.UserID]*rooms.Member, levels *event.PowerLevelsEventContent) *MemberList

type MessageDirection

type MessageDirection int
const (
	AppendMessage MessageDirection = iota
	PrependMessage
	IgnoreMessage
)

type MessageView

type MessageView struct {
	ScrollOffset    int
	MaxSenderWidth  int
	DateFormat      string
	TimestampFormat string
	TimestampWidth  int
	// contains filtered or unexported fields
}

func NewMessageView

func NewMessageView(parent *RoomView) *MessageView

func (*MessageView) AddMessage

func (view *MessageView) AddMessage(ifcMessage ifc.Message, direction MessageDirection)

func (*MessageView) AddScrollOffset

func (view *MessageView) AddScrollOffset(diff int)

func (*MessageView) CapturePlaintext

func (view *MessageView) CapturePlaintext(height int) string

func (*MessageView) Draw

func (view *MessageView) Draw(screen mauview.Screen)

func (*MessageView) Height

func (view *MessageView) Height() int

func (*MessageView) IsAtTop

func (view *MessageView) IsAtTop() bool

func (*MessageView) OnMouseEvent

func (view *MessageView) OnMouseEvent(event mauview.MouseEvent) bool

func (*MessageView) SetSelected

func (view *MessageView) SetSelected(message *messages.UIMessage)

func (*MessageView) TotalHeight

func (view *MessageView) TotalHeight() int

func (*MessageView) Unload

func (view *MessageView) Unload()

type OrderedRoom

type OrderedRoom struct {
	*rooms.Room
	// contains filtered or unexported fields
}

func NewDefaultOrderedRoom

func NewDefaultOrderedRoom(room *rooms.Room) *OrderedRoom

func NewOrderedRoom

func NewOrderedRoom(order json.Number, room *rooms.Room) *OrderedRoom

func (*OrderedRoom) Draw

func (or *OrderedRoom) Draw(roomList *RoomList, screen mauview.Screen, x, y, lineWidth int, isSelected bool)

type RainbowRenderer

type RainbowRenderer struct {
	*blackfriday.HTMLRenderer

	ColorID string
	// contains filtered or unexported fields
}

func NewRainbowRenderer

func NewRainbowRenderer(html *blackfriday.HTMLRenderer) *RainbowRenderer

func (*RainbowRenderer) RenderNode

func (r *RainbowRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus

type RoomList

type RoomList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRoomList

func NewRoomList(parent *MainView) *RoomList

func (*RoomList) Add

func (list *RoomList) Add(room *rooms.Room)

func (*RoomList) AddScrollOffset

func (list *RoomList) AddScrollOffset(offset int)

func (*RoomList) AddToTag

func (list *RoomList) AddToTag(tag rooms.RoomTag, room *rooms.Room)

func (*RoomList) Blur

func (list *RoomList) Blur()

func (*RoomList) Bump

func (list *RoomList) Bump(room *rooms.Room)

func (*RoomList) Clear

func (list *RoomList) Clear()

func (*RoomList) Contains

func (list *RoomList) Contains(roomID id.RoomID) bool

func (*RoomList) ContentHeight

func (list *RoomList) ContentHeight() (height int)

func (*RoomList) Draw

func (list *RoomList) Draw(screen mauview.Screen)

Draw draws this primitive onto the screen.

func (*RoomList) First

func (list *RoomList) First() (string, *rooms.Room)

func (*RoomList) Focus

func (list *RoomList) Focus()

func (*RoomList) GetTagDisplayName

func (list *RoomList) GetTagDisplayName(tag string) string

func (*RoomList) HasSelected

func (list *RoomList) HasSelected() bool

func (*RoomList) Last

func (list *RoomList) Last() (string, *rooms.Room)

func (*RoomList) Next

func (list *RoomList) Next() (string, *rooms.Room)

func (*RoomList) NextWithActivity

func (list *RoomList) NextWithActivity() (string, *rooms.Room)

NextWithActivity Returns next room with activity.

Sorted by (in priority):

- Highlights - Messages - Other traffic (joins, parts, etc)

TODO: Sorting. Now just finds first room with new messages.

func (*RoomList) OnKeyEvent

func (list *RoomList) OnKeyEvent(_ mauview.KeyEvent) bool

func (*RoomList) OnMouseEvent

func (list *RoomList) OnMouseEvent(event mauview.MouseEvent) bool

func (*RoomList) OnPasteEvent

func (list *RoomList) OnPasteEvent(_ mauview.PasteEvent) bool

func (*RoomList) Previous

func (list *RoomList) Previous() (string, *rooms.Room)

func (*RoomList) Remove

func (list *RoomList) Remove(room *rooms.Room)

func (*RoomList) RemoveFromTag

func (list *RoomList) RemoveFromTag(tag string, room *rooms.Room)

func (*RoomList) Selected

func (list *RoomList) Selected() (string, *rooms.Room)

func (*RoomList) SelectedRoom

func (list *RoomList) SelectedRoom() *rooms.Room

func (*RoomList) SetSelected

func (list *RoomList) SetSelected(tag string, room *rooms.Room)

type RoomView

type RoomView struct {
	Room *rooms.Room
	// contains filtered or unexported fields
}

func NewRoomView

func NewRoomView(parent *MainView, room *rooms.Room) *RoomView

func (*RoomView) AddEdit

func (view *RoomView) AddEdit(evt *muksevt.Event)

func (*RoomView) AddEvent

func (view *RoomView) AddEvent(evt *muksevt.Event) ifc.Message

func (*RoomView) AddHistoryEvent

func (view *RoomView) AddHistoryEvent(evt *muksevt.Event)

func (*RoomView) AddReaction

func (view *RoomView) AddReaction(evt *muksevt.Event, key string)

func (*RoomView) AddRedaction

func (view *RoomView) AddRedaction(redactedEvt *muksevt.Event)

func (*RoomView) AddServiceMessage

func (view *RoomView) AddServiceMessage(text string)

func (*RoomView) Blur

func (view *RoomView) Blur()

func (*RoomView) ClearAllContext

func (view *RoomView) ClearAllContext()

func (*RoomView) CopyToClipboard

func (view *RoomView) CopyToClipboard(text string, register string)

func (*RoomView) Download

func (view *RoomView) Download(url id.ContentURI, file *attachment.EncryptedFile, filename string, openFile bool)

func (*RoomView) Draw

func (view *RoomView) Draw(screen mauview.Screen)

func (*RoomView) EditNext

func (view *RoomView) EditNext()

func (*RoomView) EditPrevious

func (view *RoomView) EditPrevious()

func (*RoomView) Focus

func (view *RoomView) Focus()

func (*RoomView) GetEvent

func (view *RoomView) GetEvent(eventID id.EventID) ifc.Message

func (*RoomView) GetInputText

func (view *RoomView) GetInputText() string

func (*RoomView) GetStatus

func (view *RoomView) GetStatus() string

func (*RoomView) InputSubmit

func (view *RoomView) InputSubmit(text string)

func (*RoomView) InputTabComplete

func (view *RoomView) InputTabComplete(text string, cursorOffset int)

func (*RoomView) MessageView

func (view *RoomView) MessageView() *MessageView

func (*RoomView) MxRoom

func (view *RoomView) MxRoom() *rooms.Room

func (*RoomView) OnKeyEvent

func (view *RoomView) OnKeyEvent(event mauview.KeyEvent) bool

func (*RoomView) OnMouseEvent

func (view *RoomView) OnMouseEvent(event mauview.MouseEvent) bool

func (*RoomView) OnPasteEvent

func (view *RoomView) OnPasteEvent(event mauview.PasteEvent) bool

func (*RoomView) OnSelect

func (view *RoomView) OnSelect(message *messages.UIMessage)

func (*RoomView) Redact

func (view *RoomView) Redact(eventID id.EventID, reason string)

func (*RoomView) SelectNext

func (view *RoomView) SelectNext()

func (*RoomView) SelectPrevious

func (view *RoomView) SelectPrevious()

func (*RoomView) SendMessage

func (view *RoomView) SendMessage(msgtype event.MessageType, text string)

func (*RoomView) SendMessageHTML

func (view *RoomView) SendMessageHTML(msgtype event.MessageType, text, html string)

func (*RoomView) SendReaction

func (view *RoomView) SendReaction(eventID id.EventID, reaction string)

func (*RoomView) SetCompletions

func (view *RoomView) SetCompletions(completions []string)

func (*RoomView) SetEditing

func (view *RoomView) SetEditing(evt *muksevt.Event)

func (*RoomView) SetInputChangedFunc

func (view *RoomView) SetInputChangedFunc(fn func(room *RoomView, text string)) *RoomView

func (*RoomView) SetInputText

func (view *RoomView) SetInputText(newText string) *RoomView

func (*RoomView) SetTyping

func (view *RoomView) SetTyping(users []id.UserID)

func (*RoomView) StartSelecting

func (view *RoomView) StartSelecting(reason SelectReason, content string)

func (*RoomView) StopSelecting

func (view *RoomView) StopSelecting()

func (*RoomView) Update

func (view *RoomView) Update()

func (*RoomView) UpdateUserList

func (view *RoomView) UpdateUserList()

type SelectReason

type SelectReason string

type SimpleToggleMessage

type SimpleToggleMessage string

func (SimpleToggleMessage) Format

func (stm SimpleToggleMessage) Format(state bool) string

func (SimpleToggleMessage) Name

func (stm SimpleToggleMessage) Name() string

type SyncingModal

type SyncingModal struct {
	// contains filtered or unexported fields
}

func NewSyncingModal

func NewSyncingModal(parent *MainView) (mauview.Component, *SyncingModal)

func (*SyncingModal) Close

func (sm *SyncingModal) Close()

func (*SyncingModal) SetIndeterminate

func (sm *SyncingModal) SetIndeterminate()

func (*SyncingModal) SetMessage

func (sm *SyncingModal) SetMessage(text string)

func (*SyncingModal) SetSteps

func (sm *SyncingModal) SetSteps(max int)

func (*SyncingModal) Step

func (sm *SyncingModal) Step()

type TagNameList

type TagNameList []string

TagNameList is a list of Matrix tag names where default names are sorted in a hardcoded way.

func (TagNameList) Len

func (tnl TagNameList) Len() int

func (TagNameList) Less

func (tnl TagNameList) Less(i, j int) bool

func (TagNameList) Swap

func (tnl TagNameList) Swap(i, j int)

type TagRoomList

type TagRoomList struct {
	mauview.NoopEventHandler
	// contains filtered or unexported fields
}

func NewTagRoomList

func NewTagRoomList(parent *RoomList, name string, rooms ...*OrderedRoom) *TagRoomList

func (*TagRoomList) All

func (trl *TagRoomList) All() []*OrderedRoom

func (*TagRoomList) Bump

func (trl *TagRoomList) Bump(mxRoom *rooms.Room)

func (*TagRoomList) Draw

func (trl *TagRoomList) Draw(screen mauview.Screen)

func (*TagRoomList) DrawHeader

func (trl *TagRoomList) DrawHeader(screen mauview.Screen)

func (*TagRoomList) FirstVisible

func (trl *TagRoomList) FirstVisible() *rooms.Room

func (*TagRoomList) HasInvisibleRooms

func (trl *TagRoomList) HasInvisibleRooms() bool

func (*TagRoomList) HasVisibleRooms

func (trl *TagRoomList) HasVisibleRooms() bool

func (*TagRoomList) Index

func (trl *TagRoomList) Index(room *rooms.Room) int

func (*TagRoomList) IndexVisible

func (trl *TagRoomList) IndexVisible(room *rooms.Room) int

func (*TagRoomList) Insert

func (trl *TagRoomList) Insert(order json.Number, mxRoom *rooms.Room)

func (*TagRoomList) IsCollapsed

func (trl *TagRoomList) IsCollapsed() bool

func (*TagRoomList) IsEmpty

func (trl *TagRoomList) IsEmpty() bool

func (*TagRoomList) LastVisible

func (trl *TagRoomList) LastVisible() *rooms.Room

func (*TagRoomList) Length

func (trl *TagRoomList) Length() int

func (*TagRoomList) Remove

func (trl *TagRoomList) Remove(room *rooms.Room)

func (*TagRoomList) RemoveIndex

func (trl *TagRoomList) RemoveIndex(index int)

func (*TagRoomList) RenderHeight

func (trl *TagRoomList) RenderHeight() int

func (*TagRoomList) ShouldBeAfter

func (trl *TagRoomList) ShouldBeAfter(room1 *OrderedRoom, room2 *OrderedRoom) bool

ShouldBeAfter returns if the first room should be after the second room in the room list. The manual order and last received message timestamp are considered.

func (*TagRoomList) ToggleCollapse

func (trl *TagRoomList) ToggleCollapse()

func (*TagRoomList) TotalLength

func (trl *TagRoomList) TotalLength() int

func (*TagRoomList) Visible

func (trl *TagRoomList) Visible() []*OrderedRoom

type ToggleMessage

type ToggleMessage interface {
	Name() string
	Format(state bool) string
}

type View

type View string
const (
	ViewLogin View = "login"
	ViewMain  View = "main"
)

Allowed views in GomuksUI

Directories

Path Synopsis
Package messages contains different message types and code to generate and render them.
Package messages contains different message types and code to generate and render them.
html
gomuks - A terminal Matrix client written in Go.
gomuks - A terminal Matrix client written in Go.
tstring
Package tstring contains a string type that stores style data for each character, allowing it to be rendered to a tcell screen essentially unmodified.
Package tstring contains a string type that stores style data for each character, allowing it to be rendered to a tcell screen essentially unmodified.
Package widget contains additional tview widgets.
Package widget contains additional tview widgets.

Jump to

Keyboard shortcuts

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