From owner-freebsd-questions@FreeBSD.ORG Sat Dec 26 16:50:14 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5835F10656C6 for ; Sat, 26 Dec 2009 16:50:14 +0000 (UTC) (envelope-from dickey@saltmine.radix.net) Received: from saltmine.radix.net (saltmine.radix.net [207.192.128.40]) by mx1.freebsd.org (Postfix) with ESMTP id 126368FC16 for ; Sat, 26 Dec 2009 16:50:13 +0000 (UTC) Received: from saltmine.radix.net (localhost [127.0.0.1]) by saltmine.radix.net (8.12.2/8.12.2) with ESMTP id nBQGo6V4018897; Sat, 26 Dec 2009 11:50:06 -0500 (EST) Received: (from dickey@localhost) by saltmine.radix.net (8.12.2/8.12.2/Submit) id nBQGo6gF018891; Sat, 26 Dec 2009 11:50:06 -0500 (EST) Date: Sat, 26 Dec 2009 11:50:06 -0500 From: Thomas Dickey To: Anton Shterenlikht Message-ID: <20091226165005.GA17386@saltmine.radix.net> References: <20091225185826.GA82073@mech-cluster241.men.bris.ac.uk> <20091225204914.2a532df3.freebsd@edvax.de> <20091226153327.GA9918@mech-anton242.men.bris.ac.uk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline In-Reply-To: <20091226153327.GA9918@mech-anton242.men.bris.ac.uk> User-Agent: Mutt/1.3.27i Cc: Polytropon , freebsd-questions@freebsd.org Subject: Re: example c program that does "beep" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Dec 2009 16:50:14 -0000 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Dec 26, 2009 at 03:33:27PM +0000, Anton Shterenlikht wrote: > On Fri, Dec 25, 2009 at 08:49:14PM +0100, Polytropon wrote: > > On Fri, 25 Dec 2009 18:58:26 +0000, Anton Shterenlikht wrote: > > > How can I get a beep from c? > > > I looked at curses and syscons.c, but > > > still not clear. > >=20 > > If you want to use NCURSES / CURSES, it's a bit complicated. > >=20 > > Otherwise, just output %c (the character) 0x07, BEL, which > > generates an audible bell, or beep. > >=20 > >=20 > > *** text/plain attachement has been stripped *** RETRY *** > >=20 > > /* beepflash.c > > * ----------- > > * cc -Wall -lcurses -o beepflash beepflash.c > > * > > */ > >=20 > > #include > > #include > >=20 > > int main(int argc, char *argv[]) > > { > > initscr(); > > cbreak(); > > noecho(); > > nonl(); > > intrflush(stdscr, FALSE); > > keypad(stdscr, TRUE); > > start_color(); > >=20 > > printf("beep: %d\n", beep()); > > fflush(stdout); > >=20 > > printf("flash: %d\n", flash()); > > fflush(stdout); > >=20 > > return 0; > > } >=20 > Instead of a beep and a flash I get: >=20 > beep: 0./beepflash > flash: 0 > HAMOR> That sounds about right, given the code shown above. If you'd used just beep(); refresh(); instead of the printf/fflush, it would clear the screen and beep - if the terminal description says it can do the beep. In the ncurses sources, progs/clear.c is a simple program which sets up the terminal and calls the tputs function - something like what you're trying to do. --=20 Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net --jRHKVT23PllUwdXP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (SunOS) Comment: For info see http://www.gnupg.org iD8DBQFLNj68tIqByHxlDocRAjCmAJ9CXuxXjvcaL1fq0sNl5V3UiJW1VwCcDi+m Tqtq2u+1XfF35Da/1EKv7ds= =18by -----END PGP SIGNATURE----- --jRHKVT23PllUwdXP--