void FindSequenceDialog::sequenceSearch ( bool invers ) { bool cont = true ; int a ; wxString sub = getQuery() ; p = 0 ; if ( sub.IsEmpty() ) return ; // Preparing sequence wxString s = c->vec->getSequence() ; if ( invers ) { s = c->vec->transformSequence ( true , true ) ; } if ( c->vec->isCircular() ) { wxString t ; t = s ; while ( t.length() < sub.length() ) t += _T(" ") ; s += t.substr ( 0 , sub.length()-1 ) ; } while ( cont ) { // Now we search... a = subsearch ( s , sub , p ) ; if ( a > -1 ) { if ( lb->GetCount() > FIND_MAX ) return ; p = a+1 ; int from = a + 1 ; int to = last + 1 ; if ( to > c->vec->getSequenceLength() ) to -= c->vec->getSequenceLength() ; wxString msg ; if ( invers ) { msg = _T(" (3'->5')") ; int nt = c->vec->getSequenceLength() - from + 1 ; int nf = c->vec->getSequenceLength() - to + 1 ; from = nf ; to = nt ; } lb->Append ( wxString::Format ( _T("%s: %d-%d%s") , txt("sequence").c_str() , from , to , msg.c_str() ) ) ; vi.Add ( -1 ) ; } else { cont = false ; } } }
bool TablatureDurationFont::read(XmlReader& e) { while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "family") family = e.readElementText(); else if (tag == "displayName") displayName = e.readElementText(); else if (tag == "defaultPitch") defPitch = e.readDouble(); else if (tag == "duration") { QString val = e.attribute("value"); QString txt(e.readElementText()); QChar chr = txt[0]; if (val == "longa") displayValue[TAB_VAL_LONGA] = chr; else if (val == "brevis") displayValue[TAB_VAL_BREVIS] = chr; else if (val == "semibrevis") displayValue[TAB_VAL_SEMIBREVIS] = chr; else if (val == "minima") displayValue[TAB_VAL_MINIMA] = chr; else if (val == "semiminima") displayValue[TAB_VAL_SEMIMINIMA] = chr; else if (val == "fusa") displayValue[TAB_VAL_FUSA] = chr; else if (val == "semifusa") displayValue[TAB_VAL_SEMIFUSA] = chr; else if (val == "32") displayValue[TAB_VAL_32] = chr; else if (val == "64") displayValue[TAB_VAL_64] = chr; else if (val == "128") displayValue[TAB_VAL_128] = chr; else if (val == "256") displayValue[TAB_VAL_256] = chr; else if (val == "dot") displayDot = chr; else e.unknown(); } else { e.unknown(); return false; } } return true; }
/** * Called if window is hidden when it recieves a message. * Displays the message in a ballon-popup in the tray. * Also sets tray icon to be red, to indicate an unread message. * @brief MainWindow::displayTrayMsg * @param index Tabindex * @param text "{sender_name}|{message}" */ void MainWindow::displayTrayMsg(int index, const QString& text) { lastUpdatedTab = index; if(ui->actionBalloon_Notification->isChecked()) { QStringList lst = text.split("|", QString::SkipEmptyParts); if(lst.count() > 1) { QStringRef txt(&lst.at(1), 0, lst.at(1).length()); if(lst.at(1).length() > 20) txt = QStringRef(&lst.at(1), 0, 20); trayIcon->showMessage(lst.at(0) + " says:", txt.toString()); } } trayIcon->setIcon(QIcon(APPLICATION_ICON_RED)); }
/// <summary>Reads a string tag</summary> /// <param name="element">String 't' element</param> /// <param name="page">Containing page</param> /// <param name="v">Version of page</param> /// <returns>New language string</returns> /// <exception cref="Logic::FileFormatException">Missing element or attributes</exception> /// <exception cref="Logic::ComException">COM Error</exception> LanguageString LanguageFileReader::ReadString(XmlNodePtr& element, LanguagePage& page, GameVersion v) { // Verify string tag ReadElement(element, L"t"); // Get text wstring txt((WCHAR*)element->text); // Convert octal addition entities for (auto pos = txt.find(L"\\053"); pos != wstring::npos; pos = txt.find(L"\\053")) txt.replace(pos, 4, L"+"); // Read ID+text return LanguageString(_wtoi(ReadAttribute(element, L"id").c_str()), page.ID, txt, v); }
void QFEHelpEditorWidget::on_btnExecute_clicked() { QFTemporaryFile f; QFileInfo fi(currentScript); if (QFile::exists(currentScript)) { f.setFileTemplate(fi.absolutePath()+"/qfe_helpeditor_temp_XXXXXX.html.tmp"); } if (f.open()) { QTextStream txt(&f); txt<<ui->edtScript->getEditor()->toPlainText(); f.close(); QFPluginServices::getInstance()->displayHelpWindow(f.fileName()); } }
void Recorder::writeLog(QString str) { //write to txt QFile f("log.txt"); if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { qDebug("Open Failed."); return; } QTextStream txt(&f); txt << str; f.close(); }
void urdfLink::verifyInertia() { float c=0.0f; for (int i=0;i<9;i++) c+=fabs(inertia[i]); if (c==0.0f) { std::string txt("ERROR: found an invalid inertia entry for link '"+ name+"'"); printToConsole(txt.c_str()); inertia[0]=0.001f; inertia[4]=0.001f; inertia[8]=0.001f; } }
void tst_QTextBoundaryFinder::isAtWordStart() { QString txt("The quick brown fox jumped over $the lazy. dog I win!"); QList<int> start, end; start << 0 << 4 << 10 << 16 << 20 << 27 << 32 << 33 << 37 << 41 << 43 << 48 << 50 << 53; end << 3 << 9 << 15 << 19 << 26 << 31 << 33 << 36 << 41 << 42 << 46 << 49 << 53 << 54; QTextBoundaryFinder finder(QTextBoundaryFinder::Word, txt); for(int i=0; i < txt.length(); ++i) { finder.setPosition(i); QTextBoundaryFinder::BoundaryReasons r = finder.boundaryReasons(); // qDebug() << i << r; QCOMPARE((r & QTextBoundaryFinder::StartWord) != 0, start.contains(i) == true); QCOMPARE((r & QTextBoundaryFinder::EndWord) != 0, end.contains(i) == true); } }
JSBool facRoText(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { diaElemReadOnlyText txt("blah blah","Value:"); diaElem *elems[]={&txt }; if(diaFactoryRun("Test FileRead",1,elems)) { *rval = BOOLEAN_TO_JSVAL(1); }else *rval = BOOLEAN_TO_JSVAL(0); return JS_TRUE; }
static INT_PTR CALLBACK Dialog_GetPassword_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { Dialog_GetPassword_Data *data; //[ ACCESSKEY_GROUP Password Dialog if (WM_INITDIALOG == msg) { data = (Dialog_GetPassword_Data*)lParam; win::SetText(hDlg, _TR("Enter password")); SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data); EnableWindow(GetDlgItem(hDlg, IDC_REMEMBER_PASSWORD), data->remember != NULL); ScopedMem<WCHAR> txt(str::Format(_TR("Enter password for %s"), data->fileName)); SetDlgItemText(hDlg, IDC_GET_PASSWORD_LABEL, txt); SetDlgItemText(hDlg, IDC_GET_PASSWORD_EDIT, L""); SetDlgItemText(hDlg, IDC_STATIC, _TR("&Password:"******"&Remember the password for this document")); SetDlgItemText(hDlg, IDOK, _TR("OK")); SetDlgItemText(hDlg, IDCANCEL, _TR("Cancel")); CenterDialog(hDlg); SetFocus(GetDlgItem(hDlg, IDC_GET_PASSWORD_EDIT)); return FALSE; } //] ACCESSKEY_GROUP Password Dialog switch (msg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: data = (Dialog_GetPassword_Data*)GetWindowLongPtr(hDlg, GWLP_USERDATA); assert(data); data->pwdOut = win::GetText(GetDlgItem(hDlg, IDC_GET_PASSWORD_EDIT)); if (data->remember) *data->remember = BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_REMEMBER_PASSWORD); EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; } break; } return FALSE; }
void Client::commandStat(const std::string &arg) { if (this->user_ != NULL) { std::string txt(this->MailsInfo(this->user_->getName())); this->response_.setCode("+Ok"); this->response_.setText(txt); this->request_.resetRequest(); } else { this->response_.setCode("-Err"); this->response_.setText("Permission denied"); this->request_.resetRequest(); } }
JSBool facText(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { char *foo=ADM_strdup("blah"); diaElemText txt(&foo,"Text",NULL); diaElem *elems[]={&txt }; if(diaFactoryRun("Test FileRead",1,elems)) { *rval = BOOLEAN_TO_JSVAL(1); }else *rval = BOOLEAN_TO_JSVAL(0); return JS_TRUE; }
bool TextureManager::LoadTextureFromFile(const char *file) { std::ifstream txt(file); std::string line; std::string name; std::string path; while (getline(txt, line)) { std::istringstream ss(line); getline(ss, name, ':'); getline(ss, path, '\n'); LoadTexture(name, path); } return (true); }
void draw_chip_count(sf::RenderWindow & win, level const & lvl) { auto & res = resource_manager::get(); auto & inv = lvl.chip.get<inventory>(); unsigned req_chips = lvl.chip_count() - inv.count(entity_id::computer_chip); sf::Text txt( "Chips Left:\n " + std::to_string(req_chips) , res[font_uid::arial] , 25 ); txt.setPosition((float)chip_count_xpos, (float)chip_count_ypos); txt.setColor(sf::Color::Red); win.draw(txt); }
const char* Configuration::ReplaceShader(int count, const char *const*srcs, const int *lengths) { if (vendor == VENDOR_UNKNOWN) { vendor = VENDOR_OTHER; extern const char* myglGetString(int in); const char *vendorstr = myglGetString(GL_VENDOR); if (vendorstr) { string s(vendorstr); for (unsigned i = 0; i < s.size(); i++) if (s[i] >= 'a' && s[i] <= 'z') s[i] -= 'a' - 'A'; if (s.find("ATI") != string::npos) vendor = VENDOR_ATI; if (s.find("NVIDIA") != string::npos) vendor = VENDOR_NVIDIA; } } string txt(""); for (int i = 0; i < count; i++) { if (lengths == 0 || lengths[i] < 1) txt.append(srcs[i]); else txt.append(srcs[i], lengths[i]); } for (unsigned i = 0; i < _replacers.size(); i++) { Replacer &r = _replacers[i]; if (!(r.vendor == VENDOR_ALL || r.vendor == vendor)) continue; size_t pos = 0; int count = 0; while ((pos = txt.find(r.src, pos)) != string::npos && count++ < 1000) { txt.replace(pos, r.src.size(), r.dst); pos += r.dst.size(); } } int len = txt.size() + 1; if (_bufferpos + len >= BUFFERSIZE) _bufferpos = 0; char *ret = &_buffer[_bufferpos]; strncpy_s(ret, BUFFERSIZE - _bufferpos, txt.c_str(), len); _bufferpos += len; return ret; }
bool Kernel_base::loop(Interface_controlador& IC) { //Aquí se mide el tiempo desde el último paso por este loop... controlador_fps.iniciar_paso_loop(); Input_base& input=acc_input(); preloop(); IC.preloop(input, paso_delta); //Aquí se consume el tiempo desde el último paso en bloques de "paso_delta". while(controlador_fps.consumir_loop(paso_delta) ) { paso(); input.turno(); IC.loop(input, paso_delta); Audio::procesar_cola_sonido(); if(IC.es_romper_loop()) break; } postloop(); IC.postloop(input, paso_delta); controlador_fps.turno(); IC.dibujar(pantalla); if(mostrar_fps) { #ifdef WINCOMPIL std::string fps="FPS:"+parche_mingw::to_string(controlador_fps.acc_frames_contados())+"\n"+IC.acc_debug(); #else std::string fps="FPS:"+std::to_string(controlador_fps.acc_frames_contados())+"\n"+IC.acc_debug(); #endif DLibV::Representacion_texto_auto_estatica txt(DLibV::Gestor_superficies::obtener(acc_recurso_fps()), fps); txt.establecer_posicion(pantalla.acc_w()-128, 6); txt.volcar(pantalla); } pantalla.actualizar(); return !IC.es_abandonar_aplicacion(); }
int main() { int x; x= addition(5,7);// X is here std::cout<<"the number is "<<x<<std::endl; std::cout<<txt("word1", "word2")<<std::endl<<std::endl; baws(); std::cout<<setY(777)<<std::endl; //end stuff std::system("PAUSE");return EXIT_SUCCESS;}
short ItemExpr::codeGen(Generator * generator) { if (getOperatorType() == ITM_NATYPE || getOperatorType() == ITM_NAMED_TYPE_TO_ITEM) { Attributes ** attr; if (generator->getExpGenerator()->genItemExpr(this, &attr, (1 + getArity()), -1) == 1) return 0; return 0; } NAString txt(getText()); txt += " should never reach ItemExpr::codeGen"; GenAssert(0, txt); return -1; }
int main(int argc, char** argv) { QApplication app(argc, argv); QLineEdit txt("QLineEdit"); txt.installEventFilter(new MouseFilter(&txt)); txt.show(); QLabel lbl("QLabel"); lbl.installEventFilter(new MouseFilter(&lbl)); lbl.show(); QPushButton pcmd("QPushButton"); pcmd.installEventFilter(new MouseFilter(&pcmd)); pcmd.show(); app.exec(); }
bool Editor::Open(QString filename) { QFile file(filename); if (!file.open(QFile::ReadOnly)) { ErrorMessage(tr("Cannot read file %1:\n%2.").arg(filename).arg(file.errorString())); return false; } QTextStream in(&file); QApplication::setOverrideCursor(Qt::WaitCursor); QString txt(in.readAll()); setText(txt); SetFileName(filename); setModified(false); lastModifiedTime = QFileInfo(filename).lastModified(); return true; }
void testPaths( const char *prompt, const QwtSpline &spline, const QPolygonF& points1, const QPolygonF& points2 ) { const QPainterPath path1 = spline.painterPath( points1 ); const QPainterPath path2 = spline.painterPath( points2 ); if ( path1 != path2 ) { QString txt( "Parametric Spline" ); if ( spline.boundaryType() != QwtSpline::ConditionalBoundaries ) txt += "(closed)"; txt += ": "; txt += prompt; txt += " => failed."; qDebug() << qPrintable( txt ); } }
//***************** // 把list写入到txt文件 //***************** void Recorder::writeDataFile() { //write to txt QFile f(outFilePath); if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { qDebug("Open Failed."); return; } QTextStream txt(&f); for (int i = 0; i < strList.count(); i++) { txt << strList.at(i) <<endl; } f.close(); }
void WordSearch::read_words(const string &file_name) { ifstream txt (file_name); /* file is aumatically open */ string one_line; int line = 1; string prev = ""; while (getline(txt, one_line)) { /* change to lowercase */ transform(one_line.begin(), one_line.end(), one_line.begin(), ::tolower); /* replace non-alpha with a space */ replace_if (one_line.begin(), one_line.end(), [] (const char c) { return !isalpha(c); }, ' '); istringstream tokens{one_line}; string word; while (tokens >> word) { if (word.length() < 3) continue; if (ignored_words.find(word) == ignored_words.end()) { wordCount++; lengthMap[word.length()].insert(word); wordFrequency[word]++; wordFileMap[word].insert(file_name); if (prev != "") { predictWord[prev][word]++; } prev = word; } } line++; } txt.close(); /* close the file */ for (auto iter = wordFrequency.begin(); iter != wordFrequency.end();iter++){ leastFrequent[iter->second].insert(iter->first); } }
void urdfLink::setMeshFilename(std::string packagePath,std::string meshFilename,std::string choose) { std::cout << std::flush; std::string meshFilename_alt; // we use an alternative filename... the package location is somewhat strangely defined sometimes!! if (meshFilename.compare(0,10,"package://")==0) // condition added by Marc on 17/1/2014 { meshFilename = meshFilename.substr(9,meshFilename.size()); //to delete de package:/ part meshFilename_alt=meshFilename; meshFilename = packagePath + meshFilename; packagePath = packagePath.substr(0, packagePath.find_last_of("/")); meshFilename_alt = packagePath + meshFilename_alt; } std::string extension = meshFilename.substr(meshFilename.size()-3,meshFilename.size()); int nExtension; if(extension == "obj" || extension =="OBJ"){ nExtension = 0;} else if(extension == "dxf" || extension == "DXF"){ nExtension = 1;} else if(extension == "3ds" || extension == "3DS"){ nExtension = 2;} else if(extension == "stl" || extension == "STL"){ nExtension = 4;} else if(extension == "dae" || extension == "DAE"){ nExtension = 5;} else { nExtension = -1; std::string txt("ERROR: the extension '"+ extension +"' is not currently a supported."); printToConsole(txt.c_str()); } if(choose == "visual") { urdfElement &visual = currentVisual(); visual.meshFilename = meshFilename; visual.meshFilename_alt = meshFilename_alt; visual.meshExtension = nExtension; } if(choose == "collision") { urdfElement &collision = currentCollision(); collision.meshFilename = meshFilename; collision.meshFilename_alt = meshFilename_alt; collision.meshExtension = nExtension; } }
void PlayerBar::drawDungeonMap(sf::RenderWindow& mainWindow){ sf::RectangleShape dungeonMapRect; int spaceBetweenDungeonRect = 1; sf::Vector2f size(15,7); dungeonMapRect.setFillColor(sf::Color(110, 93, 243)); dungeonMapRect.setSize(size); std::stringstream pos; pos << "LEVEL-" << (int)currentDungeon; sf::Text txt(pos.str(), font); txt.setPosition(bar.x+16, bar.y+16); txt.setColor(sf::Color::White); txt.setCharacterSize(14); mainWindow.draw(txt); mainWindow.draw(dungeonMap); if (hasDungeonMap){ dungeonMapRect.setPosition(map.x + 56, map.y + 56); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 72, map.y + 56); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 72, map.y + 48); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 56, map.y + 48); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 40, map.y + 48); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 40, map.y + 56); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 24, map.y + 48); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 24, map.y + 56); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 56, map.y + 40); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 40, map.y + 40); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 56, map.y + 32); mainWindow.draw(dungeonMapRect); dungeonMapRect.setPosition(map.x + 72, map.y + 32); mainWindow.draw(dungeonMapRect); } if (hasDungeonCompass) mainWindow.draw(dungeonBossMarker); }
void FindSequenceDialog::restrictionSearch () { int a ; TVector *v = c->vec ; wxString s = getQuery() ; for ( a = 0 ; a < v->rc.size() ; a++ ) { if ( lb->GetCount() > FIND_MAX ) return ; wxString en = v->rc[a].getDisplayName() ; if ( en.Upper().Find(s) != -1 ) { lb->Append ( wxString::Format ( _T("%s: %s (%d)") , txt("m_restriction").c_str() , en.c_str() , v->rc[a].getPos()+1 ) ) ; vi.Add ( a ) ; } } }
/// called on text virtual void OnText( const lChar16 * text, int len, lUInt32 flags ) { CR_UNUSED(flags); lString16 txt( text, len ); switch (state) { case in_start_point: _curr_bookmark->setStartPos( txt ); break; case in_end_point: _curr_bookmark->setEndPos( txt ); break; case in_header_txt: _curr_bookmark->setTitleText( txt ); break; case in_selection_txt: _curr_bookmark->setPosText( txt ); break; case in_comment_txt: _curr_bookmark->setCommentText( txt ); break; case in_author: _curr_file->setAuthor( txt ); break; case in_title: _curr_file->setTitle( txt ); break; case in_series: _curr_file->setSeries( txt ); break; case in_filename: _curr_file->setFileName( txt ); break; case in_filepath: _curr_file->setFilePath( txt ); break; case in_filesize: _curr_file->setFileSize( txt.atoi() ); break; default: break; } }
ui_menu_display_options::ui_menu_display_options(running_machine &machine, render_container *container) : ui_menu(machine, container) { osd_options &options = downcast<osd_options &>(machine.options()); for (int d = 2; d < ARRAY_LENGTH(m_options); ++d) m_options[d].status = options.int_value(m_options[d].option); // create video list m_list.push_back("auto"); m_list.push_back("opengl"); // TODO: check USE_OPENGL std::string descr = options.description(OSDOPTION_VIDEO); descr.erase(0, descr.find(":") + 2); std::string delim = ", "; size_t p1, p2 = 0; for (;;) { p1 = descr.find_first_not_of(delim, p2); if (p1 == std::string::npos) break; p2 = descr.find_first_of(delim, p1 + 1); if (p2 != std::string::npos) { std::string txt(descr.substr(p1, p2 - p1)); if (txt != "or" && txt != "none") m_list.push_back(descr.substr(p1, p2 - p1)); } else { m_list.push_back(descr.substr(p1)); break; } } m_options[1].status = 0; for (int cur = 0; cur < m_list.size(); ++cur) if (options.video() == m_list[cur]) { m_options[1].status = cur; break; } }
void FindSequenceDialog::itemSearch () { int a ; TVector *v = c->vec ; wxString s = t->GetValue().Upper() ; // Using original input instead of filtered query for ( a = 0 ; a < v->items.size() ; a++ ) { if ( lb->GetCount() > FIND_MAX ) return ; if ( v->items[a].name.Upper().Find(s) != -1 || v->items[a].desc.Upper().Find(s) != -1 ) { lb->Append ( wxString::Format ( _T("%s: %s (%d-%d)") , txt("t_vec_item").c_str() , v->items[a].name.c_str() , v->items[a].from , v->items[a].to ) ) ; vi.Add ( a ) ; } } }
/* appends the next quoted argument and returns the position after it */ static const WCHAR *ParseQuoted(const WCHAR *arg, WStrVec *out) { AssertCrash(arg && '"' == *arg); arg++; str::Str<WCHAR> txt(str::Len(arg) / 2); const WCHAR *next; for (next = arg; *next && *next != '"'; next++) { // skip escaped quotation marks according to // http://msdn.microsoft.com/en-us/library/17w5ykft.aspx if ('\\' == *next && '"' == SkipBackslashs(next)) next++; txt.Append(*next); } out->Append(txt.StealData()); if ('"' == *next) next++; return next; }