13#ifndef _KATE_VIEW_INTERNAL_
14#define _KATE_VIEW_INTERNAL_
16#include <KSyntaxHighlighting/FoldingRegion>
18#include <ktexteditor/attribute.h>
19#include <ktexteditor/range.h>
20#include <ktexteditor/view.h>
22#include "inlinenotedata.h"
23#include "katetextcursor.h"
24#include "katetextline.h"
27#include <QElapsedTimer>
48class KateAnnotationItemDelegate;
49class KateAnnotationGroupPositionState;
52class KateAbstractInputMode;
63class KateViewInternal final :
public QWidget
67 friend class KTextEditor::ViewPrivate;
68 friend class KateIconBorder;
69 friend class KateScrollBar;
70 friend class KateAnnotationGroupPositionState;
71 friend class CalculatingCursor;
72 friend class BoundedCursor;
73 friend class WrappingCursor;
74 friend class CamelCursor;
75 friend class KateAbstractInputMode;
76 friend class ::KateTextPreview;
77 friend class KateViewTest;
87 explicit KateViewInternal(KTextEditor::ViewPrivate *view);
88 ~KateViewInternal()
override;
89 KTextEditor::ViewPrivate *view()
const
97 void editEnd(
int editTagLineStart,
int editTagLineEnd,
bool tagFrom);
99 void editSetCursor(
const KTextEditor::Cursor
cursor);
102 uint editSessionNumber;
104 KTextEditor::Cursor editOldCursor;
105 KTextEditor::Range editOldSelection;
110 bool tagLine(
const KTextEditor::Cursor virtualCursor);
112 bool tagLines(
int start,
int end,
bool realLines =
false);
114 bool tagLines(KTextEditor::Cursor
start, KTextEditor::Cursor end,
bool realCursors =
false);
116 bool tagRange(KTextEditor::Range range,
bool realCursors);
127 void updateView(
bool changed =
false,
int viewLinesScrolled = 0);
130 void makeVisible(
const KTextEditor::Cursor c,
int endCol,
bool force =
false,
bool center =
false,
bool calledExternally =
false);
134 KTextEditor::Cursor startPos()
const
138 int startLine()
const
140 return m_startPos.line();
147 KTextEditor::Cursor endPos()
const;
150 KateTextLayout yToKateTextLayout(
int y)
const;
152 void dynWrapChanged();
155 void slotIncFontSizes(qreal step = 1.0);
156 void slotDecFontSizes(qreal step = 1.0);
157 void slotResetFontSizes();
162 void scrollLines(
int line);
163 void scrollViewLines(
int offset);
164 void scrollAction(
int action);
165 void scrollNextPage();
166 void scrollPrevPage();
167 void scrollPrevLine();
168 void scrollNextLine();
169 void scrollColumns(
int x);
170 void viewSelectionChanged();
173 void cursorPrevChar(
bool sel =
false);
174 void cursorNextChar(
bool sel =
false);
175 void wordPrev(
bool sel =
false,
bool subword =
false);
176 void wordNext(
bool sel =
false,
bool subword =
false);
177 void home(
bool sel =
false);
178 void end(
bool sel =
false);
179 void cursorUp(
bool sel =
false);
180 void cursorDown(
bool sel =
false);
181 void cursorToMatchingBracket(
bool sel =
false);
184 void topOfView(
bool sel =
false);
185 void bottomOfView(
bool sel =
false);
186 void pageUp(
bool sel =
false,
bool half =
false);
187 void pageDown(
bool sel =
false,
bool half =
false);
188 void top(
bool sel =
false);
189 void bottom(
bool sel =
false);
190 void top_home(
bool sel =
false);
191 void bottom_end(
bool sel =
false);
195 KTextEditor::Cursor moveCursorToLineStart(KTextEditor::Cursor c);
197 KTextEditor::Cursor moveCursorToLineEnd(KTextEditor::Cursor c);
205 KTextEditor::Cursor cursorPosition()
const
215 KTextEditor::Cursor mousePosition()
const
220 QPoint cursorToCoordinate(
const KTextEditor::Cursor
cursor,
bool realCursor =
true,
bool includeBorder =
true)
const;
222 KTextEditor::Cursor coordinatesToCursor(
const QPoint &coord,
bool includeBorder =
true)
const;
223 QPoint cursorCoordinates(
bool includeBorder =
true)
const;
224 KTextEditor::Cursor findMatchingBracket();
227 KTEXTEDITOR_EXPORT KTextEditor::Range
228 findMatchingFoldingMarker(
const KTextEditor::Cursor current_cursor_pos,
const KSyntaxHighlighting::FoldingRegion foldingRegion,
const int maxLines);
229 KTEXTEDITOR_EXPORT
void updateFoldingMarkersHighlighting();
231 inline int getStartOffset(
int direction,
int offset,
int length)
const
233 return direction == 1 ? offset - length : offset;
236 inline int getEndOffset(
int direction,
int offset,
int length)
const
238 return direction == 1 ? offset : offset + length;
241 KateIconBorder *iconBorder()
const
248 void fixDropEvent(QDropEvent *
event);
250 static bool isAcceptableInput(
const QKeyEvent *e);
253 void hideEvent(QHideEvent *e)
override;
254 void paintEvent(QPaintEvent *e)
override;
255 bool eventFilter(
QObject *obj, QEvent *e)
override;
256 void keyPressEvent(QKeyEvent *)
override;
257 void keyReleaseEvent(QKeyEvent *)
override;
258 void resizeEvent(QResizeEvent *)
override;
259 void moveEvent(QMoveEvent *)
override;
260 void mousePressEvent(QMouseEvent *)
override;
261 void mouseDoubleClickEvent(QMouseEvent *)
override;
262 void mouseReleaseEvent(QMouseEvent *)
override;
263 void mouseMoveEvent(QMouseEvent *)
override;
264 void leaveEvent(QEvent *)
override;
265 void dragEnterEvent(QDragEnterEvent *)
override;
266 void dragMoveEvent(QDragMoveEvent *)
override;
267 void dropEvent(QDropEvent *)
override;
268 void showEvent(QShowEvent *)
override;
269 void wheelEvent(QWheelEvent *e)
override;
270 void scrollPrepareEvent(QScrollPrepareEvent *);
271 void scrollEvent(QScrollEvent *);
272 void focusInEvent(QFocusEvent *)
override;
273 void focusOutEvent(QFocusEvent *)
override;
274 void inputMethodEvent(QInputMethodEvent *e)
override;
276 void contextMenuEvent(QContextMenuEvent *e)
override;
279 void tripleClickTimeout();
283 void dropEventPass(QDropEvent *);
286 void slotRegionVisibilityChanged();
287 void slotRegionBeginEndAddedRemoved(
unsigned int);
290 void moveChar(Bias bias,
bool sel);
291 void moveEdge(Bias bias,
bool sel);
292 KTextEditor::Cursor maxStartPos(
bool changed =
false);
293 void scrollPos(KTextEditor::Cursor &c,
bool force =
false,
bool calledExternally =
false,
bool emitSignals =
true);
294 void scrollLines(
int lines,
bool sel);
297 int linesDisplayed()
const;
299 int lineToY(
int viewLine)
const;
301 void updateSecondarySelection(
int cursorIdx, KTextEditor::Cursor old, KTextEditor::Cursor newPos)
const;
302 void updateSelection(
const KTextEditor::Cursor,
bool keepSel);
303 void setSelection(KTextEditor::Range);
304 void moveCursorToSelectionEdge(
bool scroll =
true);
305 void updateCursor(
const KTextEditor::Cursor newCursor,
bool force =
false,
bool center =
false,
bool calledExternally =
false,
bool scroll =
true);
306 void updateBracketMarks();
307 void beginSelectLine(
const QPoint &
pos);
310 KTextEditor::Cursor oldPos;
311 KTextEditor::Cursor newPos;
315 void updateSecondaryCursors(
const QVarLengthArray<CursorPair, 16> &cursors,
bool sel);
316 void mergeSelections();
318 KTextEditor::Cursor cursorForPoint(QPoint p);
319 void placeCursor(
const QPoint &p,
bool keepSelection =
false,
bool updateSelection =
true);
320 bool isTargetSelected(
const QPoint &p);
322 bool rangeAffectsView(KTextEditor::Range range,
bool realCursors)
const;
326 KateRenderer *renderer()
const;
328 bool sendMouseEventToInputContext(QMouseEvent *e);
329 void commitPreedit();
331 KTextEditor::ViewPrivate *m_view;
332 class KateIconBorder *m_leftBorder;
339 std::unique_ptr<ZoomEventFilter> m_zoomEventFilter;
343 Kate::TextCursor m_cursor;
344 KTextEditor::Cursor m_mouse;
345 KTextEditor::Cursor m_displayCursor;
347 bool m_possibleTripleClick;
350 std::unique_ptr<KTextEditor::MovingRange> m_bm, m_bmStart, m_bmEnd;
351 std::unique_ptr<KTextEditor::MovingCursor> m_bmLastFlashPos;
352 std::unique_ptr<KateTextPreview> m_bmPreview;
353 void updateBracketMarkAttributes();
356 std::unique_ptr<KTextEditor::MovingRange> m_fmStart, m_fmEnd;
373 KateScrollBar *m_lineScroll;
374 qreal m_accumulatedScroll = 0.0;
379 Kate::TextCursor m_startPos;
382 uint m_visibleLineCount;
387 bool m_shiftKeyPressed;
390 void setAutoCenterLines(
int viewLines,
bool updateView =
true);
391 int m_autoCenterLines;
392 int m_minLinesVisible;
397 QScrollBar *m_columnScroll;
398 QScroller *m_scroller;
402 bool m_selChangedByUser;
403 KTextEditor::Cursor m_selectAnchor;
411 uint m_selectionMode;
415 KTextEditor::Range m_selectionCached;
418 int maxLen(
int startLine);
421 bool columnScrollingPossible();
424 bool lineScrollingPossible();
427 int lineMaxCursorX(
const KateTextLayout &line);
428 static int lineMaxCol(
const KateTextLayout &line);
430 class KateLayoutCache *cache()
const;
431 KateLayoutCache *m_layoutCache;
436 KateTextLayout currentLayout(KTextEditor::Cursor c)
const;
438 KateTextLayout previousLayout(KTextEditor::Cursor c)
const;
440 KateTextLayout nextLayout(KTextEditor::Cursor c)
const;
445 KTextEditor::Cursor viewLineOffset(
const KTextEditor::Cursor virtualCursor,
int offset,
bool keepX =
false);
447 KTextEditor::Cursor toRealCursor(
const KTextEditor::Cursor virtualCursor)
const;
448 KTextEditor::Cursor toVirtualCursor(
const KTextEditor::Cursor realCursor)
const;
454 KTextEditor::Cursor m_cachedMaxStartPos;
461 void showBracketMatchPreview();
462 void hideBracketMatchPreview();
465 QPointer<KateTextAnimation> m_textAnimation;
469 void startDragScroll();
470 void stopDragScroll();
474 QTimer m_dragScrollTimer;
475 QTimer m_scrollTimer;
476 QTimer m_cursorTimer;
477 QTimer m_textHintTimer;
479 static const int s_scrollTime = 30;
480 static const int s_scrollMargin = 16;
483 void scrollTimeout();
484 void cursorTimeout();
485 void textHintTimeout();
487 void documentTextInserted(KTextEditor::Document *document, KTextEditor::Range range);
488 void documentTextRemoved(KTextEditor::Document *document, KTextEditor::Range range,
const QString &oldText);
494 void registerTextHintProvider(KTextEditor::TextHintProvider *provider);
495 void unregisterTextHintProvider(KTextEditor::TextHintProvider *provider);
496 void setTextHintDelay(
int delay);
497 int textHintDelay()
const;
498 bool textHintsEnabled();
501 std::vector<KTextEditor::TextHintProvider *> m_textHintProviders;
503 QPoint m_textHintPos;
512 std::unique_ptr<KTextEditor::MovingRange> m_imPreeditRange;
513 std::vector<std::unique_ptr<KTextEditor::MovingRange>> m_imPreeditRangeChildren;
520 KTextEditor::DocumentPrivate *doc();
521 KTextEditor::DocumentPrivate *doc()
const;
526 KateAbstractInputMode *m_currentInputMode;
528 KateInlineNoteData m_activeInlineNote;
529 KateInlineNoteData inlineNoteAt(
const QPoint &globalPos)
const;
530 QRect inlineNoteRect(
const KateInlineNoteData ¬e)
const;
QExplicitlySharedDataPointer< Attribute > Ptr
Shared data pointer for Attribute.
Backend of KTextEditor::Document related public KTextEditor interfaces.
A range that is bound to a specific Document, and maintains its position.
Class to provide text hints for a View.
Handles all of the work of rendering the text (used for the views and printing)
This class is used to flash text in the text view.
This class represents one visible line of text; with dynamic wrapping, many KateTextLayouts can be ne...
Q_SCRIPTABLE Q_NOREPLY void start()
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
virtual bool event(QEvent *e)