diff --git a/cursor.go b/cursor.go index f329df1..f2fa871 100644 --- a/cursor.go +++ b/cursor.go @@ -1,6 +1,9 @@ package promptui -import "fmt" +import ( + "fmt" + "strings" +) // Pointer is A specific type that translates a given set of runes into a given // set of runes pointed at by the cursor. @@ -144,6 +147,11 @@ func (c *Cursor) Get() string { return string(c.input) } +// GetMask returns a mask string with length equal to the input +func (c *Cursor) GetMask(mask rune) string { + return strings.Repeat(string(mask), len(c.input)) +} + // Replace replaces the previous input with whatever is specified, and moves the // cursor to the end position func (c *Cursor) Replace(input string) { diff --git a/prompt.go b/prompt.go index 97ff373..0ec64b0 100644 --- a/prompt.go +++ b/prompt.go @@ -218,9 +218,9 @@ func (p *Prompt) Run() (string, error) { return "", err } - echo := cur.Format() + echo := cur.Get() if p.Mask != 0 { - echo = cur.FormatMask(p.Mask) + echo = cur.GetMask(p.Mask) } prompt := render(p.Templates.success, p.Label)