QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
Getting PtTerminal Screen |
Ref. No. |
QNX.000009785 |
Category(ies) |
Development |
Issue |
We developped an application, similar to a pterm, where we need to capture an image of the screen in ASCII. We would like to be able to get a copy of all characters on the screen in a buffer of 80X25 (coloumns X rows) or some other size, depending on the current screen size. By looking at PtTty and PtTerminal we tried to access 'screen' item in the PtTerminal structure, but without success (program SIGSEGV's).
What is the right way to do this?
|
Solution |
The 'screen' item is what we would recommend, except the correct way of accessing it is by getting the Pt_ARG_TERM_CONSOLE resource.
Here is a one way: x09 x09PtArg_t args[3]; x09char const *scr; x09PtTerminalRowCol_t const *size; x09PtTerminalColorMode_t const *cm; x09int i, j; x09PtSetArg(&args[0], Pt_ARG_TERM_CONSOLE, &scr,0); x09PtSetArg(&args[1], Pt_ARG_TERM_SIZE, &size, 0); x09PtGetResources(widget, 3, args); x09for(i=0; i <size->i; ++i) x09{ x09x09for(j=0; j<size->j, ++j) x09x09{ x09x09x09putchar(*scr); x09x09x09scr += cm->size; x09x09} x09x09putchar("n"); x09}
Another way would be to use the Pt_ARG_TERM_SELECTION resource to select the entire screen and then call PtTerminalGetSelection() to get its contents.
One significant difference between those two methods is that PtTerminalGetSelection() translates any non-ASCII characters to UTF, while the first method gives you the widget's internal codes (by default, PtTerminal uses the PC character set internally). |
|