GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
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
When I start irb, then I hit enter key a few times, and then I require coderay and do this:
puts CodeRay.scan('', :ruby).term
The terminal jumps to the top left, rather than continue output.
I think some escape code is used or something.
CodeRay is AWESOME, I love it. I lately use it to display content of .rb files
from within irb, and this content is colourized.
But this jumping thing disturbs me. Is there a way to turn this off
somehow? I.e. I'd love to continue to scroll down, without that
reset escape code ever hitting me.
Btw the reason I use:
is because this is the shortest way to reproduce the problem I have.
I think it is related to whatever .term does.
I stumbled into this when I was reading and displaying whole .rb files with this,
it always seems to jump, before it starts outputting stuff.
Can you provide a screenshot? I'm afraid I don't understand the "jumps to the top left" situation. Never experienced this on my system.
CodeRay.scan('', :ruby).term just outputs an empty string for me. Which CodeRay version are you using?
Here are two screenshots.
The first one is before I hit enter,
the second one after I hit enter.
In the event that you can not see it, let me
In the (1) picture, this is on IRB startup, my cursor
is right after the string CodeRay.scan('', :ruby).term
on the next line. (Ignore the other words, this is
just a bunch of files I load upon IRB startup)
Then, I hit enter, and suddenly I am at position
(2), without having done anything else BUT hitting
enter. This is the same relative position - it is
as if the prior content which you can see in (1)
is suddenly shifted to the top left.
It reminds me very much of some terminal
code that is being used when someone wants
to clear the terminal and "jump" to the top left
position again, and it happens only
when I do CodeRay.scan('', :ruby).term alone.
In normal irb, if I hit enter, I simply get scrolled
one level down, fitting to a newline.
CodeRay.scan however seems to also send
some "clear" or "reset" command.
Very strange. I can only assume that this behavior is specific to the terminal and/or IRB config you're using.
If CodeRay.scan('', :ruby).term.inspect shows an empty string for you, too, then I'm afraid I have no idea how to fix this.
Hmm yeah... shows an empty string only.
If I ever find out how this happened, I will report back. For now I am just confused, but I think it must be something with the terminal, or readline or something around that.
@shevegen Is this still an issue for you?
No, it no longer is.
I am not sure how I solved it.
I think perhaps it had to do with PS1 term in bash? I escaped the colour codes \033 and so forth incorrectly.
But I also use coderay 1.0.9 now, perhaps things changed?
I really can not tell you for sure. But what I can tell you is that this issue is gone. :)
No idea why, but I think this issue can be closed now - hope you are ok if I do so, I can assure you 100% that I can no longer reproduce the bug I had. The terminal does not jump at all anymore.