Textarea: Add API to access current textarea contents.

This commit is contained in:
Michael Drake 2017-09-18 20:18:20 +01:00
parent 4d84222654
commit 2a294adfb1
2 changed files with 21 additions and 0 deletions

View File

@ -2073,6 +2073,17 @@ int textarea_get_text(struct textarea *ta, char *buf, unsigned int len)
}
/* exported interface, documented in textarea.h */
const char * textarea_data(struct textarea *ta, unsigned int *len)
{
if (len != NULL) {
*len = ta->text.len;
}
return ta->text.data;
}
/* exported interface, documented in textarea.h */
bool textarea_set_caret(struct textarea *ta, int caret)
{

View File

@ -212,6 +212,16 @@ bool textarea_drop_text(struct textarea *ta, const char *text,
int textarea_get_text(struct textarea *ta, char *buf, unsigned int len);
/**
* Access text data in a text area
*
* \param[in] ta Text area
* \param[out] len Returns byte length of returned text, if passed non-NULL.
* \return textarea string data.
*/
const char * textarea_data(struct textarea *ta, unsigned int *len);
/**
* Set the caret's position
*