ui

package
Version: v0.0.0-...-52a80d5 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: BSD-3-Clause Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WelcomeText = `` /* 770-byte string literal not displayed */

Functions

func PrompSecretSingleLineInput

func PrompSecretSingleLineInput(app *tview.Application, title, message string) string

PrompSecretSingleLineInput shows a fullscreen input dialog that masks the user input. The returned value will either be empty or what the user has entered.

func PromptSingleLineInput

func PromptSingleLineInput(app *tview.Application,
	activePrimitiveChanged func(primitive tview.Primitive), title, message string) string

PromptSingleLineInput shows a fullscreen input dialog. The returned value will either be empty or what the user has entered.

Types

type ActiveView

type ActiveView bool
const Dms ActiveView = false
const Guilds ActiveView = true

type Autocomplete

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

type AutocompleteValue

type AutocompleteValue struct {
	RenderValue string
	InsertValue string
}

type ChannelTree

type ChannelTree struct {
	*tview.TreeView
	*sync.Mutex
	// contains filtered or unexported fields
}

ChannelTree is the component that displays the channel hierarchy of the currently loaded guild and allows interactions with those channels.

func NewChannelTree

func NewChannelTree(state *discordgo.State) *ChannelTree

NewChannelTree creates a new ready-to-be-used ChannelTree

func (*ChannelTree) AddOrUpdateChannel

func (channelTree *ChannelTree) AddOrUpdateChannel(channel *discordgo.Channel)

AddOrUpdateChannel either adds a new node for the given channel or updates its current node.

func (*ChannelTree) Clear

func (channelTree *ChannelTree) Clear()

Clear resets all current state.

func (*ChannelTree) LoadGuild

func (channelTree *ChannelTree) LoadGuild(guildID string) error

LoadGuild accesses the state in order to load all locally present channels for the passed guild.

func (*ChannelTree) MarkAsLoaded

func (channelTree *ChannelTree) MarkAsLoaded(channelID string)

MarkAsLoaded marks a channel as loaded and therefore marks all other channels as either unread, read or mentioned.

func (*ChannelTree) MarkAsMentioned

func (channelTree *ChannelTree) MarkAsMentioned(channelID string)

MarkAsMentioned marks a channel as mentioned.

func (*ChannelTree) MarkAsRead

func (channelTree *ChannelTree) MarkAsRead(channelID string)

MarkAsRead marks a channel as read.

func (*ChannelTree) MarkAsUnread

func (channelTree *ChannelTree) MarkAsUnread(channelID string)

MarkAsUnread marks a channel as unread.

func (*ChannelTree) RemoveChannel

func (channelTree *ChannelTree) RemoveChannel(channel *discordgo.Channel)

RemoveChannel removes a channels node from the tree.

func (*ChannelTree) SetOnChannelSelect

func (channelTree *ChannelTree) SetOnChannelSelect(handler func(channelID string))

SetOnChannelSelect sets the handler that reacts to channel selection events.

type ChatView

type ChatView struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

ChatView is using a tview.TextView in order to be able to display messages in a simple way. It supports highlighting specific element types and it also supports multiline.

func NewChatView

func NewChatView(state *discordgo.State, ownUserID string) *ChatView

NewChatView constructs a new ready to use ChatView.

func (*ChatView) AddMessage

func (chatView *ChatView) AddMessage(message *discordgo.Message)

AddMessage add an additional message to the ChatView.

func (*ChatView) ClearSelection

func (chatView *ChatView) ClearSelection()

ClearSelection clears the current selection of messages.

func (*ChatView) ClearViewAndCache

func (chatView *ChatView) ClearViewAndCache()

ClearViewAndCache clears the TextView buffer and removes all data for all messages.

func (*ChatView) DeleteMessage

func (chatView *ChatView) DeleteMessage(deletedMessage *discordgo.Message)

DeleteMessage drops the message from the cache and triggers a reprint

func (*ChatView) DeleteMessages

func (chatView *ChatView) DeleteMessages(deletedMessages []string)

