NYUCCL / psiTurk

An open platform for science on Amazon Mechanical Turk.
https://psiturk.org
MIT License
277 stars 140 forks source link

Color code formatting on linux #81

Closed jhamrick closed 10 years ago

jhamrick commented 10 years ago

When I run psiTurk on my linux server, the color formatting seems to have issues:

image

I think it is because of the \001 and \002 escape sequences in the colorize function in psiturk_shell.py; when I remove them, the weird unicode characters go away. These characters don't appear when I run psiTurk on OS X, and if I remove the escape sequences, it doesn't seem to matter either.

gureckis commented 10 years ago

hmm... I think @alexanderrich added these because the line length calculation in readline was messed up without them. However, it might need to check somehow what environment it is running in. This link seems to have a discussion about this.

alexanderrich commented 10 years ago

The link Todd sent seems to sum it up. It's interesting that removing the escape sequences don't make a difference on OSX - when I run psiTurk without the escape sequences long commands wrap around and start overwriting the prompt.

Based on the link, it seems like the key is that the weird characters only occur for escape sequences that aren't read by readline, like the startup message. It looks like that holds true for @jhamrick since there aren't any symbols around the red "off". I'll push a change to when the escape symbols are used and see if that helps.

jhamrick commented 10 years ago

Ah, it is entirely possible that it actually does cause problems I didn't notice -- I didn't realize it would cause issues with stuff like wrapping, so I only just launched psiturk to see if the version formatting part was affected.

Anyway, I'll check out this commit next time I'm at a linux terminal and let you know how it goes.

jhamrick commented 10 years ago

Yep, seems to fix it for me! Thanks!