composer

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEmojiCompleter

func NewEmojiCompleter(gID discord.GuildID) autocomplete.Searcher

NewEmojiCompleter creaets a new autocomplete searcher that searches for emojis.

func NewMemberCompleter

func NewMemberCompleter(chID discord.ChannelID) autocomplete.Searcher

NewMemberCompleter creates a new autocomplete searcher that searches for members.

Types

type Controller

type Controller interface {
	SendMessage(SendingMessage)
	StopEditing()
	StopReplying()
	EditLastMessage() bool
}

Controller is the parent Controller for a View.

type EmojiData

type EmojiData struct {
	Guild   *emoji.Guild
	ID      discord.EmojiID
	Name    string
	Content string
}

EmojiData is the Data structure for each emoji.

func (EmojiData) Row

func (d EmojiData) Row(ctx context.Context) *gtk.ListBoxRow

Row satisfies autocomplete.Data.

type File

type File struct {
	Name string
	Type string // MIME type
	Size int64
	Open func() (io.ReadCloser, error)
}

File contains the filename and a callback to open the file that's called asynchronously.

type Input

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

Input is the text field of the composer.

func NewInput

func NewInput(ctx context.Context, ctrl InputController, chID discord.ChannelID) *Input

NewInput creates a new Input widget.

type InputController

type InputController interface {
	// Send sends or edits everything in the current message buffer state.
	Send()
	// Escape is called when the Escape key is pressed. It is meant to stop any
	// ongoing action and return true, or false if no action.
	Escape() bool
	// EditLastMessage is called when the user wants to edit their last message.
	// False is returned if no messages can be found.
	EditLastMessage() bool
	// PasteClipboardFile is called everytime the user pastes a file from their
	// clipboard. The file is usually (but not always) an image.
	PasteClipboardFile(File)
}

InputController is the parent controller that Input controls.

type MemberData

type MemberData discord.Member

MemberData is the Data structure for each member.

func (MemberData) Row

func (d MemberData) Row(ctx context.Context) *gtk.ListBoxRow

type SendingMessage

type SendingMessage struct {
	Content    string
	Files      []File
	ReplyingTo discord.MessageID
}

SendingMessage is the message created to be sent.

type UploadTray

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

UploadTray is the tray holding files to be uploaded.

func NewUploadTray

func NewUploadTray() *UploadTray

NewUploadTray creates a new UploadTray.

func (*UploadTray) AddFile

func (t *UploadTray) AddFile(file File)

AddFile adds a file into the tray.

func (*UploadTray) Clear

func (t *UploadTray) Clear() []File

Clear clears the tray and returns the list of paths that it held.

type View

type View struct {
	*gtk.Box
	Action struct {
		*gtk.Button
		// contains filtered or unexported fields
	}
	Input       *Input
	Placeholder *gtk.Label
	UploadTray  *UploadTray
	Send        *gtk.Button
	// contains filtered or unexported fields
}

func NewView

func NewView(ctx context.Context, ctrl Controller, chID discord.ChannelID) *View

func (*View) ResetPlaceholder added in v0.0.5

func (v *View) ResetPlaceholder()

func (*View) SetPlaceholderMarkup

func (v *View) SetPlaceholderMarkup(markup string)

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

func (*View) StartEditing

func (v *View) StartEditing(msg *discord.Message)

StartEditing starts editing the given message. The message is edited once the user hits send.

func (*View) StartReplyingTo

func (v *View) StartReplyingTo(msg *discord.Message)

StartReplyingTo starts replying to the given message. Visually, there is no difference except for the send button being different.

func (*View) StopEditing

func (v *View) StopEditing()

StopEditing stops editing.

func (*View) StopReplying

func (v *View) StopReplying()

StopReplying undoes the start call.

Jump to

Keyboard shortcuts

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