DeleteMessages drops the messages from the cache and triggers a reprint

func (*ChatView) GetPrimitive

func (chatView *ChatView) GetPrimitive() tview.Primitive

GetPrimitive returns the component that can be added to a layout, since the ChatView itself is not a component.

func (*ChatView) Reprint

func (chatView *ChatView) Reprint()

Reprint clears the internal TextView and prints all currently cached messages into the internal TextView again. This will not actually cause a redraw in the user interface. This would still only be done by ForceDraw ,QueueUpdateDraw or user events. Calling this method is necessary if previously added content has changed or has been removed, since can only append to the TextViews buffers, but not cut parts out.

func (*ChatView) SetMessages

func (chatView *ChatView) SetMessages(messages []*discordgo.Message)

SetMessages defines all currently displayed messages. Parsing and manipulation of single message elements happens in this function.

func (*ChatView) SetOnMessageAction

func (chatView *ChatView) SetOnMessageAction(onMessageAction func(message *discordgo.Message, event *tcell.EventKey) *tcell.EventKey)

SetOnMessageAction sets the handler that will get called if the user tries to interact with a selected message.

func (*ChatView) SetTitle

func (chatView *ChatView) SetTitle(text string)

SetTitle sets the border text of the chatview.

func (*ChatView) SignalSelectionDeleted

func (chatView *ChatView) SignalSelectionDeleted()

SignalSelectionDeleted notifies the ChatView that its currently selected message doesn't exist anymore, moving the selection up by a row if possible.

func (*ChatView) UpdateMessage

func (chatView *ChatView) UpdateMessage(updatedMessage *discordgo.Message)

UpdateMessage reformats the passed message, updates the cache and triggers a reprint.

type CommandView

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

CommandView contains a simple textview for output and an input field for input. All commands are added to the history when confirmed via enter.

func NewCommandView

func NewCommandView(app *tview.Application, onExecuteCommand func(command string)) *CommandView

NewCommandView creates a new struct containing the components necessary for a command view. It also contains the state for those components.

func (*CommandView) GetCommandInputWidget

func (cmdView *CommandView) GetCommandInputWidget() *tview.TextView

GetCommandInputWidget returns the component that can be added to the layout for the users command input.

func (*CommandView) GetCommandOutputWidget

func (cmdView *CommandView) GetCommandOutputWidget() *tview.TextView

GetCommandOutputWidget is the component that can be added to the layout for the users command output.

func (*CommandView) SetInputCaptureForInput

func (cmdView *CommandView) SetInputCaptureForInput(handler func(event *tcell.EventKey) *tcell.EventKey)

SetInputCaptureForInput defines the input capture for the input component of the command view while prioritizing the predefined handler before passing the event to the externally specified handler.

func (*CommandView) SetInputCaptureForOutput

func (cmdView *CommandView) SetInputCaptureForOutput(handler func(event *tcell.EventKey) *tcell.EventKey)

SetInputCaptureForOutput defines the input capture for the output component of the command view while prioritizing the predefined handler before passing the event to the externally specified handler.

func (*CommandView) SetVisible

func (cmdView *CommandView) SetVisible(visible bool)

SetVisible sets the given visible state to both the input component and the output component

func (*CommandView) Write

func (cmdView *CommandView) Write(p []byte) (n int, err error)

Write lets us implement the io.Writer interface. Tab characters will be replaced with TabSize space characters. A "\n" or "\r\n" will be interpreted as a new line.

type Editor

type Editor struct {

	// App is the tview Application this editor is used in. The reference is
	// required to query the current bracketed paste state.
	App *tview.Application
	// contains filtered or unexported fields
}

Editor is a simple component that wraps tview.TextView in order to give the user minimal text edit functionality.

func NewEditor

func NewEditor(app *tview.Application) *Editor

func NewEditorWithWindow

func NewEditorWithWindow(window *Window) *Editor

NewEditor instantiates a ready to use text editor.

func (*Editor) Autocomplete

