mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
Implement String method on some enum types for easier debugging
This commit is contained in:
parent
08a8d4b5ed
commit
851d21f6c4
1 changed files with 41 additions and 0 deletions
41
ui/stash.go
41
ui/stash.go
|
@ -64,6 +64,14 @@ const (
|
|||
stashStateShowingError
|
||||
)
|
||||
|
||||
func (s stashViewState) String() string {
|
||||
return map[stashViewState]string{
|
||||
stashStateReady: "ready",
|
||||
stashStateLoadingDocument: "loading document",
|
||||
stashStateShowingError: "showing error",
|
||||
}[s]
|
||||
}
|
||||
|
||||
// The types of documents we are currently showing to the user.
|
||||
type sectionKey int
|
||||
|
||||
|
@ -74,6 +82,15 @@ const (
|
|||
filterSection
|
||||
)
|
||||
|
||||
func (s sectionKey) String() string {
|
||||
return map[sectionKey]string{
|
||||
localSection: "local",
|
||||
stashedSection: "stashed",
|
||||
newsSection: "news",
|
||||
filterSection: "filtered",
|
||||
}[s]
|
||||
}
|
||||
|
||||
// section contains definitions and state information for displaying a tab and
|
||||
// its contents in the file listing view.
|
||||
type section struct {
|
||||
|
@ -116,6 +133,14 @@ const (
|
|||
filterApplied // a filter is applied and user is not editing filter
|
||||
)
|
||||
|
||||
func (f filterState) String() string {
|
||||
return map[filterState]string{
|
||||
unfiltered: "unfiltered",
|
||||
filtering: "filtering",
|
||||
filterApplied: "filter applied",
|
||||
}[f]
|
||||
}
|
||||
|
||||
// selectionState is the state of the currently selected document.
|
||||
type selectionState int
|
||||
|
||||
|
@ -125,6 +150,14 @@ const (
|
|||
selectionPromptingDelete
|
||||
)
|
||||
|
||||
func (s selectionState) String() string {
|
||||
return map[selectionState]string{
|
||||
selectionIdle: "idle",
|
||||
selectionSettingNote: "setting note",
|
||||
selectionPromptingDelete: "prompting for deletion",
|
||||
}[s]
|
||||
}
|
||||
|
||||
// statusMessageType adds some context to the status message being sent.
|
||||
type statusMessageType int
|
||||
|
||||
|
@ -135,6 +168,14 @@ const (
|
|||
errorStatusMessage
|
||||
)
|
||||
|
||||
func (s statusMessageType) String() string {
|
||||
return map[statusMessageType]string{
|
||||
normalStatusMessage: "normal",
|
||||
subtleStatusMessage: "subtle",
|
||||
errorStatusMessage: "error",
|
||||
}[s]
|
||||
}
|
||||
|
||||
// statusMessage is an ephemeral note displayed in the UI.
|
||||
type statusMessage struct {
|
||||
status statusMessageType
|
||||
|
|
Loading…
Reference in a new issue