(P.S., If I build this code with OPTIMIZE_RAM_CALLS, it crashes with the message "Line 1111 Emulator" on the TI-89 Titanium. Is this a bug?)
#include <tigcclib.h>
#define BUFFER_SIZE 200
TEXT_EDIT gsTextEdit;
CALLBACK void textEventHandler(EVENT *psEvent)
{
if (psEvent->Type == CM_KEYPRESS && psEvent->extra.Key.Code == KEY_ENTER)
ER_throw (1); /* Exit the event loop */
if (!TE_handleEvent (&gsTextEdit, psEvent))
EV_defaultHandler (psEvent);
}
void _main(void)
{
WINDOW sWindow;
HANDLE hInputBuffer;
char *pInputBuffer;
if (!WinOpen(&sWindow, &(WIN_RECT){ScrRect->xy.x0,
ScrRect->xy.y0, ScrRect->xy.x1, ScrRect->xy.y1}, WF_NOBORDER))
return;
WinFont(&sWindow, F_6x8);
WinActivate(&sWindow);
WinClr(&sWindow);
sWindow.Flags &= ~WF_DIRTY;
hInputBuffer = HeapAlloc(BUFFER_SIZE);
pInputBuffer = HeapDeref(hInputBuffer);
memset(pInputBuffer, 0, BUFFER_SIZE);
TE_openFixed(&gsTextEdit, &sWindow, &(WIN_RECT){10, 10, 159, 17},
pInputBuffer, BUFFER_SIZE - 1, TE_MORE_ELLIPSES);
TE_select(&gsTextEdit, 0, 0);
CU_start(); /* Start the cursor */
EV_captureEvents (textEventHandler);
TRY
EV_eventLoop ();
ONERR
EV_captureEvents (NULL);
ENDTRY
CU_stop(); /* Stop the cursor */
HeapFree(hInputBuffer);
WinClose(&sWindow);
}