KTextEditor
katedocument.h
65class KTEXTEDITOR_EXPORT KTextEditor::DocumentPrivate final : public KTextEditor::Document, private KTextEditor::MovingRangeFeedback
79 explicit DocumentPrivate(bool bSingleViewMode = false, bool bReadOnly = false, QWidget *parentWidget = nullptr, QObject * = nullptr)
123 KTextEditor::View *createView(QWidget *parent, KTextEditor::MainWindow *mainWindow = nullptr) override;
147 bool insertText(KTextEditor::Cursor position, const QStringList &text, bool block = false) override;
204 void textRemoved(KTextEditor::Document *document, KTextEditor::Range range, const QString &oldText);
267 bool editWrapLine(int line, int col, bool newLine = true, bool *newLineAdded = nullptr, bool notify = true);
336 *Returns the next or previous position cursor in this document from the stack depending on the argument passed.
339 KTextEditor::Cursor lastEditingPosition(EditingPositionKind nextOrPrevious, KTextEditor::Cursor);
385 QList<KTextEditor::Range> searchText(KTextEditor::Range range, const QString &pattern, const KTextEditor::SearchOptions options) const;
410 KSyntaxHighlighting::Theme::TextStyle defaultStyleAt(KTextEditor::Cursor position) const override;
496 void readSessionConfig(const KConfigGroup &config, const QSet<QString> &flags = QSet<QString>()) override;
506 void writeSessionConfig(KConfigGroup &config, const QSet<QString> &flags = QSet<QString>()) override;
610 KTextEditor::MovingCursor::InsertBehavior insertBehavior = KTextEditor::MovingCursor::MoveOnInsert) override;
620 KTextEditor::MovingRange::InsertBehaviors insertBehaviors = KTextEditor::MovingRange::DoNotExpand,
621 KTextEditor::MovingRange::EmptyBehavior emptyBehavior = KTextEditor::MovingRange::AllowEmpty) override;
669 transformCursor(int &line, int &column, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision = -1) override;
796 void newLine(KTextEditor::ViewPrivate *view, NewLineIndent indent = NewLineIndent::Indent, NewLinePos newLinePos = Normal); // Changes input
815 void commentSelection(KTextEditor::Range selection, KTextEditor::Cursor c, bool blockSelect, CommentType changeType);
844 void transformCursorOrRange(KTextEditor::ViewPrivate *view, const KTextEditor::Cursor, KTextEditor::Range selection, TextTransform);
908 bool removeStartStopCommentFromRegion(const KTextEditor::Cursor start, const KTextEditor::Cursor end, int attrib = 0);
virtual bool openUrl(const QUrl &url)
virtual void setReadWrite(bool readwrite=true)
virtual bool queryClose()
virtual bool saveAs(const QUrl &url)
virtual bool save()
bool closeUrl() override
void setModified()
An model for providing line annotation information.
Definition annotationinterface.h:42
virtual void setAnnotationModel(AnnotationModel *model)=0
Sets a new AnnotationModel for this document to provide annotation information for each line.
virtual void setConfigValue(const QString &key, const QVariant &value)=0
Set a the key's value to value.
virtual bool documentSaveAs()=0
Save the current file to another location.
virtual QList< View * > views() const =0
Returns the views pre-casted to KTextEditor::Views.
virtual bool insertLine(int line, const QString &text)=0
Insert line(s) at the given line number.
virtual bool setEncoding(const QString &encoding)=0
Set the encoding for this document.
virtual KTextEditor::Cursor offsetToCursor(qsizetype offset) const =0
Retrives the cursor position for given offset NOTE: It will return an invalid cursor(-1,...
virtual bool isValidTextPosition(KTextEditor::Cursor cursor) const =0
Get whether cursor is a valid text position.
virtual void setModifiedOnDisk(ModifiedOnDiskReason reason)=0
Set the document's modified-on-disk state to reason.
virtual KTextEditor::Range wordRangeAt(KTextEditor::Cursor cursor) const =0
Get the text range for the word located under the text position cursor.
virtual qsizetype totalCharacters() const =0
Get the count of characters in the document.
virtual bool isDataRecoveryAvailable() const =0
Returns whether a recovery is available for the current document.
virtual bool setText(const QString &text)=0
Set the given text as new document content.
virtual void setMarkDescription(MarkTypes mark, const QString &text)=0
Set the mark's description to text.
virtual bool replaceText(Range range, const QString &text, bool block=false)
Replace text from range with specified text.
Definition document.cpp:85
virtual bool insertLines(int line, const QStringList &text)=0
Insert line(s) at the given line number.
virtual void setMarkIcon(MarkTypes markType, const QIcon &icon)=0
Set the mark's icon to icon.
virtual bool isLineTouched(int line) const =0
Check whether line was touched since the file was opened.
virtual QString wordAt(KTextEditor::Cursor cursor) const =0
Get the word at the text position cursor.
virtual qsizetype cursorToOffset(KTextEditor::Cursor c) const =0
Retrives the offset for the given cursor position NOTE: It will return -1 if the cursor was invalid o...
virtual QVariant configValue(const QString &key)=0
Get a value for the key.
virtual void discardDataRecovery()=0
If recover data is available, calling discardDataRecovery() will discard the recover data and the rec...
virtual bool removeText(Range range, bool block=false)=0
Remove the text specified in range.
virtual void setEditableMarks(uint markMask)=0
Set the mark mask the user is allowed to toggle to markMask.
QList< KTextEditor::Range > searchText(KTextEditor::Range range, const QString &pattern, const SearchOptions options=Default) const
Searches the given input range for a text pattern.
Definition document.cpp:108
virtual void addMark(int line, uint markType)=0
Add marks of type markType to line.
virtual View * createView(QWidget *parent, KTextEditor::MainWindow *mainWindow=nullptr)=0
Create a new view attached to parent.
virtual AnnotationModel * annotationModel() const =0
returns the currently set AnnotationModel or 0 if there's none set
virtual int lineLength(int line) const =0
Get the length of a given line in characters.
virtual uint editableMarks() const =0
Get, which marks can be toggled by the user.
virtual QStringList textLines(Range range, bool block=false) const =0
Get the document content within the given range.
virtual void recoverData()=0
If recover data is available, calling recoverData() will trigger the recovery of the data.
virtual bool postMessage(Message *message)=0
Post message to the Document and its Views.
virtual QString markDescription(MarkTypes mark) const =0
Get the mark's description to text.
virtual const QHash< int, KTextEditor::Mark * > & marks()=0
Get a hash holding all marks in the document.
virtual bool insertText(KTextEditor::Cursor position, const QString &text, bool block=false)=0
Insert text at position.
virtual QStringList configKeys() const =0
Get a list of all available keys.
virtual Cursor documentEnd() const =0
End position of the document.
virtual QString highlightingModeAt(KTextEditor::Cursor position)=0
Get the highlight mode used at a given position in the document.
virtual QStringList embeddedHighlightingModes() const =0
Get all available highlighting modes for the current document.
virtual bool isLineSaved(int line) const =0
Check whether line currently contains only saved text.
virtual bool isEditingTransactionRunning() const =0
Check whether an editing transaction is currently running.
virtual QIcon markIcon(MarkTypes markType) const =0
Get the mark's icon.
virtual QChar characterAt(KTextEditor::Cursor position) const =0
Get the character at text position cursor.
virtual void removeMark(int line, uint markType)=0
Remove the mark mask of type markType from line.
virtual bool isLineModified(int line) const =0
Check whether line currently contains unsaved data.
virtual void setMark(int line, uint markType)=0
Set the line's mark types to markType.
virtual void setModifiedOnDiskWarning(bool on)=0
Control, whether the editor should show a warning dialog whenever a file was modified on disk.
An object representing lines from a start line to an end line.
Definition linerange.h:41
This class allows the application that embeds the KTextEditor component to allow it to access parts o...
Definition mainwindow.h:47
A Cursor which is bound to a specific Document, and maintains its position.
Definition movingcursor.h:55
InsertBehavior
Insert behavior of this cursor, should it stay if text is insert at its position or should it move.
Definition movingcursor.h:64
A class which provides notifications of state changes to a MovingRange.
Definition movingrangefeedback.h:36
A range that is bound to a specific Document, and maintains its position.
Definition movingrange.h:145
@ DoNotExpand
Don't expand to encapsulate new characters in either direction. This is the default.
Definition movingrange.h:154
An object representing a section of text, from one Cursor to another.
Definition include/ktexteditor/range.h:49
static constexpr Range invalid() noexcept
Returns an invalid range.
Definition include/ktexteditor/range.h:121
void rangeInvalid(KTextEditor::MovingRange *movingRange) override
The range is now invalid (ie.
virtual QString variable(const QString &name) const
Returns the value for the variable name.
bool editInsertLine(int line, const QString &s, bool notify=true)
Insert a string at the given line.
bool saveFile() override
save the file obtained by the kparts framework the framework abstracts the uploading of remote files
QStringList modes() const override
Return a list of the names of all possible modes.
bool editUnWrapLine(int line, bool removeLine=true, int length=0)
Unwrap line.
bool editWrapLine(int line, int col, bool newLine=true, bool *newLineAdded=nullptr, bool notify=true)
Wrap line.
qint64 lastSavedRevision() const override
Last revision the buffer got successful saved.
void transformCursor(KTextEditor::Cursor &cursor, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision=-1) override
Transform a cursor from one revision to an other.
bool setHighlightingMode(const QString &name) override
Set the current mode of the document by giving its name.
KTextEditor::MovingRange * newMovingRange(KTextEditor::Range range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors=KTextEditor::MovingRange::DoNotExpand, KTextEditor::MovingRange::EmptyBehavior emptyBehavior=KTextEditor::MovingRange::AllowEmpty) override
Create a new moving range for this document.
QStringList highlightingModes() const override
Return a list of the names of all possible modes.
void lockRevision(qint64 revision) override
Lock a revision, this will keep it around until released again.
bool handleMarkClick(int line)
Returns true if the click on the mark should not be further processed.
void editLineUnWrapped(int line, int col)
Emitted each time text from nextLine was upwrapped onto line.
void setDontChangeHlOnSave()
allow to mark, that we changed hl on user wish and should not reset it atm used for the user visible ...
void textRemoved(KTextEditor::Document *document, KTextEditor::Range range, const QString &oldText)
The document emits this signal whenever range was removed, i.e.
QString highlightingModeSection(int index) const override
Returns the name of the section for a highlight given its index in the highlight list (as returned by...
bool openFile() override
open the file obtained by the kparts framework the framework abstracts the loading of remote files
int lineLengthLimit() const
reads the line length limit from config, if it is not overridden
QWidget * widget() override
QString highlightingMode() const override
Return the name of the currently used mode.
void removeAllTrailingSpaces()
This function doesn't check for config and is available for use all the time via an action.
QString mimeType() override
Tries to detect mime-type based on file name and content of buffer.
void typeChars(KTextEditor::ViewPrivate *view, QString chars)
Type chars in a view.
void transform(KTextEditor::ViewPrivate *view, KTextEditor::Cursor, TextTransform)
Handling uppercase, lowercase and capitalize for the view.
bool documentReload() override
Reloads the current document from disk if possible.
int findTouchedLine(int startLine, bool down)
Find the next modified/saved line, starting at startLine.
void readSessionConfig(const KConfigGroup &config, const QSet< QString > &flags=QSet< QString >()) override
Read session settings from the given config.
void rememberUserDidSetIndentationMode()
set indentation mode by user this will remember that a user did set it and will avoid reset on save
Definition katedocument.h:1095
void saveEditingPositions(const KTextEditor::Cursor cursor)
Saves the editing positions into the stack.
QString decodeCharacters(KTextEditor::Range range, KTextEditor::DocumentPrivate::OffsetList &decToEncOffsetList, KTextEditor::DocumentPrivate::OffsetList &encToDecOffsetList)
The first OffsetList is from decoded to encoded, and the second OffsetList from encoded to decoded.
bool editMarkLineAutoWrapped(int line, bool autowrapped)
Mark line as autowrapped.
bool editInsertText(int line, int col, const QString &s, bool notify=true)
Add a string in the given line/column.
virtual void slotModifiedOnDisk(KTextEditor::View *v=nullptr)
Ask the user what to do, if the file has been modified on disk.
bool editRemoveText(int line, int col, int len)
Remove a string in the given line/column.
QByteArray checksum() const override
Returns a git compatible sha1 checksum of this document on disk.
bool setMode(const QString &name) override
Set the current mode of the document by giving its name.
void transformRange(KTextEditor::Range &range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors, KTextEditor::MovingRange::EmptyBehavior emptyBehavior, qint64 fromRevision, qint64 toRevision=-1) override
Transform a range from one revision to an other.
void writeSessionConfig(KConfigGroup &config, const QSet< QString > &flags=QSet< QString >()) override
Write session settings to the config.
QString modeSection(int index) const override
Returns the name of the section for a mode given its index in the highlight list (as returned by mode...
void textInsertedRange(KTextEditor::Document *document, KTextEditor::Range range)
The document emits this signal whenever text was inserted.
bool wrapParagraph(int first, int last)
Wrap lines touched by the selection with respect of existing paragraphs.
virtual void setVariable(const QString &name, const QString &value)
Set the variable name to value.
void editLineWrapped(int line, int col, int len)
Emitted when text from line was wrapped at position pos onto line nextLine.
KTextEditor::Cursor lastEditingPosition(EditingPositionKind nextOrPrevious, KTextEditor::Cursor)
Returns the next or previous position cursor in this document from the stack depending on the argumen...
bool updateFileType(const QString &newType, bool user=false)
KTextEditor::MovingCursor * newMovingCursor(KTextEditor::Cursor position, KTextEditor::MovingCursor::InsertBehavior insertBehavior=KTextEditor::MovingCursor::MoveOnInsert) override
Create a new moving cursor for this document.
Kate::TextLine kateTextLine(int i)
Same as plainKateTextLine(), except that it is made sure the line is highlighted.
void transformCursor(int &line, int &column, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision=-1) override
Transform a cursor from one revision to an other.
void clearEditingPosStack()
Removes all the elements in m_editingStack of the respective document.
bool handleMarkContextMenu(int line, QPoint position)
Returns true if the context-menu event should not further be processed.
KSyntaxHighlighting::Theme::TextStyle defaultStyleAt(KTextEditor::Cursor position) const override
Get the default style of the character located at position.
void rangeEmpty(KTextEditor::MovingRange *movingRange) override
The range is now empty (ie.
void userSetEncodingForNextReload()
User did set encoding for next reload => enforce it!
Definition katedocument.h:1103
bool editStart()
Enclose editor actions with editStart() and editEnd() to group them.
This dialog will prompt the user for what do with a file that is modified on disk.
Definition katedialogs.h:328
Inserts a template and offers advanced snippet features, like navigation and mirroring.
Definition katetemplatehandler.h:54
Q_SCRIPTABLE Q_NOREPLY void start()
KIOCORE_EXPORT DeleteJob * del(const QList< QUrl > &src, JobFlags flags=DefaultFlags)
const QList< QKeySequence > & paste()
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition katetextblock.h:20
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.