KTextEditor
katetextbuffer.cpp
278 Q_ASSERT(!editingChangedBuffer() || (m_editingMinimalLineChanged != -1 && m_editingMaximalLineChanged != -1));
279 Q_ASSERT(!editingChangedBuffer() || (m_editingMinimalLineChanged <= m_editingMaximalLineChanged));
280 Q_ASSERT(!editingChangedBuffer() || (m_editingMinimalLineChanged >= 0 && m_editingMinimalLineChanged < m_lines));
281 Q_ASSERT(!editingChangedBuffer() || (m_editingMaximalLineChanged >= 0 && m_editingMaximalLineChanged < m_lines));
350 m_blocks.at(blockIndex)->unwrapLine(line, (blockIndex > 0) ? m_blocks.at(blockIndex - 1) : nullptr, firstLineInBlock ? (blockIndex - 1) : blockIndex);
571bool TextBuffer::load(const QString &filename, bool &encodingErrors, bool &tooLongLinesWrapped, int &longestLineLoaded, bool enforceTextCodec)
587 // 1) use BOM to decided if Unicode or if that fails, use encoding prober, if no encoding errors happen, be done
642 m_blocks.push_back(new TextBlock(this, m_blocks.back()->startLine() + m_blocks.back()->lines()));
708 if (const auto setEncoding = QStringConverter::encodingForName(m_textCodec.toUtf8().constData())) {
753 QStringEncoder encoder(m_textCodec.toUtf8().constData(), generateByteOrderMark() ? QStringConverter::Flag::WriteBom : QStringConverter::Flag::Default);
779 // TODO: this only writes bytes when there is text. This is a fine optimization for most cases, but this makes saving
803 const KCompressionDevice::CompressionType type = KCompressionDevice::compressionTypeForMimeType(m_mimeTypeForFilterDev);
827 const KCompressionDevice::CompressionType type = KCompressionDevice::compressionTypeForMimeType(m_mimeTypeForFilterDev);
844 // open buffer for write and read (read is used for checksum computing and writing to temporary file)
916void TextBuffer::notifyAboutRangeChange(KTextEditor::View *view, KTextEditor::LineRange lineRange, bool needsRepaint)
923 // update all views, this IS ugly and could be a signal, but I profiled and a signal is TOO slow, really
933 static_cast<KTextEditor::ViewPrivate *>(curView)->notifyAboutRangeChange(lineRange, needsRepaint);
static CompressionType compressionTypeForMimeType(const QString &mimetype)
QFileDevice::FileError error() const
CompressionType
void close() override
bool open(QIODevice::OpenMode mode) override
bool exec()
constexpr int column() const noexcept
Retrieve the column on which this cursor is situated.
Definition cursor.h:192
constexpr bool isValid() const noexcept
Returns whether the current position of this cursor is a valid position (line + column must both be >...
Definition cursor.h:102
constexpr int line() const noexcept
Retrieve the line on which this cursor is situated.
Definition cursor.h:174
Backend of KTextEditor::Document related public KTextEditor interfaces.
Definition katedocument.h:66
QList< KTextEditor::View * > views() const override
Returns the views pre-casted to KTextEditor::Views.
Definition katedocument.h:125
An object representing lines from a start line to an end line.
Definition linerange.h:41
An object representing a section of text, from one Cursor to another.
Definition include/ktexteditor/range.h:49
constexpr Cursor end() const noexcept
Get the end position of this range.
Definition include/ktexteditor/range.h:163
constexpr Cursor start() const noexcept
Get the start position of this range.
Definition include/ktexteditor/range.h:153
constexpr bool isEmpty() const noexcept
Returns true if this range contains no characters, ie.
Definition include/ktexteditor/range.h:301
void appendLine(const QString &textOfLine)
Append a new line with given text.
Definition katetextblock.cpp:61
virtual void removeText(KTextEditor::Range range)
Remove text at given range.
Definition katetextbuffer.cpp:414
int cursorToOffset(KTextEditor::Cursor c) const
Retrieve offset in text for the given cursor position.
Definition katetextbuffer.cpp:169
TextBuffer(KTextEditor::DocumentPrivate *parent, bool alwaysUseKAuth=false)
Construct an empty text buffer.
Definition katetextbuffer.cpp:50
virtual bool save(const QString &filename)
Save the current buffer content to the given file.
Definition katetextbuffer.cpp:723
virtual void wrapLine(const KTextEditor::Cursor position)
Wrap line at given cursor position.
Definition katetextbuffer.cpp:290
void setDigest(const QByteArray &checksum)
Set the checksum of this buffer.
Definition katetextbuffer.cpp:698
bool editingChangedBuffer() const
Query information from the last editing transaction: was the content of the buffer changed?...
Definition katetextbuffer.h:310
~TextBuffer() override
Destruct the text buffer Virtual, we allow inheritance.
Definition katetextbuffer.cpp:71
KTextEditor::Cursor offsetToCursor(int offset) const
Retrieve cursor in text for the given offset.
Definition katetextbuffer.cpp:198
virtual void insertText(const KTextEditor::Cursor position, const QString &text)
Insert text at given cursor position.
Definition katetextbuffer.cpp:379
void setLineMetaData(int line, const TextLine &textLine)
Transfer all non text attributes for the given line from the given text line to the one in the buffer...
Definition katetextbuffer.cpp:160
void setEndOfLineMode(EndOfLineMode endOfLineMode)
Set end of line mode for this buffer, not allowed to be set to unknown.
Definition katetextbuffer.h:151
void loaded(const QString &filename, bool encodingErrors)
Buffer loaded successfully a file.
void setTextCodec(const QString &codec)
Set codec for this buffer to use for load/save.
Definition katetextbuffer.cpp:703
virtual bool load(const QString &filename, bool &encodingErrors, bool &tooLongLinesWrapped, int &longestLineLoaded, bool enforceTextCodec)
Load the given file.
Definition katetextbuffer.cpp:571
virtual bool startEditing()
Start an editing transaction, the wrapLine/unwrapLine/insertText and removeText functions are only al...
Definition katetextbuffer.cpp:241
virtual void clear()
Clears the buffer, reverts to initial empty state.
Definition katetextbuffer.cpp:109
KTextEditor::DocumentPrivate * document() const
Gets the document to which this buffer is bound.
Definition katetextbuffer.h:473
void setGenerateByteOrderMark(bool generateByteOrderMark)
Generate byte order mark on save.
Definition katetextbuffer.h:132
void debugPrint(const QString &title) const
Debug output, print whole buffer content with line numbers and line length.
Definition katetextbuffer.cpp:560
const QByteArray & digest() const
Checksum of the document on disk, set either through file loading in openFile() or in KTextEditor::Do...
Definition katetextbuffer.cpp:693
File Loader, will handle reading of files + detecting encoding.
Definition katetextloader.h:34
const QString & mimeTypeForFilterDev() const
mime type used to create filter dev
Definition katetextloader.h:142
bool readLine(int &offset, int &length, bool &tooLongLinesWrapped, int &longestLineLoaded)
read a line, return length + offset in Unicode data
Definition katetextloader.h:173
TextBuffer::EndOfLineMode eol() const
Detected end of line mode for this file.
Definition katetextloader.h:124
Q_SCRIPTABLE Q_NOREPLY void start()
QVariant read(const QByteArray &data, int versionOverride=0)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
const char * constData() const const
NoError
bool flush()
virtual bool seek(qint64 pos) override
QString errorString() const const
qint64 write(const QByteArray &data)
WriteOnly
Q_EMITQ_EMIT
void clear()
bool isEmpty() const const
void reserve(qsizetype size)
qsizetype size() const const
QByteArray toUtf8() const const
std::optional< Encoding > encodingForName(const char *name)
virtual QString fileName() const const override
bool open()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:56:21 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:56:21 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.