xref: /openbsd-src/usr.bin/mg/bell.c (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1 /*	$OpenBSD: bell.c,v 1.2 2014/03/22 11:05:37 lum Exp $	*/
2 
3 /*
4  * This file is in the public domain.
5  *
6  * Author: Mark Lumsden <mark@showcomplex.com>
7  *
8  */
9 
10 /*
11  * Control how mg communicates with the user.
12  */
13 
14 #include "def.h"
15 
16 void
17 bellinit(void)
18 {
19 	doaudiblebell = 1;
20 	dovisiblebell = 0;
21 }
22 
23 void
24 dobeep(void)
25 {
26 	if (doaudiblebell) {
27 		ttbeep();
28 	}
29 	if (dovisiblebell) {
30 		sgarbf = TRUE;
31 		update(CNONE);
32 		usleep(50000);
33 	}
34 }
35 
36 /* ARGSUSED */
37 int
38 toggleaudiblebell(int f, int n)
39 {
40 	if (f & FFARG)
41 		doaudiblebell = n > 0;
42 	else
43 		doaudiblebell = !doaudiblebell;
44 
45 	return (TRUE);
46 }
47 
48 /* ARGSUSED */
49 int
50 togglevisiblebell(int f, int n)
51 {
52 	if (f & FFARG)
53 		dovisiblebell = n > 0;
54 	else
55 		dovisiblebell = !dovisiblebell;
56 
57 	return (TRUE);
58 }
59