func (editor *Editor) Autocomplete(value string)

func (*Editor) Backspace

func (editor *Editor) Backspace()

func (*Editor) DeleteRight

func (editor *Editor) DeleteRight()

func (*Editor) DeleteWordLeft

func (editor *Editor) DeleteWordLeft()

func (*Editor) FindAtSymbolIndexInCurrentWord

func (editor *Editor) FindAtSymbolIndexInCurrentWord() int

func (*Editor) GetPrimitive

func (editor *Editor) GetPrimitive() tview.Primitive

GetPrimitive returns the internal component that can be added to a layout

func (*Editor) GetRequestedHeight

func (editor *Editor) GetRequestedHeight() int

GetRequestedHeight returns the currently requested size.

func (*Editor) GetText

func (editor *Editor) GetText() string

GetText returns the text without color tags, region tags and so on.

func (*Editor) GetTextLeftOfSelection

func (editor *Editor) GetTextLeftOfSelection() string

func (*Editor) InsertCharacter

func (editor *Editor) InsertCharacter(character rune)

func (*Editor) MoveCursorEndOfLine

func (editor *Editor) MoveCursorEndOfLine()

func (*Editor) MoveCursorEndOfText

func (editor *Editor) MoveCursorEndOfText()

func (*Editor) MoveCursorLeft

func (editor *Editor) MoveCursorLeft()

MoveCursorLeft moves the cursor left by one cell.

func (*Editor) MoveCursorRight

func (editor *Editor) MoveCursorRight()

MoveCursorRight moves the cursor right by one cell.

func (*Editor) MoveCursorStartOfLine

func (editor *Editor) MoveCursorStartOfLine()

func (*Editor) MoveCursorStartOfText

func (editor *Editor) MoveCursorStartOfText()

func (*Editor) MoveCursorWordLeft

func (editor *Editor) MoveCursorWordLeft()

func (*Editor) MoveCursorWordRight

func (editor *Editor) MoveCursorWordRight()

func (*Editor) Paste

func (editor *Editor) Paste(event *tcell.EventKey)

func (*Editor) RegisterAutocomplete

func (editor *Editor) RegisterAutocomplete(firstRune rune, allowSpaces bool, valueSupplier func(string) []*AutocompleteValue)

func (*Editor) RerenderTitle

func (editor *Editor) RerenderTitle()

RerenderTitle re-renders the title text, making sure the reply user & mention, and slowmode are correct

func (*Editor) SelectAll

func (editor *Editor) SelectAll()

SelectAll selects all text (cells) currently filled. If no text is available, nothing will change.

func (*Editor) SelectToEndOfLine

func (editor *Editor) SelectToEndOfLine()

SelectToEndOfLine will select all text to the right til the next newline is found. Lines doesn't mean "editor line" in this context, as the editor doesn't currently support vertical navigation.

func (*Editor) SelectToEndOfText

func (editor *Editor) SelectToEndOfText()

SelectToEndOfText will select all text to the end of the editor. Meaning the bottom-right most cell.

func (*Editor) SelectToStartOfLine

func (editor *Editor) SelectToStartOfLine()

SelectToStartOfLine will select all text to the left til the next newline is found. Lines doesn't mean "editor line" in this context, as the editor doesn't currently support vertical navigation.

func (*Editor) SelectToStartOfText

func (editor *Editor) SelectToStartOfText()

SelectToStartOfText will select all text to the start of the editor. Meaning the top-left most cell.

func (*Editor) SelectWordLeft

func (editor *Editor) SelectWordLeft()

SelectWordLeft extends the selection one word to the left. A word may span multiple words. A word however can be one cell and mustn't be a word in terms of human language definition.

func (*Editor) SelectWordRight

func (editor *Editor) SelectWordRight()

SelectWordRight extends the selection one word to the right. A word may span multiple words. A word however can be one cell and mustn't be a word in terms of human language definition.

func (*Editor) SelectionToLeft

func (editor *Editor) SelectionToLeft()

SelectionToLeft extends the selection one cell to the left.

