home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume33 / pdcurses / part05 < prev    next >
Encoding:
Text File  |  1992-11-19  |  55.0 KB  |  1,911 lines

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