Skip to content

bpython breaks line with ANSI escape code #670

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

Closed
laike9m opened this issue Mar 19, 2017 · 6 comments
Closed

bpython breaks line with ANSI escape code #670

laike9m opened this issue Mar 19, 2017 · 6 comments

Comments

@laike9m
Copy link

laike9m commented Mar 19, 2017

This can be easily reproduced by typing

print('\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[3
1mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[3
1mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m')

In bpython
image

In Python
image

I guess when calculating the length of output, bpython counts all chars, but not all chars are visible, thus leading to this bug.

@laike9m
Copy link
Author

laike9m commented Mar 19, 2017

While I managed to get over the previous issue:
https://github.com/thomasballinger/curtsies/issues/97

I really can't get things to work without this being fixed. I'd appreciate if you could fix it.

@laike9m
Copy link
Author

laike9m commented Mar 23, 2017

@sebastinas @thomasballinger What do you think? Since no other REPLs has this issue, the inconsistency between them and bpython certainly brings undesired behavior to some libraries, which I think is a serious problem.

@sebastinas
Copy link
Contributor

sebastinas commented Mar 23, 2017

Handling of escape characters happens in curtsies. So while this certainly is an issue that affects bpython, it needs to be fixed in curtsies. I think @thomasballinger wouldn't mind getting bug reports and/or test cases for that.

@thomasballinger
Copy link
Member

thomasballinger commented Apr 4, 2017

Thanks to @ata2001 the second issue you mentioned https://github.com/thomasballinger/curtsies/issues/97 is fixed. Fixing length issues is possible via the wcwidth-based width of a curtsies FmtStr. https://github.com/thomasballinger/curtsies/issues/8 is the most relevant issue for this, we should consider this bpython issue blocked on that, because the version of curtsies currently used in bpython doesn't have this width. (probably because there's no released version of curtsies with a working .width)

@laike9m
Copy link
Author

laike9m commented May 13, 2017

Thanks guys. Looking forward to a new release. 😄

@ata2001
Copy link
Contributor

ata2001 commented May 13, 2017

Test cases would not be bad for this, but I'd need some help with doing that.

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

4 participants