MULTICS TECHNICAL BULLETIN                             MTB-767-00

To:       MTB Distribution

From:     Douglas G. Howe

Date:     September 16, 1987

Subject:  System V CURSES Port


This  MTB describes  the System  V curses  package which  will be
ported to Multics.


Comments on this MTB should be sent to the author -

     via Multics mail to:


     via telephone to:

        Douglas G.  Howe, ACTC (403) 284-6432

     via forum on System-M to:

        >udd>Multics>DGHowe>meetings>c_imp (c)


(1) UNIX is a trademark of AT&T Bell Laboratories.

(2) Reference:   UNIX  System  V   -  Release  2.0  -  Programmer
    Reference Manual.

Multics project  internal documentation; not to  be reproduced or
distributed outside the Multics project.

System V CURSES Port                                   MTB-767-00

                        TABLE OF CONTENTS

Section    Page  Subject
=======    ====  =======

1          1     Introduction
2          1     Curses Source Files
2.1        1     . . Include Files
2.2        1     . . Terminfo Data Base
2.3        2     . . Terminfo Low Level Interface
2.4        2     . . Mini-Curses Source Files
2.5        2     . . Extended Library
2.6        3     . . Termcap Support
3          4     Curses Entrypoints
3.1        4     . . Standard Entrypoints
3.2        7     . . Termcap Compatibility Entrypoints

System V CURSES Port                                   MTB-767-00

1.  Introduction

Curses is the UNIX (Trade mark  of AT&T) video and window system.
It allows users  the ability to perform simple  cursor and window
operations.  It has been decided that a direct port of the System
V  Curses would  be better  than a  translation of  Curses to the
Multics window  system in terms of time  and compatibility.  This
MTB describes the System V Curses package which will be ported.

2.  Curses Source Files

Curses  includes the  following source  files.  These  files have
been broken up into distinct categories.

2.1.  Include Files

Curses uses  the following include  files, which either  exist or
will be added to the C include hierarchy.

curses.h            curshdr.h           ns_curses.h      term.h
termio.h            unctrl.h            cvt.h            uparm.h

2.2.  Terminfo Data Base

Along with Curses comes the  terminfo data base generated by tic.
tic will be added to the UNIX commands available on Multics.  The
following is the list of terminfo files that comes with System V.

tic.c               capnames.c

adds.ti             diablo.ti           lsi.ti              special.ti
annarbor.ti         tektronix.ti        beehive.ti          general.ti
teleray.ti          cdc.ti              hardcopy.ti         microterm.ti
teletype.ti         concept.ti          hazeltine.ti        misc.ti
televideo.ti        pc.ti               ti.ti               heath.ti
perkinelm.ti        homebrew.ti         print.ti            virtual.ti
datamedia.ti        hp.ti               visual.ti           dec.ti

MTB-767-00                                   System V CURSES Port

2.3.  Terminfo Low Level Interface

The  following routines  allow the  setup and  restoration of the
terminal settings.

fixterm.c           resetterm.c         tparm.c             vidattr.c
putp.c              setupterm.c         tputs.c             vidputs.c

2.4.  Mini-Curses Source Files

The following are those routines classed under Mini-Curses.

addch.c             flushinp.c          noecho.c            unctrl.c
addstr.c            getch.c             nonl.c              wattroff.c
baudrate.c          idlok.c             noraw.c             wattron.c
beep.c              initscr.c           raw.c               wattrset.c
cbreak.c            meta.c              resetterm.c         wrefresh.c
delayoutpt.c        move.c              resetty.c           wstandend.c
echo.c              nl.c                saveterm.c          wstandout.c
endwin.c            nocbreak.c          savetty.c

2.5.  Extended Library

The following lists the complete source remaining.

_cflush.c           _tscroll.c          insch.c             numvals
_blanks.c           _window.c           insertln.c          overlay.c
_c_clean.c          boolnames           intrflush.c         overwrite.c
_clearhl.c          boolvals            keypad.c            pnoutrfrsh.c
_clearline.c        box.c               killchar.c          prefresh.c
_comphash.c                             leaveok.c           printw.c
_delay.c            caps                line_alloc.c        reset_prog.c
_delchars.c         chktypeahd.c        ll_refresh.c        resetshell.c
_dellines.c         clear.c             longname.c          restarttrm.c
_dumpwin.c          clearok.c           m_addch.c           scanw.c
_ec_quit.c          clreolinln.c        m_addstr.c          scroll.c
_fixdelay.c         clrtobot.c          m_clear.c           scrollok.c
_forcehl.c          clrtoeol.c          m_erase.c           select.c
_hlmode.c           cntcostfn.c         m_move.c            set_term.c
_id_char.c          crmode.c            m_refresh.c         setbuffred.c
_init_cost.c        curses.c            m_tstp.c            setterm.c
_inschars.c         curses.ext                              setupterm.c
_insmode.c          def_prog.c          makenew.c           show.c
_kpmode.c           def_shell.c         maketerm.ex         showstring.c

