void SubmitEditorWidget::setLineWrapWidth(int v) { if (debug) qDebug() << Q_FUNC_INFO << v << lineWrap(); if (d->m_lineWidth == v) return; d->m_lineWidth = v; if (lineWrap()) d->m_ui.description->setLineWrapColumnOrWidth(v); }
const Shaping GlyphSet::getShaping(const std::u32string &string, const float maxWidth, const float lineHeight, const float horizontalAlign, const float verticalAlign, const float justify, const float spacing, const Point<float> &translate) const { Shaping shaping(translate.x * 24, translate.y * 24, string); // the y offset *should* be part of the font metadata const int32_t yOffset = -17; float x = 0; const float y = yOffset; // Loop through all characters of this label and shape. for (uint32_t chr : string) { auto it = sdfs.find(chr); if (it != sdfs.end()) { shaping.positionedGlyphs.emplace_back(chr, x, y); x += it->second.metrics.advance + spacing; } } if (shaping.positionedGlyphs.empty()) return shaping; lineWrap(shaping, lineHeight, maxWidth, horizontalAlign, verticalAlign, justify, translate); return shaping; }
// Extract the wrapped text from a text edit, which performs // the wrapping only optically. void SubmitEditorWidget::wrapDescription() { if (!lineWrap()) return; const QChar newLine = QLatin1Char('\n'); QTextEdit e; e.setVisible(false); e.setMinimumWidth(1000); e.setFontPointSize(1.0); e.setLineWrapColumnOrWidth(d->m_ui.description->lineWrapColumnOrWidth()); e.setLineWrapMode(d->m_ui.description->lineWrapMode()); e.setWordWrapMode(d->m_ui.description->wordWrapMode()); e.setPlainText(d->m_description); d->m_description.clear(); QTextCursor cursor(e.document()); cursor.movePosition(QTextCursor::Start); while (!cursor.atEnd()) { const QString block = cursor.block().text(); if (block.startsWith(QLatin1Char('\t'))) { // Don't wrap d->m_description += block + newLine; cursor.movePosition(QTextCursor::EndOfBlock); } else { forever { cursor.select(QTextCursor::LineUnderCursor); d->m_description += cursor.selectedText(); d->m_description += newLine; cursor.clearSelection(); if (cursor.atBlockEnd()) break; cursor.movePosition(QTextCursor::NextCharacter); } } cursor.movePosition(QTextCursor::NextBlock); } }
const Shaping FontStack::getShaping(const std::u32string &string, const float maxWidth, const float lineHeight, const float horizontalAlign, const float verticalAlign, const float justify, const float spacing, const vec2<float> &translate) const { Shaping shaping(translate.x * 24, translate.y * 24); // the y offset *should* be part of the font metadata const int32_t yOffset = -17; int32_t x = std::round(translate.x * 24); // one em const int32_t y = std::round(translate.y * 24) + yOffset; // one em // Loop through all characters of this label and shape. for (uint32_t chr : string) { auto metric = metrics.find(chr); if (metric != metrics.end()) { shaping.positionedGlyphs.emplace_back(chr, x, y); x += metric->second.advance + spacing; } } if (!shaping.positionedGlyphs.size()) return shaping; lineWrap(shaping, lineHeight, maxWidth, horizontalAlign, verticalAlign, justify); return shaping; }
int putchar(int character) { switch (character) { case '\r': x = 0; break; case '\n': { x = 0; y++; if (y == LINE_PER_SCREEN) { lineWrap(); y--; } break; } case '\t': { x = (x + 4) / 4 * 4; if (x == CHAR_PER_LINE) { x = 0; y++; } if (y == LINE_PER_SCREEN) { lineWrap(); y--; } break; } case '\f': { memset((void *)VIDEO_ADDRESS, 0, CHAR_PER_LINE * LINE_PER_SCREEN * 2); x = y = 0; break; } default: { *(uint16_t *)(VIDEO_ADDRESS + calcOffset(x, y)) = character | (0xF << 8); x++; if (x == CHAR_PER_LINE) { x = 0; y++; } if (y == LINE_PER_SCREEN) { lineWrap(); y--; } break; } } return character; }
QString SubmitEditorWidget::descriptionText() const { QString rc = trimMessageText(lineWrap() ? wrappedText(m_d->m_ui.description) : m_d->m_ui.description->toPlainText()); // append field entries foreach(const SubmitFieldWidget * fw, m_d->m_fieldWidgets) rc += fw->fieldValues(); return rc; }
// ###################################################################### std::string stdLineWrap(const std::string& in, size_t linelength, const std::string& pfx, const std::string& sfx) { std::vector<std::string> words; split(in, " \t\n", std::back_inserter(words)); return lineWrap(words.begin(), words.end(), linelength, pfx, sfx); }
EnvVar::EnvVar(const std::string &sName, const std::string &sDefault, const std::string &sHelp) : m_sName(sName), m_sHelp(sHelp), m_sVal(), m_dVal(0), m_iVal(0), m_bSet(false) { if (getenv(m_sName.c_str())) { m_sVal = getenv(m_sName.c_str()); m_bSet = true; getEnvVarInUse().push_back(this); } else { m_sVal = sDefault; } m_dVal = strtod(m_sVal.c_str(), 0); m_iVal = Int(m_dVal); getEnvVarList().push_back( std::pair<std::string, std::string>(m_sName, indentNewLines(lineWrap(splitOnSettings(m_sHelp), settingHelpWidth), (settingNameWidth + 4))) ); }