Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 03-11-2002, 12:49 PM   #1
aaron
Prospect
 
Join Date: Jan 2002
Posts: 4
Unhappy Function Keys in Terminal

Does anyone know how to get the terminal.app to recognize function keys. I have emacs bindings to F1-F5 that I use all the time that terminal just refuses deal with.
aaron is offline   Reply With Quote
Old 03-11-2002, 01:10 PM   #2
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
you may wish to examine key bindings for your shell:

tcsh builtin command: bindkey

bash builtin command: bind

let us know if you get something working.
mervTormel is offline   Reply With Quote
Old 03-22-2002, 06:06 PM   #3
eisforian
Prospect
 
Join Date: Mar 2002
Posts: 5
I use GLTerm instead of Apple's Terminal. It's much faster, uses the standard BPF fonts (like Shine 5x10), and properly handles the function keys as well as page up, page down, etc. Cons: it's shareware and doesn't support translucent windows (oh well).
__________________
--Ian L.

Logical Lemon Productions
http://www.logicallemon.com/
eisforian is offline   Reply With Quote
Old 02-25-2008, 07:10 PM   #4
mlylebrown
Registered User
 
Join Date: Feb 2008
Posts: 1
Think This Might Do the Trick

Hey,

I was having the same issue, and after doing some rooting around found that the "standard" DEC key combinations for F1, F2 etc, can be done in terminal.app by doing ESC+#. So to do F1 hold ESC and press number 1. It's a bit more cumbersome than what you're probably used to, but it should help.

I had the same issues when I was trying to use IBM's smitty console, which required the use of the function keys in order to navigate the menus. Imagine my frustration when I wanted to use F3 for exiting the app and saving my changes and instead could only toggle Expose! I do hope that Apple gives some sort of workaround for this - or makes it known how to do this in their manuals.

As it is, I discovered this by looking at a terminal replacement program called iTerm, which showed the appropriate key sequences while logged in to it's app.

Try it and see if it helps you out.

- MLB
mlylebrown is offline   Reply With Quote
Old 07-01-2010, 08:07 PM   #5
rlhamil
Guest
 
Posts: n/a
Quote:
Originally Posted by aaron
Does anyone know how to get the terminal.app to recognize function keys. I have emacs bindings to F1-F5 that I use all the time that terminal just refuses deal with.

Most traditional Unix terminal based full-screen (ok,full window)
programs use the "curses" (cursor movement handling) or "ncurses"
(new curses) library. It, in turn, depends on terminal descriptions,
which deal with the fact that different model terminals may need
different escape sequences to manipulate their screen, map to
function keys on input, or have other quirks that need to be identified.

For function keys to be recognized by such a program, the key definitions
for the terminal in question need to match what is received as input
when the corresponding function key is pressed.

The traditional Unix way of fixing that would be to edit the info in the
terminfo database for the terminal type.

Terminal type is identified by the TERM environment variable.
In addition, if one doesn't want to (or isn't allowed to) alter the system
terminfo database, one needs a private one that would be checked first.
To do that, set the TERMINFO environment variable to (for example)
$HOME/.terminfo

In sh, bash, or ksh, that's
TERMINFO="$HOME/.terminfo";export TERMINFO

In csh or tcsh, that's
setenv TERMINFO "$HOME/.terminfo"

To make that permanent, add it to your .profile (sh, bash, ksh) or
.cshrc or .login (csh, tcsh).

One can extract the existing definition with

infocmp > myterm.src

and then edit it with a text editor. The format is more or less
described by the terminfo man page, i.e. man terminfo

Then, to "compile" it, run

tic myterm.src

Assuming you first set TERMINFO as above, that should create a binary
file somewhere under $HOME/.terminfo (in a subdirectory under it),
with your updated terminal description.

That's the traditional Unix way of doing it.

The reason it may be necessary for some of the function keys is that
(for whatever reason) their definitions may not match the defaults
in the keyboard settings (or else you previously changed the keyboard
settings to have those function keys generate something other than
the default). So you have to make them match.

(I've seen other complaints about this, BTW. It could be argued that
Apple made one of their few mistakes, in terms of not getting all the
settings matched up, and in terms of leaving apparently _no_ variation
of F8 unused by some special function.)

On a Mac, you can also view the keyboard settings, and change them
to match the unaltered terminfo settings. In which case, you don't
need to set TERMINFO or alter the terminfo definition; all you need
to do is view the existing terminal definition with

infocmp

and change the terminal settings to match. Hint: in a terminfo description,
\E (backslash E if that gets mangled in the post) represents the escape
(ESC) character.


See http://www.movethemarkets.com/downloads/rwt/rwt010/
for an example of changing the keyboard settings to get the function
keys working.

Assuming a Mac keyboard, there may be the Fn key to deal with.
By default, the function keys perform their pictured functions; making
them generate input passed to the terminal requires using the
Fn key with them as if it were a shift key. There's a checkmark
on the keyboard settings that can be used to reverse that behavior.

keys F14 through F20 may be shift F6 through F12 (with or without
Fn also, depending on the setting previously mentioned).

Key F8 may be unavailable under the default keyboard settings,
being used for various "Spaces" functions. You can probably free
those up if you need it.

Traditional IBM 3270 (mainframe) terminals had up to 24 function
keys (although one could get by with just 12 for normal use with
mainframe applications). For those who might occasionally use a
3270 emulator, I haven't been able to identify if there's a way to
have function keys above F20. Some 3270 emulators can display
a window with the special keys on them, where you just click the
one you want. Not as fast as having it on the keyboard, but usable.

Even if you use the Mac approach (change the keyboard settings
to match terminfo rather than changing terminfo), some keys that
terminfo _can_ know about won't be recognized. Having used traditional
Unix since long before Macs existed, I fixed this for myself by changing
terminfo, and the changes I'd made were


# changed kf1=\E[11~,kf2=\E[12,kf3=\E[13,kf4=\E[14,kf18=\E[32~,
# to
# kf1=\EOP,kf2=\EOQ,kf3=\EOR,kf4=\EOS,kf18=\E[22 to fit observed behavior of Mac
# Terminal.app
# and added
# khome=\E[H,kend=\E[F,kcbt=\E[Z,

kf1...kf18 define the input from those function keys. The ones identifying
the home key and end key should be pretty obvious (spell checker won't
let me enter those names), and kcbt is the back tab (shifted tab) key.
That's all I've found so far that can be made available to "curses" using
programs. (If the terminal were capable of them, terminfo has the
ability to define function keys F0 through F63 and a bunch of exotic
named keys like find and undo that don't exist on most keyboards.
But very few "curses" using programs probably attempt to offer the
ability to use all those.)

So...there's a couple of ways to make the basic function keys work,
and additional functionality to be had if you really want to go to the
trouble. Good luck!
  Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:13 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.