50
50
, m_generateByteOrderMark (false)
51
51
, m_endOfLineMode (eolUnix)
52
52
, m_removeTrailingSpaces (false)
53
, m_lineLengthLimit (1024)
54
55
// minimal block size must be > 0
55
56
Q_ASSERT (m_blockSize > 0);
166
167
if (m_editingTransactions > 1)
169
// reset informations about edit...
170
// reset information about edit...
170
171
m_editingLastRevision = m_revision;
171
172
m_editingLastLines = m_lines;
172
173
m_editingMinimalLineChanged = -1;
323
324
// only ranges on one line are supported
324
325
Q_ASSERT (range.start().line() == range.end().line());
326
// start colum <= end column and >= 0
327
// start column <= end column and >= 0
327
328
Q_ASSERT (range.start().column() <= range.end().column());
328
329
Q_ASSERT (range.start().column() >= 0);
470
471
m_blocks.at(i)->debugPrint (i);
473
bool TextBuffer::load (const QString &filename, bool &encodingErrors)
474
bool TextBuffer::load (const QString &filename, bool &encodingErrors, bool &tooLongLinesWrapped)
475
476
// fallback codec must exist
476
477
Q_ASSERT (m_fallbackTextCodec);
557
558
// get unicode data for this line
558
559
const QChar *unicodeData = file.unicode () + offset;
560
// construct new text line with content from file
561
TextLine textLine = TextLine (new TextLineData(QString (unicodeData, length)));
563
// ensure blocks aren't too large
564
if (m_blocks.last()->lines() >= m_blockSize)
565
m_blocks.append (new TextBlock (this, m_blocks.last()->startLine() + m_blocks.last()->lines()));
567
m_blocks.last()->appendLine (textLine);
562
* split lines, if too large
566
* calculate line length
568
int lineLength = length;
569
if ((m_lineLengthLimit > 0) && (lineLength > m_lineLengthLimit)) {
571
* search for place to wrap
573
int spacePosition = m_lineLengthLimit-1;
574
for (int testPosition = m_lineLengthLimit-1; (testPosition >= 0) && (testPosition >= (m_lineLengthLimit - (m_lineLengthLimit/10))); --testPosition) {
578
if (unicodeData[testPosition].isSpace() || unicodeData[testPosition].isPunct()) {
579
spacePosition = testPosition;
587
lineLength = spacePosition+1;
588
length -= lineLength;
589
tooLongLinesWrapped = true;
592
* be done after this round
598
* construct new text line with content from file
601
TextLine textLine = TextLine (new TextLineData(QString (unicodeData, lineLength)));
602
unicodeData += lineLength;
605
* ensure blocks aren't too large
607
if (m_blocks.last()->lines() >= m_blockSize)
608
m_blocks.append (new TextBlock (this, m_blocks.last()->startLine() + m_blocks.last()->lines()));
611
* append line to last block
613
m_blocks.last()->appendLine (textLine);
615
} while (length > 0);
571
618
// if no encoding error, break out of reading loop
790
void TextBuffer::markModifiedLinesAsSaved()
792
foreach(TextBlock* block, m_blocks)
793
block->markModifiedLinesAsSaved ();
740
796
QList<TextRange *> TextBuffer::rangesForLine (int line, KTextEditor::View *view, bool rangesWithAttributeOnly) const
742
798
// get block, this will assert on invalid line