Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

down(0) moves down one #5

Open
davidmaxwaterman opened this issue Aug 28, 2013 · 3 comments
Open

down(0) moves down one #5

davidmaxwaterman opened this issue Aug 28, 2013 · 3 comments

Comments

@davidmaxwaterman
Copy link

I've noticed that down(0) actually moves down one line when it's at the bottom of the terminal. Any ideas why?

I've had to 'if' it out.

See here :

https://github.com/davidmaxwaterman/progress

commit b86f400f3d05faed70b0468e38bba6f830b844f1 shows the error (and the commit after it has the 'if'to fix it)

$ cat tests/test1.txt | bin/progress

If you do the above at the top of the terminal window, it scrolls down endlessly, but if at the bottom, it doesn't. Having said that, while writing this, it doesn't seem to make sense, so perhaps I'm not completely understanding what's happening, but anyway, the if seems to fix it.

Comments/help welcome.

@mattijs
Copy link
Owner

mattijs commented Aug 30, 2013

Hi,

I'm sorry but I don't seem to understand what you are trying to accomplish and I'm not able to reproduce it with the code you linked.

node-terminal is just a simple wrapper for sending escape sequences to the shell. The down function just sends the escape sequence \033[xB where x is the number you provided. Normally this would be a number above 0 where the shell will just receive something like \033[1B and move down 1 line. Calling down(0) causes node-terminal to ouput \033[0B to the shell and it could be that this is an entirely different command, maybe for scrolling or something.

There is no check in the down method because this is just a simple library. And I don't know from the top of my head if \033[0B is a valid escape sequence.

What terminal and shell are you running? Maybe I can help you from there.

@davidmaxwaterman
Copy link
Author

OK, I get that node-terminal is just a wrapper, so perhaps it is fine that you choose to do nothing about this. What I am saying is that 'down(0)' shouldn't move down, when that's what it seems to do. Obviously, I'm not really calling 'down()' with a hard-wired '0', but using a variable. Of course, I could be mistaken or something, but anyway...

I'm using Ubuntu 13.04, gnome-terminal, and TERM seems to be set to 'xterm', I'm using /bin/bash (not sure why that is relevant, but anyway).

I wouldn't object to you closing this, if you decide that's the appropriate action.

@mattijs
Copy link
Owner

mattijs commented Sep 2, 2013

The (or a) VT100 spec says \033[xB, where x is is 0 should move down 0 lines. If this is not the case this is in the hands of the terminal implementation. As said before, this is just a simple wrapper sending escape sequences, it is up to the terminal implementation to handle them.

node-terminal is kept simple to keep control in your hands, meaning you have to do the checks too. To keep the control I'm reluctant to add a check to the down function. Support for different escape sequences may vary between terminal implementations and a check could make the library limiting, reducing that control.

If a check on down is introduced all movement functions should get the same love, implementing checks there too. The checks should follow the spec for escape sequences and work for all (or all major) terminal implementations. Since the implementations vary it is hard to test the checks against the spec for the implementations.

I'm not going to implement a check in the methods right now since I currently don't have the time to research the spec and movement sequences for several terminal implementations.

Pull requests with checks based on the spec are welcome though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants