[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.6

1.6     ! lum         1: /*     $OpenBSD: bell.c,v 1.5 2019/07/17 18:18: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"
1.4       lum        20: #include "macro.h"
1.1       lum        21:
                     22: void
                     23: bellinit(void)
                     24: {
                     25:        doaudiblebell = 1;
                     26:        dovisiblebell = 0;
1.6     ! lum        27: }
        !            28:
        !            29: int
        !            30: dobeep_num(const char *msg, int n)
        !            31: {
        !            32:        ewprintf("%s %d", msg, n);
        !            33:        dobeep();
        !            34:        return (FALSE);
1.5       lum        35: }
                     36:
                     37: int
                     38: dobeep_msgs(const char *msg, const char *s)
                     39: {
                     40:        ewprintf("%s %s", msg, s);
                     41:        dobeep();
                     42:        return (FALSE);
                     43: }
                     44:
                     45: int
                     46: dobeep_msg(const char *msg)
                     47: {
                     48:        ewprintf("%s", msg);
                     49:        dobeep();
                     50:        return (FALSE);
1.1       lum        51: }
                     52:
                     53: void
                     54: dobeep(void)
                     55: {
                     56:        if (doaudiblebell) {
                     57:                ttbeep();
                     58:        }
                     59:        if (dovisiblebell) {
                     60:                sgarbf = TRUE;
                     61:                update(CNONE);
1.4       lum        62:                if (inmacro)    /* avoid delaying macro execution. */
                     63:                        return;
1.1       lum        64:                usleep(50000);
                     65:        }
                     66: }
                     67:
                     68: /* ARGSUSED */
                     69: int
                     70: toggleaudiblebell(int f, int n)
                     71: {
                     72:        if (f & FFARG)
                     73:                doaudiblebell = n > 0;
                     74:        else
                     75:                doaudiblebell = !doaudiblebell;
                     76:
                     77:        return (TRUE);
                     78: }
                     79:
                     80: /* ARGSUSED */
                     81: int
                     82: togglevisiblebell(int f, int n)
                     83: {
                     84:        if (f & FFARG)
                     85:                dovisiblebell = n > 0;
                     86:        else
                     87:                dovisiblebell = !dovisiblebell;
                     88:
                     89:        return (TRUE);
                     90: }