home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sources / misc / 4090 < prev    next >
Encoding:
Text File  |  1992-11-18  |  55.2 KB  |  1,917 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: M.Hessling@gu.edu.au (Mark Hessling)
  4. Subject:  v33i085:  pdcurses - Public Domain curses library for DOS and OS/2 v2.0, Part05/11
  5. Message-ID: <1992Nov19.040314.7297@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: bc22152f6816b71345cd5daeb4b830b5
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v33i081=pdcurses.215551@sparky.IMD.Sterling.COM>
  11. Date: Thu, 19 Nov 1992 04:03:14 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 1902
  14.  
  15. Submitted-by: M.Hessling@gu.edu.au (Mark Hessling)
  16. Posting-number: Volume 33, Issue 85
  17. Archive-name: pdcurses/part05
  18. Environment: DOS,OS/2,ANSI-C
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then feed it
  22. # into a shell via "sh file" or similar.  To overwrite existing files,
  23. # type "sh file -c".
  24. # Contents:  demos/firework.c doc/overview.man nonport/resizew.c
  25. #   nonport/winprint.c portable/initpair.c portable/longname.c
  26. #   portable/pnoutref.c portable/waddch.c portable/wgetstr.c
  27. #   private/_chadd.c private/_clrupda.c private/_inswin.c
  28. #   private/_makenew.c tools/manext.c
  29. # Wrapped by kent@sparky on Wed Nov 18 21:44:07 1992
  30. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  31. echo If this archive is complete, you will see the following message:
  32. echo '          "shar: End of archive 5 (of 11)."'
  33. if test -f 'demos/firework.c' -a "${1}" != "-c" ; then 
  34.   echo shar: Will not clobber existing file \"'demos/firework.c'\"
  35. else
  36.   echo shar: Extracting \"'demos/firework.c'\" \(3454 characters\)
  37.   sed "s/^X//" >'demos/firework.c' <<'END_OF_FILE'
  38. X#include <stdio.h>
  39. X#include <signal.h>
  40. X#include <curses.h>
  41. X#include <ctype.h>
  42. X#include <sys/types.h>
  43. X#include <time.h>
  44. X#define DELAYSIZE 100
  45. Xmain()
  46. X{
  47. X       int start,end,row,diff,flag,direction,seed;
  48. X       int myrefresh();
  49. X       void explode();
  50. X
  51. X       initscr();
  52. X       if (has_colors())
  53. X          start_color();
  54. X       seed = time((time_t *)0);
  55. X       srand(seed);
  56. X       while(typeahead(stdin) == FALSE)
  57. X               {
  58. X                do {
  59. X                       start = rand() % (COLS -3);
  60. X                       end = rand() % (COLS - 3);
  61. X                       start = (start < 2) ? 2 : start;
  62. X                       end = (end < 2) ? 2 : end;
  63. X                       direction = (start > end) ? -1 : 1;
  64. X                       diff = abs(start-end);
  65. X                   } while (diff<2 || diff>=LINES-2);
  66. X                attrset(A_NORMAL);
  67. X                for (row=0;row<diff;row++)
  68. X                       {
  69. X                        mvprintw(LINES - row,start + (row * direction),
  70. X                               (direction < 0) ? "\\" : "/");
  71. X                        if (flag++)
  72. X                               {
  73. X                                myrefresh();
  74. X                                clear();
  75. X                                flag = 0;
  76. X                               }
  77. X                       }
  78. X               if (flag++)
  79. X                       {
  80. X                        myrefresh();
  81. X                        flag = 0;
  82. X                       }
  83. X               seed = time((time_t *)0);
  84. X               srand(seed);
  85. X               explode(LINES-row,start+(diff*direction));
  86. X               clear();
  87. X               myrefresh();
  88. X              }
  89. X       endwin();
  90. X       exit(0);
  91. X}
  92. Xvoid explode(row,col)
  93. Xint row,col;
  94. X{
  95. X       clear();
  96. X       mvprintw(row,col,"-");
  97. X       myrefresh();
  98. X
  99. X       init_pair(1,get_colour(),COLOR_BLACK);
  100. X       attrset(COLOR_PAIR(1));
  101. X       mvprintw(row-1,col-1," - ");
  102. X       mvprintw(row,col-1,"-+-");
  103. X       mvprintw(row+1,col-1," - ");
  104. X       myrefresh();
  105. X
  106. X       init_pair(1,get_colour(),COLOR_BLACK);
  107. X       attrset(COLOR_PAIR(1));
  108. X       mvprintw(row-2,col-2," --- ");
  109. X       mvprintw(row-1,col-2,"-+++-");
  110. X       mvprintw(row,  col-2,"-+#+-");
  111. X       mvprintw(row+1,col-2,"-+++-");
  112. X       mvprintw(row+2,col-2," --- ");
  113. X       myrefresh();
  114. X
  115. X       init_pair(1,get_colour(),COLOR_BLACK);
  116. X       attrset(COLOR_PAIR(1));
  117. X       mvprintw(row-2,col-2," +++ ");
  118. X       mvprintw(row-1,col-2,"++#++");
  119. X       mvprintw(row,  col-2,"+# #+");
  120. X       mvprintw(row+1,col-2,"++#++");
  121. X       mvprintw(row+2,col-2," +++ ");
  122. X       myrefresh();
  123. X
  124. X       init_pair(1,get_colour(),COLOR_BLACK);
  125. X       attrset(COLOR_PAIR(1));
  126. X       mvprintw(row-2,col-2,"  #  ");
  127. X       mvprintw(row-1,col-2,"## ##");
  128. X       mvprintw(row,  col-2,"#   #");
  129. X       mvprintw(row+1,col-2,"## ##");
  130. X       mvprintw(row+2,col-2,"  #  ");
  131. X       myrefresh();
  132. X
  133. X       init_pair(1,get_colour(),COLOR_BLACK);
  134. X       attrset(COLOR_PAIR(1));
  135. X       mvprintw(row-2,col-2," # # ");
  136. X       mvprintw(row-1,col-2,"#   #");
  137. X       mvprintw(row,  col-2,"     ");
  138. X       mvprintw(row+1,col-2,"#   #");
  139. X       mvprintw(row+2,col-2," # # ");
  140. X       myrefresh();
  141. X       return;
  142. X}
  143. Xint myrefresh()
  144. X{
  145. X       delay_output(DELAYSIZE);
  146. X       move(LINES-1,COLS-1);
  147. X       refresh();
  148. X}
  149. X
  150. Xint get_colour()
  151. X{
  152. X int attr;
  153. X       attr = (rand() % 16)+1;
  154. X       if (attr == 1 || attr == 9)
  155. X          attr = COLOR_RED;
  156. X       if (attr > 8)
  157. X          attr |= A_BOLD;
  158. X       return(attr);
  159. X}
  160. END_OF_FILE
  161.   if test 3454 -ne `wc -c <'demos/firework.c'`; then
  162.     echo shar: \"'demos/firework.c'\" unpacked with wrong size!
  163.   fi
  164.   # end of 'demos/firework.c'
  165. fi
  166. if test -f 'doc/overview.man' -a "${1}" != "-c" ; then 
  167.   echo shar: Will not clobber existing file \"'doc/overview.man'\"
  168. else
  169.   echo shar: Extracting \"'doc/overview.man'\" \(3058 characters\)
  170.   sed "s/^X//" >'doc/overview.man' <<'END_OF_FILE'
  171. X/*man-start*********************************************************************
  172. X
  173. X            Curses Overview
  174. X
  175. XThe X/Open Curses Interface Definition describes a set of C-Language
  176. Xfunctions that provide screen-handling and updating, which are
  177. Xcollectively known as the curses library.
  178. X
  179. XThe curses library permits manipulation of data structures called
  180. Xwindows which may be thought of as two-dimensional arrays of
  181. Xcharacters representing all or part of a terminal's screen.  The
  182. Xwindows are manipulated using a procedural interface described
  183. Xelsewhere.  The curses package maintains a record of what characters
  184. Xare on the screen.  At the most basic level, manipulation is done with
  185. Xthe routines move() and addch() which are used to "move" the curses
  186. Xaround and add characters to the default window, stdscr, which
  187. Xrepresents the whole screen.
  188. X
  189. XAn application may use these routines to add data to the window in any
  190. Xconvenient order.  Once all data have been added, the routine
  191. Xrefresh() is called.  The package then determines what changes have
  192. Xbeen made which affect the screen.  The screen contents are then
  193. Xchanged to reflect those characters now in the window. using a
  194. Xsequence of operations optimised for the type of terminal in use. 
  195. X
  196. XAt a higher level routines combining the actions of move() and addch()
  197. Xare defined, as are routines to add whole strings and to perform
  198. Xformat conversions in the manner of printf(). 
  199. X
  200. XInterfaces are alse defined to erase the entire window and to specify
  201. Xthe attributes of individual characters in the winodw.  Attributes
  202. Xsuch as inverse video, underline and blink can be used on a
  203. Xper-character basis. 
  204. X
  205. XNew windows can be created by allowing the application to build
  206. Xseveral images of the screen and display the appropriate one very
  207. Xquickly.  New windows are created using the routine newwin().  For
  208. Xeach routine that manipulates the default window, stdscr, there is a
  209. Xcorresponding routine prefixed with w to manipulate the contents of a
  210. Xspecified window; for example, move() and wmove().  In fact, move(...)
  211. Xis functionally equivalent to wmove( stdscr, ...).  This is similar to
  212. Xthe interface offered by printf(...) and fprintf(stdout, ...). 
  213. X
  214. XWindows do not have to correspond to the entire screen.  It is
  215. Xpossible to create smaller windows, and also to indicate that the
  216. Xwindow is only partially visible on the screen.  Furthermore, large
  217. Xwindows or pads, which are bigger than the actual screen size, may be
  218. Xcreated. 
  219. X
  220. XThe routine newterm() may be called to "open" additional terminals by
  221. Xlarge applications wishing to manipulate several terminals at once.
  222. XThe set_term() function is used to select the terminal whose screen is
  223. Xto be updated by the next refresh(). 
  224. X
  225. XInterfaces are also defined to allow input character manipulation and
  226. Xto disable and enable many input attributes: character echo, single
  227. Xcharacter input with or without signal processing (cbreak or raw
  228. Xmodes), carriage returns mapping to newlines, screen scrolling, etc. 
  229. X
  230. X**man-end**********************************************************************/
  231. END_OF_FILE
  232.   if test 3058 -ne `wc -c <'doc/overview.man'`; then
  233.     echo shar: \"'doc/overview.man'\" unpacked with wrong size!
  234.   fi
  235.   # end of 'doc/overview.man'
  236. fi
  237. if test -f 'nonport/resizew.c' -a "${1}" != "-c" ; then 
  238.   echo shar: Will not clobber existing file \"'nonport/resizew.c'\"
  239. else
  240.   echo shar: Extracting \"'nonport/resizew.c'\" \(3723 characters\)
  241.   sed "s/^X//" >'nonport/resizew.c' <<'END_OF_FILE'
  242. X#ifndef NO_MEMORY_H
  243. X#include <memory.h>
  244. X#endif
  245. X#define    CURSES_LIBRARY    1
  246. X#include <curses.h>
  247. X#undef    resize_win
  248. X
  249. X#ifndef NDEBUG
  250. Xchar *rcsid_resizew = "$Header: c:/curses/nonport/RCS/resizew.c%v 2.0 1992/11/15 03:18:28 MH Rel $";
  251. X#endif
  252. X
  253. X
  254. X
  255. X
  256. X/*man-start*********************************************************************
  257. X
  258. X  resize_win()    -    Resize a window
  259. X
  260. X  PDCurses Description:
  261. X     Resizes the passed WINDOW* to reflect the maximum size
  262. X     represented by the WINDOW* fields _pmaxy and _pmaxx.
  263. X
  264. X     If _maxy < _pmaxy then new lines will be added.
  265. X     The same is also true for _maxx and _pmaxx.
  266. X
  267. X     WARNING TO PROGRAMMERS:
  268. X
  269. X     This function assumes that when a window is enlarged
  270. X     horizontally, the contents on each existing line will be
  271. X     copied to the new, enlarged line and the remainder of the
  272. X     enlarged line will be cleared.
  273. X
  274. X     When a window is enlarged vertically, each new line added
  275. X     will be blank.
  276. X
  277. X     All borders will be observed and enlarged appropriately.
  278. X
  279. X     When a windows are shrunk, only the WINDOW* fields _pmaxy and
  280. X     _pmaxx are affected.
  281. X
  282. X  PDCurses Return Value:
  283. X     The resize_win() function returns a NULL pointer or a valid
  284. X     WINDOW* which may or may not point to the same physical
  285. X     window.  Besure to change all pointers to the passed window
  286. X     to the address returned by this function (but only if it is
  287. X     non-zero).
  288. X
  289. X  PDCurses Errors:
  290. X     It is an error to pass a NULL WINDOW pointer.
  291. X
  292. X  Portability:
  293. X     PDCurses    WINDOW*    resize_win( WINDOW* w, int lines, int cols );
  294. X
  295. X**man-end**********************************************************************/
  296. X
  297. XWINDOW*    resize_win(WINDOW *w, int lines, int cols)
  298. X{
  299. Xextern    void*    (*mallc)();    /* ptr to some malloc(size)    */
  300. Xextern    void*    (*callc)();    /* ptr to some ecalloc(num,size)*/
  301. Xextern    void    (*fre)();    /* ptr to some free(ptr)    */
  302. X
  303. X    WINDOW*    new;
  304. X    int    ncols  = max(cols, w->_pmaxx);
  305. X    int    nlines = max(lines, w->_pmaxy);
  306. X    int    i;
  307. X    int    j;
  308. X
  309. X    if (w == (WINDOW *)NULL)
  310. X        return( (WINDOW *)NULL );
  311. X
  312. X    if ((lines > w->_pmaxy) || (cols > w->_pmaxx))
  313. X    {
  314. X        if ((new = PDC_makenew(nlines, ncols, w->_begy, w->_begx)) == (WINDOW *)NULL)
  315. X            return( (WINDOW *)NULL );
  316. X
  317. X        new->_curx = w->_curx;
  318. X        new->_cury = w->_cury;
  319. X        new->_flags = w->_flags;
  320. X        new->_attrs = w->_attrs;
  321. X        new->_tabsize = w->_tabsize;
  322. X        new->_clear = w->_clear;
  323. X        new->_leave = w->_leave;
  324. X        new->_scroll = w->_scroll;
  325. X        new->_nodelay = w->_nodelay;
  326. X        new->_use_keypad = w->_use_keypad;
  327. X        new->_tmarg = w->_tmarg;
  328. X        new->_bmarg = w->_bmarg;
  329. X        new->_title = w->_title;
  330. X        new->_title_ofs = w->_title_ofs;
  331. X        new->_title_attr = w->_title_attr;
  332. X        new->_parent = w->_parent;
  333. X        memcpy(new->_borderchars, w->_borderchars, 8*sizeof(chtype));
  334. X
  335. X        for (i = 0; i < nlines; i++)
  336. X        {
  337. X            /*
  338. X             * make and clear the lines
  339. X             */
  340. X            if ((new->_y[i] = (chtype*)(*callc)(ncols, sizeof(chtype))) == NULL)
  341. X            {
  342. X                for (j = 0; j < i; j++)
  343. X                {
  344. X                    /*
  345. X                     * if error, free all the data
  346. X                     */
  347. X                    (*fre)(new->_y[j]);
  348. X                }
  349. X                (*fre)(new->_firstch);
  350. X                (*fre)(new->_lastch);
  351. X                (*fre)(new->_y);
  352. X                (*fre)(new);
  353. X                return( (WINDOW *)NULL );
  354. X            }
  355. X        }
  356. X        if ((w != curscr) && (w != tmpwin))
  357. X        {
  358. X            overwrite(w, new);
  359. X            wmove(new, w->_maxy - 1, 0);
  360. X            wclrtobot(new);
  361. X/* JGB box uses defaults if arguments are zero, but we don't want to do
  362. X   this if the window currently has no box */
  363. X            if (w->_borderchars[0] || w->_borderchars[2])
  364. X                box(new, w->_borderchars[0], w->_borderchars[2]);
  365. X        }
  366. X        delwin(w);
  367. X        return( new );
  368. X    }
  369. X    else
  370. X    {
  371. X        w->_bmarg = lines - 1;
  372. X        w->_maxy = lines;
  373. X        w->_maxx = cols;
  374. X/* JGB box uses defaults if arguments are zero, but we don't want to do
  375. X   this if the window currently has no box */
  376. X        if (w->_borderchars[0] || w->_borderchars[2])
  377. X            box(w, w->_borderchars[0], w->_borderchars[2]);
  378. X        return( w );
  379. X    }
  380. X}
  381. END_OF_FILE
  382.   if test 3723 -ne `wc -c <'nonport/resizew.c'`; then
  383.     echo shar: \"'nonport/resizew.c'\" unpacked with wrong size!
  384.   fi
  385.   # end of 'nonport/resizew.c'
  386. fi
  387. if test -f 'nonport/winprint.c' -a "${1}" != "-c" ; then 
  388.   echo shar: Will not clobber existing file \"'nonport/winprint.c'\"
  389. else
  390.   echo shar: Extracting \"'nonport/winprint.c'\" \(3060 characters\)
  391.   sed "s/^X//" >'nonport/winprint.c' <<'END_OF_FILE'
  392. X#ifndef NO_MEMORY_H
  393. X#define    CURSES_LIBRARY    1
  394. X#endif
  395. X#include <curses.h>
  396. X#undef    winPDC_print
  397. X
  398. X#ifndef NDEBUG
  399. Xchar *rcsid_winprint = "$Header: c:/curses/nonport/RCS/winprint.c%v 2.0 1992/11/15 03:18:31 MH Rel $";
  400. X#endif
  401. X
  402. X
  403. X
  404. X
  405. X#define PRINT    0
  406. X#define INIT    1
  407. X#define READ    2
  408. X
  409. X/*man-start*********************************************************************
  410. X
  411. X  win_print()    - print contents of window to LPT1
  412. X
  413. X  PDCurses Description:
  414. X     Prints the contents of the passed window or pad to LPT1:.  All
  415. X     attributes are ignored.     Newlines will be appended to the end
  416. X     of all win->_y[]s.  The caller must supply the compiler-
  417. X     dependent port number.
  418. X
  419. X  PDCurses Return Value:
  420. X     Return Status:    bit 0    0x01    Device Time Out
  421. X             bit 1    0x02    Bad WINDOW* passed
  422. X             bit 2    0x04    Unable to malloc memory
  423. X             bit 3    0x08    I/O Error
  424. X             bit 4    0x10    Selected
  425. X             bit 5    0x20    Out of paper
  426. X             bit 6    0x40    Acknowledge
  427. X             bit 7    0x80    Not Busy
  428. X
  429. X     A return value of 0 indicates success.
  430. X
  431. X  PDCurses Errors:
  432. X     It is an error to pass a NULL WINDOW pointer.
  433. X
  434. X  Portability:
  435. X     PDCurses    int win_print( WINDOW* win, int port );
  436. X
  437. X**man-end**********************************************************************/
  438. X
  439. Xint    win_print(WINDOW *win, int port)
  440. X{
  441. X#if    defined( DOS )
  442. X    char   *text;
  443. X    int    i;
  444. X    int    j;
  445. X    int    status;
  446. X    int    retry = 0;
  447. Xextern    void*    (*mallc)();        /* ptr to some malloc(size)    */
  448. Xextern    void*    (*callc)();        /* ptr to some ecalloc(num,size)*/
  449. Xextern    void    (*fre)();        /* ptr to some free(ptr)    */
  450. X
  451. X    if (win == (WINDOW *)NULL)
  452. X        return( 0x02 );
  453. X
  454. X    status = PDC_print(READ, 0, port);
  455. X
  456. X    if (((status & 0x20) != 0) || ((status & 0x08) != 0))
  457. X        return( status );
  458. X    /*
  459. X     * Print the window title First
  460. X     */
  461. X    text = win->_title;
  462. X    while (text != (char *)NULL)
  463. X    {
  464. X        status = PDC_print(PRINT, (int) *text, port);
  465. X        while ((status & 0x80) == 0x00)
  466. X        {
  467. X            if ((status & 0x01) == 0x01)
  468. X            {
  469. X                retry++;
  470. X                if (retry > 10)
  471. X                    return( status );
  472. X            }
  473. X            if (((status & 0x20) == 0x20) ||
  474. X                ((status & 0x10) == 0x00) ||
  475. X                ((status & 0x08) == 0x08))
  476. X            {
  477. X                return( status );
  478. X            }
  479. X            status = PDC_print(READ, 0, port);
  480. X        }
  481. X    }
  482. X    PDC_print(PRINT, '\r', port);
  483. X    PDC_print(PRINT, '\n', port);
  484. X    PDC_print(PRINT, '\n', port);
  485. X    text = (*mallc)(win->_maxx);
  486. X    if (text != (char *)NULL)
  487. X    {
  488. X        for (i = 0; i < win->_maxy; i++)
  489. X        {
  490. X            for (j = 0; j < win->_maxx; j++)
  491. X            {
  492. X                status = PDC_print(PRINT, (int) win->_y[i][j], port);
  493. X                while ((status & 0x80) == 0x00)
  494. X                {
  495. X                    if ((status & 0x01) == 0x01)
  496. X                    {
  497. X                        retry++;
  498. X                        if (retry > 10)
  499. X                        {
  500. X                            (*fre)(text);
  501. X                            return( status );
  502. X                        }
  503. X                    }
  504. X                    if (((status & 0x20) == 0x20) ||
  505. X                        ((status & 0x10) == 0x00) ||
  506. X                        ((status & 0x08) == 0x08))
  507. X                    {
  508. X                        (*fre)(text);
  509. X                        return( status );
  510. X                    }
  511. X
  512. X                    status = PDC_print(READ, 0, port);
  513. X                }
  514. X                retry = 0;
  515. X
  516. X            }
  517. X            PDC_print(PRINT, '\r', port);
  518. X            PDC_print(PRINT, '\n', port);
  519. X        }
  520. X        PDC_print(PRINT, '\f', port);
  521. X        (*fre)(text);
  522. X        return( 0x00 );
  523. X    }
  524. X    return( 0x04 );
  525. X#endif
  526. X#if    defined( HC ) && defined( FLEXOS )
  527. X    return( 0x03 );
  528. X#endif
  529. X#ifdef OS2
  530. X    return( 0x03 );
  531. X#endif
  532. X}
  533. END_OF_FILE
  534.   if test 3060 -ne `wc -c <'nonport/winprint.c'`; then
  535.     echo shar: \"'nonport/winprint.c'\" unpacked with wrong size!
  536.   fi
  537.   # end of 'nonport/winprint.c'
  538. fi
  539. if test -f 'portable/initpair.c' -a "${1}" != "-c" ; then 
  540.   echo shar: Will not clobber existing file \"'portable/initpair.c'\"
  541. else
  542.   echo shar: Extracting \"'portable/initpair.c'\" \(3582 characters\)
  543.   sed "s/^X//" >'portable/initpair.c' <<'END_OF_FILE'
  544. X#define    CURSES_LIBRARY    1
  545. X#include <curses.h>
  546. X#undef init_pair
  547. X
  548. X#ifndef    NDEBUG
  549. Xchar *rcsid_initpair = "$Header: c:/curses/portable/RCS/initpair.c%v 2.0 1992/11/15 03:28:56 MH Rel $";
  550. X#endif
  551. X
  552. X
  553. X
  554. X
  555. X/*man-start*********************************************************************
  556. X
  557. X  initpair()    - Change the definition of a color-pair.
  558. X
  559. X  PDCurses Description:
  560. X
  561. X     This routine is used to change the definition of a color-pair.
  562. X     The routine takes three arguments: the number of the color-pair
  563. X     to be redefined, and the new values of the foreground and
  564. X     background colors.
  565. X
  566. X     The value of colorpair must be between 1 and COLOR_PAIRS-1.
  567. X     The values of foreground and background must be between 0 and
  568. X     COLORS-1.
  569. X
  570. X  PDCurses Return Value:
  571. X     This function returns OK on success and ERR on error.
  572. X
  573. X  PDCurses Errors:
  574. X     It is an error to call this function with values outside of the
  575. X     ranges specified above.
  576. X
  577. X  Portability:
  578. X     PDCurses    int init_pair( int colorpair, short foreground, short background);
  579. X     SYS V Curses    int init_pair( int colorpair, short foreground, short background);
  580. X
  581. X**man-end**********************************************************************/
  582. X
  583. X
  584. Xunsigned char    atrtab[MAX_ATRTAB] = /* COLOR_PAIR to attribute encoding table. */
  585. X {0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  586. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  587. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  588. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  589. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  590. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  591. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  592. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  593. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  594. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  595. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  596. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  597. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  598. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  599. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  600. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  601. X  0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,0x07,0x0F,0x70,0x78,0x87,0x8F,0xF0,0xF8,
  602. X  0x70,0x00,0x17,0x00,0x00,0x00,0x00,0x00
  603. X  };
  604. X
  605. Xint init_pair(int colorpair,short foreground,short background)
  606. X{
  607. X extern int COLOR_PAIRS;
  608. X unsigned char norm,reverse;
  609. X
  610. X if (colorpair >= COLOR_PAIRS || colorpair < 1)
  611. X    return(ERR);
  612. X
  613. X norm = (unsigned char)(foreground & 0x0007) + ((background & 0x0007)<<4);
  614. X reverse = (unsigned char)(background & 0x0007) + ((foreground & 0x0007)<<4);
  615. X
  616. X atrtab[(colorpair*8)+0] = norm;                             /* normal */
  617. X atrtab[(colorpair*8)+1] = norm + 8;                       /* bold */
  618. X atrtab[(colorpair*8)+2] = reverse;                     /* reverse */
  619. X atrtab[(colorpair*8)+3] = reverse + 8;            /* bold-reverse */
  620. X atrtab[(colorpair*8)+4] = norm + 128;                    /* blink */
  621. X atrtab[(colorpair*8)+5] = norm + 8 + 128;           /* bold-blink */
  622. X atrtab[(colorpair*8)+6] = reverse + 128;         /* reverse-blink */
  623. X atrtab[(colorpair*8)+7] = reverse + 8 + 128;/* reverse-bold-blink */
  624. X return(OK);
  625. X}
  626. END_OF_FILE
  627.   if test 3582 -ne `wc -c <'portable/initpair.c'`; then
  628.     echo shar: \"'portable/initpair.c'\" unpacked with wrong size!
  629.   fi
  630.   # end of 'portable/initpair.c'
  631. fi
  632. if test -f 'portable/longname.c' -a "${1}" != "-c" ; then 
  633.   echo shar: Will not clobber existing file \"'portable/longname.c'\"
  634. else
  635.   echo shar: Extracting \"'portable/longname.c'\" \(3294 characters\)
  636.   sed "s/^X//" >'portable/longname.c' <<'END_OF_FILE'
  637. X#include <stdio.h>
  638. X#include <string.h>
  639. X#define    CURSES_LIBRARY    1
  640. X#include <curses.h>
  641. X#undef    longname
  642. X
  643. X#ifndef    NDEBUG
  644. Xchar *rcsid_longname = "$Header: c:/curses/portable/RCS/longname.c%v 2.0 1992/11/15 03:28:59 MH Rel $";
  645. X#endif
  646. X
  647. X
  648. X
  649. X
  650. X#ifdef    FLEXOS
  651. Xextern    char*    _flexos_gname();
  652. X#endif
  653. X
  654. Xstatic    char    _display[ 128 ];
  655. X
  656. X
  657. X
  658. X
  659. X/*man-start*********************************************************************
  660. X
  661. X  longname()    - return full terminal type name
  662. X
  663. X  X/Open Description:
  664. X     This function returns a pointer to a static area containing a
  665. X     verbose description of the current terminal.  The maximum length
  666. X     of the string is 128 characters.  It is defined only after the
  667. X     call to initscr() or newterm().  The area is overwritten by each
  668. X     call to newterm() and is not restored by set_term().  The value
  669. X     should therefore be saved between calls to newterm(), if
  670. X     longname() is going to be used with multiple terminals.
  671. X
  672. X  PDCurses Description:
  673. X     In addition to the above definition, the form of this string is
  674. X     the adapter name (or video card name) and the text resolution.
  675. X     This may also be followed by the notation that the video card
  676. X     may be a clone, which indicates that the card identification
  677. X     maps to more than one unique card.
  678. X
  679. X     e.g. The MDS Genius and the Quadram QuadHPG identify themselves
  680. X     in the same manner, but are vastly different in maximum resolution.
  681. X
  682. X  X/Open Return Value:
  683. X     The longname() function returns a pointer to a verbose description
  684. X     of the current terminal on success and the null pointer on error.
  685. X
  686. X  X/Open Errors:
  687. X     No errors are defined for this function.
  688. X
  689. X  Portability:
  690. X     PDCurses    char* longname( void );
  691. X     X/Open Dec '88    char* longname( void );
  692. X     BSD Curses    char* longname( void );
  693. X     SYS V Curses    char* longname( void );
  694. X
  695. X**man-end**********************************************************************/
  696. X
  697. Xchar*    longname(void)
  698. X{
  699. X#ifdef     OS2
  700. X    switch    (_cursvar.adapter.adapter)
  701. X    {
  702. X    case DISPLAY_CGA:    sprintf(_display, "CGA-%dx%d", LINES, COLS);      break;
  703. X    case DISPLAY_MONOCHROME:    sprintf(_display, "MDA-%dx%d", LINES, COLS);      break;
  704. X    case DISPLAY_EGA:    sprintf(_display, "EGA-%dx%d", LINES, COLS); break;
  705. X    case DISPLAY_VGA:    sprintf(_display, "VGA-%dx%d", LINES, COLS); break;
  706. X    case DISPLAY_8514A:     sprintf(_display, "8514-%dx%d", LINES, COLS);  break;
  707. X    default:    sprintf(_display, "Unknown-%dx%d", LINES, COLS);  break;
  708. X    }
  709. X#else
  710. X    switch    (_cursvar.adapter)
  711. X    {
  712. X    case _CGA:    sprintf(_display, "CGA-%dx%d", LINES, COLS);      break;
  713. X    case _MDA:    sprintf(_display, "MDA-%dx%d", LINES, COLS);      break;
  714. X    case _EGACOLOR:    sprintf(_display, "EGAColor-%dx%d", LINES, COLS); break;
  715. X    case _EGAMONO:    sprintf(_display, "EGAMono-%dx%d", LINES, COLS);  break;
  716. X    case _VGACOLOR:    sprintf(_display, "VGAColor-%dx%d", LINES, COLS); break;
  717. X    case _VGAMONO:    sprintf(_display, "VGAMono-%dx%d", LINES, COLS);  break;
  718. X    case _MCGACOLOR:sprintf(_display, "MCGAColor-%dx%d", LINES, COLS);break;
  719. X    case _MCGAMONO:    sprintf(_display, "MCGAMono-%dx%d", LINES, COLS); break;
  720. X    case _MDS_GENIUS:sprintf(_display, "Genius-%dx%d", LINES, COLS);  break;
  721. X#ifdef    FLEXOS
  722. X    case _FLEXOS:    sprintf(_display, "%s", _cursesgname());      break;
  723. X#endif
  724. X    default:    sprintf(_display, "Unknown-%dx%d", LINES, COLS);  break;
  725. X    }
  726. X#endif
  727. X
  728. X    if (_cursvar.bogus_adapter)
  729. X        strcat(_display, " (Clone)");
  730. X    return (_display);
  731. X}
  732. END_OF_FILE
  733.   if test 3294 -ne `wc -c <'portable/longname.c'`; then
  734.     echo shar: \"'portable/longname.c'\" unpacked with wrong size!
  735.   fi
  736.   # end of 'portable/longname.c'
  737. fi
  738. if test -f 'portable/pnoutref.c' -a "${1}" != "-c" ; then 
  739.   echo shar: Will not clobber existing file \"'portable/pnoutref.c'\"
  740. else
  741.   echo shar: Extracting \"'portable/pnoutref.c'\" \(3448 characters\)
  742.   sed "s/^X//" >'portable/pnoutref.c' <<'END_OF_FILE'
  743. X#ifndef NO_MEMORY_H
  744. X#include <memory.h>
  745. X#endif
  746. X#define    CURSES_LIBRARY    1
  747. X#include <curses.h>
  748. X#undef    pnoutrefresh
  749. X
  750. X#ifndef    NDEBUG
  751. Xchar *rcsid_pnoutref = "$Header: c:/curses/portable/RCS/pnoutref.c%v 2.0 1992/11/15 03:29:14 MH Rel $";
  752. X#endif
  753. X
  754. X
  755. X
  756. X
  757. X/*man-start*********************************************************************
  758. X
  759. X  pnoutrefresh()    - refresh pad without updating physical screen
  760. X
  761. X  X/Open Description:
  762. X     The prefresh routine copies the specified pad to the physical
  763. X     terminal screen.  It takes account of what is already
  764. X     displayed on the screen to optimize cursor movement.
  765. X
  766. X     The pnoutrefresh routine copies the named pad to the virtual
  767. X     screen. It then compares the virtual screen with the physical
  768. X     screen and performs the actual update.
  769. X
  770. X     These routines are analogous to the routines wrefresh and
  771. X     wnoutrefresh except that pads, instead of windows, are
  772. X     involved.  Additional parameters are also needed to indicate
  773. X     what part of the pad and screen are involved. The upper left
  774. X     corner of the part of the pad to be displayed is specified by
  775. X     py and px.  The coordinates sy1, sx1, sy2, and sx2 specify the
  776. X     edges of the screen rectangle that will contain the selected
  777. X     part of the pad.
  778. X
  779. X     The lower right corner of the pad rectangle to be displayed is
  780. X     calculated from the screen co-ordinates.  This ensures that
  781. X     the screen rectangle and the pad rectangle are the same size.
  782. X
  783. X     Both rectangles must be entirely contained within their
  784. X     respective structures.
  785. X
  786. X  PDCurses Description:
  787. X     Contrary to the statements above, the pnoutrefresh() routine
  788. X     will not perform an update to the physical screen.  This task
  789. X     is performed by doupdate().
  790. X
  791. X  X/Open Return Value:
  792. X     The prefresh() function returns OK on success and ERR on error.
  793. X
  794. X  PDCurses Errors:
  795. X     It is an error to pass a null WINDOW* pointer.
  796. X
  797. X  Portability:
  798. X     PDCurses    int pnoutrefresh( WINDOW* w, int py, int px,
  799. X                         int sy1, int sx1,
  800. X                         int sy2, int sx2 );
  801. X     X/Open Dec '88    int pnoutrefresh( WINDOW* win, int py, int px,
  802. X                         int sy1, int sx1,
  803. X                         int sy2, int sx2 );
  804. X     BSD Curses    int pnoutrefresh( WINDOW* w, int pminrow, int pmincol,
  805. X                         int sminrow, int smincol,
  806. X                         int smaxrow, int smaxcol );
  807. X     SYS V Curses    int pnoutrefresh( WINDOW* win, int py, int px,
  808. X                         int sy1, int sx1,
  809. X                         int sy2, int sx2 );
  810. X
  811. X**man-end**********************************************************************/
  812. X
  813. Xint    pnoutrefresh(WINDOW* w,int py,int px,int sy1,int sx1,int sy2,int sx2)
  814. X{
  815. Xregister chtype*    dstp;
  816. Xregister chtype*    srcp;
  817. X    WINDOW*        s = tmpwin;
  818. X    int        sline = sy1;
  819. X    int        pline = py;
  820. X
  821. X
  822. X    if (w == (WINDOW *)NULL)
  823. X        return( ERR );
  824. X
  825. X    while (sline <= sy2)
  826. X    {
  827. X        if (pline < w->_maxy)
  828. X        {
  829. X#if     defined(DOS) || defined(OS2)
  830. X#  if    SMALL || MEDIUM
  831. X            srcp = &(w->_y[pline][px]);
  832. X            dstp = &(s->_y[sline][sx1]);
  833. X            movedata(FP_SEG(srcp), FP_OFF(srcp),
  834. X                 FP_SEG(dstp), FP_OFF(dstp),
  835. X                 (sx2 - sx1 + 1) * sizeof(chtype));
  836. X#  else
  837. X            memcpy(&(s->_y[sline][sx1]),
  838. X                   &(w->_y[pline][px]),
  839. X                   (sx2 - sx1 + 1) * sizeof(chtype));
  840. X#  endif
  841. X#endif
  842. X
  843. X            if ((s->_firstch[sline] == _NO_CHANGE) ||
  844. X                (s->_firstch[sline] > sx1))
  845. X            {
  846. X                s->_firstch[sline] = sx1;
  847. X            }
  848. X
  849. X            if (sx2 > s->_lastch[sline])
  850. X                s->_lastch[sline] = sx2;
  851. X
  852. X            w->_firstch[pline] = _NO_CHANGE;  /* updated now */
  853. X            w->_lastch[pline] = _NO_CHANGE;  /* updated now */
  854. X        }
  855. X        sline++;
  856. X        pline++;
  857. X    }
  858. X
  859. X    if (w->_clear)
  860. X    {
  861. X        w->_clear = FALSE;
  862. X        s->_clear = TRUE;
  863. X    }
  864. X    return( OK );
  865. X}
  866. END_OF_FILE
  867.   if test 3448 -ne `wc -c <'portable/pnoutref.c'`; then
  868.     echo shar: \"'portable/pnoutref.c'\" unpacked with wrong size!
  869.   fi
  870.   # end of 'portable/pnoutref.c'
  871. fi
  872. if test -f 'portable/waddch.c' -a "${1}" != "-c" ; then 
  873.   echo shar: Will not clobber existing file \"'portable/waddch.c'\"
  874. else
  875.   echo shar: Extracting \"'portable/waddch.c'\" \(3156 characters\)
  876.   sed "s/^X//" >'portable/waddch.c' <<'END_OF_FILE'
  877. X#define    CURSES_LIBRARY    1
  878. X#include <curses.h>
  879. X#undef    waddch
  880. X
  881. X#ifndef    NDEBUG
  882. Xchar *rcsid_waddch = "$Header: c:/curses/portable/RCS/waddch.c%v 2.0 1992/11/15 03:29:20 MH Rel $";
  883. X#endif
  884. X
  885. X
  886. X
  887. X
  888. X/*man-start*********************************************************************
  889. X
  890. X  waddch()    - add character to window
  891. X
  892. X  X/Open Description:
  893. X     The routine addch inserts the character ch into the default
  894. X     window at the current cursor position and the window cursor is
  895. X     advanced.  The character is of the type chtype as containing
  896. X     both data and attributes.
  897. X
  898. X     The routine waddch inserts the character ch into the specified
  899. X     window at the current cursor position.  The cursor position is
  900. X     advanced.
  901. X
  902. X     The routine mvaddch moves the cursor to the specified (y, x)
  903. X     position and inserts the character ch into the default window.
  904. X     The cursor position is advanced after the character has been
  905. X     inserted.
  906. X
  907. X     The routine mvwaddch moves the cursor to the specified (y, x)
  908. X     position and inserts the character ch into the specified
  909. X     window.  The cursor position is advanced after the character
  910. X     has been inserted.
  911. X
  912. X     All these routines are similar to putchar.  The following
  913. X     information applies to all the routines.
  914. X
  915. X     If the cursor moves on to the right margin, an automatic
  916. X     newline is performed.  If scrollok is enabled, and a character
  917. X     is added to the bottom right corner of the screen, the
  918. X     scrolling region will be scrolled up one line.  If scrolling
  919. X     is not allowed, ERR will be returned.
  920. X
  921. X     If ch is a tab, newline, or backspace, the cursor will be
  922. X     moved appropriately within the window.  If ch is a newline,
  923. X     the clrtoeol routine is called before the cursor is moved to
  924. X     the beginning of the next line.  If newline mapping is off,
  925. X     the cursor will be moved to the next line, but the x
  926. X     coordinate will be unchanged.  If ch is a tab the cursor is
  927. X     moved to the next tab position within the window.  If ch is
  928. X     another control character, it will be drawn in the ^X
  929. X     notation.  Calling the inch routine after adding a control
  930. X     character returns the representation of the control character,
  931. X     not the control character.
  932. X
  933. X     Video attributes can be combined with a character by ORing
  934. X     them into the parameter.  This will result in these attributes
  935. X     being set.  The intent here is that text, including
  936. X     attributes, can be copied from one place to another using inch
  937. X     and addch.
  938. X
  939. X     NOTE: addch(), mvaddch(), and mvwaddch() are macros.
  940. X
  941. X  PDCurses Description:
  942. X     Depending upon the state of the raw character output, 7- or
  943. X     8-bit characters will be output.  NOTE: Needs work before release!
  944. X
  945. X  X/Open Return Value:
  946. X     The waddch() function returns OK on success and ERR on error.
  947. X
  948. X  X/Open Errors:
  949. X     No errors are defined for this function.
  950. X
  951. X  Portability:
  952. X     PDCurses    int waddch( WINDOW* win, chtype c );
  953. X     X/Open Dec '88    int waddch( WINDOW* win, chtype c );
  954. X     BSD Curses    int waddch( WINDOW* win, chtype c );
  955. X     SYS V Curses    int waddch( WINDOW* win, chtype c );
  956. X
  957. X**man-end**********************************************************************/
  958. X
  959. Xint    waddch(WINDOW *win, chtype c)
  960. X{
  961. X    return( PDC_chadd( win, (chtype)c, !(_cursvar.raw_out), TRUE ) );
  962. X}
  963. END_OF_FILE
  964.   if test 3156 -ne `wc -c <'portable/waddch.c'`; then
  965.     echo shar: \"'portable/waddch.c'\" unpacked with wrong size!
  966.   fi
  967.   # end of 'portable/waddch.c'
  968. fi
  969. if test -f 'portable/wgetstr.c' -a "${1}" != "-c" ; then 
  970.   echo shar: Will not clobber existing file \"'portable/wgetstr.c'\"
  971. else
  972.   echo shar: Extracting \"'portable/wgetstr.c'\" \(3103 characters\)
  973.   sed "s/^X//" >'portable/wgetstr.c' <<'END_OF_FILE'
  974. X#include <string.h>
  975. X#define    CURSES_LIBRARY    1
  976. X#include <curses.h>
  977. X#undef    wgetstr
  978. X
  979. X#ifndef    NDEBUG
  980. Xchar *rcsid_wgetstr = "$Header: c:/curses/portable/RCS/wgetstr.c%v 2.0 1992/11/15 03:29:26 MH Rel $";
  981. X#endif
  982. X
  983. X
  984. X
  985. X
  986. X/*man-start*********************************************************************
  987. X
  988. X  wgetstr()    - read string
  989. X
  990. X  X/Open Description:
  991. X     A series of characters are read until a newline or carriage
  992. X     return is received.  The resulting value is placed in the area
  993. X     pointed to by the character pointer str.  The user's erase and
  994. X     kill characters are interpreted.
  995. X
  996. X     NOTE: getstr(), mvgetstr(), and mvwgetstr() are macros.
  997. X
  998. X  PDCurses Description:
  999. X     The largest string returned will be 255 characters long.
  1000. X     This can be altered in the library be changing the MAXLINE #define.
  1001. X
  1002. X     WARNING:  This routine does not interpret the user's ERASE and
  1003. X           KILL characters as advertised.
  1004. X
  1005. X  X/Open Return Value:
  1006. X     These functions return OK on success and ERR on error.
  1007. X
  1008. X  PDCurses Errors:
  1009. X     It is an error to call this function with a NULL window pointer.
  1010. X
  1011. X  Portability:
  1012. X     PDCurses    int wgetstr( WINDOW* win, char* str );
  1013. X     X/Open Dec '88    int wgetstr( WINDOW* win, char* str );
  1014. X     BSD Curses    int wgetstr( WINDOW* win, char* str );
  1015. X     SYS V Curses    int wgetstr( WINDOW* win, char* str );
  1016. X
  1017. X**man-end**********************************************************************/
  1018. X
  1019. X
  1020. X#define MAXLINE 255
  1021. X
  1022. Xint    wgetstr(WINDOW *win, char *str)
  1023. X{
  1024. X    char    tmp[MAXLINE+1];
  1025. X    char    txt[MAXLINE+1];
  1026. X    char    new_char[2] = {0};
  1027. X    int    ch;
  1028. X    int    chars = strlen(str);
  1029. X    int    sy = win->_cury;
  1030. X    int    sx = win->_curx;
  1031. X    WINDOW*    w;
  1032. X    bool    oldecho;
  1033. X    bool    oldcbreak;
  1034. X    bool    oldnodelay;
  1035. X
  1036. X    if (win == (WINDOW *)NULL)
  1037. X        return (ERR);
  1038. X
  1039. X    w        = win;
  1040. X    c_strbeg    = txt;            /* save for backspacing */
  1041. X    oldcbreak    = _cursvar.cbreak;    /* remember states     */
  1042. X    oldecho        = _cursvar.echo;
  1043. X    oldnodelay    = w->_nodelay;
  1044. X    _cursvar.echo    = FALSE;        /* we do echo ourselves */
  1045. X    w->_nodelay    = FALSE;        /* don't return -1     */
  1046. X
  1047. X    strcpy(txt, str);
  1048. X    wprintw(w, str);
  1049. X    wrefresh(w);
  1050. X    ch = wgetch(w);
  1051. X    while (ch != '\n')
  1052. X    {
  1053. X
  1054. X        new_char[0] = (ch & CHR_MSK);
  1055. X        strcat(txt, new_char);
  1056. X        chars++;
  1057. X
  1058. X        switch (ch)
  1059. X        {
  1060. X        case 0x1b:    /* Escape */    /* Terminate String */
  1061. X        case '\r':    /* CTRL-M */
  1062. X        case KEY_ENTER:
  1063. X            chars--;
  1064. X            ch = '\n';
  1065. X            continue;
  1066. X
  1067. X        case 0x04:    /* CTRL-D */    /* Delete character */
  1068. X        case 0x08:    /* CTRL-H */
  1069. X            if (chars > 0)
  1070. X                PDC_backchar(w, txt, &chars);
  1071. X            break;
  1072. X
  1073. X        case 0x17:    /* CTRL-W */    /* Delete word */
  1074. X            chars--;
  1075. X            while ((txt[chars] == ' ') && (chars > 0))
  1076. X                PDC_backchar(w, txt, &chars);
  1077. X
  1078. X            while ((txt[chars] != ' ') && (chars > 0))
  1079. X                PDC_backchar(w, txt, &chars);
  1080. X            break;
  1081. X
  1082. X        case 0x15:    /* CTRL-U */    /* Delete line */
  1083. X        case 0x18:    /* CTRL-X */
  1084. X            chars++;
  1085. X            while (chars > 0)
  1086. X                PDC_backchar(w, txt, &chars);
  1087. X            break;
  1088. X
  1089. X        default:
  1090. X            waddch(w, ch);
  1091. X            wrefresh(w);
  1092. X            break;
  1093. X        }
  1094. X        ch = wgetch(w);
  1095. X    }
  1096. X
  1097. X    memset(str, '\0', MAXLINE+1);
  1098. X#ifdef FLEXOS
  1099. X    _split_plane(w, txt, tmp, sy, sx, w->_cury, w->_curx - 1);
  1100. X#endif
  1101. X    if (strlen(txt) > 0);
  1102. X    strcpy(str, txt);
  1103. X
  1104. X    _cursvar.echo = oldecho;
  1105. X    _cursvar.cbreak = oldcbreak;
  1106. X    win->_nodelay = oldnodelay;
  1107. X    return (OK);
  1108. X}
  1109. END_OF_FILE
  1110.   if test 3103 -ne `wc -c <'portable/wgetstr.c'`; then
  1111.     echo shar: \"'portable/wgetstr.c'\" unpacked with wrong size!
  1112.   fi
  1113.   # end of 'portable/wgetstr.c'
  1114. fi
  1115. if test -f 'private/_chadd.c' -a "${1}" != "-c" ; then 
  1116.   echo shar: Will not clobber existing file \"'private/_chadd.c'\"
  1117. else
  1118.   echo shar: Extracting \"'private/_chadd.c'\" \(4147 characters\)
  1119.   sed "s/^X//" >'private/_chadd.c' <<'END_OF_FILE'
  1120. X#define    CURSES_LIBRARY    1
  1121. X#include <curses.h>
  1122. X
  1123. X#ifndef    NDEBUG
  1124. Xchar *rcsid__chadd = "$Header: c:/curses/private/RCS/_chadd.c%v 2.0 1992/11/15 03:24:16 MH Rel $";
  1125. X#endif
  1126. X
  1127. X
  1128. X
  1129. X
  1130. X/*man-start*********************************************************************
  1131. X
  1132. X  PDC_chadd()      - Low level; Put a character to a window
  1133. X
  1134. X  PDCurses Description:
  1135. X        This is a private PDCurses function.
  1136. X
  1137. X        This routine will insert the character 'c' at the current cursor
  1138. X        position in the passed window.
  1139. X
  1140. X        If 'xlat' is TRUE, PDC_chadd() will handle things in a cooked
  1141. X        manner (tabs, newlines, carriage returns, etc).  If 'xlat' is
  1142. X        FALSE, the characters are simply output directly.
  1143. X
  1144. X        If 'advance' is TRUE, PDC_chadd() will move the current cusor position
  1145. X        appropriately. The *addch functions call PDC_chadd() with noadvance TRUE,
  1146. X        while the *insch functions call PDC_chadd() with noadvance FALSE.
  1147. X
  1148. X        The normal curses routines (non-raw-output-mode) call PDC_chadd()
  1149. X        with 'xlat' TRUE.
  1150. X
  1151. X  PDCurses Return Value:
  1152. X        This function returns OK on success and ERR on error.
  1153. X
  1154. X  PDCurses Errors:
  1155. X        It is an error to call this function with a NULL window pointer.
  1156. X
  1157. X  Portability:
  1158. X        PDCurses        int PDC_chadd( WINDOW* win, chtype ch, bool xlat, bool noadvance );
  1159. X
  1160. X**man-end**********************************************************************/
  1161. X
  1162. Xint    PDC_chadd(register WINDOW *win, chtype ch,bool xlat, bool advance)
  1163. X{
  1164. X    int    retval = ERR;
  1165. X    int    x;
  1166. X    int    y;
  1167. X    int    newx;
  1168. X    chtype    attr;
  1169. X    int    ts;
  1170. X
  1171. X    if (win    == (WINDOW *)NULL)
  1172. X        return(    retval );
  1173. X
  1174. X    x    = win->_curx;
  1175. X    y    = win->_cury;
  1176. X    ts    = win->_tabsize;
  1177. X
  1178. X/* if the incoming character doesn't have its own attribute
  1179. X   then    use the    current    attributes for the window.
  1180. X   if the incoming character has attributes but    not a colour
  1181. X   component, or the attributes    to the current attributes
  1182. X   for the window.
  1183. X   if the incoming character has a colour component use    the
  1184. X   attributes solely from the incoming character */
  1185. X
  1186. X    if ((ch    & A_ATTRIBUTES)    == 0)
  1187. X       attr    = win->_attrs;
  1188. X    else
  1189. X       if ((ch & A_COLOR) == 0)
  1190. X          attr = (ch & A_ATTRIBUTES) | win->_attrs;
  1191. X       else
  1192. X          attr = (ch & A_ATTRIBUTES);
  1193. X
  1194. X    ch    = (ch &    A_CHARTEXT);
  1195. X
  1196. X    if ((y > win->_maxy) ||
  1197. X        (x > win->_maxx) ||
  1198. X        (y < 0) ||
  1199. X        (x < 0))
  1200. X    {
  1201. X        return(    retval );
  1202. X    }
  1203. X
  1204. X    if (xlat)
  1205. X    {
  1206. X        switch (ch) {
  1207. X        case '\t':
  1208. X            for (newx = ((x    / ts) +    1) * ts; x < newx; x++)
  1209. X            {
  1210. X                if (waddch(win,    ' ') ==    ERR)
  1211. X                {
  1212. X                    return(    retval );
  1213. X                }
  1214. X                /*
  1215. X                 * if tab to next line
  1216. X                 */
  1217. X                if (win->_curx == 0)
  1218. X                {
  1219. X                    /*
  1220. X                     * exit    the loop
  1221. X                     */
  1222. X                    return(    OK );
  1223. X                }
  1224. X            }
  1225. X            return(    OK );
  1226. X
  1227. X        case '\n':
  1228. X            if (_cursvar.autocr && !(_cursvar.raw_out))
  1229. X            {
  1230. X                /*
  1231. X                 * if lf -> crlf
  1232. X                 */
  1233. X                x = 0;
  1234. X            }
  1235. X            wclrtoeol( win );
  1236. X            if ((y = PDC_newline(win, y)) < 0)
  1237. X                return(    retval );
  1238. X            if (advance)
  1239. X              {
  1240. X               win->_cury =    y;
  1241. X               win->_curx =    x;
  1242. X              }
  1243. X            return(    OK );
  1244. X
  1245. X        case '\r':
  1246. X            if (advance)
  1247. X               win->_curx =    x = 0;
  1248. X            return(    OK );
  1249. X
  1250. X        case '\b':
  1251. X            if (--x    < 0)
  1252. X            {
  1253. X                /*
  1254. X                 * no back over    left margin
  1255. X                 */
  1256. X                x = 0;
  1257. X            }
  1258. X            if (advance)
  1259. X               win->_curx =    x;
  1260. X            return(    OK );
  1261. X
  1262. X        case 0x7f:
  1263. X            if (waddch(win,    '^') ==    ERR)
  1264. X            {
  1265. X                return(    retval );
  1266. X            }
  1267. X            retval = waddch(win, '?');
  1268. X            return(    retval );
  1269. X
  1270. X        default:
  1271. X            break;
  1272. X        }        /* switch */
  1273. X
  1274. X        if (ch < ' ')
  1275. X        {
  1276. X            /*
  1277. X             * handle control chars
  1278. X             */
  1279. X            if (waddch(win,    '^') ==    ERR)
  1280. X                return(    retval );
  1281. X
  1282. X            retval = (waddch(win, ch + '@'));
  1283. X            return(    retval );
  1284. X        }
  1285. X    }
  1286. X
  1287. X    /*
  1288. X     *    Add the    attribute back into the    character.
  1289. X     */
  1290. X    ch    |= attr;
  1291. X    if (win->_y[y][x] !=    ch)
  1292. X    {
  1293. X        /*
  1294. X         * only    if data    change
  1295. X         */
  1296. X        if (win->_firstch[y] ==    _NO_CHANGE)
  1297. X        {
  1298. X            win->_firstch[y] = win->_lastch[y] = x;
  1299. X        }
  1300. X        else
  1301. X        {
  1302. X            if (x <    win->_firstch[y])
  1303. X            {
  1304. X                win->_firstch[y] = x;
  1305. X            }
  1306. X            else
  1307. X            {
  1308. X                if (x >    win->_lastch[y])
  1309. X                {
  1310. X                    win->_lastch[y] = x;
  1311. X                }
  1312. X            }
  1313. X        }
  1314. X    }
  1315. X    win->_y[y][x++] = ch;
  1316. X    if (x >= win->_maxx)
  1317. X    {
  1318. X        /*
  1319. X         * wrap    around test
  1320. X         */
  1321. X        x = 0;
  1322. X        if ((y = PDC_newline(win, y)) < 0)
  1323. X            return(    retval );
  1324. X    }
  1325. X    if (advance)
  1326. X      {
  1327. X       win->_curx =    x;
  1328. X       win->_cury =    y;
  1329. X      }
  1330. X    return(    OK );
  1331. X}
  1332. END_OF_FILE
  1333.   if test 4147 -ne `wc -c <'private/_chadd.c'`; then
  1334.     echo shar: \"'private/_chadd.c'\" unpacked with wrong size!
  1335.   fi
  1336.   # end of 'private/_chadd.c'
  1337. fi
  1338. if test -f 'private/_clrupda.c' -a "${1}" != "-c" ; then 
  1339.   echo shar: Will not clobber existing file \"'private/_clrupda.c'\"
  1340. else
  1341.   echo shar: Extracting \"'private/_clrupda.c'\" \(3916 characters\)
  1342.   sed "s/^X//" >'private/_clrupda.c' <<'END_OF_FILE'
  1343. X#ifndef NO_MEMORY_H
  1344. X#include <memory.h>
  1345. X#endif
  1346. X#define    CURSES_LIBRARY    1
  1347. X#include <curses.h>
  1348. X
  1349. X#ifndef    NDEBUG
  1350. Xchar *rcsid__clrupda = "$Header: c:/curses/private/RCS/_clrupda.c%v 2.0 1992/11/15 03:24:28 MH Rel $";
  1351. X#endif
  1352. X
  1353. X
  1354. X
  1355. X
  1356. X/*man-start*********************************************************************
  1357. X
  1358. X  PDC_clr_update()    - Updates the screen with a full redraw.
  1359. X
  1360. X  PDCurses Description:
  1361. X     Updates the screen by clearing it and then redraw it in its
  1362. X     entirety. If _cursvar.refrbrk is TRUE, and there is pending
  1363. X     input characters, the update will be prematurely terminated.
  1364. X
  1365. X  PDCurses Return Value:
  1366. X     This routine returns ERR if it is unable to accomplish it's task.
  1367. X     This return value is ONLY under FLEXOS.
  1368. X
  1369. X     The return value OK is returned if there were no errors.
  1370. X
  1371. X  PDCurses Errors:
  1372. X     No errors are defined for this function.
  1373. X
  1374. X  Portability:
  1375. X     PDCurses    int PDC_clr_update( WINDOW* s );
  1376. X
  1377. X**man-end**********************************************************************/
  1378. X
  1379. Xint    PDC_clr_update(WINDOW *s)
  1380. X{
  1381. Xregister int    i;
  1382. Xregister int    j;
  1383. X    WINDOW*    w;
  1384. X    chtype*    ch;
  1385. X    bool rc;
  1386. X#ifdef    FLEXOS
  1387. X    char    line[80];
  1388. X    char    attr[80];
  1389. X    FFRAME    sframe;
  1390. X    RECT    drect,
  1391. X        srect;
  1392. X#endif
  1393. X    extern unsigned    char atrtab[MAX_ATRTAB];
  1394. X    chtype temp_line[256]; /* this should be enough for the maximum width of a screen. MH-920715 */
  1395. X    chtype chr;
  1396. X
  1397. X    w = curscr;
  1398. X    if (w == (WINDOW *)NULL)
  1399. X        return( ERR );
  1400. X    if (_cursvar.full_redraw)
  1401. X        PDC_clr_scrn(s); /* clear physical screen */
  1402. X
  1403. X    s->_clear = FALSE;
  1404. X    for (i = 0; i < LINES; i++)    /* update physical screen */
  1405. X    {
  1406. X        if (s != w)    /* copy s to curscr */
  1407. X#ifdef    DOS
  1408. X#  if    SMALL || MEDIUM
  1409. X            movedata(FP_SEG(s->_y[i]),
  1410. X                FP_OFF(s->_y[i]),
  1411. X                FP_SEG(w->_y[i]),
  1412. X                FP_OFF(w->_y[i]),
  1413. X                COLS * sizeof(chtype));
  1414. X#  else
  1415. X            memcpy(w->_y[i], s->_y[i], COLS * sizeof(chtype));
  1416. X#  endif
  1417. X#endif
  1418. X#ifdef    OS2
  1419. X            memcpy(w->_y[i], s->_y[i], COLS * sizeof(chtype));
  1420. X#endif
  1421. X
  1422. X    ch = temp_line; /* now have ch pointing to area to contain real attributes. MH-920715 */
  1423. X#ifdef     DOS
  1424. X#  if    SMALL || MEDIUM
  1425. X        movedata(FP_SEG(s->_y[i]), FP_OFF(s->_y[i]),
  1426. X            FP_SEG(ch), FP_OFF(ch),COLS * sizeof(chtype));
  1427. X#  else
  1428. X        memcpy(ch,s->_y[i],COLS*sizeof(chtype)); /* copy current line to temp_line. MH-920715 */
  1429. X#  endif
  1430. X#else
  1431. X        memcpy(ch,s->_y[i],COLS*sizeof(chtype)); /* copy current line to temp_line. MH-920715 */
  1432. X#endif
  1433. X        for (j=0;j<COLS;j++)          /* for each chtype in the line... */
  1434. X           {
  1435. X            chr = temp_line[j] & A_CHARTEXT;
  1436. X            temp_line[j] = chtype_attr(temp_line[j]) | chr;
  1437. X           }
  1438. X
  1439. X        if (_cursvar.direct_video)
  1440. X        {
  1441. X#ifdef    FLEXOS
  1442. X            PDC_split_plane(w, &line[0], &attr[0], i, 0, i, COLS);
  1443. X/* need to translate attr[] array to real attributes before displaying it. MH-920715 */
  1444. X            drect.r_row = i;
  1445. X            drect.r_col = 0;
  1446. X            drect.r_nrow = 1;
  1447. X            drect.r_ncol = COLS;
  1448. X
  1449. X            sframe.fr_pl[0] = (UBYTE *) line;
  1450. X            sframe.fr_pl[1] = (UBYTE *) attr;
  1451. X            sframe.fr_nrow = 1;
  1452. X            sframe.fr_ncol = COLS;
  1453. X            sframe.fr_use = 0x03;
  1454. X
  1455. X            srect.r_col = 0;
  1456. X            srect.r_row = 0;
  1457. X            srect.r_nrow = 1;
  1458. X            srect.r_ncol = COLS;
  1459. X
  1460. X            s_copy(0x03, 0x01L, 0L, (far unsigned short *) &drect,
  1461. X                (far unsigned short *) &sframe,
  1462. X                (far unsigned short *) &srect);
  1463. X#endif
  1464. X#ifdef    DOS
  1465. X#  if    SMALL || MEDIUM || MSC
  1466. X            movedata(FP_SEG(ch), FP_OFF(ch),
  1467. X                _cursvar.video_seg,
  1468. X                _cursvar.video_ofs + (i*COLS*sizeof(chtype)),
  1469. X                    (COLS * sizeof(chtype)));
  1470. X#  else
  1471. X            memcpy(MK_FP(_cursvar.video_seg,
  1472. X              _cursvar.video_ofs + (i * COLS * sizeof(chtype))),
  1473. X                   ch, (COLS * sizeof(chtype)));
  1474. X#  endif
  1475. X#endif
  1476. X#ifdef    OS2
  1477. X                VioWrtCellStr ((PCH)ch, (USHORT)(COLS * sizeof(chtype)), (USHORT)i, 0, 0);
  1478. X#endif
  1479. X        }
  1480. X        else
  1481. X        {
  1482. X            for (j = 0; j < COLS; j++)
  1483. X            {
  1484. X                PDC_gotoxy(i, j);
  1485. X                PDC_putc( (*ch & A_CHARTEXT), (*ch & A_ATTRIBUTES) >> 8 );
  1486. X                ch++;
  1487. X            }
  1488. X        }
  1489. X#if defined(MSC) && defined (DOS)
  1490. X        rc = typeahead(stdin);
  1491. X        if (_cursvar.refrbrk && rc)
  1492. X#else
  1493. X        if (_cursvar.refrbrk && typeahead(stdin))
  1494. X#endif
  1495. X            return( OK );
  1496. X    }
  1497. X    return( OK );
  1498. X}
  1499. END_OF_FILE
  1500.   if test 3916 -ne `wc -c <'private/_clrupda.c'`; then
  1501.     echo shar: \"'private/_clrupda.c'\" unpacked with wrong size!
  1502.   fi
  1503.   # end of 'private/_clrupda.c'
  1504. fi
  1505. if test -f 'private/_inswin.c' -a "${1}" != "-c" ; then 
  1506.   echo shar: Will not clobber existing file \"'private/_inswin.c'\"
  1507. else
  1508.   echo shar: Extracting \"'private/_inswin.c'\" \(1923 characters\)
  1509.   sed "s/^X//" >'private/_inswin.c' <<'END_OF_FILE'
  1510. X#ifndef NO_MEMORY_H
  1511. X#include <memory.h>
  1512. X#endif
  1513. X#define    CURSES_LIBRARY    1
  1514. X#include <curses.h>
  1515. X
  1516. X#ifdef    REGISTERWINDOWS
  1517. X#ifndef    NDEBUG
  1518. Xchar *rcsid__inswin = "$Header: c:/curses/private/RCS/_inswin.c%v 2.0 1992/11/15 03:24:27 MH Rel $";
  1519. X#endif
  1520. X
  1521. X
  1522. X
  1523. X
  1524. X/*man-start*********************************************************************
  1525. X
  1526. X  _inswin()    - Register Window with PDCurses for auto refresh
  1527. X
  1528. X  PDCurses Description:
  1529. X     This is a private PDCurses routine.
  1530. X
  1531. X     This routine inserts the passed window pointer after the specified
  1532. X     window.     If the specified window is a (void*)0, then the passed
  1533. X     window pointer is inserted first in the list.
  1534. X
  1535. X     If the 'before' window is not on the visible list, then 'win'
  1536. X     will be insed to the end of the list.
  1537. X
  1538. X     This is the beginnings of full-tiled window support.  It is _very_
  1539. X     raw at this point.
  1540. X
  1541. X  PDCurses Return Value:
  1542. X     This function returns OK on success and ERR on error.
  1543. X
  1544. X  PDCurses Errors:
  1545. X     No errors are defined for this function.
  1546. X
  1547. X  Portability:
  1548. X     PDCurses    bool    _inswin( WINDOW* win, WINDOW* before );
  1549. X
  1550. X**man-end**********************************************************************/
  1551. X
  1552. Xbool    _inswin(WINDOW *win, WINDOW *before)
  1553. X{
  1554. Xextern    void*    (*mallc)( size_t );
  1555. Xextern    void*    (*callc)( size_t, size_t );
  1556. Xextern    void    (*fre)( void* );
  1557. X
  1558. X    WINDS  *root = _cursvar.visible;
  1559. X    WINDS  *wlst = _findwin(before);
  1560. X    WINDS  *new  = (*mallc)(sizeof(WINDS));
  1561. X
  1562. X    if (new == (WINDS *)NULL)
  1563. X        return( FALSE );
  1564. X
  1565. X    _rmwin(win);
  1566. X    memset(new, 0, sizeof(WINDS));
  1567. X    new->w = win;
  1568. X    if (wlst == (WINDS *)NULL)
  1569. X    {
  1570. X        if (root == (WINDS *)NULL)
  1571. X        {
  1572. X            _cursvar.visible = new;
  1573. X        }
  1574. X        else
  1575. X        {
  1576. X            new->next = root;
  1577. X            root->prev = new;
  1578. X            _cursvar.visible = new;
  1579. X        }
  1580. X    }
  1581. X    else
  1582. X    {
  1583. X        if (wlst == root)
  1584. X        {
  1585. X            new->next = root;
  1586. X            root->prev = new;
  1587. X            _cursvar.visible = new;
  1588. X        }
  1589. X        else
  1590. X        {
  1591. X            new->next = wlst;
  1592. X            new->prev = wlst->prev;
  1593. X            wlst->prev->next = new;
  1594. X            wlst->prev = new;
  1595. X        }
  1596. X    }
  1597. X    return( TRUE );
  1598. X}
  1599. X#endif
  1600. END_OF_FILE
  1601.   if test 1923 -ne `wc -c <'private/_inswin.c'`; then
  1602.     echo shar: \"'private/_inswin.c'\" unpacked with wrong size!
  1603.   fi
  1604.   # end of 'private/_inswin.c'
  1605. fi
  1606. if test -f 'private/_makenew.c' -a "${1}" != "-c" ; then 
  1607.   echo shar: Will not clobber existing file \"'private/_makenew.c'\"
  1608. else
  1609.   echo shar: Extracting \"'private/_makenew.c'\" \(3179 characters\)
  1610.   sed "s/^X//" >'private/_makenew.c' <<'END_OF_FILE'
  1611. X#ifndef NO_MEMORY_H
  1612. X#include <memory.h>
  1613. X#endif
  1614. X#define    CURSES_LIBRARY    1
  1615. X#include <curses.h>
  1616. X
  1617. X#ifndef    NDEBUG
  1618. Xchar *rcsid__makenew = "$Header: c:/curses/private/RCS/_makenew.c%v 2.0 1992/11/15 03:24:28 MH Rel $";
  1619. X#endif
  1620. X
  1621. X
  1622. X
  1623. X
  1624. X/*man-start*********************************************************************
  1625. X
  1626. X  PDC_makenew()    - Create a WINDOW* (sans line allocation)
  1627. X
  1628. X  PDCurses Description:
  1629. X     This is a private PDCurses routine.
  1630. X
  1631. X     Allocates all data for a new WINDOW* except the actual lines
  1632. X     themselves.
  1633. X
  1634. X  PDCurses Return Value:
  1635. X     This function returns a valid WINDOW* on success and NULL on error.
  1636. X
  1637. X  PDCurses Errors:
  1638. X     If PDC_makenew() is unable to allocate memory for the window
  1639. X     structure, it will free all allocated memory and return
  1640. X     a NULL pointer.
  1641. X
  1642. X  Portability:
  1643. X     PDCurses    WINDOW* makenew( int num_lines, int num_columns,
  1644. X                      int begy, int begx );
  1645. X
  1646. X**man-end**********************************************************************/
  1647. X
  1648. XWINDOW*    PDC_makenew(int num_lines, int num_columns, int begy, int begx)
  1649. X{
  1650. Xextern    void*    (*mallc)( size_t );
  1651. Xextern    void*    (*callc)( size_t, size_t );
  1652. Xextern    void    (*fre)( void* );
  1653. X
  1654. X    short    i;
  1655. X    WINDOW *win;
  1656. X
  1657. X    /*
  1658. X    *    Use the standard runtime malloc/calloc package or use
  1659. X    *    the user's emalloc/ecalloc package.
  1660. X    *
  1661. X    *    Allocate the window structure itself
  1662. X    */
  1663. X    if ((win = (*mallc)(sizeof(WINDOW))) == (WINDOW *)NULL)
  1664. X    {
  1665. X        return( win );
  1666. X    }
  1667. X
  1668. X    /*
  1669. X    * allocate the line pointer array
  1670. X    */
  1671. X    if ((win->_y = (*callc)(num_lines, sizeof(chtype *))) == NULL)
  1672. X    {
  1673. X        (*fre)(win);
  1674. X        return( (WINDOW *)NULL );
  1675. X    }
  1676. X
  1677. X    /*
  1678. X    * allocate the minchng and maxchng arrays
  1679. X    */
  1680. X    if ((win->_firstch = (*callc)(num_lines, sizeof(int))) == NULL)
  1681. X    {
  1682. X        (*fre)(win->_y);
  1683. X        (*fre)(win);
  1684. X        return( (WINDOW *)NULL );
  1685. X    }
  1686. X    if ((win->_lastch = (*callc)(num_lines, sizeof(int))) == NULL)
  1687. X    {
  1688. X        (*fre)(win->_firstch);
  1689. X        (*fre)(win->_y);
  1690. X        (*fre)(win);
  1691. X        return( (WINDOW *)NULL );
  1692. X    }
  1693. X
  1694. X    /*
  1695. X    * initialize window variables
  1696. X    */
  1697. X    win->_curx = 0;
  1698. X    win->_cury = 0;
  1699. X    win->_maxy = num_lines;        /* real max screen size */
  1700. X    win->_maxx = num_columns;    /* real max screen size */
  1701. X    win->_pmaxy = num_lines;    /* real max window size */
  1702. X    win->_pmaxx = num_columns;    /* real max window size */
  1703. X    win->_begy = begy;
  1704. X    win->_begx = begx;
  1705. X    win->_flags = 0;
  1706. X    win->_attrs = 0;        /* No attributes */
  1707. X    win->_tabsize = 8;
  1708. X    win->_clear = (bool) ((num_lines == LINES) && (num_columns == COLS));
  1709. X    win->_leave = FALSE;
  1710. X    win->_scroll = FALSE;
  1711. X    win->_nodelay = FALSE;
  1712. X    win->_use_keypad = FALSE;
  1713. X    win->_use_idl = FALSE;
  1714. X    win->_tmarg = 0;
  1715. X    win->_bmarg = num_lines - 1;
  1716. X    win->_title = NULL;
  1717. X    win->_title_ofs = 1;
  1718. X    win->_title_attr = win->_attrs;
  1719. X    win->_blank = ' ';
  1720. X    win->_parent = NULL;
  1721. X
  1722. X    memset(win->_borderchars, '\0', 8*sizeof(chtype));
  1723. X
  1724. X    /*
  1725. X    * init to say window unchanged
  1726. X    */
  1727. X    for (i = 0; i < num_lines; i++)
  1728. X    {
  1729. X        win->_firstch[i] = 0;
  1730. X        win->_lastch[i] = num_columns - 1;
  1731. X    }
  1732. X
  1733. X    /*
  1734. X    * set flags for window properties
  1735. X    */
  1736. X    if ((begy + num_lines) == LINES)
  1737. X    {
  1738. X        win->_flags |= _ENDLINE;
  1739. X        if ((begx == 0) &&
  1740. X            (num_columns == COLS) &&
  1741. X            (begy == 0))
  1742. X        {
  1743. X            win->_flags |= _FULLWIN;
  1744. X        }
  1745. X    }
  1746. X
  1747. X    if (((begy + num_lines) == LINES) &&
  1748. X        ((begx + num_columns) == COLS))
  1749. X    {
  1750. X        win->_flags |= _SCROLLWIN;
  1751. X    }
  1752. X    return( win );
  1753. X}
  1754. END_OF_FILE
  1755.   if test 3179 -ne `wc -c <'private/_makenew.c'`; then
  1756.     echo shar: \"'private/_makenew.c'\" unpacked with wrong size!
  1757.   fi
  1758.   # end of 'private/_makenew.c'
  1759. fi
  1760. if test -f 'tools/manext.c' -a "${1}" != "-c" ; then 
  1761.   echo shar: Will not clobber existing file \"'tools/manext.c'\"
  1762. else
  1763.   echo shar: Extracting \"'tools/manext.c'\" \(3983 characters\)
  1764.   sed "s/^X//" >'tools/manext.c' <<'END_OF_FILE'
  1765. X/***********************************************************************/
  1766. X/* MANEXT - Extract manual pages from C source code.                   */
  1767. X/***********************************************************************/
  1768. X/*
  1769. X * MANEXT - A program to extract manual pages from C source code.
  1770. X * Copyright (C) 1991,1992 Mark Hessling
  1771. X *
  1772. X * This program is free software; you can redistribute it and/or
  1773. X * modify it under the terms of the GNU General Public License as
  1774. X * published by the Free Software Foundation; either version 2 of
  1775. X * the License, or any later version.
  1776. X *
  1777. X * This program is distributed in the hope that it will be useful,
  1778. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1779. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1780. X * General Public License for more details.
  1781. X *
  1782. X * You should have received a copy of the GNU General Public License
  1783. X * along with this program; if not, write to:
  1784. X *
  1785. X *    The Free Software Foundation, Inc.
  1786. X *    675 Mass Ave,
  1787. X *    Cambridge, MA 02139 USA.
  1788. X *
  1789. X *
  1790. X * If you make modifications to this software that you feel increases
  1791. X * it usefulness for the rest of the community, please email the
  1792. X * changes, enhancements, bug fixes as well as any and all ideas to me.
  1793. X * This software is going to be maintained and enhanced as deemed
  1794. X * necessary by the community.
  1795. X *
  1796. X * Mark Hessling                     email: M.Hessling@itc.gu.edu.au
  1797. X * 36 David Road                     Phone: +61 7 849 7731
  1798. X * Holland Park                      Fax:   +61 7 875 7877
  1799. X * QLD 4121
  1800. X * Australia
  1801. X */
  1802. X#include <stdio.h>
  1803. X
  1804. Xvoid display_info();
  1805. X
  1806. X#define MAX_LINE 255
  1807. X
  1808. X/***********************************************************************/
  1809. Xint main(argc,argv)
  1810. Xint argc;
  1811. Xchar *argv[];
  1812. X/***********************************************************************/
  1813. X{
  1814. X char    s[MAX_LINE + 1];        /* input line */
  1815. X register int     i = 0;
  1816. X FILE *fp;
  1817. X char c;
  1818. X char append=0;
  1819. X
  1820. X if (strcmp(argv[1],"-h") == 0)
  1821. X   {
  1822. X    display_info();
  1823. X    exit(1);
  1824. X   }
  1825. X for(i=1;i<argc;i++)
  1826. X    {
  1827. X     if ((fp = fopen(argv[i],"r")) == NULL)
  1828. X       {
  1829. X        fprintf(stderr,"\nCould not open %s\n",argv[i]);
  1830. X        continue;
  1831. X       }
  1832. X     while(1)
  1833. X       {
  1834. X        if (fgets(s, (int)sizeof(s), fp) == NULL)
  1835. X          {
  1836. X       if (ferror(fp) != 0)
  1837. X             {
  1838. X              fprintf(stderr, "*** Error reading %s.  Exiting.\n",argv[i]);
  1839. X              exit(1);
  1840. X             }
  1841. X       break;
  1842. X          }
  1843. X
  1844. X        /* check for manual entry marker at beginning of line */
  1845. X        if (strncmp(s, "/*man-start*", 12) != 0)
  1846. X            continue;
  1847. X
  1848. X        /* inner loop */
  1849. X        for (;;)
  1850. X           {
  1851. X            /* read next line of manual entry */
  1852. X        if (fgets(s, (int)sizeof(s), fp) == NULL)
  1853. X              {
  1854. X           if (ferror(fp) != 0)
  1855. X         {
  1856. X          fprintf(stderr, "*** Error reading %s.  Exiting.\n",argv[i]);
  1857. X          exit(1);
  1858. X         }
  1859. X        break;
  1860. X          }
  1861. X        /* check for end of entry marker */
  1862. X        if (strncmp(s, "**man-end", 9) == 0)
  1863. X           break;
  1864. X
  1865. X        printf("     %s",s);
  1866. X            }
  1867. X    printf("\n\n\n     --------------------------------------------------------------------------\n");
  1868. X
  1869. X        /* check if end of file */
  1870. X        if (feof(fp) != 0)
  1871. X            break;
  1872. X       }
  1873. X     fclose(fp);
  1874. X    }
  1875. X printf("\n\n\n\n\n");
  1876. X return(0);
  1877. X}
  1878. X/***********************************************************************/
  1879. Xvoid display_info()
  1880. X/***********************************************************************/
  1881. X{
  1882. X/*--------------------------- local data ------------------------------*/
  1883. X/*--------------------------- processing ------------------------------*/
  1884. X
  1885. X fprintf(stderr,"\nMANEXT 1.00 Copyright (C) 1991,1992 Mark Hessling\n");
  1886. X fprintf(stderr,"All rights reserved.\n");
  1887. X fprintf(stderr,"MANEXT is distributed under the terms of the GNU\n");
  1888. X fprintf(stderr,"General Public License and comes with NO WARRANTY.\n");
  1889. X fprintf(stderr,"See the file COPYING for details.\n");
  1890. X fprintf(stderr,"\nUsage: MANEXT sourcefile [...]\n\n");
  1891. X fflush(stderr);
  1892. X return;
  1893. X}
  1894. END_OF_FILE
  1895.   if test 3983 -ne `wc -c <'tools/manext.c'`; then
  1896.     echo shar: \"'tools/manext.c'\" unpacked with wrong size!
  1897.   fi
  1898.   # end of 'tools/manext.c'
  1899. fi
  1900. echo shar: End of archive 5 \(of 11\).
  1901. cp /dev/null ark5isdone
  1902. MISSING=""
  1903. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  1904.     if test ! -f ark${I}isdone ; then
  1905.     MISSING="${MISSING} ${I}"
  1906.     fi
  1907. done
  1908. if test "${MISSING}" = "" ; then
  1909.     echo You have unpacked all 11 archives.
  1910.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1911. else
  1912.     echo You still must unpack the following archives:
  1913.     echo "        " ${MISSING}
  1914. fi
  1915. exit 0
  1916. exit 0 # Just in case...
  1917.