TE_pasteText Function (ROM Call 0xAE)

textedit.h

void TE_pasteText (TEXT_EDIT *te, const char *text, unsigned long len);

Pastes a text into the editor.

TE_pasteText inserts len bytes of the text pointed to by text into the text editor buffer (associated with the structure pointed to by te) at the current cursor position. These functions may be used together with CB_fetchTEXT and CB_replaceTEXT if necessary. Also, this function may be used for implementing various (very useful) functions like TE_printf which works like printf but "prints" the formatted output into the text editor. Among various ways of implementing such functions, I suggested the following one (which uses the unusual but powerful function vcbprintf):

CALLBACK void TE_pasteChar(char c, TEXT_EDIT *te)
{
  char str[2] = {c, 0};
  TE_pasteText (te, str, 1);
}

void TE_printf(TEXT_EDIT *te, char *format, ...)
{
  va_list arglist;
  va_start (arglist, format);
  vcbprintf ((vcbprintf_callback_t)TE_pasteChar, (void**)te, format, arglist);
  va_end (arglist);
}
This example is not so simple, so you need to be familiar with (standard) C to understand it.


Uses: TE_checkSlack, HeapRealloc, ERD_dialog, memmove, CU_start, CU_stop, sf_width, WinBegin, WinChar, WinFill, _du16u16, _mu16u16, ROM Call 0x412, ROM Call 0x471
Used by: TE_handleEvent, HomeExecute