11#ifndef KATE_VIEW_HELPERS_H
12#define KATE_VIEW_HELPERS_H
16#include <KSelectAction>
26#include "katetextline.h"
27#include <ktexteditor/cursor.h>
28#include <ktexteditor/message.h>
37class AbstractAnnotationItemDelegate;
38class StyleOptionAnnotationItem;
41class KateViewInternal;
44#define MAXFOLDINGCOLORS 16
70 int count()
const override;
72 void setGeometry(
const QRect &rect)
override;
73 QSize sizeHint()
const override;
82 ItemWrapper() =
default;
110 QSize sizeHint()
const override;
114 inline bool showMarks()
const
118 inline void setShowMarks(
bool b)
124 inline bool showMiniMap()
const
126 return m_showMiniMap;
128 void setShowMiniMap(
bool b);
130 inline bool miniMapAll()
const
134 inline void setMiniMapAll(
bool b)
141 inline bool miniMapWidth()
const
143 return m_miniMapWidth;
145 inline void setMiniMapWidth(
int width)
147 m_miniMapWidth =
width;
152 inline void queuePixmapUpdate()
154 m_updateTimer.
start();
158 void sliderMMBMoved(
int value);
171 void sliderMaybeMoved(
int value);
178 void showTextPreview();
181 void showTextPreviewDelayed();
182 void hideTextPreview();
185 void recomputeMarksPositions();
190 int minimapYToStdY(
int y);
192 struct ColumnRangeWithColor {
203 bool m_middleMouseDown;
204 bool m_leftMouseDown;
206 KTextEditor::ViewPrivate *m_view;
208 class KateViewInternal *m_viewInternal;
210 QTimer m_delayTextPreviewTimer;
217 bool m_needsUpdateOnShow;
222 QRect m_stdGroveRect;
223 QRect m_mapGroveRect;
231 static const unsigned char characterOpacity[256];
234class KateIconBorder :
public QWidget
239 KateIconBorder(KateViewInternal *internalView,
QWidget *
parent);
240 ~KateIconBorder()
override;
242 QSize sizeHint()
const override;
245 int lineNumberWidth()
const;
247 void setIconBorderOn(
bool enable);
248 void setLineNumbersOn(
bool enable);
249 void setRelLineNumbersOn(
bool enable);
250 void setAnnotationBorderOn(
bool enable);
251 void setDynWrapIndicators(
int state);
252 int dynWrapIndicators()
const
254 return m_dynWrapIndicators;
256 bool dynWrapIndicatorsOn()
const
258 return m_dynWrapIndicatorsOn;
260 void setFoldingMarkersOn(
bool enable);
261 void toggleIconBorder()
263 setIconBorderOn(!iconBorderOn());
265 void toggleLineNumbers()
267 setLineNumbersOn(!lineNumbersOn());
269 void toggleFoldingMarkers()
271 setFoldingMarkersOn(!foldingMarkersOn());
273 inline bool iconBorderOn()
const
275 return m_iconBorderOn;
277 inline bool lineNumbersOn()
const
279 return m_lineNumbersOn;
281 inline bool viRelNumbersOn()
const
283 return m_relLineNumbersOn;
285 inline bool foldingMarkersOn()
const
287 return m_foldingMarkersOn;
289 inline bool annotationBorderOn()
const
291 return m_annotationBorderOn;
294 void updateForCursorLineChange();
296 enum BorderArea { None, LineNumbers, IconBorder, FoldingMarkers, AnnotationBorder, ModificationBorder };
297 BorderArea positionToArea(
const QPoint &)
const;
301 inline bool uniformAnnotationItemSizes()
const
303 return m_hasUniformAnnotationItemSizes;
305 inline void setAnnotationUniformItemSizes(
bool enable)
307 m_hasUniformAnnotationItemSizes = enable;
311 void updateAnnotationBorderWidth();
312 void updateAnnotationLine(
int line);
314 void displayRangeChanged();
326 void mouseDoubleClickEvent(
QMouseEvent *)
override;
333 void showMarkMenu(uint line,
const QPoint &
pos);
335 void hideAnnotationTooltip();
336 void removeAnnotationHovering();
337 void showAnnotationMenu(
int line,
const QPoint &
pos);
338 void calcAnnotationBorderWidth();
345 const QString &annotationGroupIdentifier)
const;
346 QRect annotationLineRectInView(
int line)
const;
349 KTextEditor::ViewPrivate *m_view;
351 KateViewInternal *m_viewInternal;
353 bool m_iconBorderOn : 1;
354 bool m_lineNumbersOn : 1;
355 bool m_relLineNumbersOn : 1;
356 bool m_updateRelLineNumbers : 1;
357 bool m_foldingMarkersOn : 1;
358 bool m_dynWrapIndicatorsOn : 1;
359 bool m_annotationBorderOn : 1;
360 bool m_updatePositionToArea : 1;
361 bool m_mouseOver =
false;
363 typedef QPair<int, KateIconBorder::BorderArea> AreaPosition;
364 std::vector<AreaPosition> m_positionToArea;
366 const int m_separatorWidth = 2;
367 const int m_modAreaWidth = 3;
368 qreal m_maxCharWidth = 0.0;
369 int m_lineNumberAreaWidth = 0;
370 int m_iconAreaWidth = 0;
371 int m_foldingAreaWidth = 0;
372 int m_annotationAreaWidth = 0;
373 const QChar m_dynWrapIndicatorChar =
QChar(0x21AA);
374 int m_dynWrapIndicators = 0;
375 int m_lastClickedLine = -1;
378 bool m_hasUniformAnnotationItemSizes =
false;
379 bool m_isDefaultAnnotationItemDelegate =
true;
383 int m_currentLine = -1;
384 QTimer m_antiFlickerTimer;
385 void highlightFoldingDelayed(
int line);
389 void highlightFolding();
390 void handleDestroyedAnnotationItemDelegate();
391 void delayedUpdateOfSizeWithRepaint();
394 QString m_hoveredAnnotationGroupIdentifier;
402 bool setCurrentCodec(
const QString &codec);
406 void subActionTriggered(
QAction *);
409 KTextEditor::ViewPrivate *view;
411 const bool m_saveAsMode;
414 void setEncoding(
const QString &e);
415 void slotAboutToShow();
420class KateViewBarWidget :
public QWidget
423 friend class KateViewBar;
426 explicit KateViewBarWidget(
bool addCloseButton,
QWidget *
parent =
nullptr);
428 virtual void closed()
433 KateViewBar *viewBar()
444 return m_centralWidget;
452 return m_closeButton;
460 void setAssociatedViewBar(KateViewBar *bar)
466 QWidget *m_centralWidget =
nullptr;
467 KateViewBar *m_viewBar =
nullptr;
471class KateViewBar :
public QWidget
476 KateViewBar(
bool external,
QWidget *
parent, KTextEditor::ViewPrivate *view);
483 void addBarWidget(KateViewBarWidget *newBarWidget);
491 void removeBarWidget(KateViewBarWidget *barWidget);
496 bool hasBarWidget(KateViewBarWidget *barWidget)
const;
502 void showBarWidget(KateViewBarWidget *barWidget);
514 void addPermanentBarWidget(KateViewBarWidget *barWidget);
522 void removePermanentBarWidget(KateViewBarWidget *barWidget);
526 bool barWidgetVisible()
const;
532 void hideCurrentBarWidget();
542 void setViewBarVisible(
bool visible);
547 KTextEditor::ViewPrivate *m_view;
549 KateViewBarWidget *m_permanentBarWidget;
553class KateCommandLineBar :
public KateViewBarWidget
556 explicit KateCommandLineBar(KTextEditor::ViewPrivate *view,
QWidget *
parent =
nullptr);
557 ~KateCommandLineBar()
override;
559 void setText(
const QString &text,
bool selected =
true);
560 void execute(
const QString &text);
563 static void showHelpPage();
566 class KateCmdLineEdit *m_lineEdit;
574 KateCmdLineEdit(KateCommandLineBar *bar, KTextEditor::ViewPrivate *view);
575 bool event(
QEvent *e)
override;
580 void hideRequested();
583 void slotReturnPressed(
const QString &cmd);
590 void keyPressEvent(
QKeyEvent *ev)
override;
603 void fromHistory(
bool up);
606 KTextEditor::ViewPrivate *m_view;
607 KateCommandLineBar *m_bar;
613 class KateCmdLnWhatsThis *m_help;
628 void updateMenu(KTextEditor::ViewPrivate *view);
639 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