Esempio n. 1
0
//-----------------------------------------------------------------------------
void NewCmdDialog::nameChanged(int s)
{
	QString n=name->itemText(s), par, a;
	int k;
	if(n.isEmpty())	return;
	QStringList ss;	ss<<(pathHelp);
	help->setSearchPaths(ss);
	help->setSource(tr("mgl_en")+".html#"+n);
	// clear old
	kind->clear();	kinds.clear();	for(k=0;k<NUM_CH;k++)	argn[k].clear();
	// try to find the keyword
	if(!parser.CmdType(n.toStdString().c_str()))	return;
	info->setText(QString::fromLocal8Bit(parser.CmdDesc(n.toStdString().c_str())));

	par = QString::fromLocal8Bit(parser.CmdFormat(n.toStdString().c_str()));
	int i0 = par.indexOf(' ');	// first space if present
	if(i0<0)	{	kind->addItem(par);	return;	}	// no arguments
	// parse kind of arguments
	par = par.mid(i0);
	for(k=0;k<NUM_CH;k++)
	{
		a = par.section('|',k,k);
		if(a.isEmpty())	break;
		a=a.trimmed();
		kinds<<n+" "+a;
		parse(argn[k],a);
	}
	kind->addItems(kinds);	kind->setCurrentIndex(0);	replace = false;
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
void NewCmdDialog::fillList()
{
	type->addItem(QPixmap(plot_xpm), tr("1D plots"));
	type->addItem(QPixmap(preview_xpm), tr("2D plots"));
	type->addItem(QPixmap(":/png/weather-clouds.png"), tr("3D plots"));
	type->addItem(QPixmap(tiles_xpm), tr("Dual plots"));
	type->addItem(QPixmap(vect_xpm), tr("Vector plots"));
	type->addItem(QPixmap(other_xpm), tr("Other plots"));
	type->addItem(QPixmap(text_xpm), tr("Text and legend"));
	type->addItem(QPixmap(table_xpm), tr("Create data and I/O"));
	type->addItem(QPixmap(oper_dir_xpm), tr("Data transform"));
	type->addItem(QPixmap(oper_dir_xpm), tr("Data handling"));
	type->addItem(QPixmap(axis_xpm), tr("Axis and colorbar"));
	type->addItem(QPixmap(axis_sh_xpm), tr("Axis setup"));
	type->addItem(QPixmap(":/png/preferences-system.png"), tr("General setup"));
	type->addItem(QPixmap(box_xpm), tr("Scale and rotate"));
	type->addItem(QPixmap(":/png/media-playback-start.png"), tr("Program flow"));
	type->addItem(QPixmap(curve_xpm), tr("Primitives"));

	// now fill it automatically from parser for all categories
	long i, n = parser.GetCmdNum();
	for(i=0;i<n;i++)
	{
		const char *name = parser.GetCmdName(i);
		switch(parser.CmdType(name))
		{
		case 1:	cmds[5]<<name;	break;
		case 2:	cmds[5]<<name;	break;
		case 3:	cmds[12]<<name;	break;
		case 4:	cmds[9]<<name;	break;
		case 5:	cmds[7]<<name;	break;
		case 6:	cmds[13]<<name;	break;
		case 7:	cmds[14]<<name;	break;
		case 8:	cmds[0]<<name;	break;
		case 9:	cmds[1]<<name;	break;
		case 10:	cmds[2]<<name;	break;
		case 11:	cmds[3]<<name;	break;
		case 12:	cmds[4]<<name;	break;
		case 13:	cmds[10]<<name;	break;
		case 14:	cmds[15]<<name;	break;
		case 15:	cmds[11]<<name;	break;
		case 16:	cmds[6]<<name;	break;
		case 17:	cmds[8]<<name;	break;
		}
	}
}
Esempio n. 3
0
//-----------------------------------------------------------------------------
void QMGLSyntax::highlightBlock(const QString &text)
{
	register int i, j, m = text.length(),s=0;
	bool arg = false, nl = true;
	QString num("+-.0123456789:");
	i=0;
	setCurrentBlockState(-1);
	if(previousBlockState()==1)
	{
		bool cont=false;
		j=i;	i++;
		for(;i<m && text[i]!='\'';i++)
		{
			if(text[i]>' ')		cont=false;
			if(text[i]=='\\')	cont=true;
		}
		setFormat(j,i-j+1,mglColorScheme[1]);
		if(cont && i==m)	setCurrentBlockState(1);
	}
	for(;i<m;i++)				// highlight paragraph
	{
		if(text[i]=='(')	s++;	if(text[i]==')')	s--;
		if(text[i]==' ' || text[i]=='\t')	continue;
		else if(text[i]=='#')	// comment
		{	setFormat(i,m-i,mglColorScheme[0]);	break;	}
		else if(text[i]=='\'')	// string
		{
			bool cont=false;
			j=i;	i++;
			for(;i<m && text[i]!='\'';i++)
			{
				if(text[i]>' ')		cont=false;
				if(text[i]=='\\')	cont=true;
			}
			setFormat(j,i-j+1,mglColorScheme[1]);
			if(cont && i==m)	setCurrentBlockState(1);
		}
		else if(nl)				// keyword
		{
			char *s = new char[m+1];
			for(j=i;j<text.length() && !text[j].isSpace() && text[j]!=':';j++)
				s[j-i] = text[j].toLatin1();
			s[j-i]=0;
			int type = parser.CmdType(s);
			if(type)	setFormat(i,j-i+1,type!=7 ? (type==5 ? mglColorScheme[6] : mglColorScheme[2]) : mglColorScheme[7]);
			delete []s;
		}
		else if(text[i]==';')	{	arg = true;	nl = false;	continue;	}
		else if(text[i]==':' && s==0)	{	nl=true;	continue;	}
		else if(arg)			// option
		{
			const char *o[13]={"xrange","yrange","zrange","cut","meshnum","alpha","light","ambient","diffuse","size","legend","number","value"};
			unsigned l;
			for(j=0;j<13;j++)
			{
				l = strlen(o[j]);
				if(text.indexOf(o[j],i)==i && (i+l==long(text.length()) || text[i+l].isSpace()))
					setFormat(i,l,mglColorScheme[3]);
			}
		}
		else if(text[i]=='.' && i+1<text.length() && text[i+1].isLetter())	// suffix
		{
			for(j=i;j<text.length() && !text[j].isSpace();j++){};
			setFormat(i,j-i+1,mglColorScheme[4]);
		}
		else if(num.contains(text[i]))	// number
			setFormat(i,1,mglColorScheme[5]);
		else if((text[i]=='e' || text[i]=='E') && i+1<text.length() && num.contains(text[i-1]) && num.contains(text[i+1]) )
			setFormat(i,1,mglColorScheme[5]);
		else		// number as its symbolic id
		{
			const char *o[]={"nan","inf","pi","on","off"};
			int l[5] = {3, 3, 2, 2, 3};
			for(j=0;j<5;j++)
				if(text.indexOf(o[j],i)==i && (i+l[j]==text.length() || text[i+l[j]].isSpace()))
					setFormat(i,l[j],mglColorScheme[5]);
		}
		arg = nl = false;
	}
}