compose

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: AGPL-3.0 Imports: 41 Imported by: 0

Documentation

Overview

Package compose contains widgets used for composing a Matrix message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionData

type ActionData struct {
	Name string
	Icon string
	Func func()
}

ActionData is the data that the action button in the composer bar is currently doing.

type Composer

type Composer struct {
	*gtk.Box
	// contains filtered or unexported fields
}

Composer is a message composer.

func New

func New(ctx context.Context, ctrl Controller, roomID matrix.RoomID) *Composer

New creates a new Composer.

func (*Composer) Edit

func (c *Composer) Edit(eventID matrix.EventID) bool

Edit switches the composer to edit mode and grabs an older message's body. If the message cannot be fetched from just the timeline state, then it will not be shown to the user. This means that editing backlog messages will behave weirdly.

TODO(diamond): allow editing older messages. TODO(diamond): lossless Markdown editing (no mentions are lost).

func (*Composer) Input

func (c *Composer) Input() *Input

Input returns the composer's input.

func (*Composer) ReplyTo

func (c *Composer) ReplyTo(eventID matrix.EventID) bool

ReplyTo sets the event ID that the to-be-sent message is supposed to be replying to. It replaces the previously-set event ID. The event ID is cleared when the message is sent. An empty string clears the replying state.

func (*Composer) SetPlaceholder added in v0.1.2

func (c *Composer) SetPlaceholder(markup string)

SetPlaceholder sets the composer's placeholder. The default is used if an empty string is given.

type Controller

type Controller interface {
	message.MessageViewer
	// FocusLatestUserEventID returns the latest event ID of the current user,
	// or an empty string if none.
	FocusLatestUserEventID() matrix.EventID
	// AddSendingMessage adds the given RawEvent as a sending message and
	// returns a mark that is given to BindSendingMessage.
	AddSendingMessage(ev event.RoomEvent) (mark interface{})
	// AddSendingMessageCustom adds the given RawEvent as a sending message and
	// the given widget as the widget body, returning a mark that is given to
	// BindSendingMessage.
	AddSendingMessageCustom(ev event.RoomEvent, w gtk.Widgetter) (mark interface{})
	// StopSendingMessage stops sending the message with the given mark.
	StopSendingMessage(mark interface{}) bool
	// BindSendingMessage takes in the mark value returned by AddSendingMessage.
	BindSendingMessage(mark interface{}, evID matrix.EventID) (replaced bool)
}

Controller describes the parent component that the Composer controls.

type Input

type Input struct {
	*gtk.TextView
	// contains filtered or unexported fields
}

Input is the input component of the message composer.

func NewInput

func NewInput(ctx context.Context, ctrl InputController, roomID matrix.RoomID) *Input

NewInput creates a new Input instance.

func (*Input) HTML

func (i *Input) HTML(start, end *gtk.TextIter) string

HTML returns the Input's content as HTML.

func (*Input) Send

func (i *Input) Send() bool

Send sends the message inside the input off.

func (*Input) SetText

func (i *Input) SetText(text string)

SetText sets the given text (in raw Markdown format, preferably) into the input buffer and emits the right signals to render it.

func (*Input) Text

func (i *Input) Text(start, end *gtk.TextIter) string

Text returns the Input's content as plain text.

type InputController

type InputController interface {
	Controller
	// IsEditing returns true if we're currently editing a message.
	IsEditing() bool
}

InputController extends Controller to provide additional state getters.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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