components

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IconOnline       = "●"
	IconOffline      = "○"
	IconChannel      = "#"
	IconGroup        = "☰"
	IconIM           = "●"
	IconMpIM         = "☰"
	IconNotification = "*"

	PresenceAway   = "away"
	PresenceActive = "active"

	ChannelTypeChannel = "channel"
	ChannelTypeGroup   = "group"
	ChannelTypeIM      = "im"
	ChannelTypeMpIM    = "mpim"
)
View Source
const (
	CommandMode = "NORMAL"
	InsertMode  = "INSERT"
	SearchMode  = "SEARCH"
)

Variables

View Source
var (
	COLORS = []string{
		"fg-black",
		"fg-red",
		"fg-green",
		"fg-yellow",
		"fg-blue",
		"fg-magenta",
		"fg-cyan",
		"fg-white",
	}
)

Functions

This section is empty.

Types

type ChannelItem added in v0.3.0

type ChannelItem struct {
	ID             string
	Name           string
	Topic          string
	Type           string
	UserID         string
	Presence       string
	Notification   bool
	StylePrefix    string
	StyleIcon      string
	StyleText      string
	IsSearchResult bool
}

func (*ChannelItem) GetChannelName added in v0.3.0

func (c *ChannelItem) GetChannelName() string

GetChannelName will return a formatted representation of the name of the channel

func (*ChannelItem) ToString added in v0.3.0

func (c *ChannelItem) ToString() string

ToString will set the label of the channel, how it will be displayed on screen. Based on the type, different icons are shown, as well as an optional notification icon.

type Channels

type Channels struct {
	ChannelItems    map[string]*ChannelItem // mapping of channel IDs to ChannelItems
	CursorPosition  int                     // the y position of the cursor in this component
	List            *termui.List            // ui of visible channels
	Offset          int                     // offset in channel list from which items are render
	SearchPosition  int                     // current position in search results
	SelectedChannel string                  // index of which channel is selected from the List
	UnreadOnly      bool                    // only show unread messages when on
	// contains filtered or unexported fields
}

Channels is the definition of a Channels component

func CreateChannelsComponent added in v0.3.0

func CreateChannelsComponent(height int, unreadOnly bool) *Channels

CreateChannels is the constructor for the Channels component

func (*Channels) Buffer

func (c *Channels) Buffer() termui.Buffer

Buffer implements interface termui.Bufferer

func (*Channels) GetHeight

func (c *Channels) GetHeight() int

GetHeight implements interface termui.GridBufferer

func (*Channels) GetNextChannel added in v0.5.0

func (c *Channels) GetNextChannel() (next *ChannelItem, ok bool)

GetNextChannel gets the channel item that proceeds the selected channel item in the visible channel list

func (*Channels) GetPreviousChannel added in v0.5.0

func (c *Channels) GetPreviousChannel() (prev *ChannelItem, ok bool)

GetPreviousChannel gets the channel item that preceeds the selected channel item in the visible channel list

func (*Channels) GetSelectedChannel added in v0.3.0

func (c *Channels) GetSelectedChannel() (selected *ChannelItem, ok bool)

Get SelectedChannel returns the ChannelItem that is currently selected return - selected: the selected channel item - ok: true if there exists a selected channel item in the channel list

func (*Channels) GotoPosition added in v0.3.0

func (c *Channels) GotoPosition(newPos int) (ok bool)

GotoPosition scrolls the channel list to a new position in the current search results

func (*Channels) Jump added in v0.5.0

func (c *Channels) Jump()

Jump to the first channel with a notification

func (*Channels) ListChannels added in v0.5.0

func (c *Channels) ListChannels() (items []*ChannelItem)

ListChannels lists all visible channels if the application has UnreadOnly disabled, list all channels if the application has UnreadOnly enabled

  • always includes the currently selected channel (if one is selected)
  • always show channels that match the current search
  • never show channels that are read and match neither of the above conditions

func (*Channels) MarkAsRead added in v0.4.1

func (c *Channels) MarkAsRead(channelID string)

MarkAsRead marks a channel as read

func (*Channels) MarkAsUnread added in v0.4.1

func (c *Channels) MarkAsUnread(channelID string)

MarkAsUnread marks a channel as unread

func (*Channels) MoveCursorBottom

func (c *Channels) MoveCursorBottom()

MoveCursorBottom will move the cursor to the bottom of the channels

func (*Channels) MoveCursorTop

func (c *Channels) MoveCursorTop()

MoveCursorTop will move the cursor to the top of the channels

func (*Channels) ScrollToChannel added in v0.5.0

func (c *Channels) ScrollToChannel(channelID string)

ScrollToChannel repositions the Offset such that when the screen renders, the channel identified by channelID is visible.

func (*Channels) Search added in v0.2.2

func (c *Channels) Search(term string) (resultCount int)

Search will search through the channels to find a channel, when a match has been found the selected channel will then be the channel that has been found

func (*Channels) SearchNext added in v0.3.0

func (c *Channels) SearchNext()

SearchNext allows us to cycle through search results

func (*Channels) SearchPrev added in v0.3.0

func (c *Channels) SearchPrev()

SearchPrev allows us to cycle through search results

func (*Channels) SetChannels added in v0.3.0

func (c *Channels) SetChannels(channels []*ChannelItem)

SetChannels sets the channel list for this component. `channels` is assumed to be sorted

func (*Channels) SetPresence added in v0.2.2

func (c *Channels) SetPresence(channelID string, presence string)

SetPresence sets the presnce on a given channel

func (*Channels) SetSelectedChannel

func (c *Channels) SetSelectedChannel(channelID string)

SetSelectedChannel sets the SelectedChannel given its ID

func (*Channels) SetWidth

func (c *Channels) SetWidth(w int)

SetWidth implements interface termui.GridBufferer

func (*Channels) SetX

func (c *Channels) SetX(x int)

SetX implements interface termui.GridBufferer

func (*Channels) SetY

func (c *Channels) SetY(y int)

SetY implements interface termui.GridBufferer

type Chat

type Chat struct {
	List     *termui.List
	Messages map[string]Message
	Offset   int
	// contains filtered or unexported fields
}

Chat is the definition of a Chat component

func CreateChatComponent added in v0.3.0

func CreateChatComponent(inputHeight int) *Chat

CreateChatComponent is the constructor for the Chat struct

func (*Chat) AddMessage

func (c *Chat) AddMessage(message Message)

AddMessage adds a single message to Messages

func (*Chat) AddReply added in v0.5.0

func (c *Chat) AddReply(parentID string, message Message)

AddReply adds a single reply to a parent thread, it also sets the thread separator

func (*Chat) Buffer

func (c *Chat) Buffer() termui.Buffer

Buffer implements interface termui.Bufferer

func (*Chat) ClearMessages

func (c *Chat) ClearMessages()

ClearMessages clear the c.Messages

func (*Chat) DeleteMessage added in v0.5.0

func (c *Chat) DeleteMessage(messageID string)

DeleteMessage deletes a single message from Messages

func (*Chat) GetHeight

func (c *Chat) GetHeight() int

GetHeight implements interface termui.GridBufferer

func (*Chat) GetMaxItems added in v0.3.0

func (c *Chat) GetMaxItems() int

GetMaxItems return the maximal amount of items can fit in the Chat component

func (*Chat) GetMessage added in v0.5.0

func (c *Chat) GetMessage(parentID string, threadID string) (message *Message, ok bool)

GetMessage gets a message from the chat history

func (*Chat) Help added in v0.2.0

func (c *Chat) Help(usage string, cfg *config.Config)

Help shows the usage and key bindings in the chat pane

func (*Chat) MessageToCells added in v0.5.0

func (c *Chat) MessageToCells(msg Message) []termui.Cell

MessageToCells will convert a Message struct to termui.Cell

We're building parts of the message individually, or else DefaultTxBuilder will interpret potential markdown usage in a message as well.

func (*Chat) MessagesToCells added in v0.5.0

func (c *Chat) MessagesToCells(msgs map[string]Message) []termui.Cell

