Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigDir() string
- func SetThemeSetting(fsys afero.Fs, path, id string) error
- func SettingsPath() string
- func ThemeIDFromFileName(name string) (string, bool)
- type Account
- type AccountProvider
- func (a AccountProvider) Add(account Account) error
- func (a AccountProvider) GetAccountBy(id string) (Account, error)
- func (a AccountProvider) GetAllAccounts() ([]Account, error)
- func (a AccountProvider) GetMainAccount() (Account, error)
- func (a AccountProvider) MarkAccountAsMain(id string) error
- func (a AccountProvider) Remove(id string) error
- func (a AccountProvider) UpdateLoginNameFor(id, loginName string) error
- func (a AccountProvider) UpdateTokensFor(id, accessToken, refreshToken string) error
- type AppState
- type AppStateManager
- type BlockSettings
- type ChannelHistoryEntry
- type ChannelHistoryManager
- type ChatSettings
- type CustomCommand
- type KeyMap
- type KeyringWrapper
- type ModerationSettings
- type PlainKeyringFallback
- type SecuritySettings
- type Settings
- type TabState
- type Theme
- type ThemeCatalog
- type ThemeEntry
- type ThemeManager
- func (m *ThemeManager) Active() Theme
- func (m *ThemeManager) ActiveID() string
- func (m *ThemeManager) Entries() []ThemeEntry
- func (m *ThemeManager) Lookup(id string) (ThemeEntry, bool)
- func (m *ThemeManager) Reload() error
- func (m *ThemeManager) Select(id string) error
- func (m *ThemeManager) SettingsPath() string
- func (m *ThemeManager) Warnings() []string
- type ThemeResolution
- type ThemeSource
Constants ¶
const ( // DefaultThemeID is the theme used when nothing else is configured. It is a // built-in, so the default never depends on files the user has on disk. DefaultThemeID = "nord" // LegacyThemeID is the id the pre-themes/ theme.yaml file is exposed under. // Keeping it addressable means an existing customization keeps working and // can still be selected from the picker, without ever moving the file. LegacyThemeID = "custom" )
Variables ¶
var ErrAccountNotFound = errors.New("account not found")
Functions ¶
func ConfigDir ¶ added in v1.5.0
func ConfigDir() string
ConfigDir returns the chatuino configuration directory.
func SetThemeSetting ¶ added in v1.5.0
SetThemeSetting stores the theme id in the settings file at path.
The document is edited as a yaml.Node instead of being re-marshalled from Settings: settings.yaml is hand-edited by users, and a round-trip through the struct would drop every comment and every key this version does not model yet.
func SettingsPath ¶ added in v1.5.0
func SettingsPath() string
SettingsPath is where SettingsFromDisk reads the settings from. It is used in user-facing messages so an error can point at the file to edit.
func ThemeIDFromFileName ¶ added in v1.5.0
ThemeIDFromFileName derives a theme id from a file name. It reports false for anything that is not a .yaml/.yml file.
Types ¶
type Account ¶
type Account struct {
ID string `json:"id"`
IsMain bool `json:"is_main"`
IsAnonymous bool `json:"-"`
LoginName string `json:"login_name"`
DisplayName string `json:"display_name"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
CreatedAt time.Time `json:"created_at"`
}
type AccountProvider ¶
type AccountProvider struct {
// contains filtered or unexported fields
}
func NewAccountProvider ¶
func NewAccountProvider(keychain keyring.Keyring) AccountProvider
func (AccountProvider) Add ¶
func (a AccountProvider) Add(account Account) error
func (AccountProvider) GetAccountBy ¶
func (a AccountProvider) GetAccountBy(id string) (Account, error)
func (AccountProvider) GetAllAccounts ¶
func (a AccountProvider) GetAllAccounts() ([]Account, error)
func (AccountProvider) GetMainAccount ¶
func (a AccountProvider) GetMainAccount() (Account, error)
func (AccountProvider) MarkAccountAsMain ¶
func (a AccountProvider) MarkAccountAsMain(id string) error
func (AccountProvider) Remove ¶
func (a AccountProvider) Remove(id string) error
func (AccountProvider) UpdateLoginNameFor ¶ added in v1.2.0
func (a AccountProvider) UpdateLoginNameFor(id, loginName string) error
func (AccountProvider) UpdateTokensFor ¶
func (a AccountProvider) UpdateTokensFor(id, accessToken, refreshToken string) error
type AppState ¶
type AppState struct {
Tabs []TabState `json:"tabs"`
// Decode layout separately, after restoring tabs. Structurally invalid or
// newer layout metadata must not make otherwise valid tab records unloadable.
Layout jsontext.Value `json:"layout,omitempty"`
// Multi-workspace sessions keep the legacy Layout field as the active
// workspace snapshot for older readers; new readers prefer Workspaces.
Workspaces jsontext.Value `json:"workspaces,omitempty"`
}
type AppStateManager ¶ added in v0.6.2
type AppStateManager struct {
// contains filtered or unexported fields
}
func NewAppStateManager ¶ added in v0.6.2
func NewAppStateManager(fs afero.Fs) *AppStateManager
func (*AppStateManager) LoadAppState ¶ added in v0.6.2
func (a *AppStateManager) LoadAppState() (AppState, error)
func (*AppStateManager) SaveAppState ¶ added in v0.6.2
func (a *AppStateManager) SaveAppState(state AppState) error
type BlockSettings ¶ added in v0.6.0
type ChannelHistoryEntry ¶ added in v1.0.0
type ChannelHistoryEntry struct {
ChannelLogin string `json:"channel_login"`
VisitedAt time.Time `json:"visited_at"`
}
ChannelHistoryEntry records a single visited channel with timestamp.
type ChannelHistoryManager ¶ added in v1.0.0
type ChannelHistoryManager struct {
// contains filtered or unexported fields
}
ChannelHistoryManager persists recently visited channels to a JSON file.
func NewChannelHistoryManager ¶ added in v1.0.0
func NewChannelHistoryManager(fs afero.Fs) *ChannelHistoryManager
func (*ChannelHistoryManager) LoadHistory ¶ added in v1.0.0
func (m *ChannelHistoryManager) LoadHistory() ([]ChannelHistoryEntry, error)
LoadHistory reads the channel history from disk, sorted by most-recent first.
func (*ChannelHistoryManager) RecordChannel ¶ added in v1.0.0
func (m *ChannelHistoryManager) RecordChannel(login string) error
RecordChannel upserts a channel into the history, updating its timestamp. The history is capped at maxChannelHistory entries.
type ChatSettings ¶ added in v0.4.0
type ChatSettings struct {
GraphicBadges bool `yaml:"graphic_badges"`
GraphicEmotes bool `yaml:"graphic_emotes"`
GraphicScale int `yaml:"graphic_scale"` // Height of graphic emotes/badges in terminal rows (1-4), default: 1
DisableBadges bool `yaml:"disable_badges"`
DisablePaddingWrappedLines bool `yaml:"disable_padding_wrapped_lines"`
SmoothScroll bool `yaml:"smooth_scroll"`
DisableEmoteTooltip bool `yaml:"disable_emote_tooltip"` // don't show the emote name when hovering a graphic emote with the mouse
NewMessageIndicator bool `yaml:"new_message_indicator"` // show a badge when messages arrive while scrolled up; default: true
ReplyContext bool `yaml:"reply_context"` // quote the message a reply answers above it; default: true
TimeFormat string `yaml:"time_format"` // Go time format string, default: "15:04:05"
UserInspectTimeFormat string `yaml:"user_inspect_time_format"` // Go time format string, default: "2006-01-02 15:04:05"
}
type CustomCommand ¶ added in v0.5.1
type KeyMap ¶ added in v0.0.2
type KeyMap struct {
// General
Up key.Binding `yaml:"up"`
Down key.Binding `yaml:"down"`
Escape key.Binding `yaml:"escape"`
Confirm key.Binding `yaml:"confirm"`
Help key.Binding `yaml:"help"`
// App Binds
Quit key.Binding `yaml:"quit"`
Create key.Binding `yaml:"create"`
Remove key.Binding `yaml:"remove"`
CloseTab key.Binding `yaml:"close_tab"`
DumpScreen key.Binding `yaml:"dump_screen"` // used by lists, and join input type switch
ThemePicker key.Binding `yaml:"theme_picker"` // opens the theme picker and live-preview
// Tab Binds
Next key.Binding `yaml:"next"`
Previous key.Binding `yaml:"previous"`
// Pane controls (active only in pane mode, except PaneMode itself).
PaneMode key.Binding `yaml:"pane_mode"`
PaneFocusLeft key.Binding `yaml:"pane_focus_left"`
PaneFocusDown key.Binding `yaml:"pane_focus_down"`
PaneFocusUp key.Binding `yaml:"pane_focus_up"`
PaneFocusRight key.Binding `yaml:"pane_focus_right"`
PaneSwapLeft key.Binding `yaml:"pane_swap_left"`
PaneSwapDown key.Binding `yaml:"pane_swap_down"`
PaneSwapUp key.Binding `yaml:"pane_swap_up"`
PaneSwapRight key.Binding `yaml:"pane_swap_right"`
PaneSplitColumns key.Binding `yaml:"pane_split_columns"`
PaneSplitRows key.Binding `yaml:"pane_split_rows"`
PaneNarrow key.Binding `yaml:"pane_narrow"`
PaneWiden key.Binding `yaml:"pane_widen"`
PaneShorten key.Binding `yaml:"pane_shorten"`
PaneTaller key.Binding `yaml:"pane_taller"`
PaneClose key.Binding `yaml:"pane_close"`
PaneZoom key.Binding `yaml:"pane_zoom"`
PaneNext key.Binding `yaml:"pane_next"`
PanePrevious key.Binding `yaml:"pane_previous"`
// Quick Join
QuickJoin key.Binding `yaml:"quick_join"`
// Suggestion Binds (chat composer and join channel input)
AcceptSuggestion key.Binding `yaml:"accept_suggestion"`
NextSuggestion key.Binding `yaml:"next_suggestion"`
PrevSuggestion key.Binding `yaml:"prev_suggestion"`
// Chat Binds
InsertMode key.Binding `yaml:"insert_mode"`
InspectMode key.Binding `yaml:"inspect_mode"`
ChatPopUp key.Binding `yaml:"chat_pop_up"`
ChannelPopUp key.Binding `yaml:"channel_pop_up"`
GoToTop key.Binding `yaml:"go_to_top"`
GoToBottom key.Binding `yaml:"go_to_bottom"`
PageUp key.Binding `yaml:"page_up"`
PageDown key.Binding `yaml:"page_down"`
DumpChat key.Binding `yaml:"dump_chat"`
QuickTimeout key.Binding `yaml:"quick_timeout"`
QuickApprove key.Binding `yaml:"quick_approve"`
QuickDeny key.Binding `yaml:"quick_deny"`
UnbanRequests key.Binding `yaml:"unban_requests"`
CopyMessage key.Binding `yaml:"copy_message"`
CopyToClipboard key.Binding `yaml:"copy_to_clipboard"`
ReplyMessage key.Binding `yaml:"reply_message"`
SearchMode key.Binding `yaml:"search_mode"`
QuickSent key.Binding `yaml:"quick_sent"`
// Account Binds
MarkLeader key.Binding `yaml:"mark_leader"`
}
func BuildDefaultKeyMap ¶ added in v0.0.4
func BuildDefaultKeyMap() KeyMap
func CreateReadKeyMap ¶ added in v0.0.2
CreateReadKeyMap reads the keymap file, creating a default one when it does not exist yet. Existing files are never migrated or rewritten: fields that are present keep exactly the keys they list, and only fields added in newer versions fall back to their defaults.
Deleting keymap.yaml is the supported way to pick up new default aliases.
func (*KeyMap) MarshalYAML ¶ added in v0.3.0
type KeyringWrapper ¶ added in v0.0.10
type KeyringWrapper struct {
// contains filtered or unexported fields
}
func NewKeyringWrapper ¶ added in v0.6.0
func NewKeyringWrapper() *KeyringWrapper
func (KeyringWrapper) Delete ¶ added in v0.0.10
func (k KeyringWrapper) Delete(service, user string) error
func (KeyringWrapper) DeleteAll ¶ added in v0.5.0
func (k KeyringWrapper) DeleteAll(service string) error
func (KeyringWrapper) Get ¶ added in v0.0.10
func (k KeyringWrapper) Get(service, user string) (string, error)
func (KeyringWrapper) Set ¶ added in v0.0.10
func (k KeyringWrapper) Set(service, user, password string) error
type ModerationSettings ¶ added in v0.4.0
type PlainKeyringFallback ¶ added in v0.6.2
type PlainKeyringFallback struct {
// contains filtered or unexported fields
}
func NewPlainKeyringFallback ¶ added in v0.6.2
func NewPlainKeyringFallback(fs afero.Fs) *PlainKeyringFallback
func (*PlainKeyringFallback) Delete ¶ added in v0.6.2
func (p *PlainKeyringFallback) Delete(_, _ string) error
func (*PlainKeyringFallback) DeleteAll ¶ added in v0.6.2
func (p *PlainKeyringFallback) DeleteAll(_ string) error
func (*PlainKeyringFallback) Get ¶ added in v0.6.2
func (p *PlainKeyringFallback) Get(_, _ string) (string, error)
func (*PlainKeyringFallback) Set ¶ added in v0.6.2
func (p *PlainKeyringFallback) Set(_, _, jsonData string) error
type SecuritySettings ¶ added in v0.7.0
type SecuritySettings struct {
CheckLinks bool `yaml:"check_links"`
}
type Settings ¶ added in v0.4.0
type Settings struct {
VerticalTabList bool `yaml:"vertical_tab_list"`
// Theme is the id of the active theme. Empty means "nothing configured",
// which keeps a legacy theme.yaml active or falls back to the default.
Theme string `yaml:"theme"`
Mouse bool `yaml:"mouse"` // capture mouse clicks/wheel; default: true
Moderation ModerationSettings `yaml:"moderation"`
Chat ChatSettings `yaml:"chat"`
CustomCommands []CustomCommand `yaml:"custom_commands"`
BlockSettings BlockSettings `yaml:"block_settings"`
Security SecuritySettings `yaml:"security"`
}
func BuildDefaultSettings ¶ added in v0.4.0
func BuildDefaultSettings() Settings
func SettingsFromDisk ¶ added in v0.4.0
func (Settings) BuildCustomSuggestionMap ¶ added in v0.5.1
type Theme ¶ added in v0.5.0
type Theme struct {
// Name is the display name shown in the theme picker. It is optional; the
// filename (without extension) is the theme id.
Name string `yaml:"name"`
SevenTVEmoteColor string `yaml:"seven_tv_emote_color"`
TwitchTVEmoteColor string `yaml:"twitch_tv_emote_color"`
BetterTTVEmoteColor string `yaml:"better_ttv_emote_color"`
FFZEmoteColor string `yaml:"ffz_emote_color"`
InputPromptColor string `yaml:"input_prompt_color"`
ChatStreamerColor string `yaml:"chat_streamer_color"`
ChatVIPColor string `yaml:"chat_vip_color"`
ChatSubColor string `yaml:"chat_sub_color"`
ChatTurboColor string `yaml:"chat_turbo_color"`
ChatModeratorColor string `yaml:"chat_moderator_color"`
ChatIndicatorColor string `yaml:"chat_indicator_color"`
ChatSubAlertColor string `yaml:"chat_sub_alert_color"`
ChatNoticeAlertColor string `yaml:"chat_notice_alert_color"`
ChatClearChatColor string `yaml:"chat_clear_chat_color"`
ChatErrorColor string `yaml:"chat_error_color"`
ListSelectedColor string `yaml:"list_selected_color"`
ListLabelColor string `yaml:"list_label_color"`
ActiveLabelColor string `yaml:"active_label_color"`
StatusColor string `yaml:"status_color"`
ChatuinoSplashColor string `yaml:"chatuino_splash_color"`
SplashHighlightColor string `yaml:"splash_highlight_color"`
TabHeaderBackgroundColor string `yaml:"tab_header_background_color"`
TabHeaderActiveBackgroundColor string `yaml:"tab_header_active_background_color"`
InspectBorderColor string `yaml:"inspect_border_color"`
ListBackgroundColor string `yaml:"list_background_color"`
ListFontColor string `yaml:"list_font_color"`
// UI chrome
DimmedTextColor string `yaml:"dimmed_text_color"`
}
Theme is the complete set of colors one chatuino theme controls.
Every field is optional in a theme file: a file is merged over the default theme, so a theme only has to list the colors it actually changes.
func BuildDefaultTheme ¶ added in v0.5.0
func BuildDefaultTheme() Theme
BuildDefaultTheme returns the hardcoded fallback theme. It is inspired by the Nord color scheme and matches the embedded nord theme, but it exists so a damaged or missing theme catalog can never leave the UI without colors.
func ParseTheme ¶ added in v1.5.0
ParseTheme decodes one theme file. Missing keys keep their default value and unknown keys are an error, so a typo is reported instead of silently ignored.
type ThemeCatalog ¶ added in v1.5.0
type ThemeCatalog struct {
// contains filtered or unexported fields
}
ThemeCatalog is the set of built-in and user themes known to this process.
func (*ThemeCatalog) Entries ¶ added in v1.5.0
func (c *ThemeCatalog) Entries() []ThemeEntry
Entries returns the themes in picker order: built-ins alphabetically first, then user and legacy themes alphabetically.
func (*ThemeCatalog) Lookup ¶ added in v1.5.0
func (c *ThemeCatalog) Lookup(id string) (ThemeEntry, bool)
Lookup returns the entry for id, matching case-insensitively.
func (*ThemeCatalog) Resolve ¶ added in v1.5.0
func (c *ThemeCatalog) Resolve(requested string) ThemeResolution
Resolve picks the theme to use for a configured theme id.
An empty id means "nothing configured": the legacy theme.yaml stays active while it exists, otherwise the built-in default is used. A requested id that is missing or invalid falls back to the default and reports a warning.
type ThemeEntry ¶ added in v1.5.0
type ThemeEntry struct {
ID string
Source ThemeSource
Path string
Theme Theme
Err error
}
ThemeEntry is one theme known to the catalog. Err is set when the file was found but could not be loaded; the entry is still listed so the picker can show what is wrong with it.
func (ThemeEntry) Name ¶ added in v1.5.0
func (e ThemeEntry) Name() string
Name returns the display name of the theme, falling back to its id.
func (ThemeEntry) Selectable ¶ added in v1.5.0
func (e ThemeEntry) Selectable() bool
Selectable reports whether the theme can be activated.
type ThemeManager ¶ added in v1.5.0
type ThemeManager struct {
// contains filtered or unexported fields
}
ThemeManager owns the active theme of the running process. Selecting a theme persists the choice to settings.yaml and swaps the in-memory theme.
func NewThemeManager ¶ added in v1.5.0
func NewThemeManager(fsys afero.Fs, configDir, requested string) (*ThemeManager, error)
NewThemeManager loads the theme catalog and resolves requested (the persisted or command line theme id) to the theme this process starts with.
func (*ThemeManager) Active ¶ added in v1.5.0
func (m *ThemeManager) Active() Theme
Active returns the theme currently in use.
func (*ThemeManager) ActiveID ¶ added in v1.5.0
func (m *ThemeManager) ActiveID() string
ActiveID returns the id of the theme currently in use.
func (*ThemeManager) Entries ¶ added in v1.5.0
func (m *ThemeManager) Entries() []ThemeEntry
Entries returns every known theme in picker order.
func (*ThemeManager) Lookup ¶ added in v1.5.0
func (m *ThemeManager) Lookup(id string) (ThemeEntry, bool)
Lookup returns one known theme by id.
func (*ThemeManager) Reload ¶ added in v1.5.0
func (m *ThemeManager) Reload() error
Reload re-reads the theme catalog, so a theme file copied into the themes directory while chatuino runs shows up the next time the picker opens. The active theme is left alone.
func (*ThemeManager) Select ¶ added in v1.5.0
func (m *ThemeManager) Select(id string) error
Select makes id the active theme and persists the choice. An unknown or invalid theme is rejected and leaves the current theme untouched.
func (*ThemeManager) SettingsPath ¶ added in v1.5.0
func (m *ThemeManager) SettingsPath() string
SettingsPath returns the settings file a selection is persisted to.
func (*ThemeManager) Warnings ¶ added in v1.5.0
func (m *ThemeManager) Warnings() []string
Warnings returns the problems found while resolving the startup theme.
type ThemeResolution ¶ added in v1.5.0
ThemeResolution is the outcome of resolving a configured theme id. Warning is non-empty when the requested theme could not be used, so the caller can tell the user why they are looking at a fallback.
type ThemeSource ¶ added in v1.5.0
type ThemeSource int
ThemeSource reports where a theme was loaded from.
const ( ThemeSourceBuiltin ThemeSource = iota ThemeSourceUser ThemeSourceLegacy )
func (ThemeSource) String ¶ added in v1.5.0
func (s ThemeSource) String() string