Re: Disabling/Enabling Keys in BASH Script

From: Icarus Sparry (usenet_at_icarus.freeuk.com)
Date: 06/13/04


Date: Sun, 13 Jun 2004 00:20:18 GMT

On Fri, 11 Jun 2004 23:30:12 -0700, Dr. Lince M. Lawrence wrote:

> I want to run a function, say help, in my script at any time the user
> wants. Pressing a key (CTRL+ALT+F) should enable this function like
> pressing the key CTRL+C to quit.

Not easy to do in the general case. The characters (if any) returned by
different terminals in response to function keys vary a lot. It is more
portable to make a shell function to print a question, read an input line,
if the line is just "?" or "help" then display some help and re-prompt
with the question.

The way that CTRL-C works is not very flexible, and would only work if
your CTRL-ALT-F returned a single character.

Other things you can look at include using 'expect', and in particular the
"interact" command. Your program could look like

#!/usr/bin/expect
spawn real_program
interact "characters sent by CTRL-ALT-F" {puts "Here is some help"}

If you are running in an X display, you may be able to get your window
manager to intercept the CTRL-ALT-F key, and pop up another window with
some help in it.

Icarus



Relevant Pages

  • Re: KDP-2, End of year #1
    ... that or I need to bo find a 30" display or larger. ... read the characters on the screen which insn't very desirable. ... the lens window is indeed centered in the display screen and you ... the KDP-2 Optical Design Program ...
    (sci.optics)
  • Re: XCHARS RfD; clarification of XEMIT
    ... Some Forth's open their own window. ... If I want to display Spanish, ... They are, at least in Windows, out of band and are not characters per ... And for want of a proper transformation, ...
    (comp.lang.forth)
  • Re: XCHARS RfD; clarification of XEMIT
    ... Some Forth's open their own window. ... If I want to display Spanish, ... They are, at least in Windows, out of band and are not characters per ... And for want of a proper transformation, ...
    (comp.lang.forth)
  • Re: KDP-2, End of year #1
    ... that or I need to bo find a 30" display or larger. ... read the characters on the screen which insn't very desirable. ... the lens window is indeed centered in the display screen and you ... barely readable without reading glasses which bring my eyes to about 5" from ...
    (sci.optics)
  • Re: Checking for Characters
    ... >entered and if there is characters i want to display a message box. ... at the foot of the window to tell users when they key an error. ...
    (microsoft.public.dotnet.languages.vb)