I'm writing a command-line Tcl script, and I would like to open up a text editor (vi, emacs, etc.) to allow the user to enter formatted input.
My initial attempt at this failed. Here's what I did:
1. created a unique temporary file name
2. used the "exec" command to open the unique file with the editor
3. open the file using the "open" command
4. read the contents of the file using the "read" command
This approach almost works. The only problem is that the editor is not brought to the foreground, so you can't actually see the text you are entering. I can blindly type some text, save the file and exit the editor at which point the Tcl script continues executing at step 3 and 4 and I actually read the text I just blindly entered.
Is there a way to get the editor to come into the foreground (STDOUT) so that I can see the text I'm entering?
My initial attempt at this failed. Here's what I did:
1. created a unique temporary file name
2. used the "exec" command to open the unique file with the editor
3. open the file using the "open" command
4. read the contents of the file using the "read" command
This approach almost works. The only problem is that the editor is not brought to the foreground, so you can't actually see the text you are entering. I can blindly type some text, save the file and exit the editor at which point the Tcl script continues executing at step 3 and 4 and I actually read the text I just blindly entered.
Is there a way to get the editor to come into the foreground (STDOUT) so that I can see the text I'm entering?