Eddies in the Space-Time Continuum
Peter Harvey's blog
Recent entries
Archives
« November 2009
MonTueWedThuFriSatSun
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
      
Today
Click me to subscribe
Search

Twitter

follow peteh at http://twitter.com
Google Reader
Technorati
My tags
aliases announcement birth book brompton children cloud computer croudsourcing damage datamining decision dtrace ethics family fun futurology gapminder geros goalfree goals happiness home human incentives intel internet ipod junk kepner-tregoe knowledge life loft losug mail making management mdb meme methodologies metro mice modelling morals mrgum network nfs nis+ nis_cachemgr nscd opensolaris performance philosophy photo pizza poverty process programming psychology rands review rodents rules security seedcamp sgrt sigbus signals sigsegv smart smf solaris sprcfb squirrels sun sunray superhero system ted teleworking terminal terminfo thinking troubleshooting trust wisdom
Flickr
www.flickr.com
This is a Flickr badge showing public photos from peteh. Make your own badge here.
del.icio.us links
del.icio.us tags
Bookmarks
RSS Feeds
XML
All
/Family
/General
/Internet
/Links
/Mac
/Management
/Palm
/Security
/Solaris
/Sun
Links
 
Licence
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.

Today's Page Hits: 123

Thursday Jun 14, 2007
Fixing terminfo so that terminal applications like vi(1) restore the screen

Ever noticed in Solaris that when you finish using vi(1) the terminal screen is not restored? Similarly true for applications like screen(1) and prstat(1M).

This was irritating me somewhat a few months ago but I've only now just logged bug 6569261 (xterm, xtermc, xterm-color: smcup/rmcup definitions are incorrect/missing) on it.

Essentially the problem is that the smcup and rmcup definitions don't work with our gnome-terminal and xterm implementations.

terminfo(4) defines smcup and rmcup as follows:

       exit_ca_mode       rmcup  te       String to end programs
                                          that use cup

       enter_ca_mode      smcup  ti       String to begin programs
                                          that use cup

These sequences are typically used by terminal applications that control the cursor (eg vi). smcup switches to an alternate screen buffer, rmcup switches back.

The practical effect of this is that the scrolling screen buffer is replaced by a non-scrolling screen buffer when running vi and restored when vi exits.

The rmcup/smcup terminfo descriptions fail to work on Solaris xterm and gnome-terminal implementations. The scolling buffer is not restored and, in some cases, strange escape sequences are seen (eg mysterious '0' characters).

The Solaris xtermc and xterm-color terminfo defines:

    rmcup=\E@0\E[?4r
    smcup=\E@0\E[?4s\E[?4h\E@1

These escape sequences don't make much sense for xterm. The xterm terminfo has nothing for rmcup/smcup.

The Sun Freeware terminfo definitions are more as expected:


  xterm-color rmcup=\E[2J\E[?47l\E8,
              smcup=\E7\E[?47h

For 'standard' xterm: smcup saves the cursor and switches to the alternate screen buffer; rmcup clears the screen, returns to the normal screen buffer and restores the cursor position.


  xterm       rmcup=\E[?1049l
              smcup=\E[?1049h

The 1049 sequence is a XFree addition which our xterm doesn't appear to support. Our current gnome-terminal (snv_65) does support this sequence.


  xtermc      rmcup=\E@0\E[?4r
              smcup=\E@0\E[?4s\E[?4h\E@1

This is as broken as our definition.


The workaround is to define smcup and rmcup appropriately. Here's one way to fix it:

  1. mkdir $HOME/terminfo
  2. TERM=xterm infocmp > xterm.src
  3. Edit xterm.src and add/change rmcup and smcup:
    rmcup=\E[2J\E[?47l\E8, smcup=\E7\E[?47h,
    every entry must be terminated in a comma (,).
  4. TERMINFO=$HOME/terminfo tic xterm.src
  5. TERMINFO=$HOME/terminfo TERM=xterm xterm

You should now find that your scrolling terminal window is retored after 'fixed' window terminal applications finish.


Posted at 10:26AM Jun 14, 2007 by Peter Harvey in Solaris  |  Comments[4]  |  del.icio.us technorati digg