bash - How does terminal programs add scrolling to the screen? -


how programs less, more, or vi add scrolling section on terminal screen without clearing screen , how disappear afterwards?

is there way run less specific amount of time if running script or way script exit?

first off, has nothing bash or whatever shell you're using. less command handles screen updates; can run shell, or other program.

your terminal emulator supports escape sequences. writing printable characters (letters, digits, etc.) causes characters displayed. writing escape sequences causes various other things happen: moving cursor, clearing current line, clearing screen, etc.

the termcap or terminfo , curses or ncurses software packages provide access these escape sequences. less, vim, emacs, typically use ncurses manage screen.

two sequences relevant question called ti , te termcap, smcup , rmcup terminfo. smcup sequence causes terminal save current state (everything displayed on screen cursor position), switches secondary display buffer starts off empty. rmcup sequence restores saved state , goes primary display buffer. programs use ncurses will, default, print smcup sequence on entry , rmcup entry on exit. that's how such programs able restore terminal window previous state when terminate.

also there way run less specific amount of time if running script or way script exit

i don't think there's way that. less interactive program; terminates when user types q or similar. running specific amount of time goes against it's designed do, , user i'd annoyed if less terminated while i'm using it.

you could use timeout command, interferes smcup / rmcup mechanism, leaving possibly corrupted display. there's better way accomplish you're trying do.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -