promptui icon indicating copy to clipboard operation
promptui copied to clipboard

BlockCursor is broken on macOS

Open synfinatic opened this issue 2 years ago • 3 comments

Tested with both iTerm2 3.4.12 and Terminal 2.10 on macOS 10.15.7 with promptui 0.9.0 and Go 1.17.5

using:

	prompt := promptui.Prompt{
		Label:    "SSO Instance Name (DefaultSSO)",
		Validate: validateSSOName,
		Default: "Default",
		Pointer:  promptui.BlockCursor,
	}

Generates the following prompt:

SSO Instance Name (DefaultSSO): \e[7mD\e[0mefault

DefaultCursor is very painful when there is a default value since it obscures the first character, so right now that only leaves PipeCursor which is very hard to see and seems very non-standard.

synfinatic avatar Dec 16 '21 01:12 synfinatic

I think that the solution to the problem may be to set the course for the last character of the default value. I would say that this is the most natural behavior for an input field across other UIs.

lazdmx avatar Feb 07 '22 22:02 lazdmx

I ran into similar issue cursor blocking default value and found https://github.com/manifoldco/promptui/issues/146

set AllowEdit: true will move cursor to the end of default value

i9 avatar May 19 '22 07:05 i9

The problem is that the escape code for ESC must be \x1b and not as is done today in cursor.go.

A fixed blockCursor is:

func blockCursor(input []rune) []rune {
  return []rune(fmt.Sprintf("\x1b[7m%s\x1b[0m", string(input)))
}

patrikhson avatar Dec 26 '23 13:12 patrikhson