System V CURSES Port                                   MTB-767-00

_line_free.c        delch.c             miniinit.c          strnames
_ll_move.c          deleteln.c                              strvals
_outch.c            delwin.c            mvcur.c             subwin.c
_outchar.c          doprnt.c            mvprintw.c          touchwin.c
_pos.c              doscan.c            mvscanw.c           traceonoff.c
_reset.c            doupdate.c          mvwin.c             tstp.c
_scrdown.c          draino.c            mvwprintw.c         two.twostr.c
_scrollf.c          erase.c             mvwscanw.c          typeahead.c
_sethl.c            erasechar.c         naps.c              vsprintf.c
_setmode.c          flash.c             newpad.c            vsscanf.c
_setwind.c          getstr.c            newterm.c           wnoutrfrsh.c
_shove.c            gettmode.c          newwin.c            wprintw.c
_sprintw.c          has_ic.c            nocrmode.c          writechars.c
_sputc.c            has_il.c            nodelay.c           wscanw.c
_sscans.c           idln.getst.c        nttychktrm.c
_syncmodes.c        initkeypad.c        numnames

2.6.  Termcap Support

Termcap conversion is supported with the following routines.

termcap.form        tgetent.c           tgetnum.c           tgoto.c
                    tgetflag.c          tgetstr.c           tputs.c

MTB-767-00                                   System V CURSES Port

3.  Curses Entrypoints

The following is  a list of the entrypoints  available in Curses.
For a complete description see  the System V Programmer Reference
Manual section 3X.

3.1.  Standard Entrypoints

Routines listed  here may be  called when using  the full curses.
Those  marked   with  an  asterisk  may  be   called  when  using

addch(ch)*                    add a character to stdscr (like putchar)
                              (wraps to next line at end of line)
addstr(str)*                  calls addch with each character in str
attroff(attrs)*               turn off attributes named
attron(attrs)*                turn on attributes named
attrset(attrs)*               set current attributes to attrs
baudrate()*                   current terminal speed
beep()*                       sound beep on terminal
box(win, vert, hor)           draw a box around edges of win
                              vert and hor are chars to use for vert and hor,
                              edges of box
char()                        clear stdscr
clearok(win, bf)              clear screen before next redraw of win
clrtobot()                    clear to botton of stdscr
clrtoeol()                    clear to end of line on stdscr
cbreak()*                     set cbread mode
delay_output(ms)*             insert ms millisecond pause in output
delch()                       delete a character
deleteln()                    delete a line
delwin(win)                   delete win
doupdate()                    update screen from all wnoutrefresh
echo()*                       set echo mode
endwin()*                     end window modes
erase()                       erase stdscr
erasechar()                   return user's erase character
fixterm()                     restore tty to "in curses" state
flash()                       flash screen or beep
flushinp()*                   throw away any typeahead
getch()*                      get a char from tty
getstr(str)                   get a string through stdscr
gettmode()                    establish current tty modes
getyx(win, y, x)              get (y, x) coordinates
has_ic()                      true if terminal can do insert character
has_il()                      true if terminal can do insert line
idlok(win, bf)*               use terminal's insert/delete line if bf != 0

System V CURSES Port                                   MTB-767-00

inch ()                       get char at current (y, x) coordinates
initscr()*                    initialize screens
insch (c)                     insert a char
insertln()                    insert a line
intrflush(win, bf)            interrupts flush output if bf is TRUE
keypad(win, bf)               enable keypad input
killchar()                    return current user's kill character
leaveok(win, flag)            OK to leave cursor anywhere after refresh if
                              flag!=0 for win, otherwise cursor must be left
                              at current position.
