Documentation
¶
Index ¶
- Constants
- Variables
- type Buffers
- type Command
- type ComponentSize
- type Connection
- type LocalServer
- func (l *LocalServer) Buffers() *Buffers
- func (l *LocalServer) Context() *Connection
- func (l *LocalServer) Messages(name string) []Message
- func (l *LocalServer) Name() string
- func (l *LocalServer) Notifications() Notifications
- func (l *LocalServer) Online() (*cmds.Data, bool)
- func (l *LocalServer) Receive(msg Message) (bool, error)
- func (l *LocalServer) Source() net.Addr
- func (l *LocalServer) Update()
- type Message
- type Notifications
- type Parameters
- type RemoteServer
- func (s *RemoteServer) Buffers() *Buffers
- func (s *RemoteServer) Context() *Connection
- func (s *RemoteServer) Messages(name string) []Message
- func (s *RemoteServer) Name() string
- func (s *RemoteServer) Notifications() Notifications
- func (s *RemoteServer) Online() (*cmds.Data, bool)
- func (s *RemoteServer) Receive(msg Message) (bool, error)
- func (s *RemoteServer) Source() net.Addr
- func (s *RemoteServer) Update()
- type Server
- type Source
- type TUI
Constants ¶
const CommandHelp string = `` /* 5256-byte string literal not displayed */
const KeybindHelp string = `` /* 2240-byte string literal not displayed */
const Logo string = `` /* 265-byte string literal not displayed */
Variables ¶
var ( ErrorSystemBuf = errors.New("performing action on system buffer") // performing action on system buffer ErrorLocalServer = errors.New("performing action on local server") // performing action on local server ErrorNoText = errors.New("no text has been given") // no text has been given ErrorExists = errors.New("item already exists") // item already exists ErrorNotFound = errors.New("item does not exist") // item does not exist ErrorMaxBufs = errors.New("maximum amount of buffers reached") // maximum amount of buffers reached ErrorMaxServers = errors.New("maximum amount of servers reached") // maximum amount of servers reached ErrorNoBuffers = errors.New("no buffers in server") // no buffers in server ErrorEmptyCmd = errors.New("empty command given") // empty command given ErrorInvalidCmd = errors.New("invalid command given") // invalid command given ErrorAlreadyOnline = errors.New("connection is already established") // connection is already established ErrorOffline = errors.New("connection to the server is not established") // connection to the server is not established ErrorArguments = errors.New("invalid number of arguments") // invalid number of arguments ErrorLoggedIn = errors.New("you are already logged in") // you are already logged in ErrorNoRemoteUser = errors.New("user is not requested") // user is not requested ErrorDisconnection = errors.New("connection to the server has been lost") // connection to the server has been lost ErrorNotLoggedIn = errors.New("you are not logged in") // you are not logged in ErrorMessageSelf = errors.New("cannot request to message yourself") // cannot request to message yourself ErrorTypingTooFast = errors.New("you are typing too fast") // you are typing too fast ErrorPasswordNotMatch = errors.New("passwords do not match") // passwords do not match ErrorInvalidArgument = errors.New("provided argument is incorrect") // provided argument is incorrect ErrorMessageFromSelf = errors.New("received message from self") // received message from self ErrorInvalidAddress = errors.New("address of server is not valid") // address of server is not valid )
Functions ¶
This section is empty.
Types ¶
type Buffers ¶
type Buffers struct {
// contains filtered or unexported fields
}
Identifies all the buffers that conform a server. All asocciated functions are independent of the TUI rendering.
func (*Buffers) Current ¶
func (b *Buffers) Current() *tab
Assigns the buffer as online and returns whether it failed or not
func (*Buffers) Hide ¶
Hides a buffer by removing its index and putting it for use by any buffer created in the future.
type Command ¶
type Command struct {
Operation string // Name of the command
Arguments []string // List of arguments
// contains filtered or unexported fields
}
Defines a command to be ran in the TUI
type ComponentSize ¶
type ComponentSize struct {
Size uint // Specifies the size of the component
Relative bool // Specifies whether its relative to the other components
}
Used to change size of a specific component
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Defines the parent context used for any event to be cancelled throughout a connection.
func (*Connection) Cancel ¶
func (c *Connection) Cancel()
Cancels the current context and sets it to the default one
func (*Connection) Create ¶
func (c *Connection) Create(background context.Context)
Sets a new context creating it from the given one by cancelling the previous one first
type LocalServer ¶
type LocalServer struct {
// contains filtered or unexported fields
}
Specifies a local server that is not connected to any remote endpoint
func (*LocalServer) Buffers ¶
func (l *LocalServer) Buffers() *Buffers
func (*LocalServer) Context ¶
func (l *LocalServer) Context() *Connection
func (*LocalServer) Messages ¶
func (l *LocalServer) Messages(name string) []Message
func (*LocalServer) Name ¶
func (l *LocalServer) Name() string
func (*LocalServer) Notifications ¶
func (l *LocalServer) Notifications() Notifications
func (*LocalServer) Source ¶
func (l *LocalServer) Source() net.Addr
func (*LocalServer) Update ¶
func (l *LocalServer) Update()
type Message ¶
type Message struct {
Buffer string // Buffer to store it in
Sender string // Who sends it
Content string // Message text
Timestamp time.Time // Time when it occurred
Source string // Destination name
}
Identifies a TUI message.
type Notifications ¶
type Notifications struct {
// contains filtered or unexported fields
}
Struct that specifies the notification system
func (Notifications) Notify ¶
func (n Notifications) Notify(user string)
Add +1 to the notifications of a user
func (Notifications) Query ¶
func (n Notifications) Query(user string) uint
Query the amount of notifications of a user
func (Notifications) Users ¶
func (n Notifications) Users() []string
Get all users with notifications
func (Notifications) Zero ¶
func (n Notifications) Zero(user string)
Clears all notifications of a user
type Parameters ¶
type Parameters struct {
Buflist ComponentSize // Size of left bar
Userlist ComponentSize // Size of right bar
Verbose bool // Whether to print verbose or not
}
Used to modify the sizes of the components in the TUI for its configuration. Must be exported for external modification
type RemoteServer ¶
type RemoteServer struct {
// contains filtered or unexported fields
}
Specifies a remote server
func NewRemoteServer ¶
func NewRemoteServer(name string, addr Source) *RemoteServer
Creates a new empty remote server with the given data
func (*RemoteServer) Buffers ¶
func (s *RemoteServer) Buffers() *Buffers
func (*RemoteServer) Context ¶
func (s *RemoteServer) Context() *Connection
func (*RemoteServer) Messages ¶
func (s *RemoteServer) Messages(name string) []Message
func (*RemoteServer) Name ¶
func (s *RemoteServer) Name() string
func (*RemoteServer) Notifications ¶
func (s *RemoteServer) Notifications() Notifications
func (*RemoteServer) Source ¶
func (s *RemoteServer) Source() net.Addr
func (*RemoteServer) Update ¶
func (s *RemoteServer) Update()
type Server ¶
type Server interface {
// Updates the values of the server according to the database
Update()
// Returns the name of the server and if it is secure
Name() string
// Returns the address corresponding to their endpoint
// and a boolean indicating if the address is valid
Source() net.Addr
// Returns all messages contained in the specified buffer
Messages(string) []Message
// Returns all notifications belonging to the server
Notifications() Notifications
// Tries to receive a message and indicates if it was for them
// and if any error occurred
Receive(Message) (bool, error)
// Returns the internal buffer struct they may contain
Buffers() *Buffers
// Returns the context of the connection
Context() *Connection
// Returns the command asocciated data and whether
// they are connected to the endpoint or not
Online() (*cmds.Data, bool)
}
Identifies the operations a server must fulfill in order to be considered a server by the TUI.
type TUI ¶
type TUI struct {
// contains filtered or unexported fields
}
Identifies the main TUI with all its components and data.
func New ¶
func New(static cmds.StaticData, debug bool) (*TUI, *tview.Application)
Creates a new TUI and tview application by its given static data. This is needed to run the program in TUI mode.