[BACK]Return to bell.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Annotation of src/usr.bin/mg/bell.c, Revision 1.3

1.3     ! bcallah     1: /*     $OpenBSD: bell.c,v 1.2 2014/03/22 11:05:37 lum Exp $    */
1.1       lum         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:  */
1.3     ! bcallah    13:
        !            14: #include <sys/queue.h>
        !            15: #include <signal.h>
        !            16: #include <stdio.h>
        !            17: #include <unistd.h>
1.1       lum        18:
                     19: #include "def.h"
                     20:
                     21: void
                     22: bellinit(void)
                     23: {
                     24:        doaudiblebell = 1;
                     25:        dovisiblebell = 0;
                     26: }
                     27:
                     28: void
                     29: dobeep(void)
                     30: {
                     31:        if (doaudiblebell) {
                     32:                ttbeep();
                     33:        }
                     34:        if (dovisiblebell) {
                     35:                sgarbf = TRUE;
                     36:                update(CNONE);
                     37:                usleep(50000);
                     38:        }
                     39: }
                     40:
                     41: /* ARGSUSED */
                     42: int
                     43: toggleaudiblebell(int f, int n)
                     44: {
                     45:        if (f & FFARG)
                     46:                doaudiblebell = n > 0;
                     47:        else
                     48:                doaudiblebell = !doaudiblebell;
                     49:
                     50:        return (TRUE);
                     51: }
                     52:
                     53: /* ARGSUSED */
                     54: int
                     55: togglevisiblebell(int f, int n)
                     56: {
                     57:        if (f & FFARG)
                     58:                dovisiblebell = n > 0;
                     59:        else
                     60:                dovisiblebell = !dovisiblebell;
                     61:
                     62:        return (TRUE);
                     63: }