/** Add a variable occurency to variable group */ Variable * insertVariable(Variable * v_root, char * name, int line) { int cmp; Line * nl; if (v_root == NULL) { v_root = newVariable(name); v_root->last_line = newLine(line); } else if ((cmp = strcmp(name, v_root->name)) == 0) { v_root->count++; if (line == v_root->last_line->number) v_root->last_line->count++; else { nl = newLine(line); nl->prev = v_root->last_line; v_root->last_line = nl; } } else if (cmp > 0) v_root->right = insertVariable(v_root->right, name, line); else v_root->left = insertVariable(v_root->left, name, line); return v_root; }
void ShellService::executeMessage(Message* message) { int* params = message->getParams(); char* char_params = new char[message->getParamsLength()]; for (int i = 1; i < message->getParamsLength(); i++) { char_params[i - 1] = params[i]; } // read or write? ShellServiceCommand command = (ShellServiceCommand)params[0]; switch (command) { case NEXT_CHAR: if (char_params[0] == '\n' || char_params[0] == '\r' || char_params[0] == 13) { if (input.length() > 0) { newLine(); } executeCommand(input); input = ""; newLine(); writeLineStart(); } else { input.append(&(char_params[0])); echo(char_params[0]); } break; } }
CONFIRM getConfirm(void) { char confirm; printf("Is that right?(y for yes,n for no,q for quit)\n"); confirm = getchar(); newLine(); while(confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N' && confirm != 'q' && confirm != 'Q') { printf("Undifined choice.Please enter again.\n"); confirm = getchar(); newLine(); } switch (confirm) { case 'y': case 'Y': return yes; break; case 'n': case 'N': return no; break; case 'q': case 'Q': return quit; break; } }
void *runPeriodicTask (void *t){ TaskInfo s; // self reference Time c = 0; // completion time Time d = 0; // deadline s = periodicTaskTable[*(int *)t]; while (systemNotCompleted()){ // Compute the deadline or the next activation d=nextActivation(s.period); putHeader (s.name); putString ("activated"); newLine(); // Simulate the execution of this task using // computeDuringTimeSpan. Provide the name of the task, its worst // case execution time, and the period of the task. ATTENTION : // the period parameter in computeDuringTimeSPan is used to // compute the execution priority. It returns the completion time // that should be used to check whether the task missed its // deadline. Use variable c to save this value. See tasks.h. // NYI("compute task for its computation time"); //******************************************************** c = computeDuringTimeSpan(s.name, s.computation, s.period); // NYI("save the completion time in variable c for later use"); //******************************************************** // c = timeAfterTimeSpan(s.computation); putHeader (s.name); putString ("completed"); newLine(); // Check that the completion time did not occur after the deadline if (d < c) { putHeader (s.name); putString ("OVERRUN "); putTime (d); putString (" < "); putTime (c); newLine(); break; }; // Wait for the next activation. In other words, wait for the deadline. // NYI("wait for the next activation"); //********************************************************** delayUntil(d); } return NULL; }
bool GlyphString::layout() { if (mState == Invalid) return false; for (int i = 0; i < mSize; ++i) { mMap[i] = i; mLines[i] = -1; } mLineInfos.clear(); int lineNo = 0; int width = 0; int lineStart = 0; int lastSpace = -1; for (int i = 0; i <= mSize; ++i) { if (i == mSize) { mLineInfos.push_back(newLine(lineStart, i, lineNo++)); break; } //if (mCodePoints[i] == ' ') { if (mTypes[i] == FRIBIDI_TYPE_WS) { if (lineStart == i) { lineStart = i + 1; continue; } else if (lastSpace == i - 1) { clearGlyph(i - 1); lastSpace = i; continue; } lastSpace = i; } width += mGeometries[i].xAdvance; if (mMaxWidth < width) { if (lineStart == i) { return false; } if (lastSpace > lineStart) { mLineInfos.push_back(newLine(lineStart, lastSpace, lineNo++)); width = 0; lineStart = lastSpace + 1; i = lastSpace; continue; } else { mLineInfos.push_back(newLine(lineStart, i, lineNo++)); width = 0; lineStart = i; --i; continue; } } } mState = LaidOut; return true; }
/** * This is the main method. */ int main() { dtoch(42); newLine(); dtoch(11829); newLine(); dtoch(-42); newLine(); dtoch(0); newLine(); return 0; }
void FakeBacktraceGenerator::sendData(const QString & filename) { QFile file(filename); file.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream stream(&file); emit starting(); while (!stream.atEnd()) { emit newLine(stream.readLine() + '\n'); } emit newLine(QString()); }
/* * _UpdateInputLine - add data to current line; return number of chars * on next line if line break was forced */ int _UpdateInputLine( LPWDATA w, char *line, unsigned len, BOOL force_add ) { int i,j; BOOL justnew=FALSE; BOOL wassplit=FALSE; _AccessWinLines(); w->lineinprogress = TRUE; j = w->buffoff; for( i = 0; i < len; i++ ) { justnew = FALSE; if( TOOWIDE( j, w ) ) { #ifdef _MBCS FAR_mbccpy( FAR_mbsninc( (LPBYTE)w->tmpbuff->data, j ), (LPBYTE)"" ); #else w->tmpbuff->data[j] = 0; #endif w->buffoff = j; newLine( w ); j = 0; justnew = TRUE; wassplit = TRUE; } #ifdef _MBCS FAR_mbccpy( FAR_mbsninc( (LPBYTE)w->tmpbuff->data, j ), FAR_mbsninc( (LPBYTE)line, i ) ); #else w->tmpbuff->data[j] = line[i]; #endif j++; } #ifdef _MBCS FAR_mbccpy( FAR_mbsninc( (LPBYTE)w->tmpbuff->data, j ), (LPBYTE)"" ); #else w->tmpbuff->data[j] = 0; #endif if( force_add && !justnew ) { w->buffoff = j; newLine( w ); } else { _DisplayLineInWindow( w, w->LastLineNumber - w->TopLineNumber + 1, w->tmpbuff->data ); if( !wassplit ) { j = -1; } } _ReleaseWinLines(); return( j ); } /* _UpdateInputLine */
void printString(FILE *stream, Print_Data_Ptr printer, const char *pString, int32 keepWithNext) { int32 length; if (!printer->truncatedGlobal) { if (pString) length = strlen(pString); else length = 0; if ((printer->cursorPosGlobal + length + keepWithNext) > LINE_LENGTH) { newLine(stream, printer); printTab(stream, printer, GET_M_GLOBAL(indentGlobal)+1); } if (printer->lineNumGlobal < PRINT_LENGTH) { if (pString) { (void)fprintf(stream, "%s", pString); printer->cursorPosGlobal += length; } else { (void)fprintf(stream, "NULL"); printer->cursorPosGlobal += 4; } } else { printer->truncatedGlobal = 1; (void)fprintf(stream, "..."); } } }
static void run(void) { uint8_t byte; uint8_t x; uint8_t y; if(streamPop(lcdout, &byte)) { switch(byte) { case '\r': sendByte(false, CLEAR_DISPLAY); outOfBounds = false; break; case '\n': newLine(); outOfBounds = false; break; case '\v': if(streamPop(lcdout, &x) && streamPop(lcdout, &y)) { setCurser(x - 1, y - 1); outOfBounds = false; } break; case '\a': state = clearCurrentLine; outOfBounds = false; break; default: if(!outOfBounds) { writeCharacter(byte); } } } else { delay(&task, MS_TO_TICKS(20)); } }
void BacktraceGenerator::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus) { //these are useless now m_proc->deleteLater(); m_temp->deleteLater(); m_proc = NULL; m_temp = NULL; //mark the end of the backtrace for the parser emit newLine(QString()); if (exitStatus != QProcess::NormalExit || exitCode != 0) { m_state = Failed; emit someError(); return; } //no translation, string appears in the report QString tmp("Application: %progname (%execname), signal: %signame\n"); Debugger::expandString(tmp); m_parsedBacktrace = tmp + m_parser->parsedBacktrace(); m_state = Loaded; #ifdef BACKTRACE_PARSER_DEBUG //append the raw unparsed backtrace m_parsedBacktrace += "\n------------ Unparsed Backtrace ------------\n"; m_parsedBacktrace += m_debugParser->parsedBacktrace(); //it's not really parsed, it's from the null parser. #endif emit done(); }
//TODO: if the line added is not visible scroll down one void CodeEditor::addLine(const String &line) { Font *font = Preferences::instance()->getFont(); Text newLine(line, *font, mFontSize); newLine.setDoMultiColor(false); newLine.setPosition(mPos.x + mLineNumberAreaWidth, mText[mCurrentLine].getPosition().y + mFontSize + 2); newLine.setColor(mTextColor); if (mUpperBound < getLineLength(mCurrentLine)) { newLine.append(getLine(mCurrentLine).substring(mUpperBound, getLineLength(mCurrentLine) - mUpperBound)); mText[mCurrentLine].erase(mUpperBound, getLineLength(mCurrentLine) - mUpperBound); } mUpperBound = 0; mLineIndex = 0; if (++mCurrentLine > (getLineCount() - 1)) { mText.push_back(newLine); } else { mText.insert(mText.begin() + mCurrentLine, newLine); //Shift the lines down. for (int i = mCurrentLine + 1; i < mText.size(); ++i) { mText[i].setPosition(mPos.x + mLineNumberAreaWidth, mText[i].getPosition().y + mFontSize + 2); } } addLineNumber(); --mCurrentLine; moveCursorDownOne(); }
/* new line capture signal */ void Pit1ISR(void) { uint8_t i=0; PIT.CH[1].TCTRL.R = 0x000000000; /* Disable PIT1 interrupt & disable PIT counting */ if(flag_lineDone==-1) { TriggerCamera(); DumpCameraBuffer(); flag_lineDone = 0; PIT.CH[1].LDVAL.R = exposureTime*64; /* Timeout = exposureTime us */ } else if(flag_lineDone==0) { newLine(); flag_lineDone=1; PIT.CH[1].LDVAL.R = (STEERING_CONTROL_INTERVAL)*64000-exposureTime*64; } else { PIT.CH[1].LDVAL.R = 500; /* Timeout = 500 us */ flag_lineDone = -1; } PIT.CH[1].TCTRL.R = 0x000000003; /* Enable PIT1 interrupt & start PIT counting */ PIT.CH[1].TFLG.B.TIF = 1; /* MPC56xxP/B/S: CLear PIT 1 flag by writing 1 */ }
void Pretty::visitBlock(JCBlock* that) { print("{"); indent(); newLine(); auto begin = that->stats.begin(); auto end = that->stats.end(); for (auto item = begin; item != end; ++item) { (*item)->accept(this); if (item + 1 == end) { undent(); } newLine(); } print("}"); }
void LevelLoader::loadLine(QDomElement lineNode) { // Reading the line number QDomAttr attribute = lineNode.attributeNode(QStringLiteral("Number")); QDomElement attributeNode = lineNode.firstChildElement(QStringLiteral("Number")); if (!attribute.isNull()) { m_lineNumber = attribute.value().toInt(); } else if (!attributeNode.isNull()) { m_lineNumber = attributeNode.text().toInt(); } else { // Standard line numbering: load next line m_lineNumber++; } // Reading the brick information attribute = lineNode.attributeNode(QStringLiteral("Bricks")); attributeNode = lineNode.firstChildElement(QStringLiteral("Bricks")); QString line; if (!attribute.isNull()) { line = attribute.value(); } else if (!attributeNode.isNull()) { line = attributeNode.text(); } else { line = lineNode.text(); } if (line.size() > WIDTH) { qCritical() << "Invalid levelset " << m_levelname << ": too many bricks in line " << m_lineNumber << endl; } emit newLine(line, m_lineNumber); }
void SdlSymbolIconView::UpdateTexture() { double scale = 1.0; Config *cfg = Config::GetInstance(); // Scale the symbol font to fit the bounds. double iconFontSize = model.GetSize().y * 1.20; UiFont font(cfg->GetDefaultSymbolFontName(), iconFontSize); if (!model.IsLayoutUnscaled()) { font.size *= (scale = display.GetUiScale()); } int wtext[] = { model.GetSymbol() }; std::string text; utf8::utf32to8(wtext, wtext + 1, std::back_inserter(text)); std::unique_ptr<TypeLine> newLine(new TypeLine()); auto typeCase = display.GetTypeCase(font); typeCase->Prepare(text, newLine.get()); typeLine.swap(newLine); auto &glyphRect = typeLine->glyphs[0].first->srcRect; width = glyphRect.w; height = glyphRect.h; // We pre-scale the texture (by adjusting the font size) so that would // normally throw off the size adjustments later, so we need to keep track // of what the size would be (approximately) if we hadn't pre-scaled the // texture. unscaledWidth = width / scale; unscaledHeight = height / scale; }
QByteArray MediaManager::createMultipartFormData(const QMap< QString, QByteArray >& formdata, const QList< QMap< QString, QByteArray > >& mediaFiles) { QByteArray newLine("\r\n"); QString formHeader( newLine + "Content-Disposition: form-data; name=\"%1\"" ); QByteArray header(newLine + "--AaB03x"); QByteArray footer(newLine + "--AaB03x--"); QString fileHeader(newLine + "Content-Disposition: file; name=\"%1\"; filename=\"%2\""); QByteArray data; data.append(header); if ( !mediaFiles.isEmpty() ) { QList< QMap< QString, QByteArray > >::const_iterator it1 = mediaFiles.constBegin(); QList< QMap< QString, QByteArray > >::const_iterator endIt1 = mediaFiles.constEnd(); for(; it1!=endIt1; ++it1){ data.append( fileHeader.arg(it1->value("name").data()).arg(it1->value("filename").data()).toUtf8() ); data.append(newLine + "Content-Type: " + it1->value("mediumType")); data.append(newLine); data.append(newLine + it1->value("medium")); } } QMap< QString, QByteArray >::const_iterator it = formdata.constBegin(); QMap< QString, QByteArray >::const_iterator endIt = formdata.constEnd(); for(;it!=endIt; ++it){ data.append(header); data.append(formHeader.arg(it.key()).toLatin1()); data.append(newLine); data.append(newLine + it.value()); } data.append(footer); return data; }
TextManager::TextManager() : death_print(0) { newLine("The Warlock of Firetop Mountain bids you welcome. 'Mahahahahah!!'"); m_step = 0; }
void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before) { if (before == 0) { if (!lines.isEmpty() && lines.last().toolBarItems.isEmpty()) return; lines.append(QToolBarAreaLayoutLine(o)); return; } for (int j = 0; j < lines.count(); ++j) { QToolBarAreaLayoutLine &line = lines[j]; for (int k = 0; k < line.toolBarItems.count(); ++k) { if (line.toolBarItems.at(k).widgetItem->widget() == before) { if (k == 0) return; QToolBarAreaLayoutLine newLine(o); newLine.toolBarItems = line.toolBarItems.mid(k); line.toolBarItems = line.toolBarItems.mid(0, k); lines.insert(j + 1, newLine); return; } } } }
int main (int argc, const char * argv[]) { init(); #ifdef RELEASE asmheader(); #endif do { switch (look) { case '?': input(); break; case '!': output(); break; default: assignment(); break; } newLine(); } while ('.' != look); #ifdef RELEASE asmfooter(); #endif return 0; }
void HistoryScrollBuffer::addCells(const Character a[], int count) { HistoryLine newLine(count); qCopy(a,a+count,newLine.begin()); addCellsVector(newLine); }
void ShellService::echo(char ch) { // int length = echo.size(); // int* params = new int[length + 1]; int posX = SHELL_X_START + (_currentColumn * COLUMN_WIDTH); if (posX >= SHELL_X_END) { newLine(); posX = SHELL_X_START; } int posY = SHELL_Y_START + (_currentLine * LINE_HEIGHT); if (posY > SHELL_Y_END) { setColor(0x0); moveTo(SHELL_X_START, SHELL_Y_START - (LINE_HEIGHT + 5)); drawRect(SHELL_X_END, SHELL_Y_END); _currentColumn = 0; _currentLine = 0; posY = SHELL_Y_START; posX = SHELL_X_START; } while (!hasScreen()); setColor(0xFFFFFF); moveTo(posX, posY); drawChar(ch, 2); _currentColumn++; // params[0] = 0; // HDMI WRITE COMMAND :) // for (int i = 0; i < length; i++) { // params[i + 1] = (int)(echo.c_str()[i]); // } // performServiceCall(DISPLAY_SERVICE_ID, 2, params); }
void Terminal::putChar(char c) { if(c == '\n') newLine(); else if(c == '\b') putEntryAt(' ', _profile, --_column, _row); else if(c == '\t') putString(" "); else if(c != '\0') { putEntryAt(c, _profile, _column++, _row); if(_column == vga::width) newLine(); } if(!_writing) moveCursor(_column, _row); }
void TextLayout::addRightLine( const string &line ) { shared_ptr<Line> newLine( new Line() ); newLine->addRun( Run( line, mCurrentFont, mCurrentColor ) ); newLine->mJustification = Line::RIGHT; newLine->mLeadingOffset = mCurrentLeadingOffset; mLines.push_back( newLine ); }
// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// bool LuaStateManager::ExecuteResourceFile(LuaPlus::LuaStateOwner &luaState, const char * const scriptName, ResCache *rcManagerPtr) { if(!rcManagerPtr || !scriptName || strlen(scriptName) == 0) { return (false); } std::string rn(scriptName); TextResource tr(rn); boost::shared_ptr<TextResHandle> scriptHandle = boost::static_pointer_cast<TextResHandle>(rcManagerPtr->GetHandle(&tr)); if(!scriptHandle || !scriptHandle->VInitialize()) { GF_LOG_TRACE_ERR("LuaStateManager::ExecuteResourceFile()", std::string("Failed to initialize from cache: ") + tr.GetName()); return (false); } std::string scriptData(scriptHandle->GetTextBuffer()); // Split up the file by the newline character. #ifdef _WINDOWS std::string newLine("\n"); #else std::string newLine("\t\n"); #endif // Make a large vector to prevent repeating reallocations (500 - we dont know how long the file is, this is a guess to help reduce reallocations). std::vector<std::string> linesVec; linesVec.reserve(500); boost::algorithm::split(linesVec, scriptData, boost::algorithm::is_any_of(newLine)); // Trim excess capacity. std::vector<std::string>(linesVec.begin(), linesVec.end()).swap(linesVec); RemoveTrailingCr fo; std::for_each(linesVec.begin(), linesVec.end(), fo); scriptData.clear(); for(std::vector<std::string>::iterator i = linesVec.begin(), end = linesVec.end(); i != end; ++i) { scriptData += *i; } if(luaState->DoString(scriptData.c_str()) != 0) { GF_LOG_TRACE_ERR("LuaStateManager::ExecuteResourceFile()", std::string("Failed to execute ") + tr.GetName()); return (false); } return (true); }
//! [10] void DiagramScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { if (myMode == InsertLine && line != 0) { QLineF newLine(line->line().p1(), mouseEvent->scenePos()); line->setLine(newLine); } else if (myMode == MoveItem) { QGraphicsScene::mouseMoveEvent(mouseEvent); } }
//Call newLine() to create the line. //Rebuild your application, load it in AutoCAD and run it. void addLineCommand() { //{{BEGIN_LEVEL_ADVANCED if (newLine()==Acad::eOk) acutPrintf("Success\n"); else acutPrintf("Failed\n"); //{{END_LEVEL_ADVANCED }
/*--------------------------------------------------------------------------*/ char *TerminalGetString(char *prompt) { if (InitTerm) { InitializeTerminal(); InitTerm = FALSE; } newLine(); setCurrentPrompt(prompt); /* print the prompt */ displayPrompt(); /* initialize history search */ setSearchedTokenInScilabHistory(NULL); for (;;) { unsigned char cur_char = TerminalGetchar(); if (cur_char <= 0) { return NULL; } /* http://bugzilla.scilab.org/show_bug.cgi?id=1052 */ if (ismenu () == 1) { /* Abort current line */ return NULL; } if ( (cur_char == CR_1) || (cur_char == CR_2) ) { if ( isHistorySearch() ) { putLineSearchedHistory(); } else { char *line = getCurrentLine(); TerminalPutc('\n'); appendLineToScilabHistory(line); return line; } } else { TerminalPutc(cur_char); addCharacterCurrentLine(cur_char); } } return NULL; }
int drawSide(int page) { int i, j, n=3; char *contents[] = {"Introduction", "Hello Hammertime!", "The Basics"}; char str[1000][1000]; registerBody("NULL", newTextBox(10, 1, " HAMMERTIME ", -1, '#')); registerBody("NULL", newLine(2, 4, 150, 'h', '-')); registerBody("NULL", newText(10, 5, "Table of Content", 0)); registerBody("NULL", newLine(10, 6, 16, 'h', '_')); for(i=0;i<n;i++) { sprintf(str[2*i], "t%d", i); sprintf(str[2*i+1], "%d. %s", i, contents[i]); registerBody(str[2*i], newText(8, 10+2*i, str[2*i+1], 0)); } registerBody("NULL", newPoint(13, 10+2*page, '*')); return n; }
int Q3DockWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = Q3Frame::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 8) qt_static_metacall(this, _c, _id, _a); _id -= 8; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = closeMode(); break; case 1: *reinterpret_cast< bool*>(_v) = isResizeEnabled(); break; case 2: *reinterpret_cast< bool*>(_v) = isMovingEnabled(); break; case 3: *reinterpret_cast< bool*>(_v) = isHorizontallyStretchable(); break; case 4: *reinterpret_cast< bool*>(_v) = isVerticallyStretchable(); break; case 5: *reinterpret_cast< bool*>(_v) = isStretchable(); break; case 6: *reinterpret_cast< bool*>(_v) = newLine(); break; case 7: *reinterpret_cast< bool*>(_v) = opaqueMoving(); break; case 8: *reinterpret_cast< int*>(_v) = offset(); break; case 9: *reinterpret_cast< Place*>(_v) = place(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setCloseMode(*reinterpret_cast< int*>(_v)); break; case 1: setResizeEnabled(*reinterpret_cast< bool*>(_v)); break; case 2: setMovingEnabled(*reinterpret_cast< bool*>(_v)); break; case 3: setHorizontallyStretchable(*reinterpret_cast< bool*>(_v)); break; case 4: setVerticallyStretchable(*reinterpret_cast< bool*>(_v)); break; case 6: setNewLine(*reinterpret_cast< bool*>(_v)); break; case 7: setOpaqueMoving(*reinterpret_cast< bool*>(_v)); break; case 8: setOffset(*reinterpret_cast< int*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }