ui

package
v0.0.0-...-f701b90 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CommandHelp string = `` /* 5256-byte string literal not displayed */
View Source
const KeybindHelp string = `` /* 2240-byte string literal not displayed */
View Source

Variables

View Source
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) GetAll

func (b *Buffers) GetAll() []string

Gets all the buffer names

func (*Buffers) Hide

func (b *Buffers) Hide(name string) error

Hides a buffer by removing its index and putting it for use by any buffer created in the future.

func (*Buffers) New

func (b *Buffers) New(name string, system bool) error

Creates a new buffer (initially hidden).

func (*Buffers) Offline

func (b *Buffers) Offline()

Turns all tabs to offline

func (*Buffers) Remove

func (b *Buffers) Remove(name string) error

Deletes all information about a buffer. It hides the buffer first to recover its index.

func (*Buffers) Show

func (b *Buffers) Show(name string) (int, rune)

Assigns an index to a hidden buffer (unless it was not hidden) and returns the index and asocciated rune. If any index was left by another buffer it will be grabbed first.

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

func (*Connection) Get

func (c *Connection) Get() context.Context

Gets the current context

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) Online

func (l *LocalServer) Online() (*cmds.Data, bool)

func (*LocalServer) Receive

func (l *LocalServer) Receive(msg Message) (bool, error)

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) Clear

func (n Notifications) Clear()

Clears all notifications

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) Online

func (s *RemoteServer) Online() (*cmds.Data, bool)

func (*RemoteServer) Receive

func (s *RemoteServer) Receive(msg Message) (bool, error)

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 Source

type Source struct {
	Address string
	Port    uint16
}

Identifies the source used by gochat

func (Source) Network

func (s Source) Network() string

The network will always be "tcp"

func (Source) String

func (s Source) String() string

Returns the address and port of the server separated by a colon

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.

func (*TUI) Active

func (t *TUI) Active() Server

Returns the currently active server.

func (*TUI) Buffer

func (t *TUI) Buffer() string

Returns the currently active tab in the current server. Only returns the name and not the actual data.

Jump to

Keyboard shortcuts

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