"Jumping" terminal #104

Closed
shevegen opened this Issue Dec 22, 2012 · 7 comments

Comments

Projects
None yet
2 participants

Hi.

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:

puts CodeRay.scan('', :ruby).term

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.

Owner

korny commented Dec 26, 2012

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.

(1) http://i47.tinypic.com/15x5wnn.png
(2) http://i48.tinypic.com/211mnua.png

In the event that you can not see it, let me
describe it.

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.

Owner

korny commented Dec 28, 2012

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.

CodeRay.scan('', :ruby).term.inspect

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.

Owner

korny commented Apr 7, 2013

@shevegen Is this still an issue for you?

shevegen commented Apr 7, 2013

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.

@shevegen shevegen closed this Apr 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment