[Ilugc] A Terminal Chat Application

  • From: 0@xxxxxxxxxxx (0)
  • Date: Thu, 17 Nov 2011 00:18:21 +0530



We have used 'reset' because the reason is the command 'history -c' clears
only the history of commands used but not the chats that we exchanged using
our app. When the terminal window is scrolled up it shows what all we had
in chat, and its violating the privacy, so used reset to erase of
everything.


Ah ok. "reset" is the right one to use here. But, what you really need 
is cup mode. Although, they are not supported in some terminal types.

Cup mode is not very well documented so you might find a hard time 
getting details on them. Here is a short tutorial on that. On Unix 
Terminals, there is a feature to open an Alternate Screen which is 
essentially what cup mode is. To try it, you can do the following,

$ echo -en "\033[?1049h"; clear; echo "abcd"; sleep 5; echo -en 
"\033[?1049l"

The above commands create an alternate screen, stay on it for 5 seconds 
and exit to the original screen. The first echo line is to enter cup 
mode and the last echo line is to exit cup mode.

And, To check whether a terminal supports cup mode, you can do the 
following,

$ infocmp vt100 | grep smcup #vt100 doesn't support cup
$ infocmp xterm | grep smcup #xterm supports cup
         sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h,

-- 
0

Other related posts: