arrow key bindings in perl debugger mode

A

andrew

Hi. I've been pouring over the debugger perldocs trying to figure out
how to change keyboard bindings, so for example the 'left' and 'right'
arrow keys let me move the cursor around the current line instead of
spitting out things like '^[[C', and mapping the 'up' arrow key to
cycle through the command history like it would at a command line
prompt. Am I approaching this completely wrong? Any advice would be
welcome. Thanks :)
 
J

Jens Thoms Toerring

andrew said:
Hi. I've been pouring over the debugger perldocs trying to figure out
how to change keyboard bindings, so for example the 'left' and 'right'
arrow keys let me move the cursor around the current line instead of
spitting out things like '^[[C', and mapping the 'up' arrow key to
cycle through the command history like it would at a command line
prompt. Am I approaching this completely wrong? Any advice would be
welcome. Thanks :)

From 'perldoc perldebug':

As shipped, the only command-line history supplied is a simplistic
one that checks for leading exclamation points. However, if you
install the Term::ReadKey and Term::ReadLine modules from CPAN,
you will have full editing capabilities much like GNU readline(3)
provides. Look for these in the modules/by-module/Term directory
on CPAN. These do not support normal vi command-line editing,
however.

And with ReadLine support also the left and right key should
work as expected.
Regards, Jens
 
A

andrew

Hmm, these two modules are installed, but it's not exactly clear to me
how to use them to customize key bindings.
 
J

Jens Thoms Toerring

andrew said:
Hmm, these two modules are installed, but it's not exactly clear to me
how to use them to customize key bindings.

Since readline is used you can customize keybindings by creating
a .inputrc file in your home directory (or set up the INPUTRC
environment variable to the name of the init file for readline)
and putting the keybindings in there. Per default more-or-less
emacs keybindings are used. In that file you can change them.
It's admittedly not trivial (unless you're an emacs expert)
but see e.g.

http://tiswww.case.edu/php/chet/readline/rluserman.html#SEC9

Regards, Jens
 
J

Jens Thoms Toerring

Since readline is used you can customize keybindings by creating
a .inputrc file in your home directory (or set up the INPUTRC
environment variable to the name of the init file for readline)
and putting the keybindings in there. Per default more-or-less
emacs keybindings are used. In that file you can change them.
It's admittedly not trivial (unless you're an emacs expert)
but see e.g.

You should be aware that using .inputrc in your home directory
also sets the keybindings also for all other programs that use
the readline library (e.g. xterm). The simplest way around that
is probably to create an alias like (bash style)

alis pd='INPUTRC=~/.perldinputrc perl -d'

so that the INPUTRC variable gets only set to the file with
eybindings for the debugger, named here .perldinputrc in
your home directory, when you start perl in debug mode with
the new "command" 'pd'.
Regards, Jens
 
M

Michael Carman

andrew said:
Hmm, these two modules are installed, but it's not exactly clear to me
how to use them to customize key bindings.

Something else must be wrong, then. The default bindings for those keys
matches the functionality you wanted.

-mjc
 
A

Andrew DeFaria

Jens said:
You should be aware that using .inputrc in your home directory also
sets the keybindings also for all other programs that use
the readline library (e.g. xterm). The simplest way around that is
probably to create an alias like (bash style)

alis pd='INPUTRC=~/.perldinputrc perl -d'

so that the INPUTRC variable gets only set to the file with eybindings
for the debugger, named here .perldinputrc in your home directory,
when you start perl in debug mode with the new "command" 'pd'.
Why in the world would I want the Perl debugger to behave one way and
bash another?
 
J

Jens Thoms Toerring

Andrew DeFaria said:
[-- text/plain, encoding 7bit, charset: ISO-8859-1, 17 lines --]
Why in the world would I want the Perl debugger to behave one way and
bash another?

Maybe because you want to assign to some function keys an
action that doesn't make sense in an xterm? Like e.g. assigning
the debuggers 'q' command to F12 while the same function key
should emit 'exit' in an xterm?
 
A

Andrew DeFaria

Jens said:
Maybe because you want to assign to some function keys an action that
doesn't make sense in an xterm? Like e.g. assigning
the debuggers 'q' command to F12 while the same function key should
emit 'exit' in an xterm?
Well I don't use xterm. But the answer is - I wouldn't. I wouldn't
bother assigning a function key (F12) to do the "q" command to quit the
debugger when the "q" key is right within grasp (of a touch typist, one
for over 25 years and a guitarist for 30 which great control of my
fingers) and the F12 is a stretch at best!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top