ui

package
v0.0.0-...-3d71b91 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Title                   = "aezeed-recover"
	InfoPageName            = "infoPage"
	MenuPageName            = "menuPage"
	ResultPageName          = "resultPage"
	PasswordInputFooterHint = "The empty password and 'aezeed' (default) are synonymous."
	// The string concatenation is necessary to prevent IntelliJ from reformatting the string as SQL:
	MnemonicInputFooterHint = "Select mnemonic" + " words or paste from clipboard (or ESC to menu)."
)
View Source
const (
	QuitButtonLabel    = "Quit"
	ConsentButtonLabel = "Agree"
)
View Source
const (
	ShowInfoHelp             = "return to info page."
	ShowInfoShortcut         = 'i'
	RandomMnemonicHelp       = "create a random mnemonic."
	RandomMnemonicShortcut   = 'r'
	EditMnemonicHelp         = "edit or paste mnemonic words."
	EditMnemonicShortcut     = 'e'
	ClearMnemonicHelp        = "clear mnemonic words."
	ClearMnemonicShortcut    = 'c'
	FindMissingWordsHelp     = "brute force missing words."
	FindMissingWordsShortcut = 'm'
	FindSwappedWordsHelp     = "brute force swapped words."
	FindSwappedWordsShortcut = 's'
	FindWrongWordHelp        = "find a single wrong word."
	FindWrongWordShortcut    = 'w'
	DisplaySeedHelp          = "display additional seed information."
	DisplaySeedShortcut      = 'd'
	QuitHelp                 = "quit application and return to shell."
	QuitShortcut             = 'q'
)
View Source
const (
	// Url = "https://recovery.mustwork.de" // TODO - implement LnUrl
	Url               = "bc1qfkv06pjcgq280f42nu66ktdfeer7f06lmtgerp" // TODO - parse from README.md
	ReturnButtonLabel = "Return"
	Plea              = `Success! 

Please consider a donation to keep this tool awesome.`
)
View Source
const (
	InvalidWords            = "✗ invalid words"
	IncompleteMnemonic      = "✗ incomplete mnemonic"
	InvalidMnemonic         = "✗ invalid mnemonic"
	ValidMnemonic           = "✓ valid mnemonic"
	PasswordInputFieldWidth = 16
)

TODO - detect, whether terminal supports character range: check mark: '\u2713' = (✓) cross mark: '\u2717' = (✗)

Variables

This section is empty.

Functions

func CreateApplication

func CreateApplication(theme Theme, config *Config, info string) *tview.Application

func NewMenuView

func NewMenuView(theme Theme, devMode bool) (*Menu, *MenuCallbacks)

func WordCompleter

func WordCompleter(wordlist []string) func(string) []string

Types

type ButtonStyle

type ButtonStyle struct {
	Style     tcell.Style
	Activated tcell.Style
	Disabled  tcell.Style
}

func NewButtonStyle

func NewButtonStyle(theme tview.Theme) ButtonStyle

func (ButtonStyle) SetActivatedBackground

func (s ButtonStyle) SetActivatedBackground(c tcell.Color) ButtonStyle

func (ButtonStyle) SetActivatedBold

func (s ButtonStyle) SetActivatedBold(b bool) ButtonStyle

func (ButtonStyle) SetActivatedForeground

func (s ButtonStyle) SetActivatedForeground(c tcell.Color) ButtonStyle

func (ButtonStyle) SetBackground

func (s ButtonStyle) SetBackground(c tcell.Color) ButtonStyle

func (ButtonStyle) SetBold

func (s ButtonStyle) SetBold(b bool) ButtonStyle

func (ButtonStyle) SetDisabledBackground

func (s ButtonStyle) SetDisabledBackground(c tcell.Color) ButtonStyle

func (ButtonStyle) SetDisabledBold

func (s ButtonStyle) SetDisabledBold(b bool) ButtonStyle

func (ButtonStyle) SetDisabledForeground

func (s ButtonStyle) SetDisabledForeground(c tcell.Color) ButtonStyle

func (ButtonStyle) SetForeground

func (s ButtonStyle) SetForeground(c tcell.Color) ButtonStyle

type Config

type Config struct {
	Wordlist          []string
	DefaultPassword   string
	DevMode           bool
	Consent           bool
	MnemonicLength    int
	MnemonicMinLength int
}

type FocusItem

type FocusItem interface {
	FocusPrev(current int)
	FocusNext(current int)
	FocusAdjacent(current int)
}
type Footer struct {
	*responsive.ResponsiveTextView
}

func NewFooterView

func NewFooterView() *Footer

func (*Footer) Clear

func (f *Footer) Clear() *Footer

func (*Footer) SetBorder

func (f *Footer) SetBorder(b bool) *Footer

func (*Footer) SetInfo

func (f *Footer) SetInfo(s string) *Footer
type Header struct {
	*tview.TextView
}

func NewHeaderView

func NewHeaderView() *Header

func (*Header) SetBorder

func (h *Header) SetBorder(b bool) *Header

func (*Header) SetTitle

func (h *Header) SetTitle(s string) *Header

type Info

type Info struct {
	*tview.Grid
	// contains filtered or unexported fields
}

func NewInfoView

func NewInfoView(InfoText string) *Info

func (*Info) GetConfirmButton

func (o *Info) GetConfirmButton() *tview.Button

func (*Info) GetQuitButton

func (o *Info) GetQuitButton() *tview.Button

func (*Info) SetBorder

func (o *Info) SetBorder(b bool) *Info

func (*Info) SetConfirmButtonDisabled

func (o *Info) SetConfirmButtonDisabled(b bool) *Info

func (*Info) SetConfirmButtonSelectedFunc

func (o *Info) SetConfirmButtonSelectedFunc(fn func()) *Info

func (*Info) SetQuitButtonDisabled

func (o *Info) SetQuitButtonDisabled(b bool) *Info

func (*Info) SetQuitButtonSelectedFunc

func (o *Info) SetQuitButtonSelectedFunc(fn func()) *Info

type InputFieldStyle

type InputFieldStyle struct {
	Label                  tcell.Style
	Field                  tcell.Style
	Placeholder            tcell.Style
	AutocompleteMain       tcell.Style
	AutocompleteSelected   tcell.Style
	AutocompleteBackground tcell.Color
}

func NewInputFieldStyle

func NewInputFieldStyle(theme tview.Theme) InputFieldStyle

func (InputFieldStyle) SetAutocompleteBackground

func (s InputFieldStyle) SetAutocompleteBackground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetAutocompleteMainBackground

func (s InputFieldStyle) SetAutocompleteMainBackground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetAutocompleteMainBold

func (s InputFieldStyle) SetAutocompleteMainBold(b bool) InputFieldStyle

func (InputFieldStyle) SetAutocompleteMainForeground

func (s InputFieldStyle) SetAutocompleteMainForeground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetAutocompleteSelectedBackground

func (s InputFieldStyle) SetAutocompleteSelectedBackground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetAutocompleteSelectedBold

func (s InputFieldStyle) SetAutocompleteSelectedBold(b bool) InputFieldStyle

func (InputFieldStyle) SetAutocompleteSelectedForeground

func (s InputFieldStyle) SetAutocompleteSelectedForeground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetFieldBackground

func (s InputFieldStyle) SetFieldBackground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetFieldBold

func (s InputFieldStyle) SetFieldBold(b bool) InputFieldStyle

func (InputFieldStyle) SetFieldForeground

func (s InputFieldStyle) SetFieldForeground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetLabelBackground

func (s InputFieldStyle) SetLabelBackground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetLabelBold

func (s InputFieldStyle) SetLabelBold(b bool) InputFieldStyle

func (InputFieldStyle) SetLabelForeground

func (s InputFieldStyle) SetLabelForeground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetPlaceholderBackground

func (s InputFieldStyle) SetPlaceholderBackground(c tcell.Color) InputFieldStyle

func (InputFieldStyle) SetPlaceholderBold

func (s InputFieldStyle) SetPlaceholderBold(b bool) InputFieldStyle

func (InputFieldStyle) SetPlaceholderForeground

func (s InputFieldStyle) SetPlaceholderForeground(c tcell.Color) InputFieldStyle

type InputFieldStyles

type InputFieldStyles struct {
	Valid     InputFieldStyle
	Invalid   InputFieldStyle
	Highlight InputFieldStyle
}

type ListItemStyle

type ListItemStyle struct {
	Main      tcell.Style
	Secondary tcell.Style
	Shortcut  tcell.Style
	Selected  tcell.Style
}

func NewListItemStyle

func NewListItemStyle(theme tview.Theme) ListItemStyle

func (ListItemStyle) SetMainBackground

func (s ListItemStyle) SetMainBackground(c tcell.Color) ListItemStyle

func (ListItemStyle) SetMainBold

func (s ListItemStyle) SetMainBold(b bool) ListItemStyle

func (ListItemStyle) SetMainForeground

func (s ListItemStyle) SetMainForeground(c tcell.Color) ListItemStyle

func (ListItemStyle) SetSecondaryBackground

func (s ListItemStyle) SetSecondaryBackground(c tcell.Color) ListItemStyle

func (ListItemStyle) SetSecondaryBold

func (s ListItemStyle) SetSecondaryBold(b bool) ListItemStyle

func (ListItemStyle) SetSecondaryForeground

func (s ListItemStyle) SetSecondaryForeground(c tcell.Color) ListItemStyle

func (ListItemStyle) SetSelectedBackground

func (s ListItemStyle) SetSelectedBackground(c tcell.Color) ListItemStyle

func (ListItemStyle) SetSelectedBold

func (s ListItemStyle) SetSelectedBold(b bool) ListItemStyle

func (ListItemStyle) SetSelectedForeground

func (s ListItemStyle) SetSelectedForeground(c tcell.Color) ListItemStyle

func (ListItemStyle) SetShortcutBackground

func (s ListItemStyle) SetShortcutBackground(c tcell.Color) ListItemStyle

func (ListItemStyle) SetShortcutBold

func (s ListItemStyle) SetShortcutBold(b bool) ListItemStyle

func (ListItemStyle) SetShortcutForeground

func (s ListItemStyle) SetShortcutForeground(c tcell.Color) ListItemStyle

type ListItemStyles

type ListItemStyles struct {
	Enabled  ListItemStyle
	Disabled ListItemStyle
}
type Menu struct {
	*responsive.ResponsiveList
	// contains filtered or unexported fields
}
func (m *Menu) ClearBruteForceResults() *Menu
func (m *Menu) GetItem(shortcut rune) (int, *responsive.ResponsiveListItem)
func (m *Menu) MarkFailure(shortcut rune)
func (m *Menu) MarkNeutral(shortcut rune) *Menu
func (m *Menu) MarkSuccess(shortcut rune)
func (m *Menu) SetBorder(b bool) *Menu
func (m *Menu) SetClearMnemonicHandler(fn func()) *Menu
func (m *Menu) SetCreateRandomMnemonicHandler(fn func()) *Menu
func (m *Menu) SetDisplaySeedHandler(fn func()) *Menu
func (m *Menu) SetEditMnemonicHandler(fn func()) *Menu
func (m *Menu) SetExhaustedMissingWords()
func (m *Menu) SetExhaustedSwappedWords()
func (m *Menu) SetExhaustedWrongWord()
func (m *Menu) SetFindMissingWordsHandler(fn func()) *Menu
func (m *Menu) SetFindSwappedWordsHandler(fn func()) *Menu
func (m *Menu) SetFindWrongWordHandler(fn func()) *Menu
func (m *Menu) SetFoundMissingWords()
func (m *Menu) SetFoundSwappedWords()
func (m *Menu) SetFoundWrongWord()
func (m *Menu) SetNextEnabledItem() *Menu
func (m *Menu) SetPreviousEnabledItem() *Menu
func (m *Menu) SetQuitHandler(fn func()) *Menu
func (m *Menu) SetShowInfoHandler(fn func()) *Menu
type MenuCallbacks struct {
	OnMnemonicValid        func()
	OnMnemonicInvalid      func()
	OnMnemonicPartial      func()
	OnMnemonicInsufficient func()
}

type MnemonicWordInputField

type MnemonicWordInputField struct {
	*tview.InputField
	Theme Theme
	// contains filtered or unexported fields
}

func NewMnemonicInputField

func NewMnemonicInputField(seedView *SeedView, i int, wordCompleter func(string) []string) *MnemonicWordInputField

func (*MnemonicWordInputField) Highlight

func (MnemonicWordInputField) IsEmpty

func (f MnemonicWordInputField) IsEmpty() bool

func (*MnemonicWordInputField) SetText

type PasswordInputField

type PasswordInputField struct {
	*tview.InputField
}

func NewPasswordInputField

func NewPasswordInputField(theme Theme, config *Config, seedView *SeedView) *PasswordInputField

func (*PasswordInputField) SetFieldTextColor

func (p *PasswordInputField) SetFieldTextColor(color tcell.Color) *PasswordInputField

type QRCodeView

type QRCodeView struct {
	*tview.TextView
	Height int
	Width  int
}

func NewQRCodeView

func NewQRCodeView() *QRCodeView

type ResultView

type ResultView struct {
	*tview.Grid
	// contains filtered or unexported fields
}

func NewResultView

func NewResultView(setFocus func(tview.Primitive) *tview.Application) *ResultView

func (*ResultView) SetBorder

func (v *ResultView) SetBorder(b bool) *ResultView

func (*ResultView) SetQuitButtonSelectedFunc

func (v *ResultView) SetQuitButtonSelectedFunc(f func()) *ResultView

func (*ResultView) SetReturnButtonSelectedFunc

func (v *ResultView) SetReturnButtonSelectedFunc(f func()) *ResultView

type SeedView

type SeedView struct {
	*tview.Grid

	Theme Theme
	// contains filtered or unexported fields
}

func NewSeedView

func NewSeedView(theme Theme, config *Config, setFocus func(p tview.Primitive) *tview.Application) *SeedView

func (*SeedView) FocusAdjacent

func (v *SeedView) FocusAdjacent(current int)

func (*SeedView) FocusNext

func (v *SeedView) FocusNext(current int)

func (*SeedView) FocusPrev

func (v *SeedView) FocusPrev(current int)

func (*SeedView) GetCipherSeed

func (v *SeedView) GetCipherSeed() (seed *aezeed.CipherSeed, err error)

func (*SeedView) GetMnemonic

func (v *SeedView) GetMnemonic() (mnemonic aezeed.Mnemonic, err error)

func (*SeedView) GetPassword

func (v *SeedView) GetPassword() string

func (*SeedView) GetSettings

func (v *SeedView) GetSettings() crack.MnemonicSettings

func (*SeedView) GetWords

func (v *SeedView) GetWords() (words []string)

func (*SeedView) HighlightWords

func (v *SeedView) HighlightWords(xs []int) *SeedView

func (*SeedView) SetDoneFunc

func (v *SeedView) SetDoneFunc(fn func(tcell.Key)) *SeedView

func (*SeedView) SetItemText

func (v *SeedView) SetItemText(idx int, text string)

func (*SeedView) SetMnemonicInputFocusFunc

func (v *SeedView) SetMnemonicInputFocusFunc(fn func()) *SeedView

func (*SeedView) SetOnMnemonicChangedFunc

func (v *SeedView) SetOnMnemonicChangedFunc(fn func(words []string, valid bool)) *SeedView

func (*SeedView) SetPasswordInputFocusFunc

func (v *SeedView) SetPasswordInputFocusFunc(fn func()) *SeedView

func (*SeedView) SetWords

func (v *SeedView) SetWords(words []string)

type TextViewStyle

type TextViewStyle struct {
	Label tcell.Style
	Text  tcell.Style
}

func NewTextViewStyle

func NewTextViewStyle(theme tview.Theme) TextViewStyle

func (TextViewStyle) SetLabelBackground

func (s TextViewStyle) SetLabelBackground(c tcell.Color) TextViewStyle

func (TextViewStyle) SetLabelBold

func (s TextViewStyle) SetLabelBold(b bool) TextViewStyle

func (TextViewStyle) SetLabelForeground

func (s TextViewStyle) SetLabelForeground(c tcell.Color) TextViewStyle

func (TextViewStyle) SetTextBackground

func (s TextViewStyle) SetTextBackground(c tcell.Color) TextViewStyle

func (TextViewStyle) SetTextBold

func (s TextViewStyle) SetTextBold(b bool) TextViewStyle

func (TextViewStyle) SetTextForeground

func (s TextViewStyle) SetTextForeground(c tcell.Color) TextViewStyle

type TextViewStyles

type TextViewStyles struct {
	Valid   TextViewStyle
	Invalid TextViewStyle
}

type Theme

type Theme struct {
	tview.Theme
	Button     ButtonStyle
	ListItem   ListItemStyles
	InputField InputFieldStyles
	TextView   TextViewStyles
}

func UniversalTheme

func UniversalTheme() Theme

UniversalTheme returns a theme that works well with both light and dark terminal settings.

Jump to

Keyboard shortcuts

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