longname()                    return verbose name of terminal
meta(win, flag)*              allow meta characters on input if flag !=0
move(y, x)*                   move to (y, x) on stdscr
mvaddch(y, x, ch)             move (y, x) then adch (ch)
mvaddstr(y, x, str)           similar...
mvcur(oldrow, oldcol, newrow, newcol)
                              low level cursor motion
mvdelch(y, x)                 like delch, but move (y, x) first
mvgetch(y, x)                 etc.
mvgetstr(y, x)
mvinch(y, x)
mvinsch(y, x, c)
mvprintw(y, x. fmt, args)
mvscanw(y, x, fmt, args)
mvwaddch(win, y, x, ch)
mvwaddstr(win, y, x. str)
mvwdelch(win, y, x)
mvwgetch(win, y, x)
mvwgetstr(win, y, x)
mvwin(win, by, bx)
mvwinch(win, y, x)
mvwinsch(win, y, x, c)
mvwprintw(win, y, x, fmt, args)
mvwscanw(win, y, x, fmt, args)
newpad(nlines, ncols)         create a new pad with given dimensions
newterm(type, fd)             set up new terminal of given type to output on fd
newwin(lines, cols, begin_y, begin_x)
                              create a new window
nl()*                         set newline mapping
nocbread()*                   unset cbreak mode
nodelay(win, bf)              enable nodelay input mode through getch
noecho()*                     unset echo mode
nonl()*                       unset newline mapping
noraw()*                      unset raw mode
overlay(win1, win2)           overlay win1 on win2
overwrite(win1, win2)         overwrite win1 on top of win2
pnoutrefresh(pad, pminrow, pmincol, sminrow, smincol, smaxrow,
          smaxcol)            like prefresh but with no output until
                              doupdate called
prefresh(pad, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol)
                              refresh from pad starting with given upper left
                              corner of pad with output to given portion of

MTB-767-00                                   System V CURSES Port

printw(fmt, arg1, arg2, ...)  print on stdscr
raw()*                        set raw mode
refresh()*                    make current screen look like stdscr
resetterm()*                  set tty modes to "out of curses" state
resetty()*                    reset tty flags to stored value
saveterm()*                   save current modes as "in curses" state
savetty()*                    store current tty flags
scanw(fmt, arg1, arg2, ...)   scanf through stdscr
scroll(win)                   scroll win one line
scrollok(win, flag)           allow terminal to scroll if flag != 0
set_term(new)                 now talk to terminal new
setsrreg(t, b)                set user scrolling region to lines t through b
setterm(type)                 establish terminal with given type
setupterm(term, filenum, errret)
standend()*                   clear standout mode attribute
standout()*                   set standout mode attribute
subwin(win, lines, cols, begin_y, begin_x)
                              create a subwindow
touchwin(win)                 change all of win
traceoff()                    turn off debugging trace output
traceon()                     turn on debugging trace output
typeahead(fd)                 use file descriptor fd to check typeahead
unctrl(ch)*                   printable version of ch
waddch(win, ch)               add char to win
waddstr(win, str)             add string to win
wattroff(win, attrs)          turn off attrs in win
wattron(win, attrs)           turn on attrs in win
wattrset(win, attrs)          set attrs in win to attrs
wclear(win)                   clear win
wclrtobot)win)                clear to botton of win
wclrtoeol(win)                clear to end of line on win
wdelch(win, c)                delete char from win
wdeleteln(win)                delete line from win
werase(win)                   erase win
wgetch(win)                   get a char through win
wgetstr(win, str)             get a string through win
winch(win)                    get char at current (y, x) in win
winsch(win, c)                insert char into win
winsertln(win)                insert line into win
wmove(win, y, x)              set current (y, x) coordinates on win
wnoutrefresh(win)             refresh but no screen output
wprintw(win, fmt, arg1, arg2, ...)
                              printf on win
wrefresh(win)                 make screen look like win
wscan(win, fmt, arg1, arg2, ...)
                              scanf through win
wsetscrreg(win, t, b)         set scrolling region of win
wstandend(win)                clear standout attribute in win
wstandout(win)                set standout attribute in win

System V CURSES Port                                   MTB-767-00

3.2.  Termcap Compatibility Entrypoints

tgetent(bp, name)             look up termcap entry for name
tgetflag(id)                  get boolean entry for id
tgetnum(id)                   get numeric entry for id
tgetstr(id, area)             get string entry for id
tgoto(cap, col, row)          apply parms to given cap
tputs(cap, affcnt, fn)        apply padding to cap calling fn as putchar