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

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

Comments

Projects
None yet
2 participants

bilalq commented Feb 24, 2014

I cut a similar issue to the node-promptly module earlier: IndigoUnited/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 commented Sep 12, 2014

You need to calculate the length of the prompt and pass it when calling setPrompt(), see #21 and joyent/node#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