in reply to VI In A Perl Script

I've never wanted to do anything like that, but do you need the vi editing to actually happen within your application? If not, you could do like most text-mode email clients and create a temporary file, fire up an editor session to edit that file, read the temp file back in when the editor closes, and then delete the temp file when you're done with it. This also has the advantage of being easy to set up such that the user can (via config file or environment setting) specify the editor of their choice instead of being hardwired to vi.

Replies are listed 'Best First'.
Re^2: VI In A Perl Script
by Metarika (Novice) on Feb 15, 2008 at 17:15 UTC
    What I've done is set up a wrapper to R, which is command-line driven. In addition to a few other things, I want to add the command-history method that KSH would use at the command-line with vi. So I do want it in my application and not by launching it as you suggested. The other thing I thought of was to use the examples of printing with escape characters that I saw in PortableReadKey. For instance it does : printf("\e[%d;%dH", $y, $x); To move the cursor to an absolute column and row. I figure there should be codes for inserting text rather than overwriting as it does now when I move the cursor around the command line. A couple of things like that and I won't need to call vi, but I can't find them. Thanks.