View Single Post
  #2   (View Single Post)  
Old 24th October 2011
comet--berkeley comet--berkeley is offline
Real Name: Richard
Package Pilot
 
Join Date: Apr 2009
Location: California
Posts: 163
Default ncurses and function keys - new terminal type based on vt220

I had trouble with the midnight commander (mc) program using the vt220 terminal emulation and decided to create my own new TERM types.

I called them "openbsd" and for monochrome, '"openbsd-m".

Below is a script I wrote to create a .terminfo directory and termcap file in my local user home directory.

To use the script, run it and then put this in the .profile

export TERM=openbsd

I call the script maketerminfo.sh

Code:
#! /bin/sh
set -e
INFODIR=$HOME/.terminfo
CAPFILE=$HOME/.termcap
/bin/cat << THERE

 Create new terminfo/termcap entries called
   openbsd and openbsd-m
 by making a new terminfo file and terminfo entries in
 my $INFODIR directory
 and by creating my own termcap file as $CAPFILE
-----------------------------------------------------
 To use the new terminfo/termcap entries,
 put something like this in your .profile

    export TERM=openbsd

 Or if you prefer monochrome:

    export TERM=openbsd-m

THERE
/bin/mkdir -p $INFODIR
cd $INFODIR
/bin/cat /dev/null      > terminfo
/bin/cat << HERE       >> terminfo
# This is a newer version of vt220 for OpenBSD that
# fixes the Function keys and the Home and End keys.
openbsd-m|OpenBSD mono from vt220,
        am, mir, xenl, xon,
        cols#80, lines#24, vt#3,
        acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
        bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, civis=\E[?25l,
        clear=\E[H\E[2J$<50>, cnorm=\E[?25h, cr=^M,
        csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\E[B, cuf1=\E[C,
        cup=\E[%i%p1%d;%p2%dH$<10>, cuu1=\E[A, dch1=\E[P,
        dl1=\E[M, ed=\E[J$<50>, el=\E[K$<3>, home=\E[H, ht=^I,
        if=/usr/share/tabset/vt100, il1=\E[L, ind=\ED$<20/>,
        is2=\E[1;24r\E[24;1H, kbs=\177, kcub1=\E[D, kcud1=\E[B,
        kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, kend=\E[8~,
        kf1=\E[11~, kf10=\E[21~, kf11=\E22~, kf12=\E23~,
        kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~,
        kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[7~,
        kich1=\E[2~, knp=\E[6~, kpp=\E[5~, rc=\E8, rev=\E[7m$<2>,
        rf=/usr/share/tabset/vt100, ri=\EM$<14/>,
        rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, rmso=\E[27m,
        rmul=\E[24m, rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h,
        sc=\E7,
        sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;,
        sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h,
        smso=\E[7m, smul=\E[4m,

# A copy of wsvt25 for OpenBSD in color with
# Function keys and Home/End keys fixed
openbsd|OpenBSD color 25 line vt220 mode,
        am, bce, mir, msgr, xenl, xon,
        colors#8, cols#80, lines#25, ncv#3, pairs#64, vt#3,
        acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
        bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, civis=\E[?25l,
        clear=\E[H\E[2J$<50>, cnorm=\E[?25h, cr=^M,
        csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\E[B, cuf1=\E[C,
        cup=\E[%i%p1%d;%p2%dH$<10>, cuu1=\E[A, dch1=\E[P,
        dl1=\E[M, ed=\E[J$<50>, el=\E[K$<3>, home=\E[H, ht=^I,
        if=/usr/share/tabset/vt100, il1=\E[L, ind=\ED$<20/>,
        is2=\E[1;24r\E[24;1H, kbs=\177, kcub1=\E[D, kcud1=\E[B,
        kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, kend=\E[8~,
        kf1=\E[11~, kf10=\E[21~, kf11=\E22~, kf12=\E23~,
        kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~,
        kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[7~,
        kich1=\E[2~, knp=\E[6~, kpp=\E[5~, op=\E[m, rc=\E8,
        rev=\E[7m$<2>, rf=/usr/share/tabset/vt100,
        ri=\EM$<14/>, rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l,
        rmso=\E[27m, rmul=\E[24m,
        rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
        setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
        sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;,
        sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h,
        smso=\E[7m, smul=\E[4m,
HERE
/usr/bin/tic -o$INFODIR -s terminfo
/usr/bin/infotocap         terminfo > $CAPFILE
/bin/ls -aldF $HOME/.term*
exit
Reply With Quote