sindresorhus / ansi-escapes

ANSI escape codes for manipulating the terminal
MIT License
494 stars 44 forks source link

Use ^[[G instead of ^[[1000D #3

Closed Qix- closed 7 years ago

Qix- commented 7 years ago

cursorLeft currently uses the equivalent escape of move 1000 characters left, which (probably as a bug) seems to misbehave in certain emulators. Plus, for people who like really tiny text (like me!) 1000 might actually not cut it.

Instead, horizontal absolute (1) is the correct escape that should be used. I can see why it was avoided (as it's not "officially" supported in older version of Windows).

However, Node.js uses libuv which handles (see: emulates) a lot of the TTY stuff on windows for us. You can see its specific handling of ^[[G in win/tty.c of libuv.

Ref: sindresorhus/log-update#16

SamVerschueren commented 7 years ago

Thanks for looking into this @Qix- and for all the information!

So from what I understand from your comment https://github.com/sindresorhus/log-update/pull/16#issuecomment-295856742 is that this is a breaking change. The reason for this is that with the ^[[G escape, you will ALWAYS have to erase the number of lines that are being rendered?

So for instance, if I render a long piece of text that is rendered over 2 lines, I will have to call ansiEscapes.eraseLines(2) in Hyper and in iTerm? If that is the case, I guess this is a breaking change and we should release as 2.0.0.

P.S. I updated master and fixed the tests.

Qix- commented 7 years ago

Nope this is non breaking. This doesn't fix the erase lines problem, this just fixes the "absolute left" hack.

The erase lines thing will come next.

Also, the erase lines thing would be a breaking fix if there ever was one :dancer:.

sindresorhus commented 7 years ago

I think I indeed used 1000D because of Windows, though I really don't remember. This is better anyhow. Thanks for submitting this @Qix- :)


The erase lines thing will come next.

What's the erase lines "thing"?

Qix- commented 7 years ago

@sindresorhus sindresorhus/log-update#16