[Main]
Name=TE_pasteText
Type=Function
Subtype=ROM Call
Header Files=textedit.h
Definition=void TE_pasteText (TEXT_EDIT *te, const char *text, unsigned long len);

[ROM Call]
Index=$AE

[Description]
Pastes a text into the editor.

[Explanation]
TE_pasteText inserts <I>len</I> bytes of the text pointed to by <I>text</I> into the text editor
buffer (associated with the structure pointed to by <I>te</I>) at the current cursor position.
These functions may be used together with <A HREF="$$LINK(system.h/CB_fetchTEXT)">CB_fetchTEXT</A>
and <A HREF="$$LINK(system.h/CB_replaceTEXT)">CB_replaceTEXT</A> if necessary. Also, this function
may be used for implementing various (very useful) functions like <B>TE_printf</B>
which works like <A HREF="$$LINK(stdio.h/printf)">printf</A> 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 <A HREF="$$LINK(stdio.h/vcbprintf)">vcbprintf</A>):
<PRE>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);
}
</PRE>
This example is not so simple, so you need to be familiar with (standard) C to understand it.

[References]
In=TE_handleEvent, homescr.h/HomeExecute
Out=TE_checkSlack, alloc.h/HeapRealloc, error.h/ERD_dialog, mem.h/memmove, system.h/CU_start, system.h/CU_stop, unknown.h/sf_width, wingraph.h/WinBegin, wingraph.h/WinChar, wingraph.h/WinFill, unknown.h/_du16u16, unknown.h/_mu16u16, unknown.h/_ROM_CALL_412, unknown.h/_ROM_CALL_471
Out_EV_eventLoop=1