func (*Editor) SelectionToRight

func (editor *Editor) SelectionToRight()

SelectionToRight extends the selection one cell to the right.

func (*Editor) SetAutocompleteValuesUpdateHandler

func (editor *Editor) SetAutocompleteValuesUpdateHandler(handlerFunc func(values []*AutocompleteValue))

func (*Editor) SetBackgroundColor

func (editor *Editor) SetBackgroundColor(color tcell.Color)

SetBackgroundColor sets the background color of the internal TextView

func (*Editor) SetBorderBlinking

func (editor *Editor) SetBorderBlinking(blinking bool)

SetBorderBlinking sets the blinking attribute of the border in tview.

func (*Editor) SetBorderColor

func (editor *Editor) SetBorderColor(color tcell.Color)

SetBorderColor delegates to the underlying components SetBorderColor method.

func (*Editor) SetBorderFocusColor

func (editor *Editor) SetBorderFocusColor(color tcell.Color)

SetBorderFocusColor delegates to the underlying components SetBorderFocusColor method.

func (*Editor) SetInputCapture

func (editor *Editor) SetInputCapture(captureFunc func(event *tcell.EventKey) *tcell.EventKey)

SetInputCapture sets the alternative input capture that will be used if the components default controls aren't being triggered.

func (*Editor) SetOnHeightChangeRequest

func (editor *Editor) SetOnHeightChangeRequest(handler func(requestHeight int))

SetOnHeightChangeRequest handles the cases where the component thinks it needs more space or would be fine with less.

func (*Editor) SetText

func (editor *Editor) SetText(text string)

SetText sets the texts of the internal TextView, but also sets the selection and necessary groups for the navigation behaviour.

func (*Editor) SetTitle

func (editor *Editor) SetTitle(text string)

SetTitle sets the title of the internal TextView

func (*Editor) ShowReply

func (editor *Editor) ShowReply(replyUser string)

ShowReply displays replying status on top of the editor

func (*Editor) ShowSlowMode

func (editor *Editor) ShowSlowMode(slowmodeString string)

ShowSlowMode displays slowmode status on top of the editor

func (*Editor) TriggerHeightRequestIfNecessary

func (editor *Editor) TriggerHeightRequestIfNecessary()

TriggerHeightRequestIfNecessary informs the parent that more or less height is requierd for rendering than currently in use, unless the height is already optimal.

type GuildList

type GuildList struct {
	*tview.TreeView
	// contains filtered or unexported fields
}

GuildList is the UI component to hold all user guilds and allow loading one of them.

func NewGuildList

func NewGuildList(guilds []*discordgo.Guild) *GuildList

NewGuildList creates and initializes a ready to use GuildList.

func (*GuildList) AddGuild

func (g *GuildList) AddGuild(guildID, name string)

AddGuild adds a new node that references the given guildID and shows the given name.

func (*GuildList) MarkAsLoaded

func (g *GuildList) MarkAsLoaded(guildID string)

MarkAsLoaded selects the guild and marks it as loaded.

func (*GuildList) RemoveGuild

func (g *GuildList) RemoveGuild(guildID string)

RemoveGuild removes the node that refers to the given guildID.

func (*GuildList) SetOnGuildSelect

func (g *GuildList) SetOnGuildSelect(handler func(guildID string))

SetOnGuildSelect sets the handler for when a guild is selected.

func (*GuildList) UpdateName

func (g *GuildList) UpdateName(guildID, newName string)

UpdateName updates the name of the guild with the given ID.

func (*GuildList) UpdateNodeStateByGuild

func (g *GuildList) UpdateNodeStateByGuild(guild *discordgo.Guild, loaded bool)

UpdateNodeStateByGuild updates the state of a guilds node accordingly to its readstate, unless the guild represented by that node is loaded.

func (*GuildList) UpdateUnreadGuildCount

func (g *GuildList) UpdateUnreadGuildCount()

UpdateUnreadGuildCount finds the number of guilds containing unread channels and updates the title accordingly.

