Results 1 to 5 of 5
I am wondering what the difference between programs that go into full-screen such as less and vim versus regular programs.
On a plain tty, when I exit less or vim, ...
- 06-10-2009 #1
Difference Between Regular Programs and less/vim
I am wondering what the difference between programs that go into full-screen such as less and vim versus regular programs.
On a plain tty, when I exit less or vim, their output remains visible until I clear the screen, or I execute a bunch more commands. In gnome-terminal or xterm, however, the screen is unaffected upon exit from less and bash. Why is this, and how does it work?
Is it possible to make top do this as well? Is it possible for me to give a flag to let an arbitrary program do it?
- 06-11-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
On a console or x-windows terminal window, the system buffers the contents of the screen, so it can restore it after vim or less terminate. On a dumb tty device, it cannot do so (easily), so you see the remnants of the edit/view session after you terminate.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-11-2009 #3
But who does it? Do less and vim have their own code to handle it on compatible terminals, or do the terminal emulators have code to handle programs like less and vim?
Also, is it possible to make other programs use a separate buffer? For example, top, or a bash subshell?
And is it possible to tell less to remain on the screen after quitting it? Sometimes it is useful to be able to copy something from less into another command or something.
- 06-11-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
Cursor-addressed applications like vim and less use curses and the termcap/terminfo database to determine how to handle input and output, no matter what terminal type or emulator you are using. A dumb terminal cannot "scrape" the screen so it can be restored later. Terminal emulators, such as xterm, do control and know what has been written to the display, so they can restore the contents when an application such as vim or less terminate.
If you are using an xterm or other X-Windows terminal emulator program, you can simply highlight the text in less that you want to copy, quit less, and then drop text onto the command line. Some emulators such as the terminal/console programs that you get with KDE or Gnome have a copy/paste capability as well to help with these tasks.Also, is it possible to make other programs use a separate buffer? For example, top, or a bash subshell?
And is it possible to tell less to remain on the screen after quitting it? Sometimes it is useful to be able to copy something from less into another command or something.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-11-2009 #5
Of course, I was just trying to think of an example why I would like to keep the output on the screen, which I now realize is pretty much useless. The opposite however would be nice, since programs like top and bash subshells would be preferable if they remembered the screen.
So I suppose there is no way to tell the terminal emulator to handle a program one way or the other since the support is actually compiled into the programs?
Thanks for all your explanation. I will look into the curses library.


Reply With Quote
