3

I want to implement the command line features like in a linux terminal. I saw this in ftp command also.

  • If I press tab I need to list the commands.
  • If I press control characters I need to get that characters based on that I will do some action.
  • And if I give any commands it should execute.

For this I tried with Term::ReadKey that is in non-canonical mode. But here I am facing more problems like if I press any control character or arrow I got three characters. For the up arrow I got ASCII 27 91 65.

Can anyone help me out of this problem?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
sganesh
  • 1,731
  • 1
  • 13
  • 14

3 Answers3

2

I think you'd be best served by Term::Readline.

cjm
  • 61,471
  • 9
  • 126
  • 175
msw
  • 42,753
  • 9
  • 87
  • 112
  • Nice. But If I press tab I want to list my own commands not files or shell commands. – sganesh Mar 17 '10 at 05:27
  • For that you may have to drag out your compiler. There is a very well documented example at http://tiswww.case.edu/php/chet/readline/readline.html#SEC48 – msw Mar 17 '10 at 06:12
2

I got one Perl module to solve my requirement fully. that is Term::ShellUI.

Thanks for all your inputs.

And If you have any other solution is always welcome.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
sganesh
  • 1,731
  • 1
  • 13
  • 14
2

Unfortunately, the generic Term::ReadLine interface doesn't include customizable completion features. You have to pick a particular readline implementation for that.

Term::ReadLine::Gnu, Term::ReadLine::Perl, and Term::ReadLine::Zoid are all capable of performing custom completion. Term::ReadLine::Gnu is probably the best documented. Term::ReadLine::Perl is virtually undocumented, and I have no experience with Term::ReadLine::Zoid.

cjm
  • 61,471
  • 9
  • 126
  • 175