0

I'm trying to use a /bin/sh script to scroll down a couple of lines of text in terminal. A solution using smcup, rmcup is not acceptable in this case.

A couple of other options I tried all failed (includes correction from JdeBP):

  • tput cup 0 0; tput ri
  • tput cup 0 0; tput rin 3

This is a bit weird because man terminfo specifies:

To scroll text down, a program goes to the top left corner of the screen and sends the ri (reverse index) string. The strings ind and ri are undefined when not on their respective corners of the screen.

The output of terminal has to be scrollable before running any tests (try using set, env prior to tests).

A solution for xterm will suffice.

To speed up tests and clarify use this script to start:

#!/bin/sh

# create scrollable text
set

# includes correction from JdeBP
# try to scroll text down one line
tput cup 0 0; tput ri

# includes correction from JdeBP
# try to scroll text down 3 lines
tput cup 0 0; tput rin 3
  • Please make the question show the exact commands that you used, not a misleading shorthand for them. – JdeBP Mar 17 at 10:12
0
tput cup 0 0, ri

It is little wonder that this failed. This isn't the command-line syntax of the tput program.

tput cup 0 0
tput ri

Very simple.

Notes for advanced users doing complex stuff on more than just XTerm:

  • On real terminals, and good quality emulators thereof, non-default top and bottom margins and origin mode being off affect behaviour and where the cursor should be placed in order to scroll. It is not quite as simple as the terminfo model implies it to be. See the DEC VT4xx/5xx doco for details on real DEC terminals, for example.
  • In the DEC world SD and SU are window pans, not buffer scrolls. A VT525 has multiwindowing, and these control sequences move the windows around the underlying buffer.
  • Some poorer not-fully-8-bit-clean terminal emulators do not correctly recognize U+0084 and U+008D as IND and RI, and force the use of the 7-bit aliases.
| improve this answer | |
  • Tried this already and it's not doing what is requested. What it actually does is to enter a new line at the top of page. What I need is to scroll the whole text without modifying it. – Nicolae Iotu Mar 17 at 15:40
  • I'm going to change the title of this question and make it even more specific. – Nicolae Iotu Mar 17 at 15:49
  • Inserting a new erased line at the end of the scrolling region is scrolling in the world of terminals ("eliminate the top line of displayed data, move all lines of data up the screen one line, and insert a new line at the bottom" -- Auerbach Guide). What you apparently actually want is not. – JdeBP Mar 18 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.