void Tuple::Info::show_simple(STATE, Object* self, int level) { Tuple* tup = as<Tuple>(self); native_int size = tup->num_fields(); native_int stop = size < 6 ? size : 6; if(size == 0) { class_info(state, self, true); return; } class_info(state, self); std::cout << ": " << size << std::endl; ++level; for(native_int i = 0; i < stop; i++) { indent(level); Object* obj = tup->at(state, i); if(Tuple* t = try_as<Tuple>(obj)) { class_info(state, self); std::cout << ": " << t->num_fields() << ">" << std::endl; } else { obj->show_simple(state, level); } } if(tup->num_fields() > stop) ellipsis(level); close_body(level); }
void Array::Info::show(STATE, Object* self, int level) { Array* ary = as<Array>(self); native_int size = ary->size(); native_int stop = size < 5 ? size : 5; if(size == 0) { class_info(state, self, true); return; } class_info(state, self); std::cout << ": " << size << std::endl; ++level; for(native_int i = 0; i < stop; i++) { indent(level); Object* obj = ary->get(state, i); if(obj == ary) { class_info(state, obj, true); } else { obj->show(state, level); } } if(ary->size() > stop) ellipsis(level); close_body(level); }
/// same as (), but if n is too large, then returns 0 instead of raising an exception const_mv_type get_or_zero(int n) const { if ((n > order_max()) || (n < order_min())) { mv_type::regular_type r(shape()); r() = 0; return r; } return _data(n - omin, ellipsis()); }
const_mv_type operator()(int n) const { if (n > order_max()) TRIQS_RUNTIME_ERROR << " n > Max Order. n= " << n << ", Max Order = " << order_max(); if (n < order_min()) { mv_type::regular_type r(shape()); r() = 0; return r; } return _data(n - omin, ellipsis()); }
static choose_display_t choose_board_display(choose_t *cp) { choose_board_t *cbrd = cp->data; board_data_t *ptr; char tmpBM[BM_LEN - 1]; char cate[7], title[STRLEN]; int n; for (n = cp->start; n < cp->start + BBS_PAGESIZE; n++) { if (n >= cbrd->num) { prints("\n"); continue; } ptr = cbrd->brds + n; if (ptr->total == -1) { refresh(); check_newpost(ptr); } if (!cbrd->newflag) prints(" %5d", n + 1); else if (ptr->flag & BOARD_DIR_FLAG) prints(" 目录"); else prints(" %5d", ptr->total); if (ptr->flag & BOARD_DIR_FLAG) prints(" +"); else prints(" %s", ptr->unread ? "◆" : "◇"); if (!(ptr->flag & BOARD_CUSTOM_FLAG)) strcpy(tmpBM, ptr->BM); strlcpy(cate, ptr->title + 1, sizeof(cate)); strlcpy(title, ptr->title + 11, sizeof(title)); ellipsis(title, 20); prints("%c%-17s %s%s%6s %-20s %c ", (ptr->zap && !(ptr->flag & BOARD_NOZAP_FLAG)) ? '*' : ' ', ptr->name, (ptr->flag & BOARD_VOTE_FLAG) ? "\033[1;31mV\033[m" : " ", (ptr->flag & BOARD_CLUB_FLAG) ? (ptr->flag & BOARD_READ_FLAG) ? "\033[1;31mc\033[m" : "\033[1;33mc\033[m" : " ", cate, title, HAS_PERM (PERM_POST) ? ptr->property : ' '); if (ptr->flag & BOARD_DIR_FLAG) prints("[目录]\n"); else prints("%-12s %4d\n", ptr->BM[0] <= ' ' ? "诚征版主中" : strtok(tmpBM, " "), brdshm->bstatus[ptr->pos].inboard); } return 0; }
static void get_nick(char *nick, size_t size, const online_users_t *up, const online_user_info_t *ip, const struct userec *user) { if (up->follow && up->show_note) { strlcpy(nick, ip->note, size); } else { if (!ip->nick) { strlcpy(nick, user->username, size); // don't save nick here } else { strlcpy(nick, ip->nick, size); } } ellipsis(nick, 20); }
/** * Constructor. * @param window The main application window. * @param toolbar The main toolbar * @param fileDescription The description of the document file type as it is * to appear in file dialogs * @param fileExtension The file extension of the document file type (do not * include the period) * @param newFileLaunchesDialog True if creating a new file launches a dialog * to set additional parameters, false otherwise */ QQMenuHelper::QQMenuHelper(QMainWindow *window, QToolBar *toolbar, const QString &fileDescription, const QString &fileExtension, bool newFileLaunchesDialog) : QObject(window), mainWindow(window), mainToolBar(toolbar), description(fileDescription), extension(fileExtension), file(0), help(0) { QChar ellipsis(8230); // Some phrases need to be handled differently on Mac OS X QString prefsText = menuText(tr("Pr&eferences")); QString macPrefsText = QMenuBar::tr("Preferences"); QString quitText = menuText(tr("&Quit")); QString macQuitText = QMenuBar::tr("Quit %1"); QString helpText = tr("Help Contents"); QString macHelpText = tr("%1 Help").arg(qApp->applicationName()); QString aboutText = menuText(tr("&About %1")).arg(qApp->applicationName()); QString macAboutText = QMenuBar::tr("About %1"); QString aboutQtText = menuText(tr("About &Qt")); QString macAboutQtText = QMenuBar::tr("About Qt"); #ifdef Q_WS_MAC prefsText = macPrefsText; quitText = macQuitText; helpText = macHelpText; aboutText = macAboutText; aboutQtText = macAboutQtText; #endif // File menu actions QString fileNewText(tr("&New")); if (newFileLaunchesDialog) { fileNewText += ellipsis; } fileNewAction = new QAction(QIcon(":/icons/new.png"), menuText(fileNewText), window); fileNewAction->setStatusTip(tr("Create a new file")); fileNewAction->setToolTip(fileNewAction->statusTip()); fileNewAction->setShortcut(QKeySequence::New); connect(fileNewAction, SIGNAL(triggered()), this, SLOT(emitNewFile())); fileOpenAction = new QAction(QIcon(":/icons/open.png"), menuText(tr("&Open")) + ellipsis, window); fileOpenAction->setStatusTip(tr("Open an existing file")); fileOpenAction->setToolTip(fileOpenAction->statusTip()); fileOpenAction->setShortcut(QKeySequence::Open); connect(fileOpenAction, SIGNAL(triggered()), this, SLOT(emitOpenFile())); quitAction = new QAction(QIcon(":/icons/quit.png"), quitText, window); quitAction->setStatusTip(tr("Quit the application")); #if !defined(Q_WS_HILDON) quitAction->setShortcut(QKeySequence::Quit); #endif quitAction->setMenuRole(QAction::QuitRole); connect(quitAction, SIGNAL(triggered()), this, SIGNAL(quit())); fileSaveAction = new QAction(QIcon(":/icons/save.png"), menuText(tr("&Save")), window); fileSaveAction->setStatusTip(tr("Save the current file")); fileSaveAction->setToolTip(fileSaveAction->statusTip()); fileSaveAction->setShortcut(QKeySequence::Save); connect(fileSaveAction, SIGNAL(triggered()), this, SIGNAL(saveFile())); for (int i = 0; i < MAX_RECENT_FILES; i++) { // we'll set the actual paths later; just need actions that stick // around after a file is opened recentActions[i] = new QAction("", window); connect(recentActions[i], SIGNAL(triggered()), this, SLOT(openRecent())); } fileSeparatorAction = new QAction(this); fileSeparatorAction->setSeparator(true); closeAction = new QAction(QIcon(":/icons/close.png"), menuText(tr("&Close")), window); closeAction->setStatusTip(tr("Close the current file")); closeAction->setShortcut(QKeySequence::Close); connect(closeAction, SIGNAL(triggered()), this, SIGNAL(closeFile())); prefsAction = new QAction(prefsText, window); prefsAction->setStatusTip(tr("Change the application settings")); #if !defined(Q_WS_HILDON) prefsAction->setShortcut(QKeySequence::Preferences); #endif prefsAction->setMenuRole(QAction::PreferencesRole); connect(prefsAction, SIGNAL(triggered()), this, SIGNAL(editPreferences())); #if defined(Q_WS_MAC) || defined(Q_WS_HILDON) || defined(Q_WS_MAEMO_5) fileNewAction->setIconVisibleInMenu(false); fileOpenAction->setIconVisibleInMenu(false); quitAction->setIconVisibleInMenu(false); fileSaveAction->setIconVisibleInMenu(false); closeAction->setIconVisibleInMenu(false); #endif #if defined(Q_WS_MAC) docIcon = QIcon(":/icons/document_small.png"); modifiedDocIcon = QIcon(darkenPixmap(QPixmap(":/icons/document_small.png"))); #endif // File menu basic setup file = new QMenu(menuText(tr("&File")), window); recent = new QMenu(menuText(tr("Open &Recent")), window); file->addAction(fileNewAction); file->addAction(fileOpenAction); file->addMenu(recent); file->addAction(fileSaveAction); file->addAction(fileSeparatorAction); file->addAction(closeAction); file->addAction(prefsAction); insertionPoint = fileSeparatorAction; #if !defined(Q_WS_MAC) file->addSeparator(); #endif file->addAction(quitAction); #if !defined(Q_WS_HILDON) && !defined(Q_WS_MAEMO_5) window->menuBar()->addMenu(file); #endif // Help menu actions helpAction = new QAction(helpText, window); helpAction->setStatusTip(helpText); helpAction->setShortcut(QKeySequence::HelpContents); connect(helpAction, SIGNAL(triggered()), this, SLOT(showHelp())); aboutAction = new QAction(aboutText, window); aboutAction->setStatusTip(aboutText); aboutAction->setMenuRole(QAction::AboutRole); connect(aboutAction, SIGNAL(triggered()), this, SIGNAL(aboutApplication())); aboutQtAction = new QAction(aboutQtText, window); aboutQtAction->setStatusTip(aboutQtText); aboutQtAction->setMenuRole(QAction::AboutQtRole); connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(aboutQt())); // Help menu setup help = new QMenu(menuText(tr("&Help")), window); #if !defined(Q_WS_HILDON) && !defined(Q_WS_MAEMO_5) help->addAction(helpAction); #if !defined(Q_WS_MAC) // skip this on the mac, since both "About.." actions get moved elsewhere help->addSeparator(); #endif help->addAction(aboutAction); help->addAction(aboutQtAction); window->menuBar()->addMenu(help); #endif // toolbar setup addToToolBar(fileNewAction); addToToolBar(fileOpenAction); addToToolBar(fileSaveAction); // build the actions hash actions[New] = fileNewAction; actions[Open] = fileOpenAction; actions[Save] = fileSaveAction; actions[Recent1] = recentActions[0]; actions[Recent2] = recentActions[1]; actions[Recent3] = recentActions[2]; actions[Recent4] = recentActions[3]; actions[Recent5] = recentActions[4]; actions[Separator] = fileSeparatorAction; actions[Close] = closeAction; actions[Preferences] = prefsAction; actions[Quit] = quitAction; actions[Help] = helpAction; actions[About] = aboutAction; actions[AboutQt] = aboutQtAction; }
int smallest_nonzero() const { int om = omin; while ((om < order_max()) && (max_element(abs(_data(om - omin, ellipsis()))) < 1.e-10)) om++; return om; }
mv_type operator()(int n) { if (n > order_max()) TRIQS_RUNTIME_ERROR << " n > Max Order. n= " << n << ", Max Order = " << order_max(); if (n < order_min()) TRIQS_RUNTIME_ERROR << " n < Min Order. n= " << n << ", Min Order = " << order_min(); return _data(n - omin, ellipsis()); }
/** Finds the keystring from the source string and replaces it with the replacement string. The formated string is stored in the destination descriptor. */ TInt CResourceLoader::Formater(TDes& aDest, const TDesC& aSource, const TDesC& aKey, const TDesC& aSubs, TBidiText::TDirectionality aDirectionality) { // substitute string must not contain KSubStringSeparator, // or results will be unpredictable __ASSERT_DEBUG(aSubs.Locate(KSubStringSeparator) == KErrNotFound, User::Panic(KPanicCategory, EInvalidSubstitute)); TInt keylength(aKey.Length()); //aDest must be empty. aDest.Zero(); // offset indicates end of last handled key in source TInt offset(0); // offset in destination string TInt desOffset(0); // Substring directionalities are adjusted after all changes are done. TBool checkSubstringDirectionalities(EFalse); // count is the position in the source from which the substring starts TInt count(0); // Replaced parameters count TInt replaceCount(0); while (count != KErrNotFound) { // desCount is the position of the substring starts in destination. TInt desCount(0); TPtrC remainder = aSource.Right(aSource.Length() - offset); count = remainder.Find(aKey); TInt maxSubLength = -1; if (count != KErrNotFound) { replaceCount++; desOffset += count; offset += count; count = offset; desCount = desOffset; // copy source to destination if first time if (aDest.Length() == 0) aDest.Append(aSource); // delete found key from destination aDest.Delete(desCount, keylength); offset += keylength; // increase offset by key length if (count + keylength < (aSource.Length()-1)) // aKey is not at the end of string { if (aSource[count+keylength] == '[') // Key includes max datalength { maxSubLength = 10*(aSource[count+keylength+1]-'0') + (aSource[count+keylength+2]-'0'); aDest.Delete(desCount,4); // Length information stored->delete from descriptor offset += 4; // increase offset by max sub length indicator } } aDest.Insert(desCount, aSubs); desOffset = desCount + aSubs.Length(); if (maxSubLength > 0 && aSubs.Length() > maxSubLength) { aDest.Delete(desCount+maxSubLength-1, aSubs.Length()+1-maxSubLength); TText ellipsis(KEllipsis); aDest.Insert(desCount+maxSubLength-1, TPtrC(&ellipsis,1)); desOffset = desCount + maxSubLength; } TBidiText::TDirectionality subsDir = TBidiText::TextDirectionality(aDest.Mid(desCount, desOffset - desCount)); // If inserted string has different directionality, // insert directionality markers so that bidi algorithm works in a desired way. if (aDirectionality != subsDir) { checkSubstringDirectionalities = ETrue; TInt freeSpace = aDest.MaxLength() - aDest.Length(); // Protect the directionality of the inserted string. if (freeSpace >= KExtraSpaceForSubStringDirMarkers) { TBuf<1> subsMarker; subsMarker.Append(subsDir == TBidiText::ELeftToRight ? KLRMarker : KRLMarker); aDest.Insert(desOffset, subsMarker); aDest.Insert(desCount, subsMarker); desOffset += KExtraSpaceForSubStringDirMarkers; } } } } // Adjust substring directionality markers if necessary // and if there is enough room in destination string if (checkSubstringDirectionalities) { TText mainMarker = (aDirectionality == TBidiText::ELeftToRight ? KLRMarker : KRLMarker); TInt freeSpace = aDest.MaxLength() - aDest.Length(); // If not already done, protect the directionality of the original string // and all of the KSubStringSeparator separated substrings. if (freeSpace > 0 && aDest.Length() && aDest[0] != mainMarker && aDest[0] != KSubStringSeparator && aDest[0] != KDirNotFound) { aDest.Insert(0, TPtrC(&mainMarker, 1)); freeSpace--; } // Find and protect KSubStringSeparator separated substrings. // Go through string backwards so that any changes will not affect indexes // that are not yet checked. TInt j(aDest.Length()-1); while (freeSpace > 0 && j >= 0) { if (aDest[j] == KSubStringSeparator && j < (aDest.Length() - 1) && aDest[j+1] != mainMarker && aDest[j+1] != KDirNotFound) { aDest.Insert(j+1, TPtrC(&mainMarker, 1)); freeSpace--; } j--; } } return replaceCount; }
// { dg-options -std=c++11 } constexpr int ellipsis(...) { return 1; } constexpr int ellipsis_c = ellipsis(); // OK constexpr int ellipsis_c2 = ellipsis(42); // Internal error