Generally, you cannot get the screen contents, because some people view the notion of an escape sequence which can return the screen contents as a security problem.
The xterm ti/te termcap capabilities do not return the information on the screen. Instead, they tell xterm to switch between the normal and alternate screen buffers. But those cover the entire screen -- not a portion of it as your example suggests. Also, these sequences are sent by any conventional application at the beginning and end of "full-screen" mode -- so your application is likely already using the alternate screen.
Instead, your application has to keep track of what it puts on the screen, so that it can repaint after the popup window goes away. That is something that ncurses, for example, is designed to do.