Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Revising Input Method

by hakonhagland (Scribe)
on Jul 28, 2016 at 20:47 UTC ( #1168760=note: print w/replies, xml ) Need Help??

in reply to Revising Input Method

According to the documentation the package is just a front end to some other packages. It's a stub to set up a common interface to the various ReadLine implementations found on CPAN (under the Term::ReadLine::* namespace). If you haven't installed any additional packages like Term::Readline::Gnu or Term::ReadLine::EditLine, it will default to an internal default package called Term::ReadLine::Stub, this default package is very simple, and does not understand things like arrow keys. You can use $term->ReadLine to determine which package it is actually using, see below example.

I tried to install Term::ReadLine::Gnu on my Ubuntu laptop:

$ sudo apt-get install libncurses5-dev libreadline6-dev $ cpanm Term::ReadLine::Gnu
Then I tried
use feature qw(say); use strict; use warnings; use Term::ReadLine; my $term = Term::ReadLine->new('Test', \*STDIN, \*STDOUT); say "I am using the following ReadLine package: " . $term->ReadLine; $term->ornaments( 0 ); $term->addhistory("sample text added to history"); while (1) { my $line = $term->readline( 'Enter input: ' ); say "You entered: '$line'"; }

Now the up and down arrow keys are recoginzed, and used to recall the history lines. There are also some useful Emacs keybindings available, see Command Line Editing in the Gnu Bash manual for more information.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1168760]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2023-06-03 20:56 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (17 votes). Check out past polls.