home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume1 / pcurses / part06 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  57.7 KB

  1. Subject:  Terminfo/Curses Part 6 of 11
  2.  
  3. : Run this shell script with "sh" not "csh"
  4. PATH=:/bin:/usr/bin:/usr/ucb
  5. export PATH
  6. if test ! -d =src
  7. then
  8.     echo 'Making directory "=src"'
  9.     mkdir =src
  10. fi
  11. echo 'x - =src/Caps'
  12. sed 's/^X//' <<'//go.sysin dd *' >=src/Caps
  13. #*********************************************************************
  14. #                         COPYRIGHT NOTICE                           *
  15. #*********************************************************************
  16. #        This software is copyright (C) 1982 by Pavel Curtis         *
  17. #                                                                    *
  18. #        Permission is granted to reproduce and distribute           *
  19. #        this file by any means so long as no fee is charged         *
  20. #        above a nominal handling fee and so long as this            *
  21. #        notice is always included in the copies.                    *
  22. #                                                                    *
  23. #        Other rights are reserved except as explicitly granted      *
  24. #        by written permission of the author.                        *
  25. #                Pavel Curtis                                        *
  26. #                Computer Science Dept.                              *
  27. #                405 Upson Hall                                      *
  28. #                Cornell University                                  *
  29. #                Ithaca, NY 14853                                    *
  30. #                                                                    *
  31. #                Ph- (607) 256-4934                                  *
  32. #                                                                    *
  33. #                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  34. #                decvax!cornell!pavel       (UUCPnet)                *
  35. #********************************************************************/
  36.  
  37. # $Header:   RCS/Caps.v  Revision 2.1  82/10/25  14:45:23  pavel  Exp$
  38. #
  39. #       Format for the Caps file:
  40. #               variable_name    "capname"   type   Comment
  41. #
  42. #       where variable_name is the name of the variable used by a
  43. #       programmer capname is the name used inside the /etc/terminfo
  44. #       file type is one of bool, number or str and Comment is the text
  45. #       of the comment which will go in term.h.
  46. #
  47. #       All blank lines and lines beginning with '#' are ignored.
  48. #
  49. #       >>   NOTE!!!  New capabilities \must/ be placed at the end of
  50. #       >>>> the appropriate list (e.g. bools, numbers, strings).
  51. #       >>>> This allows previous versions of programs to still function
  52. #    >>   \without/ recompilation.
  53. #
  54.  
  55. auto_left_margin        "bw"     bool   cub1 wraps from column 0 to last column
  56. auto_right_margin       "am"     bool   Terminal has automatic margins
  57. beehive_glitch          "xsb"    bool   Beehive (f1=escape, f2=ctrl C)
  58. ceol_standout_glitch    "xhp"    bool   Standout not erased by overwriting (hp)
  59. eat_newline_glitch      "xenl"   bool   newline ignored after 80 cols (Concept)
  60. erase_overstrike        "eo"     bool   Can erase overstrikes with a blank
  61. generic_type            "gn"     bool   Generic line type (e.g. dialup, switch).
  62. hard_copy               "hc"     bool   Hardcopy terminal
  63. has_meta_key            "km"     bool   Has a meta key (shift, sets parity bit)
  64. has_status_line         "hs"     bool   Has extra "status line"
  65. insert_null_glitch      "in"     bool   Insert mode distinguishes nulls
  66. memory_above            "da"     bool   Display may be retained above the screen
  67. memory_below            "db"     bool   Display may be retained below the screen
  68. move_insert_mode        "mir"    bool   Safe to move while in insert mode
  69. move_standout_mode      "msgr"   bool   Safe to move in standout modes
  70. over_strike             "os"     bool   Terminal overstrikes
  71. status_line_esc_ok      "eslok"  bool   Escape can be used on the status line
  72. teleray_glitch          "xt"     bool   Tabs destructive, magic so char (Teleray 1061)
  73. tilde_glitch            "hz"     bool   Hazeltine; can't print ~'s
  74. transparent_underline   "ul"     bool   underline character overstrikes
  75. xon_xoff                "xon"    bool   Terminal uses xon/xoff handshaking
  76.  
  77. columns              "cols"   number  Number of columns in a line
  78. init_tabs         "it"     number  Tabs initially every # spaces
  79. lines                "lines"  number  Number of lines on screen or page
  80. lines_of_memory      "lm"     number  Lines of memory if > lines. 0 means varies
  81. magic_cookie_glitch  "xmc"    number  Number of blank chars left by smso or rmso
  82. padding_baud_rate    "pb"     number  Lowest baud rate where cr/nl padding needed
  83. virtual_terminal     "vt"     number  Virtual terminal number (CB/Unix)
  84. width_status_line    "wsl"    number  No. columns in status line
  85. num_labels           "nlab"   number  No. of labels on screen (start at 1)
  86. label_height         "lh"     number  No. rows in each label
  87. label_width          "lw"     number  No. cols in each label
  88.  
  89. back_tab                "cbt"    str    Back tab (P)
  90. bell                    "bel"    str    Audible signal (bell) (P)
  91. carriage_return         "cr"     str    Carriage return (P*)
  92. change_scroll_region    "csr"    str    change to lines #1 through #2 (vt100) (PG)
  93. clear_all_tabs          "tbc"    str    Clear all tab stops. (P)
  94. clear_screen            "clear"  str    Clear screen (P*)
  95. clr_eol                 "el"     str    Clear to end of line (P)
  96. clr_eos                 "ed"     str    Clear to end of display (P*)
  97. column_address          "hpa"    str    Set cursor column (PG)
  98. command_character       "CC"     str    Term. settable cmd char in prototype
  99. cursor_address          "cup"    str    Cursor motion to row #1 col #2 (PG)
  100. cursor_down             "cud1"   str    Down one line
  101. cursor_home             "home"   str    Home cursor (if no cup)
  102. cursor_invisible        "civis"  str    Make cursor invisible
  103. cursor_left             "cub1"   str    Move cursor left one space.
  104. cursor_mem_address      "mrcup"  str    Memory relative cursor addressing.
  105. cursor_normal           "cnorm"  str    Make cursor appear normal (undo vs/vi)
  106. cursor_right            "cuf1"   str    Non-destructive space (cursor right)
  107. cursor_to_ll            "ll"     str    Last line, first column (if no cup)
  108. cursor_up               "cuu1"   str    Upline (cursor up)
  109. cursor_visible          "cvvis"  str    Make cursor very visible
  110. delete_character        "dch1"   str    Delete character (P*)
  111. delete_line             "dl1"    str    Delete line (P*)
  112. dis_status_line         "dsl"    str    Disable status line
  113. down_half_line          "hd"     str    Half-line down (forward 1/2 linefeed)
  114. enter_alt_charset_mode  "smacs"  str    Start alternate character set (P)
  115. enter_blink_mode        "blink"  str    Turn on blinking
  116. enter_bold_mode         "bold"   str    Turn on bold (extra bright) mode
  117. enter_ca_mode           "smcup"  str    String to end programs that use cup
  118. enter_delete_mode       "smdc"   str    Delete mode (enter)
  119. enter_dim_mode          "dim"    str    Turn on half-bright mode
  120. enter_insert_mode       "smir"   str    Insert mode (enter);
  121. enter_secure_mode       "invis"  str    Turn on blank mode (chars invisible)
  122. enter_protected_mode    "prot"   str    Turn on protected mode
  123. enter_reverse_mode      "rev"    str    Turn on reverse video mode
  124. enter_standout_mode     "smso"   str    Begin stand out mode
  125. enter_underline_mode    "smul"   str    Start underscore mode
  126. erase_chars             "ech"    str    Erase #1 characters (PG)
  127. exit_alt_charset_mode   "rmacs"  str    End alternate character set (P)
  128. exit_attribute_mode     "sgr0"   str    Turn off all attributes
  129. exit_ca_mode            "rmcup"  str    String to begin programs that use cup
  130. exit_delete_mode        "rmdc"   str    End delete mode
  131. exit_insert_mode        "rmir"   str    End insert mode;
  132. exit_standout_mode      "rmso"   str    End stand out mode
  133. exit_underline_mode     "rmul"   str    End underscore mode
  134. flash_screen            "flash"  str    Visible bell (may not move cursor)
  135. form_feed               "ff"     str    Hardcopy terminal page eject (P*)
  136. from_status_line        "fsl"    str    Return from status line
  137. init_1string            "is1"    str    Terminal initialization string
  138. init_2string            "is2"    str    Terminal initialization string
  139. init_3string            "is3"    str    Terminal initialization string
  140. init_file               "if"     str    Name of file containing is
  141. insert_character        "ich1"   str    Insert character (P)
  142. insert_line             "il1"    str    Add new blank line (P*)
  143. insert_padding          "ip"     str    Insert pad after character inserted (P*)
  144. key_backspace           "kbs"    str    Sent by backspace key
  145. key_catab               "ktbc"   str    Sent by clear-all-tabs key.
  146. key_clear               "kclr"   str    Sent by clear screen or erase key.
  147. key_ctab                "kctab"  str    Sent by clear-tab key
  148. key_dc                  "kdch1"  str    Sent by delete character key.
  149. key_dl                  "kdl1"   str    Sent by delete line key.
  150. key_down                "kcud1"  str    Sent by terminal down arrow key
  151. key_eic                 "krmir"  str    Sent by rmir or smir in insert mode.
  152. key_eol                 "kel"    str    Sent by clear-to-end-of-line key.
  153. key_eos                 "ked"    str    Sent by clear-to-end-of-screen key.
  154. key_f0                  "kf0"    str    Sent by function key f0.
  155. key_f1                  "kf1"    str    Sent by function key f1.
  156. key_f10                 "kf10"   str    Sent by function key f10.
  157. key_f2                  "kf2"    str    Sent by function key f2.
  158. key_f3                  "kf3"    str    Sent by function key f3.
  159. key_f4                  "kf4"    str    Sent by function key f4.
  160. key_f5                  "kf5"    str    Sent by function key f5.
  161. key_f6                  "kf6"    str    Sent by function key f6.
  162. key_f7                  "kf7"    str    Sent by function key f7.
  163. key_f8                  "kf8"    str    Sent by function key f8.
  164. key_f9                  "kf9"    str    Sent by function key f9.
  165. key_home                "khome"  str    Sent by home key.
  166. key_ic                  "kich1"  str    Sent by ins char/enter ins mode key.
  167. key_il                  "kil1"   str    Sent by insert line.
  168. key_left                "kcub1"  str    Sent by terminal left arrow key
  169. key_ll            "kll"     str    Sent by "home down" key (lower left)
  170. key_npage               "knp"    str    Sent by next-page key
  171. key_ppage               "kpp"    str    Sent by previous-page key
  172. key_right               "kcuf1"  str    Sent by terminal right arrow key
  173. key_sf                  "kind"   str    Sent by scroll-forward/down key
  174. key_sr                  "kri"    str    Sent by scroll-backward/up key
  175. key_stab                "khts"   str    Sent by set-tab key
  176. key_up                  "kcuu1"  str    Sent by terminal up arrow key
  177. keypad_local            "rmkx"   str    Out of "keypad transmit" mode
  178. keypad_xmit             "smkx"   str    Put terminal in "keypad transmit" mode
  179. lab_f0                  "lf0"    str    Labels on function key f0 if not f0
  180. lab_f1                  "lf1"    str    Labels on function key f1 if not f1
  181. lab_f10                 "lf10"   str    Labels on function key f10 if not f10
  182. lab_f2                  "lf2"    str    Labels on function key f2 if not f2
  183. lab_f3                  "lf3"    str    Labels on function key f3 if not f3
  184. lab_f4                  "lf4"    str    Labels on function key f4 if not f4
  185. lab_f5                  "lf5"    str    Labels on function key f5 if not f5
  186. lab_f6                  "lf6"    str    Labels on function key f6 if not f6
  187. lab_f7                  "lf7"    str    Labels on function key f7 if not f7
  188. lab_f8                  "lf8"    str    Labels on function key f8 if not f8
  189. lab_f9                  "lf9"    str    Labels on function key f9 if not f9
  190. meta_off                "rmm"    str    Turn off "meta mode"
  191. meta_on                 "smm"    str    Turn on "meta mode" (8th bit)
  192. newline                 "nel"    str    Newline (behaves like cr followed by lf)
  193. pad_char                "pad"    str    Pad character (rather than null)
  194. parm_dch                "dch"    str    Delete #1 chars (PG*)
  195. parm_delete_line        "dl"     str    Delete #1 lines (PG*)
  196. parm_down_cursor        "cud"    str    Move cursor down #1 lines. (PG*)
  197. parm_ich                "ich"    str    Insert #1 blank chars (PG*)
  198. parm_index        "indn"     str    Scroll forward #1 lines (PG)
  199. parm_insert_line        "il"     str    Add #1 new blank lines (PG*)
  200. parm_left_cursor        "cub"    str    Move cursor left #1 spaces (PG)
  201. parm_right_cursor       "cuf"    str    Move cursor right #1 spaces. (PG*)
  202. parm_rindex        "rin"     str    Scroll backward #1 lines (PG)
  203. parm_up_cursor          "cuu"    str    Move cursor up #1 lines. (PG*)
  204. pkey_key                "pfkey"  str    Prog funct key #1 to type string #2
  205. pkey_local              "pfloc"  str    Prog funct key #1 to execute string #2
  206. pkey_xmit               "pfx"    str    Prog funct key #1 to xmit string #2
  207. print_screen            "mc0"    str    Print contents of the screen
  208. prtr_off                "mc4"    str    Turn off the printer
  209. prtr_on                 "mc5"    str    Turn on the printer
  210. repeat_char             "rep"    str    Repeat char #1 #2 times.  (PG*)
  211. reset_1string           "rs1"    str    Reset terminal completely to sane modes.
  212. reset_2string           "rs2"    str    Reset terminal completely to sane modes.
  213. reset_3string           "rs3"    str    Reset terminal completely to sane modes.
  214. reset_file              "rf"     str    Name of file containing reset string.
  215. restore_cursor          "rc"     str    Restore cursor to position of last sc.
  216. row_address             "vpa"    str    Like hpa but sets row. (PG)
  217. save_cursor             "sc"     str    Save cursor position. (P)
  218. scroll_forward          "ind"    str    Scroll text up (P)
  219. scroll_reverse          "ri"     str    Scroll text down (P)
  220. set_attributes          "sgr"    str    Define the video attributes (PG9)
  221. set_tab                 "hts"    str    Set a tab in all rows, current column.
  222. set_window              "wind"   str    Current window is lines #1-#2 cols #3-#4
  223. tab                     "ht"     str    Tab to next 8 space hardware tab stop.
  224. to_status_line          "tsl"    str    Go to status line
  225. underline_char          "uc"     str    Underscore one char and move past it
  226. up_half_line            "hu"     str    Half-line up (reverse 1/2 linefeed)
  227. init_prog               "iprog"  str    Path name of program for init
  228. key_a1                  "ka1"    str    Upper left of keypad
  229. key_a3                  "ka3"    str    Upper right of keypad
  230. key_b2                  "kb2"    str    Center of keypad
  231. key_c1                  "kc1"    str    Lower left of keypad
  232. key_c3                  "kc3"    str    Lower right of keypad
  233. prtr_non                "mc5p"   str    Turn on the printer for #1 bytes.
  234. char_padding            "rmp"    str    Like ip but when in replace mode
  235. acs_chars               "acsc"   str    Graphics char set pairs aAbBcC - defn=vt100
  236. plab_norm               "pln"    str    Prog label #1 to show string #2
  237. //go.sysin dd *
  238. echo 'x - =src/dump.c'
  239. sed 's/^X//' <<'//go.sysin dd *' >=src/dump.c
  240. X/*********************************************************************
  241. *                         COPYRIGHT NOTICE                           *
  242. **********************************************************************
  243. *        This software is copyright (C) 1982 by Pavel Curtis         *
  244. *                                                                    *
  245. *        Permission is granted to reproduce and distribute           *
  246. *        this file by any means so long as no fee is charged         *
  247. *        above a nominal handling fee and so long as this            *
  248. *        notice is always included in the copies.                    *
  249. *                                                                    *
  250. *        Other rights are reserved except as explicitly granted      *
  251. *        by written permission of the author.                        *
  252. *                Pavel Curtis                                        *
  253. *                Computer Science Dept.                              *
  254. *                405 Upson Hall                                      *
  255. *                Cornell University                                  *
  256. *                Ithaca, NY 14853                                    *
  257. *                                                                    *
  258. *                Ph- (607) 256-4934                                  *
  259. *                                                                    *
  260. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  261. *                decvax!cornell!pavel       (UUCPnet)                *
  262. *********************************************************************/
  263.  
  264. X/*
  265.  *    dump.c - dump the contents of a compiled terminfo file in a
  266.  *         human-readable format.
  267.  *
  268.  *  $Log:    RCS/dump.v $
  269.  * Revision 2.1  82/10/25  14:46:20  pavel
  270.  * Added Copyright Notice
  271.  * 
  272.  * Revision 2.0  82/10/24  15:17:29  pavel
  273.  * Beta-one Test Release
  274.  * 
  275.  * Revision 1.3  82/08/23  22:30:18  pavel
  276.  * The REAL Alpha-one Release Version
  277.  * 
  278.  * Revision 1.2  82/08/19  19:12:50  pavel
  279.  * Alpha Test Release One
  280.  * 
  281.  * Revision 1.1  82/08/12  18:39:19  pavel
  282.  * Initial revision
  283.  * 
  284.  *
  285.  */
  286.  
  287. static char RCSid[] =
  288.     "$Header:   RCS/dump.v  Revision 2.1  82/10/25  14:46:20  pavel  Exp$";
  289.  
  290. #include "compiler.h"
  291. #include "term.h"
  292.  
  293. char    *BoolNames[], *NumNames[], *StrNames[];
  294.  
  295.  
  296. main(argc, argv)
  297. int    argc;
  298. char    *argv[];
  299. {
  300.     int    i, j;
  301.     int    cur_column;
  302.     char    buffer[1024];
  303.  
  304.     for (j=1; j < argc; j++)
  305.     {
  306.         if (read_entry(argv[j], &_first_term) < 0)
  307.         {
  308.         fprintf(stderr, "read_entry bombed on %s\n", argv[j]);
  309.         abort();
  310.         }
  311.  
  312.         printf("%s,\n", _first_term.term_names);
  313.         putchar('\t');
  314.         cur_column = 9;
  315.  
  316.         for (i=0; i < BOOLCOUNT; i++)
  317.         {
  318.         if (_first_term.Booleans[i] == TRUE)
  319.         {
  320.             if (cur_column > 9
  321.                 &&  cur_column + strlen(BoolNames[i]) + 2 > 79)
  322.             {
  323.             printf("\n\t");
  324.             cur_column = 9;
  325.             }
  326.             printf("%s, ", BoolNames[i]);
  327.             cur_column += strlen(BoolNames[i]) + 2;
  328.         }
  329.         }
  330.  
  331.         for (i=0; i < NUMCOUNT; i++)
  332.         {
  333.         if (_first_term.Numbers[i] != -1)
  334.         {
  335.             if (cur_column > 9
  336.                 &&  cur_column + strlen(NumNames[i]) + 5 > 79)
  337.             {
  338.             printf("\n\t");
  339.             cur_column = 9;
  340.             }
  341.             printf("%s#%d, ", NumNames[i], _first_term.Numbers[i]);
  342.             cur_column += strlen(NumNames[i]) + 5;
  343.         }
  344.         }
  345.  
  346.         for (i=0; i < STRCOUNT; i++)
  347.         {
  348.         if (_first_term.Strings[i])
  349.         {
  350.             sprintf(buffer, "%s=%s, ", StrNames[i],
  351.                             _first_term.Strings[i]);
  352.             expand(buffer);
  353.             if (cur_column > 9  &&  cur_column + strlen(buffer) > 79)
  354.             {
  355.             printf("\n\t");
  356.             cur_column = 9;
  357.             }
  358.             printf("%s", buffer);
  359.             cur_column += strlen(buffer);
  360.         }
  361.         }
  362.  
  363.         putchar('\n');
  364.     }
  365. }
  366.  
  367.  
  368. typedef unsigned char    uchar;
  369.  
  370. expand(str)
  371. uchar    *str;
  372. {
  373.         char    buffer[1024];
  374.     int    bufp;
  375.     uchar    *ptr;
  376.  
  377.     bufp = 0;
  378.     ptr = str;
  379.     while (*str)
  380.     {
  381.         if (*str < ' ')
  382.         {
  383.         buffer[bufp++] = '^';
  384.         buffer[bufp++] = *str + '@';
  385.         }
  386.         else if (*str < '\177')
  387.         buffer[bufp++] = *str;
  388.         else
  389.         {
  390.         sprintf(&buffer[bufp], "\\%03o", *str);
  391.         bufp += 4;
  392.         }
  393.  
  394.         str++;
  395.     }
  396.  
  397.     buffer[bufp] = '\0';
  398.     strcpy(ptr, buffer);
  399. }
  400. //go.sysin dd *
  401. echo 'x - =src/lib_addch.c'
  402. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_addch.c
  403. X/*********************************************************************
  404. *                         COPYRIGHT NOTICE                           *
  405. **********************************************************************
  406. *        This software is copyright (C) 1982 by Pavel Curtis         *
  407. *                                                                    *
  408. *        Permission is granted to reproduce and distribute           *
  409. *        this file by any means so long as no fee is charged         *
  410. *        above a nominal handling fee and so long as this            *
  411. *        notice is always included in the copies.                    *
  412. *                                                                    *
  413. *        Other rights are reserved except as explicitly granted      *
  414. *        by written permission of the author.                        *
  415. *                Pavel Curtis                                        *
  416. *                Computer Science Dept.                              *
  417. *                405 Upson Hall                                      *
  418. *                Cornell University                                  *
  419. *                Ithaca, NY 14853                                    *
  420. *                                                                    *
  421. *                Ph- (607) 256-4934                                  *
  422. *                                                                    *
  423. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  424. *                decvax!cornell!pavel       (UUCPnet)                *
  425. *********************************************************************/
  426.  
  427. X/*
  428. **    lib_addch.c
  429. **
  430. **    The routine waddch().
  431. **
  432. ** $Log:    RCS/lib_addch.v $
  433.  * Revision 2.1  82/10/25  14:46:23  pavel
  434.  * Added Copyright Notice
  435.  * 
  436.  * Revision 2.0  82/10/24  15:19:46  pavel
  437.  * Beta-one Test Release
  438.  * 
  439. **
  440. */
  441.  
  442. static char RCSid[] =
  443.     "$Header:   RCS/lib_addch.v  Revision 2.1  82/10/25  14:46:23  pavel  Exp$";
  444.  
  445. #include "curses.h"
  446. #include "curses.priv.h"
  447. #include "unctrl.h"
  448.  
  449.  
  450. waddch(win, c)
  451. WINDOW    *win;
  452. char    c;
  453. {
  454.     int    x, y;
  455.     int    newx;
  456.     chtype    ch = c;
  457.  
  458. #ifdef UNDEFINED
  459.     if (_tracing)
  460.         _tracef("waddch(%o,%c) called", win, ch);
  461. #endif
  462.  
  463.     x = win->_curx;
  464.     y = win->_cury;
  465.  
  466.     if (y > win->_maxy  ||  x > win->_maxx  ||  y < 0  ||  x < 0)
  467.         return(ERR);
  468.  
  469.     switch (ch)
  470.     {
  471.         case '\t':
  472.         for (newx = x + (8 - (x & 07)); x < newx; x++)
  473.             if (waddch(win, ' ') == ERR)
  474.             return(ERR);
  475.         return(OK);
  476.  
  477.         case '\n':
  478.         wclrtoeol(win);
  479.         if (SP->_nl)
  480.             x = 0;
  481.         goto newline;
  482.  
  483.         case '\r':
  484.         x = 0;
  485.         break;
  486.  
  487.         case '\b':
  488.         if (--x < 0)
  489.             x = 0;
  490.         break;
  491.  
  492.         default:
  493.         if (ch < ' ')
  494.             return(waddstr(win, unctrl(ch)));
  495.  
  496.         ch |= win->_attrs;
  497.  
  498.         if (win->_line[y][x] != ch)
  499.         {
  500.             if (win->_firstchar[y] == _NOCHANGE)
  501.             win->_firstchar[y] = win->_lastchar[y] = x;
  502.             else if (x < win->_firstchar[y])
  503.             win->_firstchar[y] = x;
  504.             else if (x > win->_lastchar[y])
  505.             win->_lastchar[y] = x;
  506.  
  507.             win->_numchngd[y]++;
  508.         }
  509.  
  510.         win->_line[y][x++] = ch;
  511.         if (x > win->_maxx)
  512.         {
  513.             x = 0;
  514. newline:
  515.             y++;
  516.             if (y > win->_regbottom)
  517.             {
  518.             y--;
  519.             if (win->_scroll)
  520.                 scroll(win);
  521.             else
  522.                 return ERR;
  523.             }
  524.         }
  525.         break;
  526.     }
  527.  
  528.     win->_curx = x;
  529.     win->_cury = y;
  530.  
  531.     return(OK);
  532. }
  533. //go.sysin dd *
  534. echo 'x - =src/lib_addstr.c'
  535. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_addstr.c
  536. X/*********************************************************************
  537. *                         COPYRIGHT NOTICE                           *
  538. **********************************************************************
  539. *        This software is copyright (C) 1982 by Pavel Curtis         *
  540. *                                                                    *
  541. *        Permission is granted to reproduce and distribute           *
  542. *        this file by any means so long as no fee is charged         *
  543. *        above a nominal handling fee and so long as this            *
  544. *        notice is always included in the copies.                    *
  545. *                                                                    *
  546. *        Other rights are reserved except as explicitly granted      *
  547. *        by written permission of the author.                        *
  548. *                Pavel Curtis                                        *
  549. *                Computer Science Dept.                              *
  550. *                405 Upson Hall                                      *
  551. *                Cornell University                                  *
  552. *                Ithaca, NY 14853                                    *
  553. *                                                                    *
  554. *                Ph- (607) 256-4934                                  *
  555. *                                                                    *
  556. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  557. *                decvax!cornell!pavel       (UUCPnet)                *
  558. *********************************************************************/
  559.  
  560. X/*
  561. **    lib_addstr.c
  562. *
  563. **    The routine waddstr().
  564. **
  565. ** $Log:    RCS/lib_addstr.v $
  566.  * Revision 2.1  82/10/25  14:46:26  pavel
  567.  * Added Copyright Notice
  568.  * 
  569.  * Revision 2.0  82/10/24  15:19:59  pavel
  570.  * Beta-one Test Release
  571.  * 
  572. **
  573. */
  574.  
  575. static char RCSid[] =
  576.     "$Header:   RCS/lib_addstr.v  Revision 2.1  82/10/25  14:46:26  pavel  Exp$";
  577.  
  578. #include "curses.h"
  579. #include "curses.priv.h"
  580.  
  581.  
  582. waddstr(win, str)
  583. WINDOW    *win; 
  584. char    *str;
  585. {
  586. #ifdef TRACE
  587.     if (_tracing)
  588.         _tracef("waddstr(%o,%o) called", win, str);
  589. #endif
  590.  
  591.     while (*str)
  592.     {
  593.         if (waddch(win, *str++) == ERR)
  594.         return(ERR);
  595.     }
  596.  
  597.     return(OK);
  598. }
  599. //go.sysin dd *
  600. echo 'x - =src/lib_beep.c'
  601. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_beep.c
  602. X/*********************************************************************
  603. *                         COPYRIGHT NOTICE                           *
  604. **********************************************************************
  605. *        This software is copyright (C) 1982 by Pavel Curtis         *
  606. *                                                                    *
  607. *        Permission is granted to reproduce and distribute           *
  608. *        this file by any means so long as no fee is charged         *
  609. *        above a nominal handling fee and so long as this            *
  610. *        notice is always included in the copies.                    *
  611. *                                                                    *
  612. *        Other rights are reserved except as explicitly granted      *
  613. *        by written permission of the author.                        *
  614. *                Pavel Curtis                                        *
  615. *                Computer Science Dept.                              *
  616. *                405 Upson Hall                                      *
  617. *                Cornell University                                  *
  618. *                Ithaca, NY 14853                                    *
  619. *                                                                    *
  620. *                Ph- (607) 256-4934                                  *
  621. *                                                                    *
  622. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  623. *                decvax!cornell!pavel       (UUCPnet)                *
  624. *********************************************************************/
  625.  
  626. X/*
  627.  *    beep.c
  628.  *
  629.  *    Routines beep() and flash()
  630.  *
  631.  *  $Log:    RCS/lib_beep.v $
  632.  * Revision 2.1  82/10/25  14:46:29  pavel
  633.  * Added Copyright Notice
  634.  * 
  635.  * Revision 2.0  82/10/24  15:17:31  pavel
  636.  * Beta-one Test Release
  637.  * 
  638.  * Revision 1.3  82/08/23  22:30:22  pavel
  639.  * The REAL Alpha-one Release Version
  640.  * 
  641.  * Revision 1.2  82/08/19  19:11:02  pavel
  642.  * Alpha Test Release One
  643.  * 
  644.  * Revision 1.1  82/08/12  18:40:14  pavel
  645.  * Initial revision
  646.  * 
  647.  *
  648.  */
  649.  
  650. static char RCSid[] =
  651.     "$Header:   RCS/lib_beep.v  Revision 2.1  82/10/25  14:46:29  pavel  Exp$";
  652.  
  653. #include "curses.h"
  654. #include "curses.priv.h"
  655. #include "term.h"
  656.  
  657. static
  658. outc(ch)
  659. char    ch;
  660. {
  661.         putc(ch, SP->_ofp);
  662. }
  663.  
  664.  
  665.  
  666. X/*
  667.  *    beep()
  668.  *
  669.  *    Sound the current terminal's audible bell if it has one.   If not,
  670.  *    flash the screen if possible.
  671.  *
  672.  */
  673.  
  674. beep()
  675. {
  676. #ifdef TRACE
  677.     if (_tracing)
  678.         _tracef("beep() called");
  679. #endif
  680.     if (bell)
  681.         tputs(bell, 1, outc);
  682.     else if (flash_screen)
  683.         tputs(flash_screen, 1, outc);
  684. }
  685.  
  686.  
  687.  
  688. X/*
  689.  *    flash()
  690.  *
  691.  *    Flash the current terminal's screen if possible.   If not,
  692.  *    sound the audible bell if one exists.
  693.  *
  694.  */
  695.  
  696. flash()
  697. {
  698. #ifdef TRACE
  699.     if (_tracing)
  700.         _tracef("flash() called");
  701. #endif
  702.     if (flash_screen)
  703.         tputs(flash_screen, 1, outc);
  704.     else if (bell)
  705.         tputs(bell, 1, outc);
  706. }
  707. //go.sysin dd *
  708. echo 'x - =src/lib_box.c'
  709. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_box.c
  710. X/*********************************************************************
  711. *                         COPYRIGHT NOTICE                           *
  712. **********************************************************************
  713. *        This software is copyright (C) 1982 by Pavel Curtis         *
  714. *                                                                    *
  715. *        Permission is granted to reproduce and distribute           *
  716. *        this file by any means so long as no fee is charged         *
  717. *        above a nominal handling fee and so long as this            *
  718. *        notice is always included in the copies.                    *
  719. *                                                                    *
  720. *        Other rights are reserved except as explicitly granted      *
  721. *        by written permission of the author.                        *
  722. *                Pavel Curtis                                        *
  723. *                Computer Science Dept.                              *
  724. *                405 Upson Hall                                      *
  725. *                Cornell University                                  *
  726. *                Ithaca, NY 14853                                    *
  727. *                                                                    *
  728. *                Ph- (607) 256-4934                                  *
  729. *                                                                    *
  730. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  731. *                decvax!cornell!pavel       (UUCPnet)                *
  732. *********************************************************************/
  733.  
  734. X/*
  735. **    lib_box.c
  736. **
  737. **    The routine box().
  738. **
  739. ** $Log:    RCS/lib_box.v $
  740.  * Revision 2.1  82/10/25  14:46:31  pavel
  741.  * Added Copyright Notice
  742.  * 
  743.  * Revision 2.0  82/10/24  15:20:07  pavel
  744.  * Beta-one Test Release
  745.  * 
  746. **
  747. */
  748.  
  749. static char RCSid[] =
  750.     "$Header:   RCS/lib_box.v  Revision 2.1  82/10/25  14:46:31  pavel  Exp$";
  751.  
  752. #include "curses.h"
  753. #include "curses.priv.h"
  754.  
  755.  
  756.  
  757. box(win, vert, hor)
  758. WINDOW    *win;
  759. char    vert, hor;
  760. {
  761.     int    i;
  762.     int    endy, endx;
  763.     chtype    *fp, *lp;
  764.  
  765. #ifdef TRACE
  766.     if (_tracing)
  767.         _tracef("box(%o,%c,%c) called", win, vert, hor);
  768. #endif
  769.  
  770.     endx = win->_maxx;
  771.     endy = win->_maxy;
  772.  
  773.     fp = win->_line[0];
  774.     lp = win->_line[endy];
  775.  
  776.     for (i = 0; i <= endx; i++)
  777.         fp[i] = lp[i] = hor;
  778.  
  779.     for (i = 0; i <= endy; i++)
  780.     {
  781.         win->_line[i][0] = (win->_line[i][endx] = vert);
  782.         win->_firstchar[i] = 0;
  783.         win->_lastchar[i] = endx;
  784.         win->_numchngd[i] += 2;
  785.     }
  786.  
  787.     win->_numchngd[0] = win->_numchngd[endy] = endx;
  788.  
  789.     if (! win->_scroll  &&  (win->_flags & _SCROLLWIN))
  790.         fp[0] = fp[endx] = lp[0] = lp[endx] = ' ';
  791. }
  792. //go.sysin dd *
  793. echo 'x - =src/lib_clear.c'
  794. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_clear.c
  795. X/*********************************************************************
  796. *                         COPYRIGHT NOTICE                           *
  797. **********************************************************************
  798. *        This software is copyright (C) 1982 by Pavel Curtis         *
  799. *                                                                    *
  800. *        Permission is granted to reproduce and distribute           *
  801. *        this file by any means so long as no fee is charged         *
  802. *        above a nominal handling fee and so long as this            *
  803. *        notice is always included in the copies.                    *
  804. *                                                                    *
  805. *        Other rights are reserved except as explicitly granted      *
  806. *        by written permission of the author.                        *
  807. *                Pavel Curtis                                        *
  808. *                Computer Science Dept.                              *
  809. *                405 Upson Hall                                      *
  810. *                Cornell University                                  *
  811. *                Ithaca, NY 14853                                    *
  812. *                                                                    *
  813. *                Ph- (607) 256-4934                                  *
  814. *                                                                    *
  815. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  816. *                decvax!cornell!pavel       (UUCPnet)                *
  817. *********************************************************************/
  818.  
  819. X/*
  820. **    lib_clear.c
  821. **
  822. **    The routine wclear().
  823. **
  824. ** $Log:    RCS/lib_clear.v $
  825.  * Revision 2.1  82/10/25  14:46:34  pavel
  826.  * Added Copyright Notice
  827.  * 
  828.  * Revision 2.0  82/10/24  15:20:17  pavel
  829.  * Beta-one Test Release
  830.  * 
  831. **
  832. */
  833.  
  834. static char RCSid[] =
  835.     "$Header:   RCS/lib_clear.v  Revision 2.1  82/10/25  14:46:34  pavel  Exp$";
  836.  
  837. #include "curses.h"
  838. #include "curses.priv.h"
  839.  
  840.  
  841.  
  842. wclear(win)
  843. WINDOW    *win;
  844. {
  845. #ifdef TRACE
  846.     if (_tracing)
  847.         _tracef("wclear(%o) called", win);
  848. #endif
  849.  
  850.     werase(win);
  851.  
  852.     win->_clear = TRUE;
  853.  
  854.     return;
  855. }
  856. //go.sysin dd *
  857. echo 'x - =src/lib_clrbot.c'
  858. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_clrbot.c
  859. X/*********************************************************************
  860. *                         COPYRIGHT NOTICE                           *
  861. **********************************************************************
  862. *        This software is copyright (C) 1982 by Pavel Curtis         *
  863. *                                                                    *
  864. *        Permission is granted to reproduce and distribute           *
  865. *        this file by any means so long as no fee is charged         *
  866. *        above a nominal handling fee and so long as this            *
  867. *        notice is always included in the copies.                    *
  868. *                                                                    *
  869. *        Other rights are reserved except as explicitly granted      *
  870. *        by written permission of the author.                        *
  871. *                Pavel Curtis                                        *
  872. *                Computer Science Dept.                              *
  873. *                405 Upson Hall                                      *
  874. *                Cornell University                                  *
  875. *                Ithaca, NY 14853                                    *
  876. *                                                                    *
  877. *                Ph- (607) 256-4934                                  *
  878. *                                                                    *
  879. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  880. *                decvax!cornell!pavel       (UUCPnet)                *
  881. *********************************************************************/
  882.  
  883. X/*
  884. **    lib_clrbot.c
  885. **
  886. **    The routine wclrtobot().
  887. **
  888. ** $Log:    RCS/lib_clrbot.v $
  889.  * Revision 2.1  82/10/25  14:46:37  pavel
  890.  * Added Copyright Notice
  891.  * 
  892.  * Revision 2.0  82/10/24  15:20:24  pavel
  893.  * Beta-one Test Release
  894.  * 
  895. **
  896. */
  897.  
  898. static char RCSid[] =
  899.     "$Header:   RCS/lib_clrbot.v  Revision 2.1  82/10/25  14:46:37  pavel  Exp$";
  900.  
  901. #include "curses.h"
  902. #include "curses.priv.h"
  903.  
  904.  
  905. wclrtobot(win)
  906. WINDOW    *win;
  907. {
  908.     chtype    *ptr, *end, *maxx;
  909.     int    y, startx, minx;
  910.     chtype    blank = ' ' | win->_attrs;
  911.  
  912. #ifdef TRACE
  913.     if (_tracing)
  914.         _tracef("wclrtobot(%o) called", win);
  915. #endif
  916.  
  917.     startx = win->_curx;
  918.  
  919.     for (y = win->_cury; y <= win->_regbottom; y++)
  920.     {
  921.         minx = _NOCHANGE;
  922.         end = &win->_line[y][win->_maxx];
  923.  
  924.         for (ptr = &win->_line[y][startx]; ptr <= end; ptr++)
  925.         {
  926.         if (*ptr != blank)
  927.         {
  928.             maxx = ptr;
  929.             if (minx == _NOCHANGE)
  930.             minx = ptr - win->_line[y];
  931.             *ptr = blank;
  932.         }
  933.         }
  934.  
  935.         if (minx != _NOCHANGE)
  936.         {
  937.         if (win->_firstchar[y] > minx
  938.                     ||  win->_firstchar[y] == _NOCHANGE)
  939.             win->_firstchar[y] = minx;
  940.  
  941.         if (win->_lastchar[y] < maxx - win->_line[y])
  942.             win->_lastchar[y] = maxx - win->_line[y];
  943.         }
  944.  
  945.         startx = 0;
  946.     }
  947. }
  948. //go.sysin dd *
  949. echo 'x - =src/lib_clreol.c'
  950. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_clreol.c
  951. X/*********************************************************************
  952. *                         COPYRIGHT NOTICE                           *
  953. **********************************************************************
  954. *        This software is copyright (C) 1982 by Pavel Curtis         *
  955. *                                                                    *
  956. *        Permission is granted to reproduce and distribute           *
  957. *        this file by any means so long as no fee is charged         *
  958. *        above a nominal handling fee and so long as this            *
  959. *        notice is always included in the copies.                    *
  960. *                                                                    *
  961. *        Other rights are reserved except as explicitly granted      *
  962. *        by written permission of the author.                        *
  963. *                Pavel Curtis                                        *
  964. *                Computer Science Dept.                              *
  965. *                405 Upson Hall                                      *
  966. *                Cornell University                                  *
  967. *                Ithaca, NY 14853                                    *
  968. *                                                                    *
  969. *                Ph- (607) 256-4934                                  *
  970. *                                                                    *
  971. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  972. *                decvax!cornell!pavel       (UUCPnet)                *
  973. *********************************************************************/
  974.  
  975. X/*
  976. **    lib_clreol.c
  977. **
  978. **    The routine wclrtoeol().
  979. **
  980. ** $Log:    RCS/lib_clreol.v $
  981.  * Revision 2.1  82/10/25  14:46:42  pavel
  982.  * Added Copyright Notice
  983.  * 
  984.  * Revision 2.0  82/10/24  15:20:38  pavel
  985.  * Beta-one Test Release
  986.  * 
  987. **
  988. */
  989.  
  990. static char RCSid[] =
  991.     "$Header:   RCS/lib_clreol.v  Revision 2.1  82/10/25  14:46:42  pavel  Exp$";
  992.  
  993. #include "curses.h"
  994. #include "curses.priv.h"
  995.  
  996.  
  997. wclrtoeol(win)
  998. WINDOW    *win;
  999. {
  1000.     chtype    *maxx, *ptr, *end;
  1001.     int    y, x, minx;
  1002.     chtype    blank = ' ' | win->_attrs;
  1003.  
  1004. #ifdef TRACE
  1005.     if (_tracing)
  1006.         _tracef("wclrtoeol(%o) called", win);
  1007. #endif
  1008.  
  1009.     y = win->_cury;
  1010.     x = win->_curx;
  1011.  
  1012.     end = &win->_line[y][win->_maxx];
  1013.     minx = _NOCHANGE;
  1014.     maxx = &win->_line[y][x];
  1015.  
  1016.     for (ptr = maxx; ptr < end; ptr++)
  1017.     {
  1018.         if (*ptr != blank)
  1019.         {
  1020.         maxx = ptr;
  1021.         if (minx == _NOCHANGE)
  1022.             minx = ptr - win->_line[y];
  1023.         *ptr = blank;
  1024.         win->_numchngd[y] += 1;
  1025.         }
  1026.     }
  1027.  
  1028.     if (minx != _NOCHANGE)
  1029.     {
  1030.         if (win->_firstchar[y] > minx || win->_firstchar[y] == _NOCHANGE)
  1031.         win->_firstchar[y] = minx;
  1032.  
  1033.         if (win->_lastchar[y] < maxx - win->_line[y])
  1034.         win->_lastchar[y] = maxx - win->_line[y];
  1035.     }
  1036. }
  1037. //go.sysin dd *
  1038. echo 'x - =src/lib_data.c'
  1039. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_data.c
  1040. X/*********************************************************************
  1041. *                         COPYRIGHT NOTICE                           *
  1042. **********************************************************************
  1043. *        This software is copyright (C) 1982 by Pavel Curtis         *
  1044. *                                                                    *
  1045. *        Permission is granted to reproduce and distribute           *
  1046. *        this file by any means so long as no fee is charged         *
  1047. *        above a nominal handling fee and so long as this            *
  1048. *        notice is always included in the copies.                    *
  1049. *                                                                    *
  1050. *        Other rights are reserved except as explicitly granted      *
  1051. *        by written permission of the author.                        *
  1052. *                Pavel Curtis                                        *
  1053. *                Computer Science Dept.                              *
  1054. *                405 Upson Hall                                      *
  1055. *                Cornell University                                  *
  1056. *                Ithaca, NY 14853                                    *
  1057. *                                                                    *
  1058. *                Ph- (607) 256-4934                                  *
  1059. *                                                                    *
  1060. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  1061. *                decvax!cornell!pavel       (UUCPnet)                *
  1062. *********************************************************************/
  1063.  
  1064. X/*
  1065.  *    lib_data.c - Global data definitions and initialisations
  1066.  *
  1067.  */
  1068.  
  1069.  
  1070. #include "curses.priv.h"
  1071. #include "curses.h"
  1072. #include "term.h"
  1073.  
  1074.  
  1075. char    ttytype[NAMESIZE];
  1076.  
  1077. #ifdef TRACE
  1078.     int    _tracing = 1;
  1079. #else
  1080.     int    _tracing = 0;
  1081. #endif
  1082.  
  1083.  
  1084. struct screen *SP = 0;
  1085. //go.sysin dd *
  1086. echo 'x - =src/lib_delch.c'
  1087. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_delch.c
  1088. X/*********************************************************************
  1089. *                         COPYRIGHT NOTICE                           *
  1090. **********************************************************************
  1091. *        This software is copyright (C) 1982 by Pavel Curtis         *
  1092. *                                                                    *
  1093. *        Permission is granted to reproduce and distribute           *
  1094. *        this file by any means so long as no fee is charged         *
  1095. *        above a nominal handling fee and so long as this            *
  1096. *        notice is always included in the copies.                    *
  1097. *                                                                    *
  1098. *        Other rights are reserved except as explicitly granted      *
  1099. *        by written permission of the author.                        *
  1100. *                Pavel Curtis                                        *
  1101. *                Computer Science Dept.                              *
  1102. *                405 Upson Hall                                      *
  1103. *                Cornell University                                  *
  1104. *                Ithaca, NY 14853                                    *
  1105. *                                                                    *
  1106. *                Ph- (607) 256-4934                                  *
  1107. *                                                                    *
  1108. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  1109. *                decvax!cornell!pavel       (UUCPnet)                *
  1110. *********************************************************************/
  1111.  
  1112. X/*
  1113. **    lib_delch.c
  1114. **
  1115. **    The routine wdelch().
  1116. **
  1117. ** $Log:    RCS/lib_delch.v $
  1118.  * Revision 2.1  82/10/25  14:46:52  pavel
  1119.  * Added Copyright Notice
  1120.  * 
  1121.  * Revision 2.0  82/10/24  15:20:47  pavel
  1122.  * Beta-one Test Release
  1123.  * 
  1124. **
  1125. */
  1126.  
  1127. static char RCSid[] =
  1128.     "$Header:   RCS/lib_delch.v  Revision 2.1  82/10/25  14:46:52  pavel  Exp$";
  1129.  
  1130. #include "curses.h"
  1131. #include "curses.priv.h"
  1132. #include "term.h"
  1133.  
  1134. wdelch(win)
  1135. WINDOW    *win;
  1136. {
  1137.     chtype    *temp1, *temp2;
  1138.     chtype    *end;
  1139.  
  1140. #ifdef TRACE
  1141.     if (_tracing)
  1142.         _tracef("wdelch(%o) called", win);
  1143. #endif
  1144.  
  1145.     end = &win->_line[win->_cury][win->_maxx];
  1146.     temp2 = &win->_line[win->_cury][win->_curx + 1];
  1147.     temp1 = temp2 - 1;
  1148.  
  1149.     while (temp1 < end)
  1150.         *temp1++ = *temp2++;
  1151.  
  1152.     *temp1 = ' ' | win->_attrs;
  1153.  
  1154.     win->_lastchar[win->_cury] = win->_maxx;
  1155.  
  1156.     if (win->_firstchar[win->_cury] == _NOCHANGE
  1157.                    || win->_firstchar[win->_cury] > win->_curx)
  1158.         win->_firstchar[win->_cury] = win->_curx;
  1159.  
  1160.     if (delete_character)
  1161.         win->_numchngd += 1;
  1162.     else
  1163.         win->_numchngd += win->_maxx - win->_curx + 1;
  1164. }
  1165. //go.sysin dd *
  1166. echo 'x - =src/lib_deleteln.c'
  1167. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_deleteln.c
  1168. X/*********************************************************************
  1169. *                         COPYRIGHT NOTICE                           *
  1170. **********************************************************************
  1171. *        This software is copyright (C) 1982 by Pavel Curtis         *
  1172. *                                                                    *
  1173. *        Permission is granted to reproduce and distribute           *
  1174. *        this file by any means so long as no fee is charged         *
  1175. *        above a nominal handling fee and so long as this            *
  1176. *        notice is always included in the copies.                    *
  1177. *                                                                    *
  1178. *        Other rights are reserved except as explicitly granted      *
  1179. *        by written permission of the author.                        *
  1180. *                Pavel Curtis                                        *
  1181. *                Computer Science Dept.                              *
  1182. *                405 Upson Hall                                      *
  1183. *                Cornell University                                  *
  1184. *                Ithaca, NY 14853                                    *
  1185. *                                                                    *
  1186. *                Ph- (607) 256-4934                                  *
  1187. *                                                                    *
  1188. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  1189. *                decvax!cornell!pavel       (UUCPnet)                *
  1190. *********************************************************************/
  1191.  
  1192. X/*
  1193. **    lib_deleteln.c
  1194. **
  1195. **    The routine wdeleteln().
  1196. **
  1197. ** $Log:    RCS/lib_deleteln.v $
  1198.  * Revision 2.1  82/10/25  14:46:55  pavel
  1199.  * Added Copyright Notice
  1200.  * 
  1201.  * Revision 2.0  82/10/25  13:44:03  pavel
  1202.  * Beta-one Test Release
  1203.  * 
  1204. **
  1205. */
  1206.  
  1207. static char RCSid[] =
  1208.     "$Header:   RCS/lib_deleteln.v  Revision 2.1  82/10/25  14:46:55  pavel  Exp$";
  1209.  
  1210. #include "curses.h"
  1211. #include "curses.priv.h"
  1212.  
  1213.  
  1214. wdeleteln(win)
  1215. WINDOW    *win;
  1216. {
  1217.     chtype    *end, *temp;
  1218.     int    y;
  1219.  
  1220. #ifdef TRACE
  1221.     if (_tracing)
  1222.         _tracef("wdeleteln(%o) called", win);
  1223. #endif
  1224.  
  1225.     temp = win->_line[win->_cury];
  1226.  
  1227.     for (y = win->_cury; y < win->_regbottom; y++)
  1228.     {
  1229.         win->_line[y] = win->_line[y+1];
  1230.  
  1231.         win->_firstchar[y] = 0;
  1232.         win->_lastchar[y] = win->_maxx;
  1233.         win->_numchngd[y] = win->_maxx;
  1234.     }
  1235.  
  1236.     win->_line[win->_regbottom] = temp;
  1237.  
  1238.     for (end = &(temp[win->_maxx]); temp <= end; )
  1239.         *temp++ = ' ' | win->_attrs;
  1240. }
  1241. //go.sysin dd *
  1242. echo 'x - =src/lib_delwin.c'
  1243. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_delwin.c
  1244. X/*********************************************************************
  1245. *                         COPYRIGHT NOTICE                           *
  1246. **********************************************************************
  1247. *        This software is copyright (C) 1982 by Pavel Curtis         *
  1248. *                                                                    *
  1249. *        Permission is granted to reproduce and distribute           *
  1250. *        this file by any means so long as no fee is charged         *
  1251. *        above a nominal handling fee and so long as this            *
  1252. *        notice is always included in the copies.                    *
  1253. *                                                                    *
  1254. *        Other rights are reserved except as explicitly granted      *
  1255. *        by written permission of the author.                        *
  1256. *                Pavel Curtis                                        *
  1257. *                Computer Science Dept.                              *
  1258. *                405 Upson Hall                                      *
  1259. *                Cornell University                                  *
  1260. *                Ithaca, NY 14853                                    *
  1261. *                                                                    *
  1262. *                Ph- (607) 256-4934                                  *
  1263. *                                                                    *
  1264. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  1265. *                decvax!cornell!pavel       (UUCPnet)                *
  1266. *********************************************************************/
  1267.  
  1268. X/*
  1269. **    lib_delwin.c
  1270. **
  1271. **    The routine delwin().
  1272. **
  1273. ** $Log:    RCS/lib_delwin.v $
  1274.  * Revision 2.1  82/10/25  14:47:01  pavel
  1275.  * Added Copyright Notice
  1276.  * 
  1277.  * Revision 2.0  82/10/25  13:44:21  pavel
  1278.  * Beta-one Test Release
  1279.  * 
  1280. **
  1281. */
  1282.  
  1283. static char RCSid[] =
  1284.     "$Header:   RCS/lib_delwin.v  Revision 2.1  82/10/25  14:47:01  pavel  Exp$";
  1285.  
  1286. #include "curses.h"
  1287. #include "curses.priv.h"
  1288.  
  1289.  
  1290. delwin(win)
  1291. WINDOW    *win;
  1292. {
  1293.     int    i;
  1294.  
  1295. #ifdef TRACE
  1296.     if (_tracing)
  1297.         _tracef("delwin(%o) called", win);
  1298. #endif
  1299.  
  1300.     if (! (win->_flags & _SUBWIN))
  1301.     {
  1302.         for (i = 0; i <= win->_maxy  &&  win->_line[i]; i++)
  1303.         cfree(win->_line[i]);
  1304.     }
  1305.  
  1306.     cfree(win->_numchngd);
  1307.     cfree(win->_firstchar);
  1308.     cfree(win->_lastchar);
  1309.     cfree(win->_line);
  1310.     cfree(win);
  1311. }
  1312. //go.sysin dd *
  1313. echo 'x - =src/lib_endwin.c'
  1314. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_endwin.c
  1315. X/*********************************************************************
  1316. *                         COPYRIGHT NOTICE                           *
  1317. **********************************************************************
  1318. *        This software is copyright (C) 1982 by Pavel Curtis         *
  1319. *                                                                    *
  1320. *        Permission is granted to reproduce and distribute           *
  1321. *        this file by any means so long as no fee is charged         *
  1322. *        above a nominal handling fee and so long as this            *
  1323. *        notice is always included in the copies.                    *
  1324. *                                                                    *
  1325. *        Other rights are reserved except as explicitly granted      *
  1326. *        by written permission of the author.                        *
  1327. *                Pavel Curtis                                        *
  1328. *                Computer Science Dept.                              *
  1329. *                405 Upson Hall                                      *
  1330. *                Cornell University                                  *
  1331. *                Ithaca, NY 14853                                    *
  1332. *                                                                    *
  1333. *                Ph- (607) 256-4934                                  *
  1334. *                                                                    *
  1335. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  1336. *                decvax!cornell!pavel       (UUCPnet)                *
  1337. *********************************************************************/
  1338.  
  1339. X/*
  1340. **    lib_endwin.c
  1341. **
  1342. **    The routine endwin().
  1343. **
  1344. ** $Log:    RCS/lib_endwin.v $
  1345.  * Revision 2.1  82/10/25  14:47:13  pavel
  1346.  * Added Copyright Notice
  1347.  * 
  1348.  * Revision 2.0  82/10/25  13:45:05  pavel
  1349.  * Beta-one Test Release
  1350.  * 
  1351. **
  1352. */
  1353.  
  1354. static char RCSid[] =
  1355.     "$Header:   RCS/lib_endwin.v  Revision 2.1  82/10/25  14:47:13  pavel  Exp$";
  1356.  
  1357. #include "term.h"
  1358. #include "curses.h"
  1359. #include "curses.priv.h"
  1360.  
  1361.  
  1362. static
  1363. outc(ch)
  1364. char    ch;
  1365. {
  1366.         putc(ch, SP->_ofp);
  1367. }
  1368.  
  1369.  
  1370. endwin()
  1371. {
  1372. #ifdef TRACE
  1373.     if (_tracing)
  1374.         _tracef("endwin() called");
  1375. #endif
  1376.  
  1377.     resetterm();
  1378.  
  1379.     mvcur(-1, -1, LINES - 1, 0);
  1380.  
  1381.     if (exit_ca_mode)
  1382.         tputs(exit_ca_mode, 1, outc);
  1383.  
  1384.     if (curscr  &&  (curscr->_attrs != A_NORMAL))
  1385.     {
  1386.         vidputs(A_NORMAL, outc);
  1387.  
  1388.         curscr->_attrs = A_NORMAL;
  1389.     }
  1390.  
  1391.     fflush(SP->_ofp);
  1392. }
  1393. //go.sysin dd *
  1394. echo 'x - =src/lib_erase.c'
  1395. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_erase.c
  1396. X/*********************************************************************
  1397. *                         COPYRIGHT NOTICE                           *
  1398. **********************************************************************
  1399. *        This software is copyright (C) 1982 by Pavel Curtis         *
  1400. *                                                                    *
  1401. *        Permission is granted to reproduce and distribute           *
  1402. *        this file by any means so long as no fee is charged         *
  1403. *        above a nominal handling fee and so long as this            *
  1404. *        notice is always included in the copies.                    *
  1405. *                                                                    *
  1406. *        Other rights are reserved except as explicitly granted      *
  1407. *        by written permission of the author.                        *
  1408. *                Pavel Curtis                                        *
  1409. *                Computer Science Dept.                              *
  1410. *                405 Upson Hall                                      *
  1411. *                Cornell University                                  *
  1412. *                Ithaca, NY 14853                                    *
  1413. *                                                                    *
  1414. *                Ph- (607) 256-4934                                  *
  1415. *                                                                    *
  1416. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  1417. *                decvax!cornell!pavel       (UUCPnet)                *
  1418. *********************************************************************/
  1419.  
  1420. X/*
  1421. **    lib_erase.c
  1422. **
  1423. **    The routine werase().
  1424. **
  1425. ** $Log:    RCS/lib_erase.v $
  1426.  * Revision 2.2  82/11/03  12:27:41  pavel
  1427.  * Fixed off-by-one error...  If only I had used an invariant...
  1428.  * 
  1429.  * Revision 2.1  82/10/25  14:47:17  pavel
  1430.  * Added Copyright Notice
  1431.  * 
  1432.  * Revision 2.0  82/10/25  13:45:12  pavel
  1433.  * Beta-one Test Release
  1434.  * 
  1435. **
  1436. */
  1437.  
  1438. static char RCSid[] =
  1439.     "$Header:   RCS/lib_erase.v  Revision 2.2  82/11/03  12:27:41  pavel  Exp$";
  1440.  
  1441. #include "curses.h"
  1442. #include "curses.priv.h"
  1443.  
  1444.  
  1445.  
  1446. werase(win)
  1447. WINDOW    *win;
  1448. {
  1449.     int    y;
  1450.     chtype    *sp, *end, *start, *maxx;
  1451.     int    minx;
  1452.     chtype    blank = ' ' | win->_attrs;
  1453.  
  1454. #ifdef TRACE
  1455.     if (_tracing)
  1456.         _tracef("werase(%o) called", win);
  1457. #endif
  1458.  
  1459.     for (y = win->_regtop; y <= win->_regbottom; y++)
  1460.     {
  1461.         minx = _NOCHANGE;
  1462.         start = win->_line[y];
  1463.         end = &start[win->_maxx];
  1464.  
  1465.         for (sp = start; sp <= end; sp++)
  1466.         {
  1467.         if (*sp != blank)
  1468.         {
  1469.             maxx = sp;
  1470.             if (minx == _NOCHANGE)
  1471.             minx = sp - start;
  1472.  
  1473.             *sp = blank;
  1474.  
  1475.             win->_numchngd[y] += 1;
  1476.         }
  1477.         }
  1478.  
  1479.         if (minx != _NOCHANGE)
  1480.         {
  1481.         if (win->_firstchar[y] > minx
  1482.                         ||  win->_firstchar[y] == _NOCHANGE)
  1483.             win->_firstchar[y] = minx;
  1484.  
  1485.         if (win->_lastchar[y] < maxx - win->_line[y])
  1486.             win->_lastchar[y] = maxx - win->_line[y];
  1487.         }
  1488.     }
  1489.  
  1490.     win->_curx = win->_cury = 0;
  1491. }
  1492. //go.sysin dd *
  1493. echo 'x - =src/lib_fixterm.c'
  1494. sed 's/^X//' <<'//go.sysin dd *' >=src/lib_fixterm.c
  1495. X/*********************************************************************
  1496. *                         COPYRIGHT NOTICE                           *
  1497. **********************************************************************
  1498. *        This software is copyright (C) 1982 by Pavel Curtis         *
  1499. *                                                                    *
  1500. *        Permission is granted to reproduce and distribute           *
  1501. *        this file by any means so long as no fee is charged         *
  1502. *        above a nominal handling fee and so long as this            *
  1503. *        notice is always included in the copies.                    *
  1504. *                                                                    *
  1505. *        Other rights are reserved except as explicitly granted      *
  1506. *        by written permission of the author.                        *
  1507. *                Pavel Curtis                                        *
  1508. *                Computer Science Dept.                              *
  1509. *                405 Upson Hall                                      *
  1510. *                Cornell University                                  *
  1511. *                Ithaca, NY 14853                                    *
  1512. *                                                                    *
  1513. *                Ph- (607) 256-4934                                  *
  1514. *                                                                    *
  1515. *                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
  1516. *                decvax!cornell!pavel       (UUCPnet)                *
  1517. *********************************************************************/
  1518.  
  1519. X/*
  1520.  *    fixterm.c
  1521.  *
  1522.  *    Routines:
  1523.  *        fixterm()
  1524.  *        resetterm()
  1525.  *        saveterm()
  1526.  *        gettmode()
  1527.  *        setterm()
  1528.  *        baudrate()
  1529.  *        erasechar()
  1530.  *        killchar()
  1531.  *        flushinp()
  1532.  *        savetty()
  1533.  *        resetty()
  1534.  *
  1535.  *  $Log:    RCS/lib_fixterm.v $
  1536.  * Revision 2.1  82/10/25  14:47:22  pavel
  1537.  * Added Copyright Notice
  1538.  * 
  1539.  * Revision 2.0  82/10/24  15:17:36  pavel
  1540.  * Beta-one Test Release
  1541.  * 
  1542.  * Revision 1.3  82/08/23  22:30:27  pavel
  1543.  * The REAL Alpha-one Release Version
  1544.  * 
  1545.  * Revision 1.2  82/08/19  19:11:21  pavel
  1546.  * Alpha Test Release One
  1547.  * 
  1548.  * Revision 1.1  82/08/12  18:40:30  pavel
  1549.  * Initial revision
  1550.  * 
  1551.  *
  1552.  */
  1553.  
  1554. static char RCSid[] =
  1555.     "$Header:   RCS/lib_fixterm.v  Revision 2.1  82/10/25  14:47:22  pavel  Exp$";
  1556.  
  1557. #include <sys/ioctl.h>
  1558. #include "curses.h"
  1559. #include "curses.priv.h"
  1560. #include "term.h"
  1561.  
  1562.  
  1563. X/*
  1564.  *    fixterm()
  1565.  *    resetterm()
  1566.  *
  1567.  *    fixterm() establishes the tty modes contained in cur_term->Nttyb.
  1568.  *    resetterm() establishes those in cur_term->Ottyb.
  1569.  *
  1570.  */
  1571.  
  1572.  
  1573. fixterm()
  1574. {
  1575. #ifdef TRACE
  1576.     if (_tracing)
  1577.         _tracef("fixterm() called");
  1578. #endif
  1579.         stty(cur_term->Filedes, &cur_term->Nttyb);
  1580. }
  1581.  
  1582.  
  1583. resetterm()
  1584. {
  1585. #ifdef TRACE
  1586.     if (_tracing)
  1587.         _tracef("resetterm() called");
  1588. #endif
  1589.         stty(cur_term->Filedes, &cur_term->Ottyb);
  1590. }
  1591.  
  1592.  
  1593.  
  1594. saveterm()
  1595. {
  1596. #ifdef TRACE
  1597.     if (_tracing)
  1598.         _tracef("saveterm() called");
  1599. #endif
  1600.     gtty(cur_term->Filedes, &cur_term->Nttyb);
  1601. }
  1602.  
  1603.  
  1604.  
  1605. X/*
  1606.  *    gettmode()
  1607.  *    setterm(type)
  1608.  *
  1609.  *    These are kept around for backward compatibilty.  gettmode() does
  1610.  *    nothing.  setterm() results in a proper call to setupterm()
  1611.  *
  1612.  */
  1613.  
  1614. gettmode()
  1615. {
  1616. #ifdef TRACE
  1617.     if (_tracing)
  1618.         _tracef("gettmode() called");
  1619. #endif
  1620. }
  1621.  
  1622.  
  1623. setterm(type)
  1624. char    *type;
  1625. {
  1626. #ifdef TRACE
  1627.     if (_tracing)
  1628.         _tracef("setterm() called");
  1629. #endif
  1630.         setupterm(type, 1, 0);
  1631. }
  1632.  
  1633.  
  1634.  
  1635.  
  1636. X/*
  1637.  *    erasechar()
  1638.  *
  1639.  *    Return erase character as given in cur_term->Ottyb.
  1640.  *
  1641.  */
  1642.  
  1643. char
  1644. erasechar()
  1645. {
  1646. #ifdef TRACE
  1647.     if (_tracing)
  1648.         _tracef("erasechar() called");
  1649. #endif
  1650.     return(cur_term->Ottyb.sg_erase);
  1651. }
  1652.  
  1653.  
  1654.  
  1655. X/*
  1656.  *    killchar()
  1657.  *
  1658.  *    Return kill character as given in cur_term->Ottyb.
  1659.  *
  1660.  */
  1661.  
  1662. char
  1663. killchar()
  1664. {
  1665. #ifdef TRACE
  1666.     if (_tracing)
  1667.         _tracef("killchar() called");
  1668. #endif
  1669.     return(cur_term->Ottyb.sg_kill);
  1670. }
  1671.  
  1672.  
  1673.  
  1674. X/*
  1675.  *    flushinp()
  1676.  *
  1677.  *    Flush any input on cur_term->Filedes
  1678.  *
  1679.  */
  1680.  
  1681. flushinp()
  1682. {
  1683. #ifdef TRACE
  1684.     if (_tracing)
  1685.         _tracef("flushinp() called");
  1686. #endif
  1687.         ioctl(cur_term->Filedes, TIOCFLUSH, 0);
  1688.     
  1689.         if (SP)
  1690.         SP->_backcnt = 0;
  1691. }
  1692.  
  1693.  
  1694.  
  1695. X/*
  1696.  *    int
  1697.  *    baudrate()
  1698.  *
  1699.  *    Returns the current terminal's baud rate.
  1700.  *
  1701.  */
  1702.  
  1703. static int speeds[] =
  1704. {
  1705.     0, 50, 75, 110, 134, 150, 200, 300, 600,
  1706.     1200, 1800, 2400, 4800, 9600, 19200, 38400
  1707. };
  1708.  
  1709. int
  1710. baudrate()
  1711. {
  1712. #ifdef UNDEFINED
  1713.     if (_tracing)
  1714.         _tracef("baudrate() called");
  1715. #endif
  1716.     return(speeds[cur_term->Nttyb.sg_ospeed]);
  1717. }
  1718.  
  1719.  
  1720. X/*
  1721. **    savetty()  and  resetty()
  1722. **
  1723. **    Kept around for compatibility.
  1724. **    
  1725. */
  1726.  
  1727. static struct sgttyb    sgbuf;
  1728.  
  1729. savetty()
  1730. {
  1731. #ifdef TRACE
  1732.     if (_tracing)
  1733.         _tracef("savetty() called");
  1734. #endif
  1735.  
  1736.     gtty(cur_term->Filedes, &sgbuf);
  1737. }
  1738.  
  1739. resetty()
  1740. {
  1741. #ifdef TRACE
  1742.     if (_tracing)
  1743.         _tracef("resetty() called");
  1744. #endif
  1745.  
  1746.     stty(cur_term->Filedes, &sgbuf);
  1747. }
  1748. //go.sysin dd *
  1749. exit
  1750.