Documentation ¶
Index ¶
- Constants
- Variables
- func GetConfigDirectory() (string, error)
- func GetConfigFile() (string, error)
- func GetScriptDirectory() string
- func GetThemeFile() (string, error)
- func LoadConfig() error
- func LoadTheme() error
- func PersistConfig() error
- func SetConfigDirectory(directoryPath string) error
- func SetConfigFile(configFilePath string) error
- func SetScriptDirectory(directoryPath string) error
- func UpdateCurrentToken(newToken string)
- type Account
- type Config
- type Theme
- type UserColor
Constants ¶
const ( //AppNameLowercase is the representative name, but lowercase. //It us used for filepaths and such. AppNameLowercase = "gord" //HourMinuteAndSeconds is the time format HH:MM:SS. HourMinuteAndSeconds = 0 //HourAndMinute is the time format HH:MM. HourAndMinute = 1 //NoTime means that not time at all will be displayed. NoTime = 2 // DoNothingOnTypeInList means that when typing in a list (treeview) simply // nothing will happen. DoNothingOnTypeInList = 0 // SearchOnTypeInList will cause the widget to search through it's // children, trying to find anything that is prefixed with the // previously entered characters. SearchOnTypeInList = 1 // FocusMessageInputOnTypeInList will automatically focus the message input // component and transfer the typed character into it as well. FocusMessageInputOnTypeInList = 2 // NoColor will render all usernames using the PrimaryTextColor defined in // the theme that's currently loaded. NoColor UserColor = "none" // SingleColor causes cordless to take the color specified in the theme SingleColor UserColor = "single" // RandomColor causes cordless to take a random color from the theme // specified pool of usable random colors. RandomColor UserColor = "random" // RoleColor attempts to use the first colored role it finds for a user. RoleColor UserColor = "role" )
Variables ¶
var (
//Current is the currently loaded configuration.
Current = createDefaultConfig()
)
Functions ¶
func GetConfigDirectory ¶
GetConfigDirectory retrieves the directory that stores cordless' settings from cache or sets it to the default location
func GetConfigFile ¶
GetConfigFile retrieves the config file path from cache or sets it to the default config file location
func GetScriptDirectory ¶
func GetScriptDirectory() string
GetScriptDirectory retrieves the script path from cache or sets it to the default script directory location
func GetThemeFile ¶
GetThemeFile returns the path to the theme file.
func LoadConfig ¶
func LoadConfig() error
LoadConfig loads the configuration. After loading the configuration, it can be accessed via config.Current.
func LoadTheme ¶
func LoadTheme() error
LoadTheme reads the theme from the users configuration folder and stored it in the local state. It can be retrieved via GetTheme.
func PersistConfig ¶
func PersistConfig() error
PersistConfig saves the current configuration onto the filesystem.
func SetConfigDirectory ¶
SetConfigDirectory sets the directory cache
func SetConfigFile ¶
SetConfigFile sets the config file path cache to the entered value
func SetScriptDirectory ¶
SetScriptDirectory sets the script directory cache to the specified value
func UpdateCurrentToken ¶
func UpdateCurrentToken(newToken string)
UpdateCurrentToken updates the current token and all accounts where the token was also used.
Types ¶
type Account ¶
Account has a name and a token. The name is just for the users recognition. The token is the actual token used to authenticate against the discord API.
type Config ¶
type Config struct { //Token is the authorization token for accessing the discord API. Token string //Autocomplete decides whether the chat automatically offers autocomplete //values for the currently given text. Autocomplete bool //Times decides on the time format (none, short and long). Times int //UserColors decides how cordless determines in which color it displays //a user in the chat or the user tree. UserColors UserColor //FocusChannelAfterGuildSelection will cause the widget focus to move over //to the channel tree after selecting a guild. FocusChannelAfterGuildSelection bool //FocusMessageInputAfterChannelSelection will cause the widget focus to //move over to the message input widget after channel selection FocusMessageInputAfterChannelSelection bool //ShowUserContainer decides whether the user container is part of the //layout or not. ShowUserContainer bool //UseFixedLayout defines whether the FixedSizeLeft and FixedSizeRight //values will be applied or not. UseFixedLayout bool //FixedSizeLeft determines the size of the guilds/channels/friends //container on the left side of the layout. FixedSizeLeft int //FixedSizeRight defines the size of the users container on the right. FixedSizeRight int // OnTypeInListBehaviour defines whether the application focus the input // input field on typing, searches the list or does nothing. OnTypeInListBehaviour int // MouseEnabled decides whether the mouse is usable or not. MouseEnabled bool // ShortenLinks decides whether cordless starts a local webserver in order // to be able to shorten links ShortenLinks bool // ShortenWithExtension defines whether the suffix is added to the shortened // url ShortenWithExtension bool // ShortenerPort defines the port, that the webserver for the linkshortener // will be using. ShortenerPort int // DesktopNotifications decides whether a popup will be shown in the users // system when a notification needs to be sent. DesktopNotifications bool // DesktopNotificationsUserInactivityThreshold defines how many seconds // have to pass between now and the last user input (key stroke) in order // for a notification to be sent. DesktopNotificationsUserInactivityThreshold int // DesktopNotificationsForLoadedChannel Defines whether notifications are // also sent for the currently selected (loaded) channel. DesktopNotificationsForLoadedChannel bool // ShowPlaceholderForBlockedMessages will cause blocked message to shown // as a placeholder message, replacing user and message with generic text. // The time of the message will still be correct in order to not mess up // the timeline of messages. ShowPlaceholderForBlockedMessages bool // ShowUpdateNotifications decides whether update notifications are // shown at all. ShowUpdateNotifications bool // DontShowUpdateNotificationFor decides what version to skip update // notifications for. Since there's always only one latest version, this // is a string and not an array of strings. DontShowUpdateNotificationFor string // Accounts contains all saved accounts, allowing the user to dynamically // switch between the accounts. Accounts []*Account // Show a padlock prefix of the channels that have access restriction IndicateChannelAccessRestriction bool // ShowBottomBar decides whether an informational line is shown at the // bottom of cordless or not. ShowBottomBar bool // ShowNicknames decides whether nicknames are shown throughout the // application, as there are some childish goons that deem it funny // to impersonate people or change their name every 5 minutes. ShowNicknames bool // ShowReactionsInline decides whether reactions are displayed below a // message. ShowReactionsInline bool // FileHandlers allow registering specific file-handers for certain FileOpenHandlers map[string]string // FileOpenSaveFilesPermanently decides whether opened files are saved // in the system cache (temporary) or in the user specified path. FileOpenSaveFilesPermanently bool // FileDownloadSaveLocation defines the folder where cordless generally // download files to. If FileOpenSaveFilesPermanently has been set to // true, then all opened files are saved in this folder for example. FileDownloadSaveLocation string }
Config contains all possible configuration for the application.
func (*Config) GetAccountToken ¶
GetAccountToken returns the token for the given account or an empty string if the account can't be found or has no token set up.
type Theme ¶
type Theme struct { *tview.Theme BlockedUserColor tcell.Color InfoMessageColor tcell.Color BotColor tcell.Color MessageTimeColor tcell.Color DefaultUserColor tcell.Color LinkColor tcell.Color AttentionColor tcell.Color ErrorColor tcell.Color RandomUserColors []tcell.Color ReplyColor tcell.Color }
Theme is a wrapper around the tview.Theme. This wrapper can be extended with additional theming properties and the underlying tview.Theme can still be applied to tview.Styles