type Login

type Login struct {
	*tview.Flex
	// contains filtered or unexported fields
}

func NewLogin

func NewLogin(app *tview.Application, configDir string) *Login

NewLogin creates a new login screen with the login components hidden by default.

func (*Login) RequestLogin

func (login *Login) RequestLogin(additionalMessage string) (*discordgo.Session, error)

RequestLogin prompts the user for a discord login. Login can either be done via e-mail and password or an authentication token.

type LoginType

type LoginType int
const (
	None     LoginType = 0
	Token    LoginType = 1
	Password LoginType = 2
)

type PrivateChatList

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

PrivateChatList holds the nodes and handlers for the private view. That is the one responsible for managing private chats and friends.

func NewPrivateChatList

func NewPrivateChatList(state *discordgo.State) *PrivateChatList

NewPrivateChatList creates a new ready to use private chat list.

func (*PrivateChatList) AddOrUpdateChannel

func (privateList *PrivateChatList) AddOrUpdateChannel(channel *discordgo.Channel)

AddOrUpdateChannel either adds a channel or updates the node if it is already present

func (*PrivateChatList) AddOrUpdateFriend

func (privateList *PrivateChatList) AddOrUpdateFriend(user *discordgo.User)

AddOrUpdateFriend either adds a friend or updates the node if it is already present.

func (*PrivateChatList) FetchStatus

func (privateList *PrivateChatList) FetchStatus(id string) (status string)

func (*PrivateChatList) GetComponent

func (privateList *PrivateChatList) GetComponent() *tview.TreeView

GetComponent returns the TreeView component that is used. This component is the top-level container of this struct.

func (*PrivateChatList) Load

func (privateList *PrivateChatList) Load()

Load loads all present data (chats, groups and friends).

func (*PrivateChatList) MarkAsLoaded

func (privateList *PrivateChatList) MarkAsLoaded(channelID string)

MarkAsLoaded marks a channel as loaded, coloring it blue. If a different channel had loaded before, it's set to read.

func (*PrivateChatList) MarkAsRead

func (privateList *PrivateChatList) MarkAsRead(channelID string)

MarkAsRead marks a channel as read.

func (*PrivateChatList) MarkAsUnread

func (privateList *PrivateChatList) MarkAsUnread(channelID string)

MarkAsUnread marks the channel as unread, coloring it red.

func (*PrivateChatList) RemoveChannel

func (privateList *PrivateChatList) RemoveChannel(channel *discordgo.Channel)

RemoveChannel removes a channel node if present.

func (*PrivateChatList) RemoveFriend

func (privateList *PrivateChatList) RemoveFriend(userID string)

RemoveFriend removes a friend node if present. This will not trigger any action on the channel list.

func (*PrivateChatList) Reorder

func (privateList *PrivateChatList) Reorder()

Reorder resorts the list of private chats according to their last message times.

func (*PrivateChatList) SetInputCapture

func (privateList *PrivateChatList) SetInputCapture(capture func(event *tcell.EventKey) *tcell.EventKey)

SetInputCapture delegates to tviews SetInputCapture

func (*PrivateChatList) SetOnChannelSelect

func (privateList *PrivateChatList) SetOnChannelSelect(handler func(channelID string))

SetOnChannelSelect sets the handler that decides what happens when a channel node gets selected.

func (*PrivateChatList) SetOnFriendSelect

func (privateList *PrivateChatList) SetOnFriendSelect(handler func(userID string))

SetOnFriendSelect sets the handler that decides what happens when a friend node gets selected.

type UserTree

type UserTree struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

UserTree represents the visual list of users in a guild.

func NewUserTree

func NewUserTree(state *discordgo.State) *UserTree

NewUserTree creates a new pre-configured UserTree that is empty.

func (*UserTree) AddOrUpdateMember

func (userTree *UserTree) AddOrUpdateMember(member *discordgo.Member)

AddOrUpdateMember adds the passed member to the tree, unless it is already part of the tree, in that case the nodes name is updated.

