#include "kantinuous.h"
#include "kant parser dispatch.h"
#include "error.h"
#include "text twiddling.h"
#include "program globals.h"
#include "graphics.h"
#include "window layer.h"

void Kantinuous(void)
{
	unsigned char	*sectionStr="\p&section\r&section\r&section\r";
	WindowPtr		mainWindow;
	enum ErrorTypes	resultCode;
	
	mainWindow=GetIndWindowPtr(kMainWindow);
	if (mainWindow!=0L)
	{
		MySelectWindow(mainWindow);
		CloseTheWindow(mainWindow);
	}
	OpenTheIndWindow(kMainWindow);
	mainWindow=GetIndWindowPtr(kMainWindow);
	InsertAfterEnd(mainWindow, sectionStr);
	while ((resultCode=ParserDispatch(mainWindow))==allsWell)
	{
		SetWindowIsModified(mainWindow, FALSE);
		CloseTheWindow(mainWindow);
		OpenTheIndWindow(kMainWindow);
		mainWindow=GetIndWindowPtr(kMainWindow);
		InsertAfterEnd(mainWindow, sectionStr);
	}
	
	HandleError(resultCode, FALSE, TRUE);
}
