ncurses 4.1
[ncurses.git] / ncurses / lib_beep.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
23 /*
24  *      beep.c
25  *
26  *      Routines beep() and flash()
27  *
28  */
29
30 #include <curses.priv.h>
31 #include <term.h>       /* beep, flash */
32
33 MODULE_ID("$Id: lib_beep.c,v 1.3 1997/02/02 00:27:01 tom Exp $")
34
35 /*
36  *      beep()
37  *
38  *      Sound the current terminal's audible bell if it has one.   If not,
39  *      flash the screen if possible.
40  *
41  */
42
43 int beep(void)
44 {
45         T((T_CALLED("beep()")));
46
47         /* FIXME: should make sure that we are not in altchar mode */
48         if (bell) {
49                 TPUTS_TRACE("bell");
50                 return(putp(bell));
51         } else if (flash_screen) {
52                 TPUTS_TRACE("flash_screen");
53                 return(putp(flash_screen));
54         }
55         else
56                 returnCode(ERR);
57 }
58
59 /*
60  *      flash()
61  *
62  *      Flash the current terminal's screen if possible.   If not,
63  *      sound the audible bell if one exists.
64  *
65  */
66
67 int flash(void)
68 {
69         T((T_CALLED("flash()")));
70
71         /* FIXME: should make sure that we are not in altchar mode */
72         if (flash_screen) {
73                 TPUTS_TRACE("flash_screen");
74                 returnCode(putp(flash_screen));
75         } else if (bell) {
76                 TPUTS_TRACE("bell");
77                 returnCode(putp(bell));
78         }
79         else
80                 returnCode(ERR);
81 }