MessagesToCells is a wrapper around MessageToCells to use for a slice of of type Message

func (*Chat) ScrollDown

func (c *Chat) ScrollDown()

ScrollDown will render the chat messages based on the Offset of the Chat pane.

Offset is 0 when scrolled down. (we loop backwards over the array, so we start with rendering last item in the list at the maximum y of the Chat pane). Increasing the Offset will thus result in substracting the offset from the len(Chat.Messages).

func (*Chat) ScrollUp

func (c *Chat) ScrollUp()

ScrollUp will render the chat messages based on the Offset of the Chat pane.

Offset is 0 when scrolled down. (we loop backwards over the array, so we start with rendering last item in the list at the maximum y of the Chat pane). Increasing the Offset will thus result in substracting the offset from the len(Chat.Messages).

func (*Chat) SetBorderLabel

func (c *Chat) SetBorderLabel(channelName string)

SetBorderLabel will set Label of the Chat pane to the specified string

func (*Chat) SetMessages added in v0.3.0

func (c *Chat) SetMessages(messages []Message)

SetMessages will put the provided messages into the Messages field of the Chat view

func (*Chat) SetWidth

func (c *Chat) SetWidth(w int)

SetWidth implements interface termui.GridBufferer

func (*Chat) SetX

func (c *Chat) SetX(x int)

SetX implements interface termui.GridBufferer

func (*Chat) SetY

func (c *Chat) SetY(y int)

SetY implements interface termui.GridBufferer

func (*Chat) ToggleMessageIDs added in v0.5.0

func (c *Chat) ToggleMessageIDs()

ToggleMessageIDs toggles the visibility of message IDs on and off in chat view

type Debug added in v0.3.0

type Debug struct {
	Par  *termui.Par
	List *termui.List
}

Debug can be used to relay debugging information in the Debug component, see event.go on how to use it

func CreateDebugComponent added in v0.3.0

func CreateDebugComponent(inputHeight int) *Debug

func (*Debug) Buffer added in v0.3.0

func (d *Debug) Buffer() termui.Buffer

Buffer implements interface termui.Bufferer

func (*Debug) GetHeight added in v0.3.0

func (d *Debug) GetHeight() int

GetHeight implements interface termui.GridBufferer

func (*Debug) Println added in v0.3.0

func (d *Debug) Println(text string)

Println will add the text to the Debug component

func (*Debug) SetWidth added in v0.3.0

func (d *Debug) SetWidth(w int)

SetWidth implements interface termui.GridBufferer

func (*Debug) SetX added in v0.3.0

func (d *Debug) SetX(x int)

SetX implements interface termui.GridBufferer

func (*Debug) SetY added in v0.3.0

func (d *Debug) SetY(y int)

SetY implements interface termui.GridBufferer

func (*Debug) Sprintf added in v0.5.0

func (d *Debug) Sprintf(format string, a ...interface{})

type Input

type Input struct {
	Par                  *termui.Par
	Text                 []rune
	CursorPositionScreen int
	CursorPositionText   int
	Offset               int
}

Input is the definition of an Input component

func CreateInputComponent added in v0.3.0

func CreateInputComponent() *Input

CreateInput is the constructor of the Input struct

func (*Input) Backspace

func (i *Input) Backspace()

Backspace will remove a character in front of the CursorPositionText

func (*Input) Buffer

func (i *Input) Buffer() termui.Buffer

Buffer implements interface termui.Bufferer

func (*Input) CalculateOffset added in v0.3.0

func (i *Input) CalculateOffset() int

CalculateOffset will, based on the width of the runes on the left of the text cursor, calculate the offset that needs to be used by the Inpute Component

func (*Input) Clear

func (i *Input) Clear()

Clear will empty the input and move the cursor to the start position

func (*Input) Delete

func (i *Input) Delete()

Delete will remove a character at the CursorPositionText

func (*Input) GetHeight

func (i *Input) GetHeight() int

GetHeight implements interface termui.GridBufferer

func (*Input) GetMaxWidth added in v0.3.0

func (i *Input) GetMaxWidth() int

GetMaxWidth returns the maximum number of positions the Input component can display

