本文整理汇总了C++中TextLine类的典型用法代码示例。如果您正苦于以下问题:C++ TextLine类的具体用法?C++ TextLine怎么用?C++ TextLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blockList
CompactHistoryLine::CompactHistoryLine ( const TextLine& line, CompactHistoryBlockList& bList )
: blockList(bList),
formatLength(0)
{
length=line.size();
if (line.size() > 0) {
formatLength=1;
int k=1;
// count number of different formats in this text line
Character c = line[0];
while ( k<length )
{
if ( !(line[k].equalsFormat(c)))
{
formatLength++; // format change detected
c=line[k];
}
k++;
}
//kDebug() << "number of different formats in string: " << formatLength;
formatArray = (CharacterFormat*) blockList.allocate(sizeof(CharacterFormat)*formatLength);
Q_ASSERT (formatArray!=nullptr);
text = (quint16*) blockList.allocate(sizeof(quint16)*line.size());
Q_ASSERT (text!=nullptr);
length=line.size();
wrapped=false;
// record formats and their positions in the format array
c=line[0];
formatArray[0].setFormat ( c );
formatArray[0].startPos=0; // there's always at least 1 format (for the entire line, unless a change happens)
k=1; // look for possible format changes
int j=1;
while ( k<length && j<formatLength )
{
if (!(line[k].equalsFormat(c)))
{
c=line[k];
formatArray[j].setFormat(c);
formatArray[j].startPos=k;
//kDebug() << "format entry " << j << " at pos " << formatArray[j].startPos << " " << &(formatArray[j].startPos) ;
j++;
}
k++;
}
// copy character values
for ( int i=0; i<line.size(); i++ )
{
text[i]=line[i].character;
//kDebug() << "char " << i << " at mem " << &(text[i]);
}
}
//kDebug() << "line created, length " << length << " at " << &(length);
}
示例2: ASFUNCTIONBODY
ASFUNCTIONBODY(TextBlock, createTextLine)
{
TextBlock* th=static_cast<TextBlock*>(obj);
_NR<TextLine> previousLine;
int32_t width;
ARG_UNPACK (previousLine, NullRef) (width, MAX_LINE_WIDTH);
if (argslen > 2)
LOG(LOG_NOT_IMPLEMENTED, "TextBlock::createTextLine ignored some parameters");
if (width <= 0 || width > MAX_LINE_WIDTH)
throw Class<ArgumentError>::getInstanceS("Invalid width");
if (!previousLine.isNull())
{
LOG(LOG_NOT_IMPLEMENTED, "TextBlock::createTextLine supports a single line only");
return getSys()->getNullRef();
}
th->incRef();
TextLine *textLine = Class<TextLine>::getInstanceS(th->content, _MNR(th));
textLine->width = (uint32_t)width;
textLine->updateSizes();
return textLine;
}
示例3: Line
void TextDisplay::HideCaret () {
if (Interactor::ValidCanvas(canvas) &&
caretline >= topline && caretline <= bottomline
) {
TextLine* l = Line(caretline, true);
l->Draw(this, caretline, caretindex-1, caretindex);
}
}
示例4: Line
IntCoord TextDisplay::Right (int line, int index) {
TextLine* l = Line(line, false);
if (l == nil) {
return xmin + x0;
} else {
return xmin + x0 + l->Offset(this, index+1) - 1;
}
}
示例5: parent
void Text::layout()
{
if (styled() && !_editMode) {
SimpleText::layout();
}
else {
_doc->setDefaultFont(textStyle().font(spatium()));
qreal w = -1.0;
qreal x = 0.0;
qreal y = 0.0;
if (parent() && layoutToParentWidth()) {
w = parent()->width();
if (parent()->type() == HBOX || parent()->type() == VBOX || parent()->type() == TBOX) {
Box* box = static_cast<Box*>(parent());
x += box->leftMargin() * MScore::DPMM;
y += box->topMargin() * MScore::DPMM;
w = box->width() - ((box->leftMargin() + box->rightMargin()) * MScore::DPMM);
}
}
QTextOption to = _doc->defaultTextOption();
to.setUseDesignMetrics(true);
to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
_doc->setDefaultTextOption(to);
if (w < 0.0)
w = _doc->idealWidth();
_doc->setTextWidth(w);
setbbox(QRectF(QPointF(0.0, 0.0), _doc->size()));
if (hasFrame())
layoutFrame();
_doc->setModified(false);
textStyle().layout(this); // process alignment
#if 0 // TODO TEXT_STYLE_TEXTLINE
if ((textStyle().align() & ALIGN_VCENTER) && (textStyle() == TEXT_STYLE_TEXTLINE)) {
// special case: vertically centered text with TextLine needs to
// take into account the line width
TextLineSegment* tls = static_cast<TextLineSegment*>(parent());
TextLine* tl = tls->textLine();
if (tl) {
qreal textlineLineWidth = point(tl->lineWidth());
rypos() -= textlineLineWidth * .5;
}
}
#endif
rxpos() += x;
rypos() += y;
}
if (parent() && parent()->type() == SEGMENT) {
Segment* s = static_cast<Segment*>(parent());
rypos() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
}
adjustReadPos();
}
示例6:
void
LineRenderer::refresh_tokens( TextLine & line ) {
if ( AudicleWindow::main()->m_syntax_query->parseLine ( line.str(), tokenized ) ) {
//if ( fakeTokenizer( line.str() , tokenized ) ) {
line.tokens() = tokenized;
}
line.dirty() = false;
}
示例7: PDFTextWordInterop
PDFTextWordInterop *PDFTextLineInterop::getWords()
{
if(_words == NULL)
{
TextLine *line = (TextLine *)_textLine;
TextWord *words = line->getWords();
_words = new PDFTextWordInterop(_textBlock, this, words, 0);
}
return _words;
}
示例8: sizeof
const char& TextFileIterator::operator *() const {
if (mLineIndex == mFile->getLineCount()) {
return *"\0";
}
TextLine *line = mFile->mLines[mLineIndex];
if (mLineFeedIndex != -1) {
const char *lfBytes = line->getLineFeed();
assert((size_t) mLineFeedIndex < sizeof(lfBytes) - 1);
return lfBytes[mLineFeedIndex];
}
return (*line)[mColumnIndex];
}
示例9: PDFTextLineInterop
PDFTextLineInterop *PDFTextLineInterop::getNext()
{
if(next == NULL)
{
TextLine *line = (TextLine *)_textLine;
TextLine *nextLine = line->getNext();
if(nextLine == NULL)
return NULL;
next = new PDFTextLineInterop(_textBlock, nextLine, _currentLine +1);
}
return next;
}
示例10:
TextFileIterator& TextFileIterator::operator --() {
if (0 < mColumnIndex) {
mColumnIndex--;
} else {
if (0 < mLineIndex) {
mLineIndex--;
TextLine *beforeLine = mFile->mLines[mLineIndex];
mColumnIndex = beforeLine->size() - 1;
}
}
return *this;
}
示例11: Q_ASSERT
void TextCursor::setPosition(const KTextEditor::Cursor& position, bool init)
{
// any change or init? else do nothing
if (!init && position.line() == line() && position.column() == m_column)
return;
// remove cursor from old block in any case
if (m_block)
m_block->removeCursor (this);
// first: validate the line and column, else invalid
if (position.column() < 0 || position.line () < 0 || position.line () >= m_buffer.lines ()) {
if (!m_range)
m_buffer.m_invalidCursors.insert (this);
m_block = 0;
m_line = m_column = -1;
return;
}
// else, find block
TextBlock *block = m_buffer.blockForIndex (m_buffer.blockForLine (position.line()));
Q_ASSERT(block);
// get line
TextLine textLine = block->line (position.line());
#if 0 // this is no good idea, smart cursors don't do that, too, for non-wrapping cursors
// now, validate column, else stay invalid
if (position.column() > textLine->text().size()) {
if (!m_range)
m_buffer.m_invalidCursors.insert (this);
m_block = 0;
m_line = m_column = -1;
return;
}
#endif
// if cursor was invalid before, remove it from invalid cursor list
if (!m_range && !m_block && !init) {
Q_ASSERT(m_buffer.m_invalidCursors.contains (this));
m_buffer.m_invalidCursors.remove (this);
}
// else: valid cursor
m_block = block;
m_line = position.line () - m_block->startLine ();
m_column = position.column ();
m_block->insertCursor (this);
}
示例12: getWordCount
int PDFTextLineInterop::getWordCount()
{
if(_wordCount == -1)
{
TextLine *line = (TextLine *)_textLine;
TextWord *words = line->getWords();
TextWord *word = NULL;
_wordCount = 0;
while(words)
{
word = words;
words = words->getNext();
_wordCount++;
}
}
return _wordCount;
}
示例13: towstring
stl::wstring towstring (const TextLine& line)
{
if (sizeof (wchar_t) == 4)
return stl::wstring ((const wchar_t*)line.TextUtf32 (), line.TextLength ());
stl::wstring result;
result.fast_resize (line.TextLength ());
const void* source = line.TextUtf32 ();
size_t source_size = line.TextLength () * sizeof (unsigned int);
void* destination = &result [0];
size_t destination_size = result.size () * sizeof (wchar_t);
convert_encoding (common::Encoding_UTF32LE, source, source_size, common::Encoding_UTF16LE, destination, destination_size);
return result;
}
示例14: glLineWidth
void
ShellContent::drawPromptLine( TextLine &s ) {
glLineWidth ( _fontWeight * 1.0 );
bufferFont->draw_sub( _prompt + "% " ); // we lose kerning from one to the next, but otherwise this is pretty legal.
glLineWidth ( _fontWeight * 2.0 );
bufferFont->draw_sub( s.str() );
}
示例15: if
void
TextBuffer::addTextLine( TextLine &t, int pos ) {
if ( empty() )
_lines[0] = t;
else if ( pos > (int)_lines.size() || pos == -1 )
_lines.push_back(t);
else
_lines.insert(_lines.begin()+pos, t );
t.dirty() = true;
}