int main(void) { Run r[20]; int numRuns = readRunsFromFile(r, "run.data"); char loop; displayRuns(r, numRuns); printf("(a)dd run or (q)uit: "); scanf("%c", &loop); if(loop == 'q') printf("\n"); while(loop != 'q') { printf("\n"); if (loop == 'a') numRuns = addRun(r, numRuns); printf("\n"); displayRuns(r, numRuns); printf("(a)dd run or (q)uit: "); scanf(" %c", &loop); printf("\n"); } writeFile(r, numRuns); printf("Happy trails!\n"); return 0; }
void TestRailInterface::updateSectionsComboData(int exitCode, QProcess::ExitStatus exitStatus) { // Quit if user has previously cancelled if (_testRailRunSelectorWindow.getUserCancelled()) { return; } // Check if process completed successfully if (exitStatus != QProcess::NormalExit) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not get sections from TestRail"); exit(-1); } // Create map of sections from the file created by the process _sectionNames.clear(); QString filename = _outputDirectory + "/sections.txt"; if (!QFile::exists(filename)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not find sections.txt in " + _outputDirectory); exit(-1); } QFile file(filename); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not open " + filename); exit(-1); } QTextStream in(&file); QString line = in.readLine(); while (!line.isNull()) { // The section name is all the words except for the last // The id is the last word QString section = line.left(line.lastIndexOf(" ")); QString id = line.right(line.length() - line.lastIndexOf(" ") - 1); _sectionIDs.push_back(id.toInt()); _sectionNames << section; line = in.readLine(); } file.close(); // Update the combo _testRailRunSelectorWindow.updateSectionsComboBoxData(_sectionNames); _testRailRunSelectorWindow.exec(); if (_testRailRunSelectorWindow.getUserCancelled()) { return; } // The test cases are now read from TestRail // When this is complete, the Run can be created addRun(); }
int main(void) { Run r[MAX_RUNS]; int numRuns; numRuns = readFile(r); displayRuns(r, numRuns); addRun(r, numRuns); printf("\nHappy trails!\n"); return 0; }
TextGroup::TextGroup(const std::string &input, hb_script_t script, const std::string &lang, hb_direction_t overallDirection) :script_(script) ,lang_(lang) ,overallDirection_(overallDirection) { if(hb_script_get_horizontal_direction(script_) == HB_DIRECTION_LTR) { addRun(input, HB_DIRECTION_LTR); } else { auto text = UnicodeString::fromUTF8(input); auto length = text.length(); printf("Hominlinx-->TextGroup::TextGroup str unicodelen[%d] ====text[0x%x]\n",length, text.charAt(0) ); UErrorCode err = U_ZERO_ERROR; UBiDi *bidi = ubidi_openSized(length, 0, &err);//Bidrectional text ubidi_setPara(bidi, text.getBuffer(), length, hbDirectionToUBIDILevel(overallDirection_), 0, &err); auto direction = ubidi_getDirection(bidi); if(direction != UBIDI_MIXED) { addRun(input, uciDirectionToHB(direction)); } else { auto count = ubidi_countRuns(bidi, &err); for(int i=0; i < count; ++i) { int32_t start, length; direction = ubidi_getVisualRun(bidi, i, &start, &length); addRun(text, direction, start, start + length); } } ubidi_close(bidi); } }
void createLayout (const AttributedString& text, TextLayout& layout) { tokens.ensureStorageAllocated (64); layout.ensureStorageAllocated (totalLines); addTextRuns (text); layoutRuns ((int) layout.getWidth()); int charPosition = 0; int lineStartPosition = 0; int runStartPosition = 0; TextLayout::Line* glyphLine = new TextLayout::Line(); TextLayout::Run* glyphRun = new TextLayout::Run(); for (int i = 0; i < tokens.size(); ++i) { const Token* const t = tokens.getUnchecked (i); const Point<float> tokenPos (t->area.getPosition().toFloat()); Array <int> newGlyphs; Array <float> xOffsets; t->font.getGlyphPositions (t->text.trimEnd(), newGlyphs, xOffsets); glyphRun->glyphs.ensureStorageAllocated (glyphRun->glyphs.size() + newGlyphs.size()); for (int j = 0; j < newGlyphs.size(); ++j) { if (charPosition == lineStartPosition) glyphLine->lineOrigin = tokenPos.translated (0, t->font.getAscent()); const float x = xOffsets.getUnchecked (j); glyphRun->glyphs.add (TextLayout::Glyph (newGlyphs.getUnchecked(j), Point<float> (tokenPos.getX() + x, 0), xOffsets.getUnchecked (j + 1) - x)); ++charPosition; } if (t->isWhitespace || t->isNewLine) ++charPosition; const Token* const nextToken = tokens [i + 1]; if (nextToken == nullptr) // this is the last token { addRun (glyphLine, glyphRun, t, runStartPosition, charPosition); glyphLine->stringRange = Range<int> (lineStartPosition, charPosition); layout.addLine (glyphLine); } else { if (t->font != nextToken->font || t->colour != nextToken->colour) { addRun (glyphLine, glyphRun, t, runStartPosition, charPosition); runStartPosition = charPosition; glyphRun = new TextLayout::Run(); } if (t->line != nextToken->line) { addRun (glyphLine, glyphRun, t, runStartPosition, charPosition); glyphLine->stringRange = Range<int> (lineStartPosition, charPosition); layout.addLine (glyphLine); runStartPosition = charPosition; lineStartPosition = charPosition; glyphLine = new TextLayout::Line(); glyphRun = new TextLayout::Run(); } } } if ((text.getJustification().getFlags() & (Justification::right | Justification::horizontallyCentred)) != 0) { const int totalW = (int) layout.getWidth(); for (int i = 0; i < totalLines; ++i) { const int lineW = getLineWidth (i); float dx = 0; if ((text.getJustification().getFlags() & Justification::right) != 0) dx = (float) (totalW - lineW); else dx = (totalW - lineW) / 2.0f; TextLayout::Line& glyphLine = layout.getLine (i); glyphLine.lineOrigin.x += dx; } } }