zvt_term_get_buffer

Name

zvt_term_get_buffer —

Synopsis

char * zvt_term_get_buffer (ZvtTerm * term, int * len, int type, int sx, int sy, int ex, int ey);

Arguments

term

Valid ZvtTerm widget.

len

Placeholder to store the length of text selected. May be NULL in which case the value is not returned.

type

Type of selection. VT_SELTYPE_LINE, select by line, VT_SELTYPE_WORD, select by word, or VT_SELTYPE_CHAR, select by character.

sx

Start of selection, horizontal.

sy

Start of selection, vertical. 0 is the top of the visible screen, <0 is scrollback lines, >0 is visible lines (upto the height of the window).

ex

End of selection, horizontal.

ey

End of selection, vertical, as above.

Description

Convert the buffer memory into a contiguous array which may be saved or processed. Note that this is not gauranteed to match the order of characters processed by the terminal, only the order in which they were displayed. Tabs will normally be preserved in the output.

All inputs are range-checked first, so it is possible to fudge a full buffer grab.

Examples

Example 1.

data = zvt_term_get_buffer(term, NULL, VT_SELTYPE_LINE, -term->vx->vt.scrollbackmax, 0, term->vx->vt.height, 0); or, as a rule - data = zvt_term_get_buffer(term, NULL, VT_SELTYPE_LINE, -10000, 0, 10000, 0);

Will return the contents of the entire scrollback and on-screen buffers, remembering that all inputs are range-checked first.

data = zvt_term_get_buffer(term, NULL, VT_SELTYPE_CHAR, 0, 0, 5, 10);

Will return the first 5 lines of the visible screen, and the 6th line upto column 10.

Return value

A pointer to a NUL terminated buffer containing the raw text from the buffer. If memory could not be allocated, then returns NULL. Note that it is upto the caller to free the memory, using g_free(3c). If len was supplied, then the length of data is stored there.