My first thought was this, use the ANSI terminal cursor position read function, but it doesn't work as expected (not for me at least). I guess you need a real terminal to be able to intercept the information returned....
Code:
#!/bin/bash
# from http://sunsite.nus.edu.sg/pub/os2/os...aq.2.0062.html
# Escape Code Sequence Function
# Cursor Controls
# ESC[#;#H or ESC[#;#f Moves cursor to line #, column #
# ESC[#A Moves cursor up # lines
# ESC[#B Moves cursor down # lines
# ESC[#C Moves cursor forward # spaces
# ESC[#D Moves cursor back # spaces
# ESC[#;#R Reports current cursor line and column
# ESC[s Saves cursor position for recall later
# ESC[u Return to saved cursor position
# Erase Functions
# ESC[2J Clear screen and home cursor
# ESC[K Clear to end of line
# clear screen
echo -ne "\\e[2J"
# move cursor
echo -ne "\\e[10;5H"
# print something
echo -ne "Hello"
# read cursor position - by sending the Device status report
# see http://vt100.net/docs/vt100-ug/chapter3.html#DSR
echo -ne "\\e[6n"
# this 'works', but the result gets printed to the screen!!! (not good)
Note: this is the bash echo command. The way you generate escape sequences using other echo commands is specific, so you'd need to read up on them if you wanted to try stuff.
Enough of that, this is plan B
Code:
myproIVprog | tee spy
Try running your proIV program as shown above. If it works, you should find a copy of everything sent to the screen inside the file as well. With a bit of effort, you should be able to spot cursor movements, track them and hence figure out the final cursor position.
Yes, it's a HACK!!!