11#ifndef KATE_VIEW_HELPERS_H
12#define KATE_VIEW_HELPERS_H
16#include <KSelectAction>
27#include "katetextline.h"
28#include <ktexteditor/cursor.h>
29#include <ktexteditor/message.h>
38class AbstractAnnotationItemDelegate;
39class StyleOptionAnnotationItem;
42class KateViewInternal;
45#define MAXFOLDINGCOLORS 16
72 int count()
const override;
74 void setGeometry(
const QRect &rect)
override;
75 QSize sizeHint()
const override;
84 ItemWrapper() =
default;
112 QSize sizeHint()
const override;
116 inline bool showMarks()
const
120 inline void setShowMarks(
bool b)
126 inline bool showMiniMap()
const
128 return m_showMiniMap;
130 void setShowMiniMap(
bool b);
132 inline bool miniMapAll()
const
136 inline void setMiniMapAll(
bool b)
143 inline bool miniMapWidth()
const
145 return m_miniMapWidth;
147 inline void setMiniMapWidth(
int width)
149 m_miniMapWidth =
width;
154 inline void queuePixmapUpdate()
156 m_updateTimer.
start();
160 void sliderMMBMoved(
int value);
173 void sliderMaybeMoved(
int value);
180 void showTextPreview();
183 void showTextPreviewDelayed();
184 void hideTextPreview();
187 void recomputeMarksPositions();
192 int minimapYToStdY(
int y);
194 struct ColumnRangeWithColor {
205 bool m_middleMouseDown;
206 bool m_leftMouseDown;
208 KTextEditor::ViewPrivate *m_view;
210 class KateViewInternal *m_viewInternal;
212 QTimer m_delayTextPreviewTimer;
219 bool m_needsUpdateOnShow;
224 QRect m_stdGroveRect;
225 QRect m_mapGroveRect;
229 QLabel m_tooltipLineNoInfo;
234 static const unsigned char characterOpacity[256];
237class KateIconBorder :
public QWidget
242 KateIconBorder(KateViewInternal *internalView,
QWidget *
parent);
243 ~KateIconBorder()
override;
245 QSize sizeHint()
const override;
248 int lineNumberWidth()
const;
250 void setIconBorderOn(
bool enable);
251 void setLineNumbersOn(
bool enable);
252 void setRelLineNumbersOn(
bool enable);
253 void setAnnotationBorderOn(
bool enable);
254 void setDynWrapIndicators(
int state);
255 int dynWrapIndicators()
const
257 return m_dynWrapIndicators;
259 bool dynWrapIndicatorsOn()
const
261 return m_dynWrapIndicatorsOn;
263 void setFoldingMarkersOn(
bool enable);
264 void toggleIconBorder()
266 setIconBorderOn(!iconBorderOn());
268 void toggleLineNumbers()
270 setLineNumbersOn(!lineNumbersOn());
272 void toggleFoldingMarkers()
274 setFoldingMarkersOn(!foldingMarkersOn());
276 inline bool iconBorderOn()
const
278 return m_iconBorderOn;
280 inline bool lineNumbersOn()
const
282 return m_lineNumbersOn;
284 inline bool viRelNumbersOn()
const
286 return m_relLineNumbersOn;
288 inline bool foldingMarkersOn()
const
290 return m_foldingMarkersOn;
292 inline bool annotationBorderOn()
const
294 return m_annotationBorderOn;
297 void updateForCursorLineChange();
307 BorderArea positionToArea(
const QPoint &)
const;
311 inline bool uniformAnnotationItemSizes()
const
313 return m_hasUniformAnnotationItemSizes;
315 inline void setAnnotationUniformItemSizes(
bool enable)
317 m_hasUniformAnnotationItemSizes = enable;
321 void updateAnnotationBorderWidth();
322 void updateAnnotationLine(
int line);
324 void displayRangeChanged();
336 void mouseDoubleClickEvent(
QMouseEvent *)
override;
343 void showMarkMenu(uint line,
const QPoint &
pos);
345 void hideAnnotationTooltip();
346 void removeAnnotationHovering();
347 void showAnnotationMenu(
int line,
const QPoint &
pos);
348 void calcAnnotationBorderWidth();
355 const QString &annotationGroupIdentifier)
const;
356 QRect annotationLineRectInView(
int line)
const;
359 KTextEditor::ViewPrivate *m_view;
361 KateViewInternal *m_viewInternal;
363 bool m_iconBorderOn : 1;
364 bool m_lineNumbersOn : 1;
365 bool m_relLineNumbersOn : 1;
366 bool m_updateRelLineNumbers : 1;
367 bool m_foldingMarkersOn : 1;
368 bool m_dynWrapIndicatorsOn : 1;
369 bool m_annotationBorderOn : 1;
370 bool m_updatePositionToArea : 1;
371 bool m_mouseOver =
false;
373 typedef QPair<int, KateIconBorder::BorderArea> AreaPosition;
374 std::vector<AreaPosition> m_positionToArea;
376 const int m_separatorWidth = 2;
377 const int m_modAreaWidth = 3;
378 qreal m_maxCharWidth = 0.0;
379 int m_lineNumberAreaWidth = 0;
380 int m_iconAreaWidth = 0;
381 int m_foldingAreaWidth = 0;
382 int m_annotationAreaWidth = 0;
383 const QChar m_dynWrapIndicatorChar =
QChar(0x21AA);
384 int m_dynWrapIndicators = 0;
385 int m_lastClickedLine = -1;
388 bool m_hasUniformAnnotationItemSizes =
false;
389 bool m_isDefaultAnnotationItemDelegate =
true;
393 int m_currentLine = -1;
394 QTimer m_antiFlickerTimer;
395 void highlightFoldingDelayed(
int line);
399 void highlightFolding();
400 void handleDestroyedAnnotationItemDelegate();
401 void delayedUpdateOfSizeWithRepaint();
404 QString m_hoveredAnnotationGroupIdentifier;
412 bool setCurrentCodec(
const QString &codec);
416 void subActionTriggered(
QAction *);
419 KTextEditor::ViewPrivate *view;
421 const bool m_saveAsMode;
424 void setEncoding(
const QString &e);
425 void slotAboutToShow();
430class KateViewBarWidget :
public QWidget
433 friend class KateViewBar;
436 explicit KateViewBarWidget(
bool addCloseButton,
QWidget *
parent =
nullptr);
438 virtual void closed()
443 KateViewBar *viewBar()
454 return m_centralWidget;
462 return m_closeButton;
470 void setAssociatedViewBar(KateViewBar *bar)
476 QWidget *m_centralWidget =
nullptr;
477 KateViewBar *m_viewBar =
nullptr;
481class KateViewBar :
public QWidget
486 KateViewBar(
bool external,
QWidget *
parent, KTextEditor::ViewPrivate *view);
493 void addBarWidget(KateViewBarWidget *newBarWidget);
501 void removeBarWidget(KateViewBarWidget *barWidget);
506 bool hasBarWidget(KateViewBarWidget *barWidget)
const;
512 void showBarWidget(KateViewBarWidget *barWidget);
524 void addPermanentBarWidget(KateViewBarWidget *barWidget);
532 void removePermanentBarWidget(KateViewBarWidget *barWidget);
536 bool barWidgetVisible()
const;
542 void hideCurrentBarWidget();
552 void setViewBarVisible(
bool visible);
557 KTextEditor::ViewPrivate *m_view;
559 KateViewBarWidget *m_permanentBarWidget;
563class KateCommandLineBar :
public KateViewBarWidget
566 explicit KateCommandLineBar(KTextEditor::ViewPrivate *view,
QWidget *
parent =
nullptr);
567 ~KateCommandLineBar()
override;
569 void setText(
const QString &text,
bool selected =
true);
570 void execute(
const QString &text);
573 static void showHelpPage();
576 class KateCmdLineEdit *m_lineEdit;
584 KateCmdLineEdit(KateCommandLineBar *bar, KTextEditor::ViewPrivate *view);
585 bool event(
QEvent *e)
override;
590 void hideRequested();
593 void slotReturnPressed(
const QString &cmd);
600 void keyPressEvent(
QKeyEvent *ev)
override;
613 void fromHistory(
bool up);
616 KTextEditor::ViewPrivate *m_view;
617 KateCommandLineBar *m_bar;
623 class KateCmdLnWhatsThis *m_help;
638 void updateMenu(KTextEditor::ViewPrivate *view);
649 void slotAboutToShow();
A delegate for rendering line annotation information and handling events.
An model for providing line annotation information.
An Editor command line command.
Backend of KTextEditor::Document related public KTextEditor interfaces.
MessagePosition
Message position used to place the message either above or below of the KTextEditor::View.
@ AboveView
show message above view.
A range that is bound to a specific Document, and maintains its position.
The style option set for an annotation item, as painted by AbstractAnnotationItemDelegate.
Class to layout KTextEditor::Messages in KateView.
This class represents one visible line of text; with dynamic wrapping, many KateTextLayouts can be ne...
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
QObject * parent() const const