func (*UserTree) AddOrUpdateMembers

func (userTree *UserTree) AddOrUpdateMembers(members []*discordgo.Member)

AddOrUpdateMembers adds the all passed members to the tree, unless a node is already part of the tree, in that case the nodes name is updated.

func (*UserTree) AddOrUpdateUser

func (userTree *UserTree) AddOrUpdateUser(user *discordgo.User)

AddOrUpdateUser adds a user to the tree, unless the user already exists, in that case the users node gets updated.

func (*UserTree) AddOrUpdateUsers

func (userTree *UserTree) AddOrUpdateUsers(users []*discordgo.User)

AddOrUpdateUsers adds users to the tree, unless they already exists, in that case the users nodes gets updated.

func (*UserTree) Clear

func (userTree *UserTree) Clear()

Clear removes all nodes and data out of the view.

func (*UserTree) FetchStatus

func (userTree *UserTree) FetchStatus(id string) (status string)

func (*UserTree) LoadGroup

func (userTree *UserTree) LoadGroup(channelID string) error

LoadGroup loads all users for a group-channel.

func (*UserTree) LoadGuild

func (userTree *UserTree) LoadGuild(guildID string) error

LoadGuild will load all available roles of the guild and then load all available members. Afterwards the first available node will be selected.

func (*UserTree) RemoveMember

func (userTree *UserTree) RemoveMember(member *discordgo.Member)

RemoveMember finds and removes a node from the tree.

func (*UserTree) RemoveMembers

func (userTree *UserTree) RemoveMembers(members []*discordgo.Member)

RemoveMembers finds and removes all passed members from the tree.

func (*UserTree) SetInputCapture

func (userTree *UserTree) SetInputCapture(capture func(event *tcell.EventKey) *tcell.EventKey)

SetInputCapture delegates to tviews SetInputCapture

type Window

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

Window is basically the whole application, as it contains all the components and the necessary global state.

func NewWindow

func NewWindow(app *tview.Application, session *discordgo.Session, readyEvent *discordgo.Ready) (*Window, error)

NewWindow constructs the whole application window and also registers all necessary handlers and functions. If this function returns an error, we can't start the application.

func (*Window) ApplyFixedLayoutSettings

func (window *Window) ApplyFixedLayoutSettings()

ApplyFixedLayoutSettings applies the current settings for the FixedLayout to the window. This means resizing the components.

func (*Window) DisplaySlowmode

func (window *Window) DisplaySlowmode(currentTime, totalTime int)

DisplaySlowmode takes the slowmode of a channel and the current remaining countdown wait time and displays it on the chatbox

func (*Window) ExecuteCommand

func (window *Window) ExecuteCommand(input string)

ExecuteCommand tries to execute the given input as a command. The first word will be passed as the commands name and the rest will be parameters. If a command can't be found, that info will be printed onto the command output.

func (*Window) FindCommand

func (window *Window) FindCommand(name string) commands.Command

FindCommand searches through the registered command, whether any of them equals the passed name.

func (*Window) ForceRedraw

func (window *Window) ForceRedraw()

ForceRedraw triggers ForceDraw on the underlying tview application, causing it to redraw all currently shown components.

func (*Window) GetRegisteredCommands

func (window *Window) GetRegisteredCommands() []commands.Command

GetRegisteredCommands returns the map of all registered commands.

func (*Window) GetSelectedChannel

func (window *Window) GetSelectedChannel() *discordgo.Channel

GetSelectedChannel returns a reference to the currently selected Channel.

func (*Window) GetSelectedGuild

func (window *Window) GetSelectedGuild() *discordgo.Guild

GetSelectedGuild returns a reference to the currently selected Guild.

func (*Window) IsCursorInsideCodeBlock

func (window *Window) IsCursorInsideCodeBlock() bool

IsCursorInsideCodeBlock checks if the cursor comes after three backticks that don't have another 3 backticks following after them.

func (*Window) LoadChannel

func (window *Window) LoadChannel(channel *discordgo.Channel) error

LoadChannel eagerly loads the channels messages.

func (*Window) OpenDirectMessage

func (window *Window) OpenDirectMessage(userID string) error

OpenDirectMessage creates a new chat with the given user or loads an already existing one. On success, the channel is loaded.

func (*Window) PromptSecretInput

func (window *Window) PromptSecretInput(title, message string) string

PromptSecretInput shows a fullscreen input dialog that masks the user input. The returned value will either be empty or what the user has entered.

func (*Window) QueueUpdateDrawSynchronized

func (window *Window) QueueUpdateDrawSynchronized(runnable func())

QueueUpdateDrawSynchronized is meant to be used by goroutines that aren't the main goroutine in order to wait for the UI-Thread to execute the given If this method is ever called from the main thread, the application will deadlock.

func (*Window) RegisterCommand

func (window *Window) RegisterCommand(command commands.Command)

RegisterCommand register a command. That makes the command available for being called from the message input field, in case the user-defined prefix is in front of the input.

func (*Window) Run

func (window *Window) Run() error

Run Shows the window optionally returning an error.

func (*Window) SetCommandModeEnabled

func (window *Window) SetCommandModeEnabled(enabled bool)

SetCommandModeEnabled hides or shows the command ui elements and toggles the commandMode flag.

func (*Window) ShowCustomErrorDialog

func (window *Window) ShowCustomErrorDialog(title, text string)

ShowCustomErrorDialog shows a simple error dialog with a custom title and text. The button says "Okay" and only closes the dialog.

func (*Window) ShowDialog

func (window *Window) ShowDialog(color tcell.Color, text string, buttonHandler func(button string), buttons ...string)

ShowDialog shows a dialog at the bottom of the window. It doesn't surrender its focus and requires action before allowing the user to proceed. The buttons are handled depending on their text.

func (*Window) ShowErrorDialog

func (window *Window) ShowErrorDialog(text string)

ShowErrorDialog shows a simple error dialog that has only an Okay button, a generic title and the given text.

func (*Window) ShowTFASetup

func (window *Window) ShowTFASetup() error

ShowTFASetup generates a new TFA-Secret and shows a QR-Code. The QR-Code can be scanned and the resulting TFA-Token can be entered into cordless and used to enable TFA on this account.

func (*Window) Shutdown

func (window *Window) Shutdown()

Shutdown disconnects from the discord API and stops the tview application.

func (*Window) SwitchToFriendsPage

func (window *Window) SwitchToFriendsPage()

SwitchToFriendsPage switches the left side of the layout over to the view where you can see your private chats and groups. In addition to that it hides the user list.

func (*Window) SwitchToGuildsPage

func (window *Window) SwitchToGuildsPage()

SwitchToGuildsPage the left side of the layout over to the view where you can see the servers and their channels. In additional to that, it also shows the user list in case the user didn't explicitly hide it.

func (*Window) SwitchToPreviousChannel

func (window *Window) SwitchToPreviousChannel() error

SwitchToPreviousChannel loads the previously loaded channel and focuses it in it's respective UI primitive.

func (*Window) SwitchToPrivateChannel

func (window *Window) SwitchToPrivateChannel(channel *discordgo.Channel)

SwitchToPrivateChannel switches to the friends page, loads the given channel and then focuses the input primitive.

func (*Window) TrySendMessage

func (window *Window) TrySendMessage(targetChannel *discordgo.Channel, message string, replyMsg *discordgo.Message, replyMention bool)

func (*Window) UnloadChannel

func (window *Window) UnloadChannel()

UnloadChannel resets the windows to the state at which no channel has been loaded yet.

func (*Window) UpdateChatHeader

func (window *Window) UpdateChatHeader(channel *discordgo.Channel)

UpdateChatHeader updates the bordertitle of the chatviews container.o The title consist of the channel name and its topic for guild channels. For private channels it's either the recipient in a dm, or all recipients in a group dm channel. If the channel has a nickname, that is chosen.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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