KTextEditor
katetextbuffer.cpp
101 // kill all invalid cursors, do this after block deletion, to uncover if they might be still linked in blocks
127 // clean out all cursors and lines, either move them to newBlock or invalidate them, if belonging to a range
221 Q_ASSERT(!editingChangedBuffer() || (m_editingMinimalLineChanged != -1 && m_editingMaximalLineChanged != -1));
222 Q_ASSERT(!editingChangedBuffer() || (m_editingMinimalLineChanged <= m_editingMaximalLineChanged));
223 Q_ASSERT(!editingChangedBuffer() || (m_editingMinimalLineChanged >= 0 && m_editingMinimalLineChanged < m_lines));
224 Q_ASSERT(!editingChangedBuffer() || (m_editingMaximalLineChanged >= 0 && m_editingMaximalLineChanged < m_lines));
299 m_blocks.at(blockIndex)->unwrapLine(line, (blockIndex > 0) ? m_blocks.at(blockIndex - 1) : nullptr, firstLineInBlock ? (blockIndex - 1) : blockIndex);
548 bool TextBuffer::load(const QString &filename, bool &encodingErrors, bool &tooLongLinesWrapped, int &longestLineLoaded, bool enforceTextCodec)
564 // 1) use BOM to decided if Unicode or if that fails, use encoding prober, if no encoding errors happen, be done
609 BUFFER_DEBUG << "Failed try to load file" << filename << "with codec" << (file.textCodec() ? file.textCodec()->name() : "(null)");
627 for (int testPosition = m_lineLengthLimit - 1; (testPosition >= 0) && (testPosition >= (m_lineLengthLimit - (m_lineLengthLimit / 10)));
652 m_blocks.push_back(new TextBlock(this, m_blocks.back()->startLine() + m_blocks.back()->lines()));
689 BUFFER_DEBUG << "Loaded file " << filename << "with codec" << m_textCodec->name() << (encodingErrors ? "with" : "without") << "encoding errors";
758 std::unique_ptr<QTextEncoder> encoder(m_textCodec->makeEncoder(generateByteOrderMark() ? QTextCodec::DefaultConversion : QTextCodec::IgnoreHeader));
784 // TODO: this only writes bytes when there is text. This is a fine optimization for most cases, but this makes saving
808 const KCompressionDevice::CompressionType type = KCompressionDevice::compressionTypeForMimeType(m_mimeTypeForFilterDev);
832 const KCompressionDevice::CompressionType type = KCompressionDevice::compressionTypeForMimeType(m_mimeTypeForFilterDev);
849 // open buffer for write and read (read is used for checksum computing and writing to temporary file)
921 void TextBuffer::notifyAboutRangeChange(KTextEditor::View *view, KTextEditor::LineRange lineRange, bool needsRepaint)
928 // update all views, this IS ugly and could be a signal, but I profiled and a signal is TOO slow, really
TextBuffer::EndOfLineMode eol() const
Detected end of line mode for this file.
Definition: katetextloader.h:122
void setDigest(const QByteArray &checksum)
Set the checksum of this buffer.
Definition: katetextbuffer.cpp:709
virtual bool load(const QString &filename, bool &encodingErrors, bool &tooLongLinesWrapped, int &longestLineLoaded, bool enforceTextCodec)
Load the given file.
Definition: katetextbuffer.cpp:548
QString errorString() const const
virtual void clear()
Clears the buffer, reverts to initial empty state.
Definition: katetextbuffer.cpp:116
virtual void insertText(const KTextEditor::Cursor position, const QString &text)
Insert text at given cursor position.
Definition: katetextbuffer.cpp:331
WriteOnly
virtual void wrapLine(const KTextEditor::Cursor position)
Wrap line at given cursor position.
Definition: katetextbuffer.cpp:236
File Loader, will handle reading of files + detecting encoding.
Definition: katetextloader.h:30
Q_EMITQ_EMIT
Type type(const QSqlDatabase &db)
bool editingChangedBuffer() const
Query information from the last editing transaction: was the content of the buffer changed?...
Definition: katetextbuffer.h:295
void setEndOfLineMode(EndOfLineMode endOfLineMode)
Set end of line mode for this buffer, not allowed to be set to unknown.
Definition: katetextbuffer.h:153
Q_SCRIPTABLE Q_NOREPLY void start()
CompressionType
An object representing lines from a start line to an end line.
Definition: linerange.h:37
An object representing a section of text, from one Cursor to another.
Definition: include/ktexteditor/range.h:44
const QString & mimeTypeForFilterDev() const
mime type used to create filter dev
Definition: katetextloader.h:140
virtual void removeText(KTextEditor::Range range)
Remove text at given range.
Definition: katetextbuffer.cpp:369
virtual QString fileName() const const override
virtual int mibEnum() const const=0
const QByteArray & digest() const
Checksum of the document on disk, set either through file loading in openFile() or in KTextEditor::Do...
Definition: katetextbuffer.cpp:704
bool readLine(int &offset, int &length)
read a line, return length + offset in Unicode data
Definition: katetextloader.h:169
~TextBuffer() override
Destruct the text buffer Virtual, we allow inheritance.
Definition: katetextbuffer.cpp:78
virtual bool startEditing()
Start an editing transaction, the wrapLine/unwrapLine/insertText and removeText functions are only al...
Definition: katetextbuffer.cpp:181
void loaded(const QString &filename, bool encodingErrors)
Buffer loaded successfully a file.
static CompressionType compressionTypeForMimeType(const QString &mimetype)
NoError
bool isEmpty() const const
virtual bool save(const QString &filename)
Save the current buffer content to the given file.
Definition: katetextbuffer.cpp:728
virtual bool seek(qint64 pos) override
void textRemoved(KTextEditor::Range range, const QString &text)
Text got removed.
bool isPunct() const const
static bool unitTestMode()
Returns true, if the unit test mode was enabled through a call of enableUnitTestMode(),...
Definition: kateglobal.cpp:64
TextBuffer(KTextEditor::DocumentPrivate *parent, int blockSize=64, bool alwaysUseKAuth=false)
Construct an empty text buffer.
Definition: katetextbuffer.cpp:50
DefaultConversion
bool flush()
bool open(QIODevice::OpenMode mode) override
void textInserted(const KTextEditor::Cursor position, const QString &text)
Text got inserted.
void lineWrapped(const KTextEditor::Cursor position)
A line got wrapped.
void close() override
QFileDevice::FileError error() const
QVariant read(const QByteArray &data, int versionOverride=0)
void debugPrint(const QString &title) const
Debug output, print whole buffer content with line numbers and line length.
Definition: katetextbuffer.cpp:537
void appendLine(const QString &textOfLine)
Append a new line with given text.
Definition: katetextblock.cpp:50
constexpr int line() const Q_DECL_NOEXCEPT
Retrieve the line on which this cursor is situated.
Definition: cursor.h:195
bool open()
void setGenerateByteOrderMark(bool generateByteOrderMark)
Generate byte order mark on save.
Definition: katetextbuffer.h:134
void setTextCodec(QTextCodec *codec)
Set codec for this buffer to use for load/save.
Definition: katetextbuffer.cpp:714
bool exec()
qint64 write(const char *data, qint64 maxSize)
QTextEncoder * makeEncoder(QTextCodec::ConversionFlags flags) const const
virtual QByteArray name() const const=0
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:52:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:52:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.