but unfortunately it doesn't work if I put this at the top of the script$input = Complete('prompt_string', \@completion_list);
That's the wrong place. You probably must make the mainloop aware of tab completion via set_binding(), and handle the completion in a subroutine. Another candidate is add_callback().
Edit:
use Curses::UI; use Term::Complete; ... sub complete { my @words = ( 'perl', 'pepper', 'peace' ); # thanks marto! my $input = Complete('',\@words); $editor->add_string($input); } ... $cui->set_binding(\&complete,"\t");
Note that with this binding you have to press <Tab> twice, one to invoke sub complete, then for the completion itself.
You will have to get the substring upon which the completion was invoked and strip that from $input and handle the newline which ends the completion routine by repositioning the cursor. Or just do a screen redraw (bound to ^L).
In reply to Re: word auto-corrector in Curses::UI
by shmem
in thread word auto-corrector in Curses::UI
by Bpl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |