/***************************************************************************
 *   Copyright (C) 2010 by Juergen Thies                                   *
 *   layout@juergenthies.de                                                *
 *                                                                         *
 ***************************************************************************/
#include "textedit/textdisplay.h"


void macro::textDisplayHandler_registerKeywords(keywords **keyword_){
  *keyword_= new keywords(*keyword_);
 (*keyword_)->keyword="textDisplay";
 (*keyword_)->type=type;
 (*keyword_)->typeHandler=&macro::textDisplayHandler_typeHandler;
}

void macro::textDisplayHandler_typeHandler(int *counter,keywords **keyword_,bool single){
generalTypeProcessing(counter,keyword_,ptrTextDisplay,ptrTextDisplay,single);
}

returnValue macro::textDisplayHandler_classHandler(int *counter, keywords *keyword_,returnValue* r,bool left){
 QString s;
 returnValue ret;
 parserValue p;
 if (r->type==ptrTextDisplay){
   if (checkClassPointer(counter)) {
   }
   else { 
   	if (left) { compute(r,counter,keyword_);return ret;}
     	else return *r;
	}
   }
 textDisplay *l= r->getTextDisplay();
 p=next(counter);
  if (((p.type==keyword)&&(p.value=="openFile"))) { testParenOpen(counter);
	returnValue s=calculate(counter,keyword_);testParenClose(counter);
	l->openFile(s.getString());}
 else if (((p.type==keyword)&&(p.value=="saveFile"))) { testParenOpen(counter);
	returnValue s=calculate(counter,keyword_);testParenClose(counter);
	l->saveFile(s.getString());}
  else if (((p.type==keyword)&&(p.value=="setText"))) { testParenOpen(counter);
	returnValue s=calculate(counter,keyword_);testParenClose(counter);
	l->setText(s.getString());}
  else if (((p.type==keyword)&&(p.value=="setLexer"))) { testParenOpen(counter);
	returnValue s=calculate(counter,keyword_);testParenClose(counter);
	l->setLexer(s.getString());}
 else {
  	error->addItem(tr("Class textDisplay has no member ")+p.value,1,message((*counter)));
	throw 1;
 	}
 if (left)  if (!checkSemicolon(counter)) {throw 15;}  
 return ret;
}

