]> ncurses.scripts.mit.edu Git - ncurses.git/blob - include/capdefaults.c
a7ceda19fcbbefe95cf0693b51b10b60b89a8a55
[ncurses.git] / include / capdefaults.c
1
2 /***************************************************************************
3 *                            COPYRIGHT NOTICE                              *
4 ****************************************************************************
5 *                ncurses is copyright (C) 1992-1995                        *
6 *                          Zeyd M. Ben-Halim                               *
7 *                          zmbenhal@netcom.com                             *
8 *                          Eric S. Raymond                                 *
9 *                          esr@snark.thyrsus.com                           *
10 *                                                                          *
11 *        Permission is hereby granted to reproduce and distribute ncurses  *
12 *        by any means and for any fee, whether alone or as part of a       *
13 *        larger distribution, in source or in binary form, PROVIDED        *
14 *        this notice is included with any such distribution, and is not    *
15 *        removed from any of its header files. Mention of ncurses in any   *
16 *        applications linked with it is highly appreciated.                *
17 *                                                                          *
18 *        ncurses comes AS IS with no warranty, implied or expressed.       *
19 *                                                                          *
20 ***************************************************************************/
21
22 /* $Id: capdefaults.c,v 1.4 1996/08/18 00:56:09 tom Exp $ */
23
24         /*
25          * Compute obsolete capabilities.  The reason this is an include file
26          * is that the two places where it's needed want the macros to
27          * generate offsets to different structures.  See the file Caps for
28          * explanations of these conversions.
29          *
30          * Note: This code is the functional inverse of the first part
31          * of postprocess_entry().
32          */
33         {
34                 char *sp;
35                 int capval;
36
37 #define VALID_STRING(s) ((s) && s != CANCELLED_STRING)
38 #define EXTRACT_DELAY(str)      (sp = strchr(str, '*'), sp ? atoi(sp+1) : 0)
39
40                 /* current (4.4BSD) capabilities marked obsolete */
41                 if (VALID_STRING(carriage_return)
42                                 && (capval = EXTRACT_DELAY(carriage_return)))
43                         carriage_return_delay = capval;
44                 if (VALID_STRING(newline) && (capval = EXTRACT_DELAY(newline)))
45                         new_line_delay = capval;
46
47                 /* current (4.4BSD) capabilities not obsolete */
48                 if (!VALID_STRING(termcap_init2) && VALID_STRING(init_3string))
49                 {
50                         termcap_init2 = init_3string;
51                         init_3string = (char *)NULL;
52                 }
53                 if (VALID_STRING(reset_1string)
54                         && !VALID_STRING(reset_2string)
55                         && VALID_STRING(reset_3string))
56                 {
57                         termcap_reset = reset_1string;
58                         reset_1string = (char *)NULL;
59                 }
60                 if (magic_cookie_glitch_ul < 0 && magic_cookie_glitch && VALID_STRING(enter_underline_mode))
61                         magic_cookie_glitch_ul = magic_cookie_glitch;
62
63                 /* totally obsolete capabilities */
64                 linefeed_is_newline = VALID_STRING(newline)
65                                         && (strcmp("\n", newline) == 0);
66                 if (VALID_STRING(cursor_left)
67                                 && (capval = EXTRACT_DELAY(cursor_left)))
68                         backspace_delay = capval;
69                 if (VALID_STRING(tab) && (capval = EXTRACT_DELAY(tab)))
70                         horizontal_tab_delay = capval;
71 #undef EXTRACT_DELAY
72         }