static void switchEcho(int tokenCount, char **tokens) { int state; if (tokenCount < 2) { printText("Echo on or off?"); return; } switch (*(tokens[1])) { case '0': state = 0; oK(_echo(&state)); break; case '1': state = 1; oK(_echo(&state)); break; default: printText("Echo on or off?"); } }
int main() { setlocale(LC_ALL, "RUS"); char text[SIZE], sym; char *head, *tail; int i; srand(time(NULL)); for (i = 0; i < SIZE ; i++) { text[i] = 97 + (rand() % 25); } printf("Исходный массив символов:\n"); printText(text, SIZE); for (head = text, tail = &text[SIZE - 1]; head < tail;) { sym = *head; *head++ = *tail; *tail-- = sym; } printf("В обратном порядке:\n"); printText(text, SIZE); return 0; }
void Colormap::render(float min, float max, int minorTicks) { int step = 1; int width = 50; glTranslatef(10, 10, 10); glColor3f(1, 1, 1); glBegin(GL_LINES); glVertex2f(1, 1); glVertex2f(1, 256 * step + 2); glVertex2f(1, 256 * step + 2); glVertex2f(width, 256 * step + 2); glVertex2f(width, 256 * step + 2); glVertex2f(width, 1); glVertex2f(width, 1); glVertex2f(1, 1); glEnd(); glBegin(GL_QUADS); for (size_t i = 0; i < 256; i++) { glColor3f(colors[i].red, colors[i].green, colors[i].blue); glVertex2f(1, 1 + (i * step) + step); // Top Left glVertex2f(width - 1, 1 + (i * step) + step); // Top Right glColor3f(colors[i].red, colors[i].green, colors[i].blue); glVertex2f(width - 1, 1 + i * step); // Bottom Right glVertex2f(1, 1 + i * step); // Bottom Left } glEnd(); glColor3f(1, 1, 1); glBegin(GL_LINES); glVertex2f(width, 2); glVertex2f(width + 5, 2); glEnd(); printText(width + 8, 1 - 3.5, float2str(min)); minorTicks = minorTicks + 1; for (int tick = 1; tick < minorTicks; tick++) { glBegin(GL_LINES); glVertex2f(width, tick * ((256 * step) / minorTicks)); glVertex2f(width + 2, tick * ((256 * step) / minorTicks)); glEnd(); float val = min + tick * (fabs(min - max) / minorTicks); printText(width + 5, tick * ((256 * step) / minorTicks) - 3.5, float2str(val)); } glBegin(GL_LINES); glVertex2f(width, 256 * step + 1); glVertex2f(width + 5, 256 * step + 1); glEnd(); printText(width + 8, 256 * step - 3.5, float2str(max)); glTranslatef(-10, -10, -10); }
void SenMLRecord::fieldsToJson() { int bnLength = this->_name.length(); if(bnLength){ printText("\"n\":\"", 5); printText(this->_name.c_str(), bnLength); printText("\"", 1); } if(!isnan(this->_time)){ printText(",\"t\":", 5); printDouble(this->_time, SENML_MAX_DOUBLE_PRECISION); } if(this->_unit != SENML_UNIT_NONE){ printText(",\"u\":\"", 6); printUnit(this->_unit); printText("\"", 1); } if(this->_updateTime != 0){ printText(",\"ut\":", 5); #ifdef __MBED__ char buf[10]; sprintf(buf, "%d", this->_updateTime); String val = buf; #else String val(this->_updateTime); #endif printText(val.c_str(), val.length()); } }
static void infoProfile(int tokenCount, char **tokens) { DtpcVdb *vdb = getDtpcVdb(); Profile *vprofile; PsmAddress elt; PsmPartition wm = getIonwm(); unsigned int profileID; if (tokenCount != 3) { SYNTAX_ERROR; return; } profileID = atoi(tokens[2]); for (elt = sm_list_first(wm, vdb->profiles); elt; elt = sm_list_next(wm, elt)) { vprofile = (Profile *) psp(wm, sm_list_data(wm, elt)); if (vprofile->profileID == profileID) { break; } } if (elt == 0) { printText("Unknown profile."); return; } printProfile(vprofile); }
static void executeAdd(int tokenCount, char **tokens) { if (tokenCount < 2) { printText("Add what?"); return; } if (strcmp(tokens[1], "profile") == 0) { if (tokenCount != 10 && tokenCount != 9) { SYNTAX_ERROR; return; } oK(addProfile(strtol(tokens[2], NULL, 0), strtol(tokens[3], NULL, 0), strtol(tokens[4], NULL, 0), strtol(tokens[5], NULL, 0), strtol(tokens[6], NULL, 0), tokens[7], tokens[8], tokens[9])); return; } SYNTAX_ERROR; }
void TextDisplayer::printCharacterText(const char *text, int8 charNum, int charX) { int top, left, x1, x2, w, x; char *msg; text = preprocessString(text); int lineCount = buildMessageSubstrings(text); w = getWidestLineWidth(lineCount); x = charX; calcWidestLineBounds(x1, x2, w, x); uint8 color = 0; if (_vm->gameFlags().platform == Common::kPlatformAmiga) { const uint8 colorTable[] = { 0x1F, 0x1B, 0xC9, 0x80, 0x1E, 0x81, 0x11, 0xD8, 0x55, 0x3A, 0x3A }; color = colorTable[charNum]; setTextColor(color); } else { const uint8 colorTable[] = { 0x0F, 0x09, 0xC9, 0x80, 0x05, 0x81, 0x0E, 0xD8, 0x55, 0x3A, 0x3A }; color = colorTable[charNum]; } for (int i = 0; i < lineCount; ++i) { top = i * 10 + _talkMessageY; msg = &_talkSubstrings[i * TALK_SUBSTRING_LEN]; left = getCenterStringX(msg, x1, x2); printText(msg, left, top, color, 0xC, 0); } }
void TextDisplayer::printTalkTextMessage(const char *text, int x, int y, uint8 color, int srcPage, int dstPage) { char *str = preprocessString(text); int lineCount = buildMessageSubstrings(str); int top = y - lineCount * 10; if (top < 0) { top = 0; } _talkMessageY = top; _talkMessageH = lineCount * 10; int w = getWidestLineWidth(lineCount); int x1, x2; calcWidestLineBounds(x1, x2, w, x); _talkCoords.x = x1; _talkCoords.w = w + 2; _screen->copyRegion(_talkCoords.x, _talkMessageY, _talkCoords.x, _talkCoords.y, _talkCoords.w, _talkMessageH, srcPage, dstPage, Screen::CR_NO_P_CHECK); int curPage = _screen->_curPage; _screen->_curPage = srcPage; if (_vm->gameFlags().platform == Common::kPlatformAmiga) setTextColor(color); for (int i = 0; i < lineCount; ++i) { top = i * 10 + _talkMessageY; char *msg = &_talkSubstrings[i * TALK_SUBSTRING_LEN]; int left = getCenterStringX(msg, x1, x2); printText(msg, left, top, color, 0xC, 0); } _screen->_curPage = curPage; _talkMessagePrinted = true; }
int main() { int key = 0; setlocale(LC_ALL, "rus"); printf("Enter '1' if you want to sort poem in forward order \n" "Enter '2' if you want to sort poem in reverse order and get new part of poem \n" "You choise > "); if (!scanf_s("%d", &key) || (key != 1 && key != 2)) { printf("Wrong format. Try again (maybe without brackets)\n" "> "); key = getchar(); if (!scanf_s("%d", &key)) printf("Sorry, I'm closing.\n"); } //unsigned int start_time = clock(); int StringCount = 0; size_t Textlen = 0; Text_t *text = InitText(&StringCount, &Textlen); int isOkSort = sortText(text, key, &StringCount, Textlen); assert(isOkSort); int isOkPrint = printText(text, StringCount, key); assert(isOkPrint); int isOkMemory = Struct_Destrucktor(text); assert(isOkMemory); //unsigned int end_time = clock(); //unsigned int search_time = end_time - start_time; //printf("%u\n", search_time); return 0; }
//----------------------------------------------------------------------------- void MainWindow::makeMenu() { QAction *a; QMenu *o; // file menu { o = menuBar()->addMenu(_("File")); a = new QAction(QPixmap(":/png/document-new.png"), _("New script"), this); connect(a, SIGNAL(triggered()), this, SLOT(newDoc())); a->setToolTip(_("Create new empty script window (Ctrl+N).")); a->setShortcut(Qt::CTRL+Qt::Key_N); o->addAction(a); o->addAction(aload); o->addAction(asave); a = new QAction(_("Save as ..."), this); connect(a, SIGNAL(triggered()), this, SLOT(saveAs())); o->addAction(a); o->addSeparator(); o->addAction(_("Print script"), edit, SLOT(printText())); a = new QAction(QPixmap(":/png/document-print.png"), _("Print graphics"), this); connect(a, SIGNAL(triggered()), graph->mgl, SLOT(print())); a->setToolTip(_("Open printer dialog and print graphics (Ctrl+P)")); a->setShortcut(Qt::CTRL+Qt::Key_P); o->addAction(a); o->addSeparator(); fileMenu = o->addMenu(_("Recent files")); o->addSeparator(); o->addAction(_("Quit"), qApp, SLOT(closeAllWindows())); } menuBar()->addMenu(edit->menu); menuBar()->addMenu(graph->menu); // settings menu { o = menuBar()->addMenu(_("Settings")); a = new QAction(QPixmap(":/png/preferences-system.png"), _("Properties"), this); connect(a, SIGNAL(triggered()), this, SLOT(properties())); a->setToolTip(_("Show dialog for UDAV properties.")); o->addAction(a); o->addAction(_("Set arguments"), createArgsDlg(this), SLOT(exec())); o->addAction(acalc); o->addAction(ainfo); o->addAction(ahide); } menuBar()->addSeparator(); o = menuBar()->addMenu(_("Help")); a = new QAction(QPixmap(":/png/help-contents.png"), _("MGL help"), this); connect(a, SIGNAL(triggered()), this, SLOT(showHelp())); a->setToolTip(_("Show help on MGL commands (F1).")); a->setShortcut(Qt::Key_F1); o->addAction(a); a = new QAction(QPixmap(":/png/help-faq.png"), _("Hints"), this); connect(a, SIGNAL(triggered()), this, SLOT(showHint())); a->setToolTip(_("Show hints of MGL usage.")); o->addAction(a); o->addAction(_("About"), this, SLOT(about())); o->addAction(_("About Qt"), this, SLOT(aboutQt())); }
/*! \fn static void printBlock(uint8_t num) * \brief Print text 'Block' followed by blocknumber * * \param uint8_t num - number to be printed next to 'Block #' string */ static void printBlock(uint8_t num) { char str[4]; printTextP(PSTR("\nBlock #")); char_to_string(num, str); printText(str); }
void Terminal::readError() { while(process->canReadLine()){ QByteArray array(process->readLine().constData()); emit printText(array); } }
void Terminal::accept(QString command) { acceptedCommands << command; QByteArray aa=command.append("\n").toUtf8(); process->write(aa); emit printText(command); }
int _tmain(int argc, _TCHAR* argv[]) { setlocale(LC_ALL, "rus"); int key = 0; //char codeWord[8] = {}; printf("Enter '1' if you want to sort poem in forward order \n" "Enter '2' if you want to sort poem in reverse order and get new part of poem \n" "You choise: "); scanf_s("%d", &key); //unsigned int start_time = clock(); int count = 0; size_t len = 0; char** text = InitText(&count,&len); int isOkSort = sortText(text, key, &count, len); assert(isOkSort); int isOkPrint = printText(text, count, key); assert(isOkPrint); int isOkMemory = freeMemory(text); assert(isOkMemory); //unsigned int end_time = clock(); //unsigned int search_time = end_time - start_time; //printf("%u\n", search_time); return 0; }
static void executeList(int tokenCount, char **tokens) { Sdr sdr = getIonsdr(); PsmPartition ionwm = getIonwm(); IonVdb *vdb = getIonVdb(); PsmAddress elt; PsmAddress addr; char buffer[RFX_NOTE_LEN]; if (tokenCount < 2) { printText("List what?"); return; } if (strcmp(tokens[1], "contact") == 0) { CHKVOID(sdr_begin_xn(sdr)); for (elt = sm_rbt_first(ionwm, vdb->contactIndex); elt; elt = sm_rbt_next(ionwm, elt)) { addr = sm_rbt_data(ionwm, elt); rfx_print_contact(addr, buffer); printText(buffer); } sdr_exit_xn(sdr); return; } if (strcmp(tokens[1], "range") == 0) { CHKVOID(sdr_begin_xn(sdr)); for (elt = sm_rbt_first(ionwm, vdb->rangeIndex); elt; elt = sm_rbt_next(ionwm, elt)) { addr = sm_rbt_data(ionwm, elt); rfx_print_range(addr, buffer); printText(buffer); } sdr_exit_xn(sdr); return; } SYNTAX_ERROR; }
static void printKin(uvast kin, uvast parent) { char buffer[32]; isprintf(buffer, sizeof buffer, UVAST_FIELDSPEC " %s", kin, kin == parent ? "parent" : ""); printText(buffer); }
/* Put all your code here */ void main(void) { /* uint8_t is an unsigned integer that can range from 0-255. It performs faster than just an int, so try to use it (or int8_t) when possible */ uint8_t count; /* This function cleans up the screen and gets everything ready for the OS */ prgm_CleanUp(); /* Print a few strings */ printText( HelloWorld, 0, 0 ); printText( Welcome, 0, 1 ); /* Wait for a key press */ while( !os_GetCSC() ); /* Clean up, and exit */ prgm_CleanUp(); }
void SenMLPack::contentToJson() { printText("{", 1); this->fieldsToJson(); SenMLBase *next = this->_start; if(next && next->isPack() == false){ //we can only inline the first record. If the first item is a Pack (child device), then don't inline it. printText(",", 1); next->fieldsToJson(); next = next->getNext(); } printText("}", 1); while(next){ printText(",", 1); next->contentToJson(); next = next->getNext(); } }
static void printSyntaxError(int lineNbr) { char buffer[80]; isprintf(buffer, sizeof buffer, "Syntax error at line %d of dtpcadmin.c", lineNbr); printText(buffer); }
static void switchWatch(int tokenCount, char **tokens) { CfdpVdb *vdb = getCfdpVdb(); char buffer[80]; char *cursor; if (tokenCount < 2) { printText("Switch watch in what way?"); return; } if (strcmp(tokens[1], "1") == 0) { vdb->watching = -1; return; } vdb->watching = 0; if (strcmp(tokens[1], "0") == 0) { return; } cursor = tokens[1]; while (*cursor) { switch (*cursor) { case 'p': vdb->watching |= WATCH_p; break; case 'q': vdb->watching |= WATCH_q; break; default: isprintf(buffer, sizeof buffer, "Invalid watch char %c.", *cursor); printText(buffer); } cursor++; } }
void gameOver() { // gameOver start = false; glColor3ub(255,255,255); if(win == true) { char mess10[] = "You won!"; printText(strlen(mess10), mess10, width/2 - 10, length - 25 - 25); } else { char mess10[] = "You lost!"; printText(strlen(mess10), mess10, width/2 - 10, length - 25 - 25); } printScore(); }
static void executeManage(int tokenCount, char **tokens) { if (tokenCount < 2) { printText("Manage what?"); return; } if (strcmp(tokens[1], "discard") == 0) { manageDiscard(tokenCount, tokens); return; } if (strcmp(tokens[1], "requirecrc") == 0) { manageRequirecrc(tokenCount, tokens); return; } if (strcmp(tokens[1], "fillchar") == 0) { manageFillchar(tokenCount, tokens); return; } if (strcmp(tokens[1], "ckperiod") == 0) { manageCkperiod(tokenCount, tokens); return; } if (strcmp(tokens[1], "maxtimeouts") == 0) { manageMaxtimeouts(tokenCount, tokens); return; } if (strcmp(tokens[1], "maxtrnbr") == 0) { manageMaxtrnbr(tokenCount, tokens); return; } if (strcmp(tokens[1], "segsize") == 0) { manageSegsize(tokenCount, tokens); return; } if (strcmp(tokens[1], "mtusize") == 0) { manageMtusize(tokenCount, tokens); return; } SYNTAX_ERROR; }
static void printEnd(struct frag *frag, const char *name) { if (frag->cop->unwrap) { if (!strcmp(name, "body")) { if (frag->cop->wrap) fputs("\n</body></html>", frag->fp); fclose(frag->fp); exit(0); } else { printText((const char *)charData_retrieve(), frag->fp); fprintf(frag->fp, "</%s>", name); return; } } printText((const char *)charData_retrieve(), frag->fp); fprintf(frag->fp, "</%s>", name); if (!--frag->nesting) { if (frag->cop->html) { if (!strcmp(name, "head")) fputs("<body>", frag->fp); else fputs("</body></html>", frag->fp); } else { if (need_gdf_closer) fputs("</gdf:dataset>", frag->fp); else { if (frag->cop->wrap) fputs("</body></html>", frag->fp); fclose(frag->fp); exit(0); } } } }
void printStart(struct frag *frag, const char *name, const char **atts) { const char **ap = atts; printText((const char*)charData_retrieve(), frag->fp); fprintf(frag->fp, "<%s", name); if (atts) { for (ap = atts; ap[0]; ) { fprintf(frag->fp, " %s=\"",*ap++); printText(*ap++, frag->fp); fputc('"', frag->fp); } } fputc('>', frag->fp); ++frag->nesting; }
void TableDiff::printTextWithDiv(const String & input) { // Wrap string in a <div> if it's not empty if (input.size() > 0) { result.append("<div>"); printText(input); result.append("</div>"); } }
void GamesItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { painter->save(); QString gameName = qvariant_cast<QString>(index.data(ROLE_NAME)); QString viewers = qvariant_cast<QString>(index.data(ROLE_VIEWERS)); QString channels_nr = qvariant_cast<QString>(index.data(ROLE_CHANNEL_NR)); QRect iconRect = option.rect; QRect gameNameRect = option.rect; QRect viewersRect = option.rect; QRect viewersLegendRect = option.rect; QRect channelsRect = option.rect; QRect channelsLegendRect = option.rect; printIcon(iconRect, painter, index); setRightOf(iconRect,gameNameRect); printHeader(gameNameRect,gameName,painter); setUnder(gameNameRect, viewersLegendRect); printLegend(viewersLegendRect,viewersLegend,painter); setRightOf(viewersLegendRect,viewersRect); printText(viewersRect,viewers,painter); setRightOf(viewersRect,channelsLegendRect); printLegend(channelsLegendRect,channelsLegend,painter); setRightOf(channelsLegendRect,channelsRect); printText(channelsRect,channels_nr,painter); // focus elements drawFocus(painter, option, option.rect); painter->restore(); }
static int attachToDtpc() { if (dtpcAttach() < 0) { printText("DTPC not initialized yet."); return -1; } return 0; }
void InlineDiff::printWrappedLine(const char* pre, const String& line, const char* post) { result += pre; if (line.empty()) { result += " "; } else { printText(line); } result += post; }
static int attachToCfdp() { if (cfdpAttach() < 0) { printText("CFDP not initialized yet."); return -1; } return 0; }
static void printStart(struct frag *frag, const char *name, const char **atts, const char *xid) { const char **ap = atts; printText((const char*)charData_retrieve(), frag->fp); fprintf(frag->fp, "<%s", name); if (xid && frag->cop->hilite_id && !strcmp(xid, frag->cop->hilite_id)) atts = addClassSelect(atts); if (atts) { for (ap = atts; ap[0]; ) { if (frag->cop->sigs && *ap[0] == 'h' && !strcmp(ap[0], "href")) { const char *pop1sig = NULL; fprintf(stderr, "content:printStart: found href\n"); if ((pop1sig = strstr(ap[1], "pop1sig("))) { const char *p; fprintf(frag->fp, " href=\""); for (p = ap[1]; p < pop1sig; ++p) fputc(*p, frag->fp); for (p = pop1sig; '(' != *p; ++p) fputc(*p, frag->fp); fputc('(', frag->fp); ++p; fprintf(frag->fp, "'%s','',", project); printText(p, frag->fp); fputc('"', frag->fp); ap += 2; continue; } } fprintf(frag->fp, " %s=\"",*ap++); printText(*ap++, frag->fp); fputc('"', frag->fp); } } fputc('>', frag->fp); ++frag->nesting; }