func (*Input) GetRuneWidthLeft added in v0.3.0

func (i *Input) GetRuneWidthLeft() int

GetRuneWidthLeft will get the width of a rune on the left side of the CursorPositionText

func (*Input) GetRuneWidthOffsetToCursor added in v0.3.0

func (i *Input) GetRuneWidthOffsetToCursor() int

GetRunWidthOffsetToCursor will get the rune width of all the runes from the offset until the text cursor

func (*Input) GetRuneWidthRight added in v0.3.0

func (i *Input) GetRuneWidthRight() int

GetRuneWidthLeft will get the width of a rune on the right side of the CursorPositionText

func (*Input) GetText

func (i *Input) GetText() string

GetText returns the text currently in the input

func (*Input) Insert

func (i *Input) Insert(key rune)

Insert will insert a given key at the place of the current CursorPositionText

func (*Input) IsEmpty

func (i *Input) IsEmpty() bool

IsEmpty will return true when the input is empty

func (*Input) MoveCursorLeft

func (i *Input) MoveCursorLeft()

MoveCursorLeft will decrease the current CursorPositionText with 1

func (*Input) MoveCursorRight

func (i *Input) MoveCursorRight()

MoveCursorRight will increase the current CursorPositionText with 1

func (*Input) ScrollLeft added in v0.3.0

func (i *Input) ScrollLeft()

func (*Input) ScrollRight added in v0.3.0

func (i *Input) ScrollRight()

func (*Input) SetText added in v0.5.0

func (i *Input) SetText(text string)

SetText sets the text of the input and places the cursor at the end of it

func (*Input) SetWidth

func (i *Input) SetWidth(w int)

SetWidth implements interface termui.GridBufferer

func (*Input) SetX

func (i *Input) SetX(x int)

SetX implements interface termui.GridBufferer

func (*Input) SetY

func (i *Input) SetY(y int)

SetY implements interface termui.GridBufferer

type Message added in v0.3.0

type Message struct {
	ID          string
	Edited      bool
	MsgID       string
	ThreadID    string
	Messages    map[string]Message
	Time        time.Time
	Thread      string
	Name        string
	Content     string
	StyleTime   string
	StyleThread string
	StyleName   string
	StyleText   string
	FormatTime  string
}

func SortMessages added in v0.5.0

func SortMessages(msgs map[string]Message) []Message

func (Message) GetContent added in v0.5.0

func (m Message) GetContent() string

func (Message) GetMsgID added in v0.5.0

func (m Message) GetMsgID() string

func (Message) GetName added in v0.5.0

func (m Message) GetName() string

func (Message) GetThread added in v0.5.0

func (m Message) GetThread() string

func (Message) GetTime added in v0.5.0

func (m Message) GetTime() string

type Mode

type Mode struct {
	Par *termui.Par
}

Mode is the definition of Mode component

func CreateModeComponent added in v0.3.0

func CreateModeComponent() *Mode

CreateMode is the constructor of the Mode struct

func (*Mode) Buffer

func (m *Mode) Buffer() termui.Buffer

Buffer implements interface termui.Bufferer

func (*Mode) GetHeight

func (m *Mode) GetHeight() int

GetHeight implements interface termui.GridBufferer

func (*Mode) SetCommandMode added in v0.3.0

func (m *Mode) SetCommandMode()

func (*Mode) SetInsertMode added in v0.3.0

func (m *Mode) SetInsertMode()

func (*Mode) SetSearchMode added in v0.3.0

func (m *Mode) SetSearchMode()

func (*Mode) SetWidth

func (m *Mode) SetWidth(w int)

SetWidth implements interface termui.GridBufferer

func (*Mode) SetX

func (m *Mode) SetX(x int)

SetX implements interface termui.GridBufferer

func (*Mode) SetY

func (m *Mode) SetY(y int)

SetY implements interface termui.GridBufferer

type Threads added in v0.5.0

type Threads struct {
	*Channels
}

func CreateThreadsComponent added in v0.5.0

func CreateThreadsComponent(height int) *Threads

Jump to

Keyboard shortcuts

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