From owner-freebsd-questions@FreeBSD.ORG Fri Oct 7 07:32:24 2011 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 E3D2B1065672 for ; Fri, 7 Oct 2011 07:32:24 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id A796D8FC0A for ; Fri, 7 Oct 2011 07:32:24 +0000 (UTC) Received: from r56.edvax.de (port-92-195-41-66.dynamic.qsc.de [92.195.41.66]) by mx02.qsc.de (Postfix) with ESMTP id CDCAB1E557; Fri, 7 Oct 2011 09:32:23 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id p977WNLa001927; Fri, 7 Oct 2011 09:32:23 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Fri, 7 Oct 2011 09:32:23 +0200 From: Polytropon To: Gary Kline Message-Id: <20111007093223.3681c1fc.freebsd@edvax.de> In-Reply-To: <20111007045101.GA603@thought.org> References: <20111006224114.GA15978@thought.org> <20111006233725.GA18837@saltmine.radix.net> <20111007045101.GA603@thought.org> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Mailing List Subject: Re: OT: how to tell when i've hit a Fn key? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2011 07:32:25 -0000 On Thu, 6 Oct 2011 21:51:01 -0700, Gary Kline wrote: > On Thu, Oct 06, 2011 at 07:37:25PM -0400, Thomas Dickey wrote: > > Date: Thu, 6 Oct 2011 19:37:25 -0400 > > From: Thomas Dickey > > Subject: Re: OT: how to tell when i've hit a Fn key? > > To: Gary Kline > > Cc: FreeBSD Mailing List > > > > On Thu, Oct 06, 2011 at 03:41:17PM -0700, Gary Kline wrote: > > > > > > I've got a 103-key keyboard. most of them produce the right WAV > > > file. i was having some trouble with the arrow key, but think i've > > > found a resolution. next are the Function key, F1 to F12. > > > > > > anybody on-list familiar with curses and can help me with this? > > > right now, most of the function keys output 4 clicks [!]. > > > > I generally use tack for verifying the function-keys against the terminal > > description. (I don't recall seeing a port for tack, but it can probably > > be built starting with ncurses-devel, though I haven't tried that, since > > I build development versions of ncurses outside the ports). > > > > For _seeing_ the codes, it helps to type ^V (lnext) right before pressing > > a given key, making the escape character visible. > > > > Hm. no joy in mudville. i know the first byte ia an > ESC [ '\033]. the last, for F1, is an A. the others are > hidden. >From DOS times (that DOS, not _the_ DOS!) I remember that the function keys do generate a "two-key sequene": The first character is a 0x00 byte, the next one is a regular key, such as "A" for PF1. So you did basically check (in pseudocode): extended = false c = read character if c == 0x00 { extended = true c = read character } act upon c && if extended > i'll check ncurses-devel and see w hat it has. REAL code > helps in stuff like this... . I've written a (partially working) dialog library comparable to NCurses Forms in C, using ncurses' built-in functionality. So if you can, use what's already present and working. Instead of dealing with the zero-bytes, it's much easier to use the ncurses functionality. Like this (except this is nonsense): int c; c = getch(); if(c == KEY_F(1)) /* PF1 */ do_stuff(); if(c == KEY_UP) /* Cursor up */ do_more_stuff(); if(c == 27) /* Escape key! */ get_out_of_prison(); >From memory: Space is 32, Return is 13, Backspace is 8, Tab is 9. I think most of them are defined as macros in NCurses. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...