Skip to content

gettext

Thomas Foster edited this page Apr 9, 2021 · 1 revision

Function   Copies text from text mode screen to memory.

Syntaxint gettext(int left, int top, int right, int bottom, void *destin);

Prototype in   conio.h

Return valuegettext returns 1 if the operation succeeds. It returns 0 if it fails (for example, if you gave coordinates outside the range of the current screen mode).

See also movetext, puttext

Remarks

gettext stores the contents of an onscreen text rectangle defined by left, right, top, right, and bottom, into the area of memory pointed to by destin.

All coordinates are absolute screen coordinates, not window-relative.

gettext reads the contents of the rectangle into memory sequentially from left to right and top to bottom.

Each position onscreen takes 2 bytes of memory: The first byte is the character in the cell, and the second is the cell's video attribute. The space required for a rectangle w columns wide by h rows high is defined as

bytes = (h rows) × (w columns) × 2

Example

char buf[20*10*2];

/* save rectangle */
gettext(1, 1, 20, 10, buf);

/* ... */

/* restore screen */
puttext(1, 1, buf);

Header Files

Clone this wiki locally