inline void ActionForSourceCodeScript::pushStr(void) { char* lastToken = getLastToken(); if (NULL != lastToken) { mData.push(RuntimeBuilderData::TokenInfo(lastToken, RuntimeBuilderData::STRING_TOKEN)); } }
//Determines which token(s) from the list that should be in the replacement char *getTokenSequenceForList (struct token *list, int *iPointer, const char *oldLine, int *replacementStatus) { if (oldLine[iPointer[0]] == '^'){ return getTokenForPos (list, 1); } else if (oldLine[iPointer[0]] == '$'){ return getLastToken (list); } else if (oldLine[iPointer[0]] == ':'){ if (strlen(&oldLine[iPointer[0]]) > 1) { if (oldLine[iPointer[0] + 1] >= 48 && oldLine[iPointer[0] + 1] <= 57) { char *endptr; int tokenNum = strtol (&oldLine[iPointer[0] + 1], &endptr, 10); char *tokenReturned = getTokenForPos (list, tokenNum); int numLength = getIntLength (tokenNum); iPointer[0] += numLength; return tokenReturned; } } } else if (oldLine[iPointer[0]] == '*'){ return convertAllButFirst (list); } iPointer[0] --; return convertTokensToString(list); }
void Layered::fillProperties(ParsedBlock& pb) { char name[128]; char value[256]; int srcLine; for (int i = 0; i < pb.getBlockLines(); i++) { // fetch and parse all lines like "layer <shader>, <color>[, <texture>]" pb.getBlockLine(i, srcLine, name, value); if (!strcmp(name, "layer")) { char shaderName[200]; char textureName[200] = ""; bool err = false; if (!getFrontToken(value, shaderName)) { err = true; } else { stripPunctuation(shaderName); } if (!strlen(value)) err = true; if (!err && value[strlen(value) - 1] != ')') { if (!getLastToken(value, textureName)) { err = true; } else { stripPunctuation(textureName); } } if (!err && !strcmp(textureName, "NULL")) strcpy(textureName, ""); Shader* shader = NULL; Texture* texture = NULL; if (!err) { shader = pb.getParser().findShaderByName(shaderName); err = (shader == NULL); } if (!err && strlen(textureName)) { texture = pb.getParser().findTextureByName(textureName); err = (texture == NULL); } if (err) throw SyntaxError(srcLine, "Expected a line like `layer <shader>, <color>[, <texture>]'"); double x, y, z; get3Doubles(srcLine, value, x, y, z); addLayer(shader, Color((float) x, (float) y, (float) z), texture); } } }
/*! \brief \fn CCompletion::complete \param c \param trigger */ void CCompletion::complete(const QDocumentCursor &c, const QString &trigger) { // test if there is selected text // etendre le texte selectionner au mot complet // si il a pour next char une ( alors afficher un calltips if ( (trigger == "(" ) || !c.selectedText().isEmpty()) { QStringList tips; //qDebug("fn %s", fn.constData()); QList<QCodeNode*> nodes = mainwindow->windowide->completionScan(editor()); tips = mainwindow->windowide->getProc(getLastToken(c)); if ( tips.count() ) { CDOxyItem * di = mainwindow->windowide->getDOxygenInfo(getLastToken(c).trimmed()); if (di) { tips[0] += QString("\n")+di->brief; if (di->params.count()) { for (int j=0;j<di->params.size();j++) { tips[0] += QString("\n")+di->params.at(j); } } if (!(di->returnTyp.isEmpty())) tips[0]+=QString("\nReturn value : ")+di->returnTyp; if (tips[0].right(1)=="\n") tips[0].chop(1); } QRect r = editor()->cursorRect(); QDocumentCursor cursor = editor()->cursor(); QDocumentLine line = cursor.line(); int hx = editor()->horizontalOffset(), cx = line.cursorToX(cursor.columnNumber()); QCallTip *ct = new QCallTip(editor()->viewport()); ct->move(cx - hx, r.y() + r.height()); ct->setTips(tips); ct->show(); ct->setFocus(); #ifdef TRACE_COMPLETION qDebug("parsing + scoping + search + pre-display : elapsed %i ms", time.elapsed()); #endif } } else { if ( pPopup && pPopup->editor() != editor() ) { delete pPopup; pPopup = 0; } if ( !pPopup ) { pPopup = new QCodeCompletionWidget(editor()); } pPopup->clear(); pPopup->setCursor(editor()->cursor()); QTime time; time.start(); QList<QCodeNode*> nodes = mainwindow->windowide->completionScan(editor()); pPopup->setPrefix(getLastToken(c)); pPopup->setCompletions(nodes); pPopup->update(); pPopup->popup(); } #if 1 #endif }