summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcons/ChangeLog15
-rw-r--r--libcons/file-changed.c12
-rw-r--r--libcons/opts-std-startup.c39
-rw-r--r--libcons/priv.h17
4 files changed, 78 insertions, 5 deletions
diff --git a/libcons/ChangeLog b/libcons/ChangeLog
index 445e4f2c..d18b6868 100644
--- a/libcons/ChangeLog
+++ b/libcons/ChangeLog
@@ -1,3 +1,18 @@
+2003-08-01 Marco Gerards <metgerards@student.han.nl>
+
+ * opts-std-startup.c: Include <string.h>.
+ (OPT_VISUAL_BELL): New macro.
+ (OPT_AUDIBLE_BELL): Likewise.
+ (_cons_visual_bell): New variable.
+ (_cons_audible_bell): Likewise.
+ (startup_options): Added options "--visual-bell" and
+ "--audible-bell" ...
+ (parse_startup_opt): ...and parse those new options here.
+ * priv.h (bell_type_t): New enumeration.
+ (_cons_visual_bell): New external variable.
+ (_cons_audible_bell): Likewise.
+ * file-changed.c (cons_S_file_changed): Use the right bell.
+
2002-10-04 Marcus Brinkmann <marcus@gnu.org>
* vcons-open.c (cons_vcons_open): Add casts to silence gcc
diff --git a/libcons/file-changed.c b/libcons/file-changed.c
index f65eb0b5..40c00af8 100644
--- a/libcons/file-changed.c
+++ b/libcons/file-changed.c
@@ -1,5 +1,5 @@
/* file-changed.c - Handling file changed notifications.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
This file is part of the GNU Hurd.
@@ -202,7 +202,10 @@ cons_S_file_changed (cons_notify_t notify, natural_t tickno,
while (vcons->state.bell.audible
< vcons->display->bell.audible)
{
- cons_vcons_beep (vcons);
+ if (_cons_audible_bell == BELL_AUDIBLE)
+ cons_vcons_beep (vcons);
+ else if (_cons_audible_bell == BELL_VISUAL)
+ cons_vcons_flash (vcons);
vcons->state.bell.audible++;
}
}
@@ -211,7 +214,10 @@ cons_S_file_changed (cons_notify_t notify, natural_t tickno,
while (vcons->state.bell.visible
< vcons->display->bell.visible)
{
- cons_vcons_flash (vcons);
+ if (_cons_visual_bell == BELL_VISUAL)
+ cons_vcons_flash (vcons);
+ else if (_cons_visual_bell == BELL_AUDIBLE)
+ cons_vcons_beep (vcons);
vcons->state.bell.visible++;
}
}
diff --git a/libcons/opts-std-startup.c b/libcons/opts-std-startup.c
index 085f960b..29278cc2 100644
--- a/libcons/opts-std-startup.c
+++ b/libcons/opts-std-startup.c
@@ -1,5 +1,5 @@
/* opts-std-startup.c - Standard startup-time command line parser.
- Copyright (C) 1995,96,97,98,99,2001,02 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,97,98,99,2001,02,2003 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org> and Marcus Brinkmann.
This file is part of the GNU Hurd.
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <argp.h>
+#include <string.h>
#include "priv.h"
@@ -30,6 +31,8 @@
#define OPT_NO_JUMP_DOWN_ON_INPUT 602 /* --no-jump-down-on-input */
#define OPT_JUMP_DOWN_ON_OUTPUT 603 /* --jump-down-on-output */
#define OPT_NO_JUMP_DOWN_ON_OUTPUT 604 /* --no-jump-down-on-output */
+#define OPT_VISUAL_BELL 605 /* --visual-bell */
+#define OPT_AUDIBLE_BELL 606 /* --audible-bell */
/* Common value for diskfs_common_options and diskfs_default_sync_interval. */
#define DEFAULT_SLACK 100
@@ -50,6 +53,12 @@ int _cons_jump_down_on_output;
/* The filename of the console server. */
char *_cons_file;
+/* The type of bell used for the visual bell. */
+bell_type_t _cons_visual_bell = BELL_VISUAL;
+
+/* The type of bell used for the audible bell. */
+bell_type_t _cons_audible_bell = BELL_AUDIBLE;
+
static const struct argp_option
startup_options[] =
{
@@ -63,6 +72,10 @@ startup_options[] =
"End scrollback when something is printed" },
{ "no-jump-down-on-output", OPT_NO_JUMP_DOWN_ON_OUTPUT, NULL, 0,
"End scrollback when something is printed (default)" },
+ { "visual-bell", OPT_VISUAL_BELL, "BELL", 0, "Visual bell: on (default), "
+ "off, visual, audible" },
+ { "audible-bell", OPT_AUDIBLE_BELL, "BELL", 0, "Audible bell: on (default), "
+ "off, visual, audible" },
{ 0, 0 }
};
@@ -95,6 +108,30 @@ parse_startup_opt (int opt, char *arg, struct argp_state *state)
_cons_jump_down_on_output = 0;
break;
+ case OPT_AUDIBLE_BELL:
+ if (!strcasecmp ("on", arg) || !strcasecmp ("audible", arg))
+ _cons_audible_bell = BELL_AUDIBLE;
+ else if (!strcasecmp ("off", arg))
+ _cons_audible_bell = BELL_OFF;
+ else if (!strcasecmp ("visual", arg))
+ _cons_audible_bell = BELL_VISUAL;
+ else
+ argp_error (state, "The audible bell can be one of: on, off, visual, "
+ "audible");
+ break;
+
+ case OPT_VISUAL_BELL:
+ if (!strcasecmp ("on", arg) || !strcasecmp ("visual", arg))
+ _cons_visual_bell = BELL_VISUAL;
+ else if (!strcasecmp ("off", arg))
+ _cons_visual_bell = BELL_OFF;
+ else if (!strcasecmp ("audible", arg))
+ _cons_visual_bell = BELL_AUDIBLE;
+ else
+ argp_error (state, "The visual bell can be one of: on, off, visual, "
+ "audible");
+ break;
+
case ARGP_KEY_ARG:
if (state->arg_num > 0)
/* Too many arguments. */
diff --git a/libcons/priv.h b/libcons/priv.h
index 598590e5..a1ec2451 100644
--- a/libcons/priv.h
+++ b/libcons/priv.h
@@ -1,5 +1,5 @@
/* Private declarations for cons library
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -21,6 +21,15 @@
#include "cons.h"
+/* The kind of bells available. */
+typedef enum
+ {
+ BELL_OFF,
+ BELL_VISUAL,
+ BELL_AUDIBLE
+ } bell_type_t;
+
+
/* Number of records the client is allowed to lag behind the
server. */
extern int _cons_slack;
@@ -34,6 +43,12 @@ extern int _cons_jump_down_on_output;
/* The filename of the console server. */
extern char *_cons_file;
+/* The type of bell used for the visual bell. */
+extern bell_type_t _cons_visual_bell;
+
+/* The type of bell used for the audible bell. */
+extern bell_type_t _cons_audible_bell;
+
/* Non-locking version of cons_vcons_scrollback. Does also not update
the display. */