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 swapWithClipboard();
143 void applyWordWrap();
148 void copyFileLocation()
const;
154 void setContextMenu(
QMenu *menu)
override;
155 QMenu *contextMenu()
const override;
156 QMenu *defaultContextMenu(
QMenu *menu =
nullptr)
const override;
159 void aboutToShowContextMenu();
160 void aboutToHideContextMenu();
179 QPoint cursorPositionCoordinates()
const override;
183 QScrollBar *verticalScrollBar()
const override;
184 QScrollBar *horizontalScrollBar()
const override;
191 int virtualCursorColumn()
const;
193 bool mouseTrackingEnabled()
const override;
194 bool setMouseTrackingEnabled(
bool enable)
override;
201 struct PlainSecondaryCursor {
204 friend bool operator<(
const PlainSecondaryCursor &l,
const PlainSecondaryCursor &r)
206 return l.pos < r.pos;
209 struct SecondaryCursor {
210 std::unique_ptr<Kate::TextCursor> pos;
211 std::unique_ptr<Kate::TextRange> range;
216 return pos->toCursor();
219 friend bool operator<(
const SecondaryCursor &l,
const SecondaryCursor &r)
221 return l.cursor() < r.cursor();
226 return l.cursor() < r;
229 friend bool operator==(
const SecondaryCursor &l,
const SecondaryCursor &r)
231 return l.cursor() == r.cursor() && l.selectionRange() == r.selectionRange();
239 void clearSelection()
247 bool isMulticursorNotAllowed()
const;
253 const std::vector<SecondaryCursor> &secondaryCursors()
const;
257 void clearSecondaryCursors();
258 void clearSecondarySelections();
262 void ensureUniqueCursors(
bool matchLine =
false);
272 bool hasSelections()
const;
275 KTEXTEDITOR_NO_EXPORT
276 bool removeSecondaryCursors(
const std::vector<KTextEditor::Cursor> &cursorToRemove,
bool removeIfOverlapsSelection =
false);
277 KTEXTEDITOR_NO_EXPORT
279 KTEXTEDITOR_NO_EXPORT
281 KTEXTEDITOR_NO_EXPORT
284 std::vector<SecondaryCursor> m_secondaryCursors;
285 bool m_skipCurrentSelection =
false;
287 void addSecondaryCursorDown();
289 void addSecondaryCursorUp();
293 KTEXTEDITOR_NO_EXPORT
298 bool setCursorPositionInternal(
const KTextEditor::Cursor position, uint tabwidth = 1,
bool calledExternally =
false);
306 void setConfigValue(
const QString &key,
const QVariant &value)
override;
319 bool unfoldLine(
int line);
325 bool toggleFoldingOfLine(
int line);
335 bool toggleFoldingsInRange(
int line);
339 bool isCompletionActive()
const override;
341 void startCompletion(
const Range &word,
343 KTextEditor::CodeCompletionModel::InvocationType invocationType = KTextEditor::CodeCompletionModel::ManualInvocation)
override;
344 void abortCompletion()
override;
345 void forceCompletion()
override;
350 bool isAutomaticInvocationEnabled()
const override;
351 void setAutomaticInvocationEnabled(
bool enabled =
true)
override;
358 void userInvokedCompletion();
364 void sendCompletionAborted();
372 void setTextHintDelay(
int delay)
override;
373 int textHintDelay()
const override;
376 bool dynWordWrap()
const
392 std::vector<KTextEditor::InlineNoteProvider *> m_inlineNoteProviders;
395 void inlineNotesReset();
396 void inlineNotesLineChanged(
int line);
404 bool removeSelection()
override
406 return clearSelection();
409 bool removeSelectionText()
override
411 return removeSelectedText();
414 bool setBlockSelection(
bool on)
override;
415 bool toggleBlockSelection();
417 bool clearSelection();
418 bool clearSelection(
bool redraw,
bool finishedChangingSelection =
true);
420 bool removeSelectedText();
425 bool selection()
const override;
426 QString selectionText()
const override;
427 bool blockSelection()
const override;
437 void deactivateEditActions();
438 void activateEditActions();
445 bool wrapCursor()
const;
449 bool lineSelected(
int line);
451 bool lineHasSelected(
int line);
452 bool lineIsSelection(
int line);
454 void ensureCursorColumnValid();
464 void editEnd(
int editTagLineStart,
int editTagLineEnd,
bool tagFrom);
482 void repaintText(
bool paintOnlyDirty =
false);
484 void updateView(
bool changed =
false);
493 void setAnnotationBorderVisible(
bool visible)
override;
494 bool isAnnotationBorderVisible()
const override;
497 void setAnnotationUniformItemSizes(
bool enable)
override;
498 bool uniformAnnotationItemSizes()
const override;
502 void navigateRight();
505 void navigateAccept();
515 void emitNavigateLeft()
517 Q_EMIT navigateLeft();
519 void emitNavigateRight()
521 Q_EMIT navigateRight();
523 void emitNavigateUp()
527 void emitNavigateDown()
529 Q_EMIT navigateDown();
531 void emitNavigateAccept()
533 Q_EMIT navigateAccept();
535 void emitNavigateBack()
537 Q_EMIT navigateBack();
542 bool isOverwriteMode()
const;
544 bool isLineRTL(
int line)
const;
557 void toggleComment();
563 void goToPreviousEditingPosition();
568 void goToNextEditingPosition();
613 void noIndentNewline();
629 void deleteWordLeft();
644 void deleteWordRight();
660 void transposeWord();
662 void shiftCursorLeft();
664 void shiftCursorRight();
666 void shiftWordLeft();
668 void shiftWordRight();
669 void markSelection();
681 void shiftTopOfView();
683 void shiftBottomOfView();
687 void shiftPageDown();
692 void toMatchingBracket();
693 void shiftToMatchingBracket();
694 void toPrevModifiedLine();
695 void toNextModifiedLine();
731 void setEol(
int eol);
732 void setAddBom(
bool enabled);
734 void findSelectedForwards();
735 void findSelectedBackwards();
736 void findNextOccurunceAndSelect();
737 void findAllOccuruncesAndSelect();
738 void skipCurrentOccurunceSelection();
742 void showSearchWrappedHint(
bool isReverseSearch);
743 void createMultiCursorsFromSelection();
744 void removeCursorsFromEmptyLines();
746 void setFoldingMarkersOn(
bool enable);
747 void setIconBorder(
bool enable);
748 void setLineNumbersOn(
bool enable);
749 void setScrollBarMarks(
bool enable);
750 void setScrollBarMiniMap(
bool enable);
751 void setScrollBarMiniMapAll(
bool enable);
752 void setScrollBarMiniMapWidth(
int width);
753 void toggleFoldingMarkers();
754 void toggleIconBorder();
755 void toggleLineNumbersOn();
756 void toggleScrollBarMarks();
757 void toggleScrollBarMiniMap();
758 void toggleScrollBarMiniMapAll();
759 void toggleShowSpaces();
760 void toggleDynWordWrap();
761 void setDynWrapIndicators(
int mode);
769 KateRendererConfig *rendererConfig();
772 bool lineNumbersOn();
773 bool scrollBarMarks();
774 bool scrollBarMiniMap();
775 bool scrollBarMiniMapAll();
776 int dynWrapIndicators();
777 bool foldingMarkersOn();
778 bool forceRTLDirection()
const;
784 void slotSelectionChanged();
786 void toggleInputMode();
787 void cycleInputMode();
804 void slotUpdateUndo();
807 void toggleWWMarker();
808 void toggleNPSpaces();
809 void toggleWordCount(
bool on);
810 void toggleWriteLock();
811 void switchToCmdLine();
812 void slotReadWriteChanged();
813 void toggleCamelCaseCursor();
825 return m_textFolding;
831 void exportHtmlToFile(
const QString &file);
834 void slotDocumentReloaded();
835 void slotDocumentAboutToReload();
837 void slotLostFocus();
838 void slotSaveCanceled(
const QString &error);
839 void slotConfigDialog();
840 void exportHtmlToClipboard();
841 void exportHtmlToFile();
844 void slotFoldToplevelNodes();
845 void slotExpandToplevelNodes();
846 void slotToggleFolding();
847 void slotToggleFoldingsInRange();
850 KTEXTEDITOR_NO_EXPORT
852 KTEXTEDITOR_NO_EXPORT
853 void setupConnections();
854 KTEXTEDITOR_NO_EXPORT
856 KTEXTEDITOR_NO_EXPORT
857 void setupEditActions();
858 KTEXTEDITOR_NO_EXPORT
859 void setupCodeFolding();
860 KTEXTEDITOR_NO_EXPORT
861 void setupSpeechActions();
863 std::vector<QAction *> m_editActions;
866 bool m_gotoBottomAfterReload;
867 bool m_markedSelection;
892 QAction *m_pasteSelection =
nullptr;
896 QAction *m_screenshotSelection =
nullptr;
906 bool m_forceRTL =
false;
907 bool m_accessibilityEnabled =
false;
911 KateViewConfig *
const m_config;
913 KateViewInternal *
const m_viewInternal;
914 KateSpellCheckDialog *m_spell;
915 KateBookmarks *
const m_bookmarks;
924 void slotHlChanged();
930 inline KateViewConfig *config()
937 void updateDocumentConfig();
939 void updateRendererConfig();
942 void updateFoldingConfig();
946 bool m_updatingDocumentConfig;
962 KateViewBar *bottomViewBar()
const;
963 KateDictionaryBar *dictionaryBar();
966 KTEXTEDITOR_NO_EXPORT
967 KateGotoBar *gotoBar();
975 KateViewBar *m_bottomViewBar;
978 KateGotoBar *m_gotoBar;
979 KateDictionaryBar *m_dictionaryBar;
983 KateAbstractInputMode *currentInputMode()
const;
992 KateSpellingMenu *m_spellingMenu;
995 void toggleOnTheFlySpellCheck(
bool b);
998 void changeDictionary();
999 void reflectOnTheFlySpellCheckStatus(
bool enabled);
1002 KateSpellingMenu *spellingMenu();
1005 bool m_userContextMenuSet;
1011 void saveFoldingState();
1016 void applyFoldingState();
1022 void clearFoldingState();
1025 KTEXTEDITOR_NO_EXPORT
1026 void clearHighlights();
1027 KTEXTEDITOR_NO_EXPORT
1028 void createHighlights();
1031 KTEXTEDITOR_NO_EXPORT
1032 void selectionChangedForHighlights();
1039 QString m_currentTextForHighlights;
1041 std::vector<std::unique_ptr<KTextEditor::MovingRange>> m_rangesForHighlights;
1055 void slotDelayedUpdateOfView();
1061 void delayedUpdateOfView();
1076 return &m_rangesMouseIn;
1085 return &m_rangesCaretIn;
1101 QTimer m_delayedUpdateTimer;
1132 std::array<KateMessageWidget *, 5> m_messageWidgets{{
nullptr}};
1150 bool print()
override;
1158 KateStatusBar *statusBar()
const
1166 void toggleStatusBar();
1172 KateViewEncodingAction *encodingAction()
const
1174 return m_encodingAction;
1181 KateModeMenu *modeAction()
const
1183 return m_modeAction;
1190 KateStatusBar *m_statusBar;
1195 KateViewEncodingAction *m_encodingAction;
1200 KateModeMenu *m_modeAction;
1205 bool m_temporaryAutomaticInvocationDisabled;
1223 bool m_autoFoldedFirstLine;
1228 void setHorizontalScrollPositionInternal(
int x);
1232 int firstDisplayedLineInternal(LineType lineType)
const;
1234 int lastDisplayedLineInternal(LineType lineType)
const;
1236 QRect textAreaRectInternal()
const;
1244 std::unique_ptr<KateScriptActionMenu> m_scriptActionMenu;
1248 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 * printPreview(const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & cut()
const QList< QKeySequence > & print()
const QList< QKeySequence > & find()
const QList< QKeySequence > & paste()
const QList< QKeySequence > & end()
const QList< QKeySequence > & home()
const QList< QKeySequence > & copy()
const QList< QKeySequence > & up()
const QList< QKeySequence > & findNext()
const QList< QKeySequence > & selectAll()
const QList< QKeySequence > & replace()
const QList< QKeySequence > & gotoLine()
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)