Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird formatting of colored prompt message #19

Open
bilalq opened this issue Feb 24, 2014 · 1 comment
Open

Weird formatting of colored prompt message #19

bilalq opened this issue Feb 24, 2014 · 1 comment

Comments

@bilalq
Copy link

bilalq commented Feb 24, 2014

I cut a similar issue to the node-promptly module earlier: moxystudio/node-promptly#2

When the prompt contains colored/formatted text, the cursor is indented far to the right.

I skimmed through the code, and I think I see where the issue is:
https://github.com/isaacs/read/blob/master/lib/read.js#L56

Formatted strings end up with ANSI color codes are part of the string. Looking up the length property on them returns a misleading result. Would you accept a patch to strip ANSI codes before reading the length of the prompt?

@tmpfs
Copy link

tmpfs commented Sep 12, 2014

You need to calculate the length of the prompt and pass it when calling setPrompt(), see #21 and nodejs/node-v0.x-archive#3860.

A modified version of read that allows for this is here:

https://github.com/freeformsystems/cli-input/blob/master/lib/read.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants