13#include <ktexteditor/linerange.h>
14#include <ktexteditor/mainwindow.h>
15#include <ktexteditor/view.h>
17#include <QJsonDocument>
23#include "katetextfolding.h"
24#include "katetextrange.h"
30class InlineNoteProvider;
39class KateRendererConfig;
42class KateSpellCheckDialog;
44class KateViewInternal;
48class KateDictionaryBar;
49class KateSpellingMenu;
53class KateViewEncodingAction;
55class KateAbstractInputMode;
80 friend class ::KateViewInternal;
81 friend class ::KateIconBorder;
82 friend class ::KateTextPreview;
83 friend MulticursorTest;
87 ~ViewPrivate()
override;
100 ViewMode viewMode()
const override;
101 QString viewModeHuman()
const override;
102 InputMode viewInputMode()
const override;
103 QString viewInputModeHuman()
const override;
105 void setViewInputMode(InputMode mode)
override
110 void setInputMode(InputMode mode,
const bool rememberInConfig =
true);
113 KateViewInternal *getViewInternal()
115 return m_viewInternal;
137 void pasteFromFile();
142 void swapWithClipboard();
148 void applyWordWrap();
153 void copyFileLocation()
const;
159 void setContextMenu(
QMenu *menu)
override;
160 QMenu *contextMenu()
const override;
161 QMenu *defaultContextMenu(
QMenu *menu =
nullptr)
const override;
164 void aboutToShowContextMenu();
165 void aboutToHideContextMenu();
184 QPoint cursorPositionCoordinates()
const override;
188 QScrollBar *verticalScrollBar()
const override;
189 QScrollBar *horizontalScrollBar()
const override;
196 int virtualCursorColumn()
const;
198 bool mouseTrackingEnabled()
const override;
199 bool setMouseTrackingEnabled(
bool enable)
override;
206 struct PlainSecondaryCursor {
209 friend bool operator<(
const PlainSecondaryCursor &l,
const PlainSecondaryCursor &r)
211 return l.pos < r.pos;
214 struct SecondaryCursor {
215 std::unique_ptr<Kate::TextCursor> pos;
216 std::unique_ptr<Kate::TextRange> range;
221 return pos->toCursor();
224 friend bool operator<(
const SecondaryCursor &l,
const SecondaryCursor &r)
226 return l.cursor() < r.cursor();
231 return l.cursor() < r;
234 friend bool operator==(
const SecondaryCursor &l,
const SecondaryCursor &r)
236 return l.cursor() == r.cursor() && l.selectionRange() == r.selectionRange();
244 void clearSelection()
252 bool isMulticursorNotAllowed()
const;
258 const std::vector<SecondaryCursor> &secondaryCursors()
const;
262 void clearSecondaryCursors();
263 void clearSecondarySelections();
267 void ensureUniqueCursors(
bool matchLine =
false);
277 bool hasSelections()
const;
280 KTEXTEDITOR_NO_EXPORT
281 bool removeSecondaryCursors(
const std::vector<KTextEditor::Cursor> &cursorToRemove,
bool removeIfOverlapsSelection =
false);
282 KTEXTEDITOR_NO_EXPORT
284 KTEXTEDITOR_NO_EXPORT
286 KTEXTEDITOR_NO_EXPORT
289 std::vector<SecondaryCursor> m_secondaryCursors;
290 bool m_skipCurrentSelection =
false;
292 void addSecondaryCursorDown();
294 void addSecondaryCursorUp();
298 KTEXTEDITOR_NO_EXPORT
303 bool setCursorPositionInternal(
const KTextEditor::Cursor position, uint tabwidth = 1,
bool calledExternally =
false);
311 void setConfigValue(
const QString &key,
const QVariant &value)
override;
324 bool unfoldLine(
int line);
330 bool toggleFoldingOfLine(
int line);
340 bool toggleFoldingsInRange(
int line);
344 bool isCompletionActive()
const override;
346 void startCompletion(
const Range &word,
348 KTextEditor::CodeCompletionModel::InvocationType invocationType = KTextEditor::CodeCompletionModel::ManualInvocation)
override;
349 void abortCompletion()
override;
350 void forceCompletion()
override;
355 bool isAutomaticInvocationEnabled()
const override;
356 void setAutomaticInvocationEnabled(
bool enabled =
true)
override;
363 void userInvokedCompletion();
369 void sendCompletionAborted();
377 void setTextHintDelay(
int delay)
override;
378 int textHintDelay()
const override;
381 bool dynWordWrap()
const
397 std::vector<KTextEditor::InlineNoteProvider *> m_inlineNoteProviders;
400 void inlineNotesReset();
401 void inlineNotesLineChanged(
int line);
409 bool removeSelection()
override
411 return clearSelection();
414 bool removeSelectionText()
override
416 return removeSelectedText();
419 bool setBlockSelection(
bool on)
override;
420 bool toggleBlockSelection();
422 bool clearSelection();
423 bool clearSelection(
bool redraw,
bool finishedChangingSelection =
true);
425 bool removeSelectedText();
430 bool selection()
const override;
431 QString selectionText()
const override;
432 bool blockSelection()
const override;
442 void deactivateEditActions();
443 void activateEditActions();
450 bool wrapCursor()
const;
454 bool lineSelected(
int line);
456 bool lineHasSelected(
int line);
457 bool lineIsSelection(
int line);
459 void ensureCursorColumnValid();
469 void editEnd(
int editTagLineStart,
int editTagLineEnd,
bool tagFrom);
487 void repaintText(
bool paintOnlyDirty =
false);
489 void updateView(
bool changed =
false);
498 void setAnnotationBorderVisible(
bool visible)
override;
499 bool isAnnotationBorderVisible()
const override;
502 void setAnnotationUniformItemSizes(
bool enable)
override;
503 bool uniformAnnotationItemSizes()
const override;
507 void navigateRight();
510 void navigateAccept();
520 void emitNavigateLeft()
522 Q_EMIT navigateLeft();
524 void emitNavigateRight()
526 Q_EMIT navigateRight();
528 void emitNavigateUp()
532 void emitNavigateDown()
534 Q_EMIT navigateDown();
536 void emitNavigateAccept()
538 Q_EMIT navigateAccept();
540 void emitNavigateBack()
542 Q_EMIT navigateBack();
547 bool isOverwriteMode()
const;
549 bool isLineRTL(
int line)
const;
562 void toggleComment();
568 void goToPreviousEditingPosition();
573 void goToNextEditingPosition();
618 void noIndentNewline();
634 void deleteWordLeft();
649 void deleteWordRight();
665 void transposeWord();
667 void shiftCursorLeft();
669 void shiftCursorRight();
671 void shiftWordLeft();
673 void shiftWordRight();
674 void markSelection();
686 void shiftTopOfView();
688 void shiftBottomOfView();
692 void shiftPageDown();
697 void toMatchingBracket();
698 void shiftToMatchingBracket();
699 void toPrevModifiedLine();
700 void toNextModifiedLine();
736 void setEol(
int eol);
737 void setAddBom(
bool enabled);
739 void findSelectedForwards();
740 void findSelectedBackwards();
741 void findNextOccurunceAndSelect();
742 void findAllOccuruncesAndSelect();
743 void skipCurrentOccurunceSelection();
747 void showSearchWrappedHint(
bool isReverseSearch);
748 void createMultiCursorsFromSelection();
749 void removeCursorsFromEmptyLines();
751 void setFoldingMarkersOn(
bool enable);
752 void setIconBorder(
bool enable);
753 void setLineNumbersOn(
bool enable);
754 void setScrollBarMarks(
bool enable);
755 void setScrollBarMiniMap(
bool enable);
756 void setScrollBarMiniMapAll(
bool enable);
757 void setScrollBarMiniMapWidth(
int width);
758 void toggleFoldingMarkers();
759 void toggleIconBorder();
760 void toggleLineNumbersOn();
761 void toggleScrollBarMarks();
762 void toggleScrollBarMiniMap();
763 void toggleScrollBarMiniMapAll();
764 void toggleShowSpaces();
765 void toggleDynWordWrap();
766 void setDynWrapIndicators(
int mode);
774 KateRendererConfig *rendererConfig();
777 bool lineNumbersOn();
778 bool scrollBarMarks();
779 bool scrollBarMiniMap();
780 bool scrollBarMiniMapAll();
781 int dynWrapIndicators();
782 bool foldingMarkersOn();
783 bool forceRTLDirection()
const;
789 void slotSelectionChanged();
791 void toggleInputMode();
792 void cycleInputMode();
809 void slotUpdateUndo();
812 void toggleWWMarker();
813 void toggleNPSpaces();
814 void toggleWordCount(
bool on);
815 void toggleWriteLock();
816 void switchToCmdLine();
817 void slotReadWriteChanged();
818 void toggleCamelCaseCursor();
830 return m_textFolding;
836 void exportHtmlToFile(
const QString &file);
839 void slotDocumentReloaded();
840 void slotDocumentAboutToReload();
842 void slotLostFocus();
843 void slotSaveCanceled(
const QString &error);
844 void slotConfigDialog();
845 void exportHtmlToClipboard();
846 void exportHtmlToFile();
849 void slotFoldToplevelNodes();
850 void slotExpandToplevelNodes();
851 void slotToggleFolding();
852 void slotToggleFoldingsInRange();
855 KTEXTEDITOR_NO_EXPORT
857 KTEXTEDITOR_NO_EXPORT
858 void setupConnections();
859 KTEXTEDITOR_NO_EXPORT
861 KTEXTEDITOR_NO_EXPORT
862 void setupEditActions();
863 KTEXTEDITOR_NO_EXPORT
864 void setupCodeFolding();
865 KTEXTEDITOR_NO_EXPORT
866 void setupSpeechActions();
868 std::vector<QAction *> m_editActions;
871 bool m_gotoBottomAfterReload;
872 bool m_markedSelection;
897 QAction *m_pasteSelection =
nullptr;
901 QAction *m_screenshotSelection =
nullptr;
911 bool m_forceRTL =
false;
912 bool m_accessibilityEnabled =
false;
916 KateViewConfig *
const m_config;
918 KateViewInternal *
const m_viewInternal;
919 KateSpellCheckDialog *m_spell;
920 KateBookmarks *
const m_bookmarks;
929 void slotHlChanged();
935 inline KateViewConfig *config()
942 void updateDocumentConfig();
944 void updateRendererConfig();
947 void updateFoldingConfig();
951 bool m_updatingDocumentConfig;
967 KateViewBar *bottomViewBar()
const;
968 KateDictionaryBar *dictionaryBar();
971 KTEXTEDITOR_NO_EXPORT
972 KateGotoBar *gotoBar();
980 KateViewBar *m_bottomViewBar;
983 KateGotoBar *m_gotoBar;
984 KateDictionaryBar *m_dictionaryBar;
988 KateAbstractInputMode *currentInputMode()
const;
997 KateSpellingMenu *m_spellingMenu;
1000 void toggleOnTheFlySpellCheck(
bool b);
1003 void changeDictionary();
1004 void reflectOnTheFlySpellCheckStatus(
bool enabled);
1007 KateSpellingMenu *spellingMenu();
1010 bool m_userContextMenuSet;
1016 void saveFoldingState();
1021 void applyFoldingState();
1027 void clearFoldingState();
1030 KTEXTEDITOR_NO_EXPORT
1031 void clearHighlights();
1032 KTEXTEDITOR_NO_EXPORT
1033 void createHighlights();
1036 KTEXTEDITOR_NO_EXPORT
1037 void selectionChangedForHighlights();
1044 QString m_currentTextForHighlights;
1046 std::vector<std::unique_ptr<KTextEditor::MovingRange>> m_rangesForHighlights;
1060 void slotDelayedUpdateOfView();
1066 void delayedUpdateOfView();
1081 return &m_rangesMouseIn;
1090 return &m_rangesCaretIn;
1106 QTimer m_delayedUpdateTimer;
1137 std::array<KateMessageWidget *, 5> m_messageWidgets{{
nullptr}};
1155 bool print()
override;
1163 KateStatusBar *statusBar()
const
1171 void toggleStatusBar();
1177 KateViewEncodingAction *encodingAction()
const
1179 return m_encodingAction;
1186 KateModeMenu *modeAction()
const
1188 return m_modeAction;
1195 KateStatusBar *m_statusBar;
1200 KateViewEncodingAction *m_encodingAction;
1205 KateModeMenu *m_modeAction;
1210 bool m_temporaryAutomaticInvocationDisabled;
1228 bool m_autoFoldedFirstLine;
1233 void setHorizontalScrollPositionInternal(
int x);
1237 int firstDisplayedLineInternal(LineType lineType)
const;
1239 int lastDisplayedLineInternal(LineType lineType)
const;
1241 QRect textAreaRectInternal()
const;
1249 std::unique_ptr<KateScriptActionMenu> m_scriptActionMenu;
1253 bool m_isLastSearchReversed =
false;
A delegate for rendering line annotation information and handling events.
An model for providing line annotation information.
ActivationType
Several automatic activation mechanisms exist for associated attributes.
An item model for providing code completion, and meta information for enhanced presentation.
The Cursor represents a position in a Document.
static constexpr Cursor invalid() noexcept
Returns an invalid cursor.
Backend of KTextEditor::Document related public KTextEditor interfaces.
A KParts derived class representing a text document.
A source of inline notes for a document.
An object representing lines from a start line to an end line.
This class allows the application that embeds the KTextEditor component to allow it to access parts o...
This class holds a Message to display in Views.
An object representing a section of text, from one Cursor to another.
static constexpr Range invalid() noexcept
Returns an invalid range.
Class to provide text hints for a View.
A text widget with KXMLGUIClient that represents a Document.
Internal data container for KTextEditor::InlineNote interface.
Class to layout KTextEditor::Messages in KateView.
Handles all of the work of rendering the text (used for the views and printing)
Class representing the folding information for a TextBuffer.
Q_SCRIPTABLE Q_NOREPLY void start()
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
QAction * up(const QObject *recvr, const char *slot, QObject *parent)
QAction * home(const QObject *recvr, const char *slot, QObject *parent)
QAction * paste(const QObject *recvr, const char *slot, QObject *parent)
QAction * replace(const QObject *recvr, const char *slot, QObject *parent)
QAction * cut(const QObject *recvr, const char *slot, QObject *parent)
QAction * copy(const QObject *recvr, const char *slot, QObject *parent)
QAction * selectAll(const QObject *recvr, const char *slot, QObject *parent)
QAction * printPreview(const QObject *recvr, const char *slot, QObject *parent)
QAction * findNext(const QObject *recvr, const char *slot, QObject *parent)
QAction * gotoLine(const QObject *recvr, const char *slot, QObject *parent)
QAction * find(const QObject *recvr, const char *slot, QObject *parent)
QAction * clear(const QObject *recvr, const char *slot, QObject *parent)
QAction * print(const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & end()
const QList< QKeySequence > & pasteSelection()
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
bool operator<(const PosRange< Trait > &l, const PosRange< Trait > &r)
bool operator==(const StyleDelim &l, const StyleDelim &r)