15#include "kateviewhelpers.h"
17#include "kateabstractinputmode.h"
18#include "kateannotationitemdelegate.h"
20#include "katecommandrangeexpressionparser.h"
21#include "kateconfig.h"
22#include "katedocument.h"
23#include "kateglobal.h"
24#include "katelayoutcache.h"
25#include "katepartdebug.h"
26#include "katerenderer.h"
27#include "katesyntaxmanager.h"
28#include "katetextlayout.h"
29#include "katetextpreview.h"
31#include "kateviewinternal.h"
32#include <katebuffer.h>
33#include <ktexteditor/annotationinterface.h>
34#include <ktexteditor/attribute.h>
35#include <ktexteditor/command.h>
36#include <ktexteditor/movingrange.h>
38#include <KActionCollection>
41#include <KConfigGroup>
43#include <KLocalizedString>
46#include <QActionGroup>
49#include <QGuiApplication>
51#include <QLinearGradient>
54#include <QPainterPath>
57#include <QRegularExpression>
58#include <QStackedWidget>
60#include <QStyleOption>
65#include <QtAlgorithms>
70KateMessageLayout::KateMessageLayout(
QWidget *parent)
76KateMessageLayout::~KateMessageLayout()
91 add(
new QWidgetItem(
widget), pos);
94int KateMessageLayout::count()
const
96 return m_items.size();
99QLayoutItem *KateMessageLayout::itemAt(
int index)
const
101 return m_items.value(index).item;
104void KateMessageLayout::setGeometry(
const QRect &rect)
108 const QRect adjustedRect = rect.
adjusted(s, s, -s, -s);
110 for (
const auto &wrapper : std::as_const(m_items)) {
112 auto position = wrapper.position;
125 r.moveCenter(adjustedRect.
center());
128 Q_ASSERT_X(
false,
"setGeometry",
"Only TopInView, CenterInView, and BottomInView are supported.");
133QSize KateMessageLayout::sizeHint()
const
140 if (index >= 0 && index < m_items.size()) {
141 return m_items.takeAt(index).item;
148 m_items.push_back({item, pos});
153static const int s_lineWidth = 100;
154static const int s_pixelMargin = 8;
155static const int s_linePixelIncLimit = 6;
157KateScrollBar::KateScrollBar(
Qt::Orientation orientation, KateViewInternal *parent)
159 , m_middleMouseDown(false)
160 , m_leftMouseDown(false)
161 , m_view(parent->m_view)
162 , m_doc(parent->doc())
163 , m_viewInternal(parent)
164 , m_textPreview(nullptr)
166 , m_showMiniMap(false)
168 , m_needsUpdateOnShow(false)
170 , m_grooveHeight(height())
171 , m_tooltipLineNoInfo(this)
176 m_updateTimer.setInterval(300);
177 m_updateTimer.setSingleShot(
true);
183 m_delayTextPreviewTimer.setSingleShot(
true);
184 m_delayTextPreviewTimer.setInterval(250);
185 connect(&m_delayTextPreviewTimer, &
QTimer::timeout,
this, &KateScrollBar::showTextPreview);
187 m_tooltipLineNoInfo.setTextFormat(Qt::TextFormat::RichText);
189 m_tooltipLineNoInfo.setContentsMargins({2, 2, 2, 2});
190 m_tooltipLineNoInfo.setAutoFillBackground(
true);
191 m_tooltipLineNoInfo.setVisible(
false);
194void KateScrollBar::showEvent(
QShowEvent *event)
198 if (m_needsUpdateOnShow) {
199 m_needsUpdateOnShow =
false;
204KateScrollBar::~KateScrollBar()
206 delete m_textPreview;
209void KateScrollBar::setShowMiniMap(
bool b)
211 if (b && !m_showMiniMap) {
228QSize KateScrollBar::sizeHint()
const
236int KateScrollBar::minimapYToStdY(
int y)
239 if (m_stdGroveRect.height() == m_mapGroveRect.height()) {
244 if ((
y < m_stdGroveRect.top()) || (
y > m_stdGroveRect.bottom())) {
248 if (
y < m_mapGroveRect.top()) {
249 return m_stdGroveRect.top() + 1;
252 if (
y > m_mapGroveRect.bottom()) {
253 return m_stdGroveRect.bottom() - 1;
257 if (m_mapGroveRect.height() == 0) {
261 int newY = (
y - m_mapGroveRect.top()) * m_stdGroveRect.height() / m_mapGroveRect.height();
262 newY += m_stdGroveRect.top();
272 m_middleMouseDown =
true;
274 m_leftMouseDown =
true;
278 if (!m_sliderRect.contains(e->
pos()) && m_leftMouseDown && e->
pos().
y() > m_mapGroveRect.top() && e->
pos().
y() < m_mapGroveRect.bottom()) {
280 int newVal = (e->
pos().
y() - m_mapGroveRect.top()) / (double)m_mapGroveRect.height() * (double)(
maximum() +
pageStep()) -
pageStep() / 2;
281 newVal = qBound(0, newVal,
maximum());
284 const QPoint
pos(6, minimapYToStdY(e->
pos().
y()));
292 toolTipPos.ry() += m_sliderRect.height();
293 m_toolTipPos = toolTipPos;
294 const int fromLine = m_viewInternal->toRealCursor(m_viewInternal->startPos()).line() + 1;
295 const int lastLine = m_viewInternal->toRealCursor(m_viewInternal->endPos()).line() + 1;
296 const QString text =
i18nc(
"from line - to line",
"<center>%1<br/>—<br/>%2</center>", fromLine, lastLine);
297 m_tooltipLineNoInfo.setText(text);
298 m_tooltipLineNoInfo.setVisible(
true);
299 m_tooltipLineNoInfo.adjustSize();
305void KateScrollBar::mouseReleaseEvent(
QMouseEvent *e)
308 m_middleMouseDown =
false;
310 m_leftMouseDown =
false;
315 m_tooltipLineNoInfo.setVisible(
false);
318 const QPoint
pos(e->
pos().
x(), minimapYToStdY(e->
pos().
y()));
329 const QPoint
pos(e->
pos().
x(), minimapYToStdY(e->
pos().
y()));
341 toolTipPos.ry() += m_sliderRect.height();
342 m_toolTipPos = toolTipPos;
343 const int fromLine = m_viewInternal->toRealCursor(m_viewInternal->startPos()).line() + 1;
344 const int lastLine = m_viewInternal->toRealCursor(m_viewInternal->endPos()).line() + 1;
345 const QString text =
i18nc(
"from line - to line",
"<center>%1<br/>—<br/>%2</center>", fromLine, lastLine);
346 m_tooltipLineNoInfo.setText(text);
347 m_tooltipLineNoInfo.setVisible(
true);
348 m_tooltipLineNoInfo.adjustSize();
352 showTextPreviewDelayed();
355void KateScrollBar::leaveEvent(
QEvent *event)
362bool KateScrollBar::eventFilter(
QObject *
object,
QEvent *event)
376 if (m_doc->marks().size() != m_lines.size()) {
377 recomputeMarksPositions();
380 miniMapPaintEvent(e);
386void KateScrollBar::showTextPreviewDelayed()
388 if (!m_textPreview) {
389 if (!m_delayTextPreviewTimer.isActive()) {
390 m_delayTextPreviewTimer.start();
397void KateScrollBar::showTextPreview()
411 grooveRect = m_mapGroveRect;
413 QStyleOptionSlider opt;
421 opt.sliderValue =
value();
428 if (m_view->config()->scrollPastEnd()) {
431 grooveRect.
adjust(0, 0, 0, -adjust);
435 if (grooveRect.
contains(cursorPos)) {
436 if (!m_textPreview) {
437 m_textPreview =
new KateTextPreview(m_view,
this);
442 qApp->installEventFilter(
this);
445 const qreal posInPercent =
static_cast<double>(cursorPos.
y() - grooveRect.
top()) / grooveRect.
height();
446 const qreal startLine = posInPercent * m_view->textFolding().visibleLines();
448 m_textPreview->resize(m_view->width() / 2, m_view->height() / 5);
450 const int yGlobal = qMin(
mapToGlobal(QPoint(0,
height())).
y() - m_textPreview->height(),
452 m_textPreview->move(xGlobal - m_textPreview->width(), yGlobal);
453 m_textPreview->setLine(startLine);
454 m_textPreview->setCenterView(
true);
455 m_textPreview->setScaleFactor(0.75);
456 m_textPreview->raise();
457 m_textPreview->show();
463void KateScrollBar::hideTextPreview()
465 if (m_delayTextPreviewTimer.isActive()) {
466 m_delayTextPreviewTimer.stop();
469 qApp->removeEventFilter(
this);
470 delete m_textPreview;
482 auto getPen = [&](
const QBrush &color) ->
int {
483 uint rgb = color.color().rgb();
484 auto it = std::find_if(penCache.begin(), penCache.end(), [rgb](
const std::pair<QRgb, QPen> &rgbToPen) {
485 return rgb == rgbToPen.first;
487 if (it != penCache.end()) {
488 return it - penCache.begin();
490 penCache.push_back({rgb, QPen(color, 1)});
491 return (
int)penCache.size() - 1;
494 constexpr QChar space = QLatin1Char(
' ');
495 constexpr QChar tab = QLatin1Char(
'\t');
497 for (
int i = 0; i < text.
size() && i < s_lineWidth; ++i) {
498 if (text[i] == space || text[i] == tab) {
502 bool styleFound =
false;
503 for (
auto range : decorations) {
504 if (range->containsColumn(i)) {
505 QBrush color = range->attribute()->foreground();
507 int startCol = range->start().column();
508 int endCol = range->end().column();
509 ranges << ColumnRangeWithColor{.penIndex = getPen(color), .startColumn = startCol, .endColumn = endCol};
522 qsizetype attributeIndex = 0;
523 while ((attributeIndex < attributes.
size()) && ((attributes[attributeIndex].offset + attributes[attributeIndex].length) < i)) {
526 if (attributeIndex < attributes.
size()) {
527 const auto attr = attributes[attributeIndex];
528 if ((i < attr.offset + attr.length)) {
529 QBrush color = m_view->renderer()->attribute(attr.attributeValue)->foreground();
530 int startCol = attr.offset;
531 int endCol = attr.offset + attr.length;
532 ranges << ColumnRangeWithColor{.penIndex = getPen(color), .startColumn = startCol, .endColumn = endCol};
539void KateScrollBar::updatePixmap()
544 if (!m_showMiniMap) {
552 m_needsUpdateOnShow =
true;
558 int docLineCount = m_view->textFolding().visibleLines();
559 int pixmapLineCount = docLineCount;
560 if (m_view->config()->scrollPastEnd()) {
563 int pixmapLinesUnscaled = pixmapLineCount;
564 if (m_grooveHeight < 5) {
567 int charIncrement = 1;
568 int lineIncrement = 1;
569 if ((m_grooveHeight > 10) && (pixmapLineCount >= m_grooveHeight * 2)) {
570 charIncrement = pixmapLineCount / m_grooveHeight;
571 while (charIncrement > s_linePixelIncLimit) {
573 pixmapLineCount = pixmapLinesUnscaled / lineIncrement;
574 charIncrement = pixmapLineCount / m_grooveHeight;
576 pixmapLineCount /= charIncrement;
579 int pixmapLineWidth = s_pixelMargin + s_lineWidth / charIncrement;
584 const QBrush backgroundColor = m_view->defaultStyleAttribute(KSyntaxHighlighting::Theme::TextStyle::Normal)->background();
585 const QBrush defaultTextColor = m_view->defaultStyleAttribute(KSyntaxHighlighting::Theme::TextStyle::Normal)->foreground();
586 const QBrush selectionBgColor = m_view->rendererConfig()->selectionColor();
588 QColor modifiedLineColor = m_view->rendererConfig()->modifiedLineColor();
589 QColor savedLineColor = m_view->rendererConfig()->savedLineColor();
591 modifiedLineColor.
setHsv(modifiedLineColor.
hue(), 255, 255 - backgroundColor.
color().
value() / 3);
592 savedLineColor.
setHsv(savedLineColor.
hue(), 100, 255 - backgroundColor.
color().
value() / 3);
594 const QBrush modifiedLineBrush = modifiedLineColor;
595 const QBrush savedLineBrush = savedLineColor;
598 m_pixmap = QPixmap(pixmapLineWidth * m_view->devicePixelRatioF(), pixmapLineCount * m_view->devicePixelRatioF());
599 m_pixmap.fill(QColor(
"transparent"));
602 const KTextEditor::Range selection = m_view->selectionRange();
603 const bool hasSelection = !selection.
isEmpty();
605 QList<KateScrollBar::ColumnRangeWithColor> colorRangesForLine;
606 const QPen defaultTextPen = QPen(defaultTextColor, 1);
608 QList<Kate::TextRange *> decorations;
611 if (painter.
begin(&m_pixmap)) {
613 painter.
setPen(QPen(selectionBgColor, 1));
616 const bool simpleMode = m_doc->lines() > 7500;
622 QVarLengthArray<std::pair<QRgb, QPen>, 20> penCache;
625 for (
int virtualLine = 0; virtualLine < docLineCount; virtualLine += lineIncrement) {
626 int realLineNumber = m_view->textFolding().visibleLineToLine(virtualLine);
627 const Kate::TextLine kateline = m_doc->plainKateTextLine(realLineNumber);
628 const QString lineText = kateline.
text();
631 m_doc->buffer().ensureHighlighted(realLineNumber);
638 m_view->doc()->buffer().rangesForLine(realLineNumber, m_view,
true, decorations);
642 int pixelX = s_pixelMargin;
645 if (selection.
contains(KTextEditor::Cursor(realLineNumber, 0)) && lineText.
size() == 0) {
646 if (selectionBgColor != painter.
pen().
brush()) {
647 painter.
setPen(QPen(selectionBgColor, 1));
649 painter.
drawLine(s_pixelMargin, pixelY, s_pixelMargin + s_lineWidth - 1, pixelY);
654 for (
int x = 0; (
x < lineText.
size() &&
x < s_lineWidth);
x += charIncrement) {
655 if (pixelX >= s_lineWidth + s_pixelMargin) {
659 if (selection.
contains(KTextEditor::Cursor(realLineNumber,
x))) {
660 if (selStartX == -1) {
664 if (lineText.
size() - 1 ==
x) {
665 selEndX = s_lineWidth + s_pixelMargin - 1;
669 if (lineText[
x] == QLatin1Char(
'\t')) {
670 pixelX += qMax(4 / charIncrement, 1);
676 if (selStartX != -1) {
677 if (selectionBgColor != painter.
pen().
brush()) {
678 painter.
setPen(QPen(selectionBgColor, 1));
680 painter.
drawLine(selStartX, pixelY, selEndX, pixelY);
685 getCharColorRanges(attributes, decorations, lineText, colorRangesForLine, penCache);
686 pixelX = s_pixelMargin;
687 for (
int x = 0; (
x < lineText.
size() &&
x < s_lineWidth);
x += charIncrement) {
688 if (pixelX >= s_lineWidth + s_pixelMargin) {
693 if (lineText[
x] == QLatin1Char(
' ')) {
695 }
else if (lineText[
x] == QLatin1Char(
'\t')) {
696 pixelX += qMax(4 / charIncrement, 1);
698 const QPen *pen =
nullptr;
699 int rangeEnd =
x + 1;
700 for (
const auto &cr : colorRangesForLine) {
701 if (cr.startColumn <=
x &&
x <= cr.endColumn) {
702 rangeEnd = cr.endColumn;
703 if (cr.penIndex != -1) {
704 pen = &penCache[cr.penIndex].second;
710 pen = &defaultTextPen;
716 QVarLengthArray<QPoint, 100> points;
717 for (;
x < rangeEnd;
x += charIncrement) {
718 if (pixelX >= s_lineWidth + s_pixelMargin) {
721 points.
append({pixelX++, pixelY});
727 if (((drawnLines) % charIncrement) == 0) {
735 if (m_doc->lines() < 50000) {
736 for (
int lineno = 0; lineno < docLineCount; lineno++) {
737 int realLineNo = m_view->textFolding().visibleLineToLine(lineno);
738 const auto line = m_doc->plainKateTextLine(realLineNo);
739 const QBrush &col = line.markedAsModified() ? modifiedLineBrush : savedLineBrush;
740 if (line.markedAsModified() || line.markedAsSavedOnDisk()) {
741 int pos = (lineno * pixmapLineCount) / pixmapLinesUnscaled;
752 m_pixmap.setDevicePixelRatio(m_view->devicePixelRatioF());
759void KateScrollBar::miniMapPaintEvent(
QPaintEvent *e)
763 QPainter painter(
this);
765 QStyleOptionSlider opt;
773 opt.sliderValue =
value();
778 m_stdGroveRect = grooveRect;
781 grooveRect.
moveTop(alignMargin);
788 m_grooveHeight = grooveRect.
height();
790 const int docXMargin = 1;
795 const int docHeight = qMin(grooveRect.
height(),
int(m_pixmap.height() / m_pixmap.devicePixelRatio() * 2)) - 2 * docXMargin;
796 const int yoffset = 1;
797 const QRect docRect(QPoint(grooveRect.
left() + docXMargin, yoffset + grooveRect.
top()), QSize(grooveRect.
width() - docXMargin, docHeight));
798 m_mapGroveRect = docRect;
801 int max = qMax(
maximum() + 1, 1);
802 int visibleStart =
value() * docHeight / (max +
pageStep()) + docRect.top() + 0.5;
804 QRect visibleRect = docRect;
805 visibleRect.
moveTop(visibleStart);
806 visibleRect.
setHeight(visibleEnd - visibleStart);
809 const QColor backgroundColor = m_view->defaultStyleAttribute(KSyntaxHighlighting::Theme::TextStyle::Normal)->background().
color();
810 const QColor foregroundColor = m_view->defaultStyleAttribute(KSyntaxHighlighting::Theme::TextStyle::Normal)->foreground().color();
811 const QColor highlightColor =
palette().highlight().color();
813 const int backgroundLightness = backgroundColor.
lightness();
814 const int foregroundLightness = foregroundColor.
lightness();
815 const int lighnessDiff = (foregroundLightness - backgroundLightness);
822 darkShieldColor.
getHsl(&hue, &sat, &light);
824 darkShieldColor.
setHsl(hue, sat, backgroundLightness + lighnessDiff * 0.35);
826 QLinearGradient gradient(0, 0,
width(), 0);
827 gradient.setColorAt(0, darkShieldColor);
828 gradient.setColorAt(0.3, darkShieldColor.
lighter(115));
829 gradient.setColorAt(1, darkShieldColor);
831 QColor lightShieldColor;
832 lightShieldColor.
setHsl(hue, sat, backgroundLightness + lighnessDiff * 0.15);
835 outlineColor.
setHsl(hue, sat, backgroundLightness + lighnessDiff * 0.5);
844 sliderRect.
setX(docXMargin);
847 if ((docHeight + 2 * docXMargin >= grooveRect.
height()) && (sliderRect.
height() > visibleRect.
height() + 2)) {
848 visibleRect.
adjust(2, 0, -3, 0);
850 visibleRect.
adjust(1, 0, -1, 2);
851 sliderRect.
setTop(visibleRect.
top() - 1);
856 if (grooveRect.
height() < m_pixmap.height() / m_pixmap.devicePixelRatio()) {
861 QRect pixmapMarginRect(QPoint(0, 0), QSize(s_pixelMargin, m_pixmap.height() / m_pixmap.devicePixelRatio()));
862 QRect docPixmapMarginRect(QPoint(0, docRect.top()), QSize(s_pixelMargin, docRect.height()));
863 painter.
drawPixmap(docPixmapMarginRect, m_pixmap, pixmapMarginRect);
866 QRect pixmapRect(QPoint(s_pixelMargin, 0),
867 QSize(m_pixmap.width() / m_pixmap.devicePixelRatio() - s_pixelMargin, m_pixmap.height() / m_pixmap.devicePixelRatio()));
868 QRect docPixmapRect(QPoint(s_pixelMargin, docRect.top()), QSize(docRect.width() - s_pixelMargin, docRect.height()));
869 painter.
drawPixmap(docPixmapRect, m_pixmap, pixmapRect);
872 const int y = docPixmapRect.height() + grooveRect.
y();
873 if (
y + 2 < grooveRect.
y() + grooveRect.
height()) {
874 QColor fg(foregroundColor);
877 painter.
setPen(QPen(fg, 1));
882 const QRect top(grooveRect.
x(),
885 visibleRect.
y() - grooveRect.
y()
887 const QRect bottom(grooveRect.
x(),
888 grooveRect.
y() + visibleRect.
y() + visibleRect.
height() - grooveRect.
y(),
890 grooveRect.
height() - (visibleRect.
y() - grooveRect.
y()) - visibleRect.
height());
892 QColor faded(backgroundColor);
898 QColor c(foregroundColor);
900 painter.
setPen(QPen(c, 1));
904 QHashIterator<int, QColor> it = m_lines;
912 int y = (it.
key() - grooveRect.
top()) * docHeight / grooveRect.
height() + docRect.top();
923 int y = (it.
key() - grooveRect.
top()) * docHeight / grooveRect.
height() + docRect.top();
929 QColor sliderColor(highlightColor);
930 sliderColor.setAlpha(50);
931 painter.
fillRect(sliderRect, sliderColor);
932 painter.
setPen(QPen(highlightColor, 0));
933 m_sliderRect = sliderRect;
941void KateScrollBar::normalPaintEvent(
QPaintEvent *e)
949 QPainter painter(
this);
951 QStyleOptionSlider opt;
959 opt.sliderValue =
value();
965 if (sideMargin < 4) {
970 QHashIterator<int, QColor> it = m_lines;
986 m_updateTimer.start();
991void KateScrollBar::sliderChange(SliderChange change)
1002 if (m_leftMouseDown || m_middleMouseDown) {
1003 const int fromLine = m_viewInternal->toRealCursor(m_viewInternal->startPos()).line() + 1;
1004 const int lastLine = m_viewInternal->toRealCursor(m_viewInternal->endPos()).line() + 1;
1005 const QString text =
i18nc(
"from line - to line",
"<center>%1<br/>—<br/>%2</center>", fromLine, lastLine);
1006 m_tooltipLineNoInfo.setText(text);
1007 m_tooltipLineNoInfo.setVisible(
true);
1008 m_tooltipLineNoInfo.adjustSize();
1013void KateScrollBar::marksChanged()
1019void KateScrollBar::redrawMarks()
1027void KateScrollBar::recomputeMarksPositions()
1030 QStyleOptionSlider opt;
1035 const int top = grooveRect.
top();
1036 const int h = grooveRect.
height() - 1;
1044 int visibleLines = m_view->textFolding().visibleLines() - 1;
1045 if (m_view->config()->scrollPastEnd()) {
1046 visibleLines += m_viewInternal->linesDisplayed() - 1;
1047 visibleLines -= m_view->config()->autoCenterLines();
1050 const QColor searchMatchColor = m_view->defaultStyleAttribute(KSyntaxHighlighting::Theme::TextStyle::Normal)->foreground().color();
1054 const QHash<int, KTextEditor::Mark *> &marks = m_doc->marks();
1055 for (QHash<int, KTextEditor::Mark *>::const_iterator i = marks.
constBegin(); i != marks.
constEnd(); ++i) {
1056 KTextEditor::Mark *mark = i.value();
1057 const int line = m_view->textFolding().lineToVisibleLine(mark->
line);
1058 const double ratio =
static_cast<double>(line) / visibleLines;
1059 const QColor markColor = mark->
type == KTextEditor::Document::SearchMatch
1062 m_lines.insert(top + (
int)(h * ratio), markColor);
1066void KateScrollBar::sliderMaybeMoved(
int value)
1068 if (m_middleMouseDown) {
1072 m_middleMouseDown =
false;
1083class KateCmdLineEditFlagCompletion :
public KCompletion
1086 KateCmdLineEditFlagCompletion()
1091 QString makeCompletion(
const QString & )
override
1099KateCommandLineBar::KateCommandLineBar(KTextEditor::ViewPrivate *view,
QWidget *parent)
1100 : KateViewBarWidget(true, parent)
1104 m_lineEdit =
new KateCmdLineEdit(
this, view);
1105 connect(m_lineEdit, &KateCmdLineEdit::hideRequested,
this, &KateCommandLineBar::hideMe);
1114 setFocusProxy(m_lineEdit);
1117void KateCommandLineBar::showHelpPage()
1122KateCommandLineBar::~KateCommandLineBar() =
default;
1126void KateCommandLineBar::setText(
const QString &text,
bool selected)
1128 m_lineEdit->setText(text);
1130 m_lineEdit->selectAll();
1134void KateCommandLineBar::execute(
const QString &text)
1136 m_lineEdit->slotReturnPressed(text);
1139KateCmdLineEdit::KateCmdLineEdit(KateCommandLineBar *bar, KTextEditor::ViewPrivate *view)
1146 , m_command(nullptr)
1150 setCompletionObject(KateCmd::self()->commandCompletionObject());
1151 setAutoDeleteCompletionObject(
false);
1153 m_hideTimer =
new QTimer(
this);
1154 m_hideTimer->setSingleShot(
true);
1155 connect(m_hideTimer, &
QTimer::timeout,
this, &KateCmdLineEdit::hideLineEdit);
1164void KateCmdLineEdit::hideEvent(
QHideEvent *e)
1171 const QString beg = QStringLiteral(
"<qt background=\"white\"><div><table width=\"100%\"><tr><td bgcolor=\"brown\"><font color=\"white\"><b>Help: <big>");
1172 const QString mid = QStringLiteral(
"</big></b></font></td></tr><tr><td>");
1173 const QString
end = QStringLiteral(
"</td></tr></table></div><qt>");
1175 const QString t =
text();
1176 static const QRegularExpression re(QStringLiteral(
"\\s*help\\s+(.*)"));
1177 auto match = re.match(t);
1178 if (
match.hasMatch()) {
1182 if (name == QLatin1String(
"list")) {
1183 return beg +
i18n(
"Available Commands") + mid + KateCmd::self()->commandList().
join(QLatin1Char(
' '))
1184 +
i18n(
"<p>For help on individual commands, do <code>'help <command>'</code></p>") +
end;
1186 KTextEditor::Command *cmd = KateCmd::self()->queryCommand(name);
1188 if (cmd->
help(m_view, name, s)) {
1189 return beg +
name + mid + s +
end;
1191 return beg +
name + mid +
i18n(
"No help for '%1'", name) +
end;
1194 return beg + mid +
i18n(
"No such command <b>%1</b>", name) +
end;
1200 +
i18n(
"<p>This is the Katepart <b>command line</b>.<br />"
1201 "Syntax: <code><b>command [ arguments ]</b></code><br />"
1202 "For a list of available commands, enter <code><b>help list</b></code><br />"
1203 "For help for individual commands, enter <code><b>help <command></b></code></p>")
1207bool KateCmdLineEdit::event(
QEvent *e)
1242void KateCmdLineEdit::slotReturnPressed(
const QString &text)
1244 static const QRegularExpression focusChangingCommands(QStringLiteral(
"^(?:buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e)$"));
1246 if (
text.isEmpty()) {
1251 const uint textlen =
text.length();
1252 while ((n < textlen) && (
text[n].isSpace())) {
1260 QString cmd =
text.mid(n);
1263 QString leadingRangeExpression;
1264 KTextEditor::Range range = CommandRangeExpressionParser::parseRangeExpression(cmd, m_view, leadingRangeExpression, cmd);
1270 KateCmd::self()->appendHistory(cmd);
1271 m_histpos = KateCmd::self()->historyLength();
1277 KTextEditor::Command *p = KateCmd::self()->queryCommand(cmd);
1279 m_oldText = leadingRangeExpression + cmd;
1283 if (focusChangingCommands.matchView(QStringView(cmd).
left(cmd.indexOf(QLatin1Char(
' ')))).hasMatch()) {
1291 setText(
i18n(
"Error: No range allowed for command \"%1\".", cmd));
1294 if (p->
exec(m_view, cmd, msg, range)) {
1296 KateCmd::self()->appendHistory(leadingRangeExpression + cmd);
1297 m_histpos = KateCmd::self()->historyLength();
1308 if (msg.
contains(QLatin1Char(
'\n'))) {
1327 m_command =
nullptr;
1330 if (!focusChangingCommands.matchView(QStringView(cmd).
left(cmd.indexOf(QLatin1Char(
' ')))).hasMatch()) {
1335 m_hideTimer->start(4000);
1339void KateCmdLineEdit::hideLineEdit()
1346void KateCmdLineEdit::focusInEvent(
QFocusEvent *ev)
1357void KateCmdLineEdit::keyPressEvent(
QKeyEvent *ev)
1373 if (!m_cmdend || cursorpos <= m_cmdend) {
1379 if (!m_cmdend && !c.
isNull()) {
1380 if (!c.
isLetterOrNumber() && c != QLatin1Char(
'-') && c != QLatin1Char(
'_')) {
1381 m_command = KateCmd::self()->queryCommand(
text().trimmed());
1386 m_cmdend = cursorpos;
1394 m_command = KateCmd::self()->queryCommand(
text().trimmed());
1400 for (; (int)m_cmdend < t.
length(); m_cmdend++) {
1401 if (t[m_cmdend].isLetter()) {
1404 if (b && (!t[m_cmdend].isLetterOrNumber() && t[m_cmdend] != QLatin1Char(
'-') && t[m_cmdend] != QLatin1Char(
'_'))) {
1409 if (c == QLatin1Char(
':') && cursorpos == m_cmdend) {
1427 KCompletion *cmpl = m_command->completionObject(m_view,
text().
left(m_cmdend).trimmed());
1438 if (m_command->wantsToProcessText(
text().
left(m_cmdend).trimmed())) {
1439 m_command->processText(m_view,
text());
1444void KateCmdLineEdit::fromHistory(
bool up)
1446 if (!KateCmd::self()->historyLength()) {
1453 if (m_histpos > 0) {
1455 s = KateCmd::self()->fromHistory(m_histpos);
1458 if (m_histpos < (KateCmd::self()->historyLength() - 1)) {
1460 s = KateCmd::self()->fromHistory(m_histpos);
1462 m_histpos = KateCmd::self()->historyLength();
1471 if (
match.hasMatch()) {
1481KateIconBorder::KateIconBorder(KateViewInternal *internalView,
QWidget *parent)
1483 , m_view(internalView->m_view)
1484 , m_doc(internalView->doc())
1485 , m_viewInternal(internalView)
1486 , m_iconBorderOn(false)
1487 , m_lineNumbersOn(false)
1488 , m_relLineNumbersOn(false)
1489 , m_updateRelLineNumbers(false)
1490 , m_foldingMarkersOn(false)
1491 , m_dynWrapIndicatorsOn(false)
1492 , m_annotationBorderOn(false)
1493 , m_updatePositionToArea(true)
1494 , m_annotationItemDelegate(new KateAnnotationItemDelegate(this))
1496 setAcceptDrops(
true);
1506 setMouseTracking(
true);
1514 m_antiFlickerTimer.setSingleShot(
true);
1515 m_antiFlickerTimer.setInterval(300);
1516 connect(&m_antiFlickerTimer, &
QTimer::timeout,
this, &KateIconBorder::highlightFolding);
1522KateIconBorder::~KateIconBorder()
1524 delete m_foldingPreview;
1525 delete m_foldingRange;
1528void KateIconBorder::setIconBorderOn(
bool enable)
1530 if (enable == m_iconBorderOn) {
1534 m_iconBorderOn = enable;
1536 m_updatePositionToArea =
true;
1541void KateIconBorder::setAnnotationBorderOn(
bool enable)
1543 if (enable == m_annotationBorderOn) {
1547 m_annotationBorderOn = enable;
1550 if (!m_annotationBorderOn && !m_hoveredAnnotationGroupIdentifier.isEmpty()) {
1551 m_hoveredAnnotationGroupIdentifier.clear();
1552 hideAnnotationTooltip();
1555 Q_EMIT m_view->annotationBorderVisibilityChanged(m_view, enable);
1557 m_updatePositionToArea =
true;
1562void KateIconBorder::removeAnnotationHovering()
1565 if (m_annotationBorderOn && !m_hoveredAnnotationGroupIdentifier.isEmpty()) {
1566 m_hoveredAnnotationGroupIdentifier.clear();
1571void KateIconBorder::setLineNumbersOn(
bool enable)
1573 if (enable == m_lineNumbersOn) {
1577 m_lineNumbersOn = enable;
1578 m_dynWrapIndicatorsOn = (m_dynWrapIndicators == 1) ? enable : m_dynWrapIndicators;
1580 m_updatePositionToArea =
true;
1585void KateIconBorder::setRelLineNumbersOn(
bool enable)
1587 if (enable == m_relLineNumbersOn) {
1591 m_relLineNumbersOn = enable;
1596 m_updatePositionToArea =
true;
1601void KateIconBorder::updateForCursorLineChange()
1603 if (m_relLineNumbersOn) {
1604 m_updateRelLineNumbers =
true;
1611void KateIconBorder::setDynWrapIndicators(
int state)
1613 if (state == m_dynWrapIndicators) {
1617 m_dynWrapIndicators = state;
1618 m_dynWrapIndicatorsOn = (state == 1) ? m_lineNumbersOn : state;
1620 m_updatePositionToArea =
true;
1625void KateIconBorder::setFoldingMarkersOn(
bool enable)
1627 if (enable == m_foldingMarkersOn) {
1631 m_foldingMarkersOn = enable;
1633 m_updatePositionToArea =
true;
1638QSize KateIconBorder::sizeHint()
const
1642 const int i = m_positionToArea.size();
1644 w = m_positionToArea.at(i - 1).first;
1652void KateIconBorder::updateFont()
1655 const QFontMetricsF &fm = m_view->renderer()->currentFontMetrics();
1656 m_maxCharWidth = 0.0;
1657 for (
char c =
'0'; c <=
'9'; ++c) {
1659 m_maxCharWidth = qMax(m_maxCharWidth, charWidth);
1668 m_iconAreaWidth = fm.
height();
1671 m_foldingAreaWidth = m_iconAreaWidth;
1673 calcAnnotationBorderWidth();
1675 m_updatePositionToArea =
true;
1685int KateIconBorder::lineNumberWidth()
const
1689 if (m_lineNumbersOn) {
1691 const int digits = (int)ceil(log10((
double)(m_view->doc()->lines() + 1)));
1692 width = (int)ceil((digits + 1) * m_maxCharWidth);
1695 if ((
width < 1) && m_dynWrapIndicatorsOn && m_view->config()->dynWordWrap()) {
1698 width = 2 * m_maxCharWidth;
1706 m_view->m_viewInternal->dragEnterEvent(
event);
1714 QPoint
pos(0,
event->position().y());
1716 m_view->m_viewInternal->placeCursor(
pos,
true,
false);
1717 m_view->m_viewInternal->fixDropEvent(
event);
1720void KateIconBorder::dropEvent(
QDropEvent *event)
1722 m_view->m_viewInternal->dropEvent(
event);
1730static void paintTriangle(
QPainter &painter,
QColor c,
int xOffset,
int yOffset,
int width,
int height,
bool open)
1734 qreal size = qMin(width, height);
1763 qreal halfSize = size / 2;
1764 qreal halfSizeP = halfSize * 0.6;
1765 QPointF middle(xOffset + (qreal)width / 2, yOffset + (qreal)height / 2);
1783class KateAnnotationGroupIdentifier
1786 KateAnnotationGroupIdentifier(
const QVariant &identifier)
1787 : m_isValid(identifier.isValid() && identifier.
canConvert<QString>())
1788 , m_id(m_isValid ? identifier.
toString() : QString())
1791 KateAnnotationGroupIdentifier() =
default;
1792 KateAnnotationGroupIdentifier(
const KateAnnotationGroupIdentifier &rhs) =
default;
1794 KateAnnotationGroupIdentifier &operator=(
const KateAnnotationGroupIdentifier &rhs)
1796 m_isValid = rhs.m_isValid;
1800 KateAnnotationGroupIdentifier &operator=(
const QVariant &identifier)
1811 bool operator==(
const KateAnnotationGroupIdentifier &rhs)
const
1813 return (m_isValid == rhs.m_isValid) && (!m_isValid || (m_id == rhs.m_id));
1815 bool operator!=(
const KateAnnotationGroupIdentifier &rhs)
const
1817 return (m_isValid != rhs.m_isValid) || (m_isValid && (m_id != rhs.m_id));
1825 bool isValid()
const
1829 const QString &id()
const
1835 bool m_isValid =
false;
1843class KateAnnotationGroupPositionState
1851 KateAnnotationGroupPositionState(KateViewInternal *viewInternal,
1852 const KTextEditor::AnnotationModel *model,
1853 const QString &hoveredAnnotationGroupIdentifier,
1861 void nextLine(KTextEditor::StyleOptionAnnotationItem &styleOption, uint z,
int realLine);
1864 KateViewInternal *m_viewInternal;
1865 const KTextEditor::AnnotationModel *
const m_model;
1866 const QString m_hoveredAnnotationGroupIdentifier;
1868 int m_visibleWrappedLineInAnnotationGroup = -1;
1869 KateAnnotationGroupIdentifier m_lastAnnotationGroupIdentifier;
1870 KateAnnotationGroupIdentifier m_nextAnnotationGroupIdentifier;
1871 bool m_isSameAnnotationGroupsSinceLast =
false;
1874KateAnnotationGroupPositionState::KateAnnotationGroupPositionState(KateViewInternal *viewInternal,
1876 const QString &hoveredAnnotationGroupIdentifier,
1879 : m_viewInternal(viewInternal)
1881 , m_hoveredAnnotationGroupIdentifier(hoveredAnnotationGroupIdentifier)
1887 if (!m_model || (
static_cast<int>(startz) >= m_viewInternal->cache()->viewCacheLineCount())) {
1891 const auto realLineAtStart = m_viewInternal->cache()->viewLine(startz).line();
1892 m_nextAnnotationGroupIdentifier = m_model->data(realLineAtStart, (
Qt::ItemDataRole)KTextEditor::AnnotationModel::GroupIdentifierRole);
1893 if (m_nextAnnotationGroupIdentifier.isValid()) {
1896 if (realLineAtStart > 0) {
1900 m_lastAnnotationGroupIdentifier = m_model->data(realLineAtStart - 1, (Qt::ItemDataRole)KTextEditor::AnnotationModel::GroupIdentifierRole);
1901 m_isSameAnnotationGroupsSinceLast = (m_lastAnnotationGroupIdentifier == m_nextAnnotationGroupIdentifier);
1904 const auto realLineBeforeStart = m_viewInternal->cache()->viewLine(startz - 1).line();
1905 m_lastAnnotationGroupIdentifier = m_model->data(realLineBeforeStart, (Qt::ItemDataRole)KTextEditor::AnnotationModel::GroupIdentifierRole);
1906 if (m_lastAnnotationGroupIdentifier.isValid()) {
1907 if (m_lastAnnotationGroupIdentifier.id() == m_nextAnnotationGroupIdentifier.id()) {
1908 m_isSameAnnotationGroupsSinceLast = true;
1910 for (uint z = startz; z > 0; --z) {
1911 const auto realLine = m_viewInternal->cache()->viewLine(z - 1).line();
1912 const KateAnnotationGroupIdentifier identifier =
1913 m_model->data(realLine, (Qt::ItemDataRole)KTextEditor::AnnotationModel::GroupIdentifierRole);
1914 if (identifier != m_lastAnnotationGroupIdentifier) {
1917 ++m_visibleWrappedLineInAnnotationGroup;
1927 styleOption.
wrappedLine = m_viewInternal->cache()->viewLine(z).viewLine();
1928 styleOption.
wrappedLineCount = m_viewInternal->cache()->viewLineCount(realLine);
1931 const KateAnnotationGroupIdentifier annotationGroupIdentifier = m_nextAnnotationGroupIdentifier;
1932 bool isSameAnnotationGroupsSinceThis =
false;
1936 m_nextAnnotationGroupIdentifier = annotationGroupIdentifier;
1937 isSameAnnotationGroupsSinceThis =
true;
1939 if (
static_cast<int>(z + 1) < m_viewInternal->cache()->viewCacheLineCount()) {
1940 const int realLineAfter = m_viewInternal->cache()->viewLine(z + 1).line();
1942 int rl = realLine + 1;
1943 for (; rl <= realLineAfter; ++rl) {
1944 m_nextAnnotationGroupIdentifier = m_model->data(rl, (
Qt::ItemDataRole)KTextEditor::AnnotationModel::GroupIdentifierRole);
1945 if (!m_nextAnnotationGroupIdentifier.isValid() || (m_nextAnnotationGroupIdentifier.id() != annotationGroupIdentifier.id())) {
1949 isSameAnnotationGroupsSinceThis = (rl > realLineAfter);
1950 if (rl < realLineAfter) {
1951 m_nextAnnotationGroupIdentifier = m_model->data(realLineAfter, (
Qt::ItemDataRole)KTextEditor::AnnotationModel::GroupIdentifierRole);
1955 m_nextAnnotationGroupIdentifier.clear();
1956 isSameAnnotationGroupsSinceThis =
false;
1960 if (annotationGroupIdentifier.isValid()) {
1961 if (m_hoveredAnnotationGroupIdentifier == annotationGroupIdentifier.id()) {
1964 styleOption.state &= ~QStyle::State_MouseOver;
1967 if (m_isSameAnnotationGroupsSinceLast) {
1968 ++m_visibleWrappedLineInAnnotationGroup;
1970 m_visibleWrappedLineInAnnotationGroup = 0;
1974 if (!m_isSameAnnotationGroupsSinceLast) {
1977 if (!isSameAnnotationGroupsSinceThis) {
1981 m_visibleWrappedLineInAnnotationGroup = 0;
1985 m_lastAnnotationGroupIdentifier = m_nextAnnotationGroupIdentifier;
1986 m_isSameAnnotationGroupsSinceLast = isSameAnnotationGroupsSinceThis;
1989void KateIconBorder::paintBorder(
int ,
int y,
int ,
int height)
1991 const uint h = m_view->renderer()->lineHeight();
1992 const uint startz = (
y / h);
1993 const uint endz = qMin(startz + 1 + (
height / h),
static_cast<uint
>(m_viewInternal->cache()->viewCacheLineCount()));
1994 const uint currentLine = m_view->cursorPosition().line();
1997 int m_px = (h - 11) / 2;
2003 const int newNeededWidth = lineNumberWidth();
2005 if (m_updatePositionToArea || (newNeededWidth != m_lineNumberAreaWidth)) {
2006 m_lineNumberAreaWidth = newNeededWidth;
2007 m_updatePositionToArea =
true;
2008 m_positionToArea.clear();
2013 p.setFont(m_view->renderer()->currentFont());
2015 KTextEditor::AnnotationModel *model = m_view->annotationModel() ? m_view->annotationModel() : m_doc->annotationModel();
2016 KateAnnotationGroupPositionState annotationGroupPositionState(m_viewInternal, model, m_hoveredAnnotationGroupIdentifier, startz, m_annotationBorderOn);
2019 const int w =
width();
2020 const QColor iconBarColor = m_view->rendererConfig()->iconBarColor();
2021 const QColor lineNumberColor = m_view->rendererConfig()->lineNumberColor();
2022 const QColor backgroundColor = m_view->rendererConfig()->backgroundColor();
2023 const QColor currentLineHighlight = m_view->rendererConfig()->highlightedLineColor();
2026 for (uint z = startz; z < endz; z++) {
2028 const uint
y = h * z;
2034 const KateTextLayout lineLayout = m_viewInternal->cache()->viewLine(z);
2035 const int realLine = lineLayout.line();
2038 p.fillRect(lnX,
y, w, h, iconBarColor);
2041 const bool isCurrentLine = (realLine ==
static_cast<int>(currentLine)) && lineLayout.includesCursor(m_view->cursorPosition());
2042 if (isCurrentLine) {
2043 p.fillRect(lnX,
y, w, h, currentLineHighlight);
2047 if (realLine >= 0) {
2049 if (m_iconBorderOn) {
2050 const uint mrk(m_doc->mark(realLine));
2051 if (mrk && lineLayout.startCol() == 0) {
2052 for (uint bit = 0; bit < 32; bit++) {
2053 Document::MarkTypes markType = (Document::MarkTypes)(1U << bit);
2054 if (mrk & markType) {
2055 const QIcon markIcon = m_doc->markIcon(markType);
2057 if (!markIcon.
isNull() && h > 0 && m_iconAreaWidth > 0) {
2058 const int s = qMin(m_iconAreaWidth,
static_cast<int>(h)) - 2;
2061 const int x_px = qMax(m_iconAreaWidth - s, 0) / 2;
2062 const int y_px = qMax(
static_cast<int>(h) - s, 0) / 2;
2064 markIcon.
paint(&p, lnX + x_px,
y + y_px, s, s);
2070 lnX += m_iconAreaWidth;
2071 if (m_updatePositionToArea) {
2072 m_positionToArea.push_back(AreaPosition(lnX, IconBorder));
2077 if (m_annotationBorderOn) {
2079 p.setPen(lineNumberColor);
2080 p.setBrush(lineNumberColor);
2082 const qreal borderX = lnX + m_annotationAreaWidth + 0.5;
2083 p.drawLine(QPointF(borderX,
y + 0.5), QPointF(borderX,
y + h - 0.5));
2086 KTextEditor::StyleOptionAnnotationItem styleOption;
2087 initStyleOption(&styleOption);
2088 styleOption.rect.setRect(lnX,
y, m_annotationAreaWidth, h);
2089 annotationGroupPositionState.nextLine(styleOption, z, realLine);
2091 m_annotationItemDelegate->paint(&p, styleOption, model, realLine);
2094 lnX += m_annotationAreaWidth + m_separatorWidth;
2095 if (m_updatePositionToArea) {
2096 m_positionToArea.push_back(AreaPosition(lnX, AnnotationBorder));
2101 if (m_lineNumbersOn || m_dynWrapIndicatorsOn) {
2102 QColor usedLineNumberColor;
2103 const int distanceToCurrent = abs(realLine -
static_cast<int>(currentLine));
2104 if (distanceToCurrent == 0) {
2105 usedLineNumberColor = m_view->rendererConfig()->currentLineNumberColor();
2107 usedLineNumberColor = lineNumberColor;
2109 p.setPen(usedLineNumberColor);
2110 p.setBrush(usedLineNumberColor);
2112 if (lineLayout.startCol() == 0) {
2113 if (m_relLineNumbersOn) {
2114 if (distanceToCurrent == 0) {
2115 p.drawText(lnX + m_maxCharWidth / 2,
2117 m_lineNumberAreaWidth - m_maxCharWidth,
2122 p.drawText(lnX + m_maxCharWidth / 2,
2124 m_lineNumberAreaWidth - m_maxCharWidth,
2129 if (m_updateRelLineNumbers) {
2130 m_updateRelLineNumbers =
false;
2133 }
else if (m_lineNumbersOn) {
2134 p.drawText(lnX + m_maxCharWidth / 2,
2136 m_lineNumberAreaWidth - m_maxCharWidth,
2141 }
else if (m_dynWrapIndicatorsOn) {
2142 p.drawText(lnX + m_maxCharWidth / 2,
2144 m_lineNumberAreaWidth - m_maxCharWidth,
2147 m_dynWrapIndicatorChar);
2150 lnX += m_lineNumberAreaWidth + m_separatorWidth;
2151 if (m_updatePositionToArea) {
2152 m_positionToArea.push_back(AreaPosition(lnX, LineNumbers));
2157 if (m_view->config()->lineModification() && !m_doc->url().isEmpty()) {
2158 const auto tl = m_doc->plainKateTextLine(realLine);
2159 if (tl.markedAsModified()) {
2160 p.fillRect(lnX,
y, m_modAreaWidth, h, m_view->rendererConfig()->modifiedLineColor());
2161 }
else if (tl.markedAsSavedOnDisk()) {
2162 p.fillRect(lnX,
y, m_modAreaWidth, h, m_view->rendererConfig()->savedLineColor());
2165 lnX += m_modAreaWidth;
2166 if (m_updatePositionToArea) {
2167 m_positionToArea.push_back(AreaPosition(lnX, None));
2172 if (m_foldingMarkersOn) {
2173 const QColor foldingColor(m_view->rendererConfig()->foldingColor());
2175 if (m_foldingRange && m_foldingRange->overlapsLine(realLine)) {
2176 p.fillRect(lnX,
y, m_foldingAreaWidth, h, foldingColor);
2179 if (lineLayout.startCol() == 0) {
2180 QList<QPair<qint64, Kate::TextFolding::FoldingRangeFlags>> startingRanges = m_view->textFolding().foldingRangesStartingOnLine(realLine);
2181 bool anyFolded =
false;
2182 for (
int i = 0; i < startingRanges.
size(); ++i) {
2187 if (!m_view->config()->showFoldingOnHoverOnly() || m_mouseOver) {
2188 if (!startingRanges.
isEmpty() || m_doc->buffer().isFoldingStartingOnLine(realLine).first) {
2190 paintTriangle(p, foldingColor, lnX,
y, m_foldingAreaWidth, h,
false);
2193 paintTriangle(p, lineNumberColor, lnX,
y, m_foldingAreaWidth, h,
true);
2199 lnX += m_foldingAreaWidth;
2200 if (m_updatePositionToArea) {
2201 m_positionToArea.push_back(AreaPosition(lnX, FoldingMarkers));
2211 p.fillRect(w - 2 * m_separatorWidth,
y, w, h, backgroundColor);
2214 if (realLine >= 0 && m_view->selection() && !m_view->blockSelection() && m_view->selectionRange().start() < lineLayout.start()
2215 && m_view->selectionRange().end() >= lineLayout.start()) {
2217 p.fillRect(w - 2 * m_separatorWidth,
y, w, h, m_view->rendererConfig()->selectionColor());
2218 }
else if (isCurrentLine) {
2220 p.fillRect(w - 2 * m_separatorWidth,
y, w, h, currentLineHighlight);
2225 p.setPen(m_view->rendererConfig()->separatorColor());
2226 p.setBrush(m_view->rendererConfig()->separatorColor());
2227 p.drawLine(w - 2 * m_separatorWidth,
y, w - 2 * m_separatorWidth,
y + h);
2230 if ((realLine >= 0) && m_updatePositionToArea) {
2231 m_updatePositionToArea =
false;
2233 lnX += 2 * m_separatorWidth;
2234 m_positionToArea.push_back(AreaPosition(lnX, None));
2243KateIconBorder::BorderArea KateIconBorder::positionToArea(
const QPoint &p)
const
2245 auto it = std::find_if(m_positionToArea.cbegin(), m_positionToArea.cend(), [p](
const AreaPosition &ap) {
2246 return p.x() <= ap.first;
2248 if (it != m_positionToArea.cend()) {
2254void KateIconBorder::mousePressEvent(
QMouseEvent *e)
2256 const KateTextLayout &t = m_viewInternal->yToKateTextLayout(e->
position().
y());
2258 m_lastClickedLine = t.line();
2259 const auto area = positionToArea(e->
pos());
2261 if (area != IconBorder && area != AnnotationBorder) {
2265 m_viewInternal->beginSelectLine(
pos);
2268 m_viewInternal->mousePressEvent(&forward);
2276void KateIconBorder::highlightFoldingDelayed(
int line)
2278 if ((line == m_currentLine) || (line >= m_doc->buffer().lines())) {
2282 m_currentLine = line;
2284 if (m_foldingRange) {
2288 }
else if (!m_antiFlickerTimer.isActive()) {
2289 m_antiFlickerTimer.start();
2293void KateIconBorder::highlightFolding()
2298 for (
int line = m_currentLine; line >= qMax(0, m_currentLine - 1024); --line) {
2300 KTextEditor::Range foldingRange = m_doc->buffer().computeFoldingRangeForStartLine(line);
2301 if (!foldingRange.
isValid()) {
2307 newRange = foldingRange;
2312 if (newRange.
isValid() && m_foldingRange && *m_foldingRange == newRange) {
2318 delete m_foldingRange;
2319 m_foldingRange =
nullptr;
2321 delete m_foldingPreview;
2323 bool showPreview =
false;
2327 showPreview = !m_view->textFolding().isLineVisible(newRange.
start().
line() + 1);
2335 attr->setBackground(QBrush(m_view->rendererConfig()->foldingColor()));
2337 m_foldingRange->setView(m_view);
2339 m_foldingRange->setZDepth(-100.0);
2340 m_foldingRange->setAttribute(attr);
2346 if (showPreview && m_view->config()->foldingPreview() && isWindowActive) {
2347 m_foldingPreview =
new KateTextPreview(m_view,
this);
2352 const int lineHeight = m_view->renderer()->lineHeight();
2353 const int foldingStartLine = m_foldingRange->start().line();
2355 const QPoint
pos = m_viewInternal->mapFrom(m_view, m_view->cursorToCoordinate(KTextEditor::Cursor(foldingStartLine, 0)));
2356 const int lineInDisplay =
pos.y() / lineHeight;
2358 const int extra = (m_viewInternal->height() % lineHeight) > (lineHeight * 0.6) ? 1 : 0;
2359 const int lineCount = qMin(m_foldingRange->numberOfLines() + 1, m_viewInternal->linesDisplayed() - lineInDisplay + extra);
2361 m_foldingPreview->resize(m_viewInternal->width(), lineCount * lineHeight + 2 * m_foldingPreview->frameWidth());
2363 const int yGlobal = m_view->mapToGlobal(m_view->cursorToCoordinate(KTextEditor::Cursor(foldingStartLine, 0))).y();
2364 m_foldingPreview->move(QPoint(xGlobal, yGlobal) - m_foldingPreview->contentsRect().topLeft());
2365 m_foldingPreview->setLine(foldingStartLine);
2366 m_foldingPreview->setCenterView(
false);
2367 m_foldingPreview->setShowFoldedLines(
true);
2368 m_foldingPreview->raise();
2369 m_foldingPreview->show();
2373void KateIconBorder::hideFolding()
2375 if (m_antiFlickerTimer.isActive()) {
2376 m_antiFlickerTimer.stop();
2380 delete m_foldingRange;
2381 m_foldingRange =
nullptr;
2383 delete m_foldingPreview;
2386void KateIconBorder::enterEvent(
QEnterEvent *event)
2389 if (m_view->config()->showFoldingOnHoverOnly())
2394void KateIconBorder::leaveEvent(
QEvent *event)
2396 m_mouseOver =
false;
2398 removeAnnotationHovering();
2399 if (m_view->config()->showFoldingOnHoverOnly())
2405void KateIconBorder::mouseMoveEvent(
QMouseEvent *e)
2407 const KateTextLayout &t = m_viewInternal->yToKateTextLayout(e->
position().
y());
2410 removeAnnotationHovering();
2414 const BorderArea area = positionToArea(e->
pos());
2415 if (area == FoldingMarkers) {
2416 highlightFoldingDelayed(t.line());
2420 if (area == AnnotationBorder) {
2421 KTextEditor::AnnotationModel *model = m_view->annotationModel() ? m_view->annotationModel() : m_doc->annotationModel();
2423 m_hoveredAnnotationGroupIdentifier = model->
data(t.line(), (
Qt::ItemDataRole)KTextEditor::AnnotationModel::GroupIdentifierRole).
toString();
2424 const QPoint viewRelativePos = m_view->mapFromGlobal(e->
globalPosition()).toPoint();
2426 KTextEditor::StyleOptionAnnotationItem styleOption;
2427 initStyleOption(&styleOption);
2428 styleOption.rect = annotationLineRectInView(t.line());
2429 setStyleOptionLineData(&styleOption, e->
position().
y(), t.line(), model, m_hoveredAnnotationGroupIdentifier);
2430 m_annotationItemDelegate->helpEvent(&helpEvent, m_view, styleOption, model, t.line());
2435 if (area == IconBorder) {
2439 m_hoveredAnnotationGroupIdentifier.clear();
2442 if (area != IconBorder) {
2445 m_viewInternal->mouseMoveEvent(&forward);
2452void KateIconBorder::mouseReleaseEvent(
QMouseEvent *e)
2454 const int cursorOnLine = m_viewInternal->yToKateTextLayout(e->
position().
y()).line();
2455 if (cursorOnLine == m_lastClickedLine && cursorOnLine >= 0 && cursorOnLine <= m_doc->lastLine()) {
2456 const BorderArea area = positionToArea(e->
pos());
2457 if (area == IconBorder) {
2459 if (!m_doc->handleMarkClick(cursorOnLine)) {
2460 KateViewConfig *config = m_view->config();
2461 const uint editBits = m_doc->editableMarks();
2464 if (qPopulationCount(editBits) == 1 || ctrlPressed) {
2465 const uint singleMark = (qPopulationCount(editBits) > 1) ? (editBits & config->defaultMarkType()) : editBits;
2466 if (m_doc->mark(cursorOnLine) & singleMark) {
2467 m_doc->removeMark(cursorOnLine, singleMark);
2469 m_doc->addMark(cursorOnLine, singleMark);
2471 }
else if (config->allowMarkMenu()) {
2480 if (area == FoldingMarkers) {
2482 const int lineToToggle = m_foldingRange ? m_foldingRange->toRange().start().line() : cursorOnLine;
2484 m_view->toggleFoldingOfLine(lineToToggle);
2486 m_view->toggleFoldingsInRange(lineToToggle);
2489 delete m_foldingPreview;
2492 if (area == AnnotationBorder) {
2495 Q_EMIT m_view->annotationActivated(m_view, cursorOnLine);
2502 m_viewInternal->mouseReleaseEvent(&forward);
2505void KateIconBorder::mouseDoubleClickEvent(
QMouseEvent *e)
2507 int cursorOnLine = m_viewInternal->yToKateTextLayout(e->
position().
y()).line();
2509 if (cursorOnLine == m_lastClickedLine && cursorOnLine <= m_doc->lastLine()) {
2510 const BorderArea area = positionToArea(e->
pos());
2512 if (area == AnnotationBorder && !singleClick) {
2513 Q_EMIT m_view->annotationActivated(m_view, cursorOnLine);
2518 m_viewInternal->mouseDoubleClickEvent(&forward);
2523 const BorderArea area = positionToArea(e->
pos());
2524 const int cursorOnLine = m_viewInternal->yToKateTextLayout(e->
y()).line();
2526 if (area == AnnotationBorder) {
2527 showAnnotationMenu(cursorOnLine, e->
globalPos());
2533 KActionCollection *ac = m_view->actionCollection();
2536 if (QAction *bookmarkToggle = ac->
action(QStringLiteral(
"bookmarks_toggle"))) {
2537 menu.addAction(bookmarkToggle);
2539 if (QAction *bookmarkClear = ac->
action(QStringLiteral(
"bookmarks_clear"))) {
2540 menu.addAction(bookmarkClear);
2543 menu.addSeparator();
2545 if (
auto a = ac->
action(QStringLiteral(
"edit_copy_file_location"))) {
2549 menu.addSeparator();
2551 if (QAction *toggleDynWrap = ac->
action(QStringLiteral(
"view_dynamic_word_wrap"))) {
2552 menu.addAction(toggleDynWrap);
2554 menu.addSeparator();
2555 if (QAction *toggleIconBar = ac->
action(QStringLiteral(
"view_border"))) {
2556 menu.addAction(toggleIconBar);
2558 if (QAction *toggleLineNumbers = ac->
action(QStringLiteral(
"view_line_numbers"))) {
2559 menu.addAction(toggleLineNumbers);
2561 if (QAction *toggleFoldingMarkers = ac->
action(QStringLiteral(
"view_folding_markers"))) {
2562 menu.addAction(toggleFoldingMarkers);
2573void KateIconBorder::showMarkMenu(uint line,
const QPoint &pos)
2575 if (m_doc->handleMarkContextMenu(line,
pos)) {
2579 if (!m_view->config()->allowMarkMenu()) {
2584 QMenu selectDefaultMark;
2585 auto selectDefaultMarkActionGroup =
new QActionGroup(&selectDefaultMark);
2587 std::vector<int> vec(33);
2590 for (uint bit = 0; bit < 32; bit++) {
2592 if (!(m_doc->editableMarks() & markType)) {
2598 const QIcon icon = m_doc->markIcon(markType);
2599 if (!m_doc->markDescription(markType).isEmpty()) {
2600 mA = markMenu.
addAction(icon, m_doc->markDescription(markType));
2601 dMA = selectDefaultMark.
addAction(icon, m_doc->markDescription(markType));
2603 mA = markMenu.
addAction(icon,
i18n(
"Mark Type %1", bit + 1));
2604 dMA = selectDefaultMark.
addAction(icon,
i18n(
"Mark Type %1", bit + 1));
2606 selectDefaultMarkActionGroup->addAction(dMA);
2611 if (m_doc->mark(line) & markType) {
2615 if (markType & KateViewConfig::global()->defaultMarkType()) {
2619 vec[i++] = markType;
2630 QAction *rA = markMenu.
exec(
pos);
2636 KateViewConfig::global()->
setValue(KateViewConfig::DefaultMarkType, vec[result - 100]);
2639 if (m_doc->mark(line) & markType) {
2640 m_doc->removeMark(line, markType);
2642 m_doc->addMark(line, markType);
2649 return m_annotationItemDelegate;
2654 if (delegate == m_annotationItemDelegate) {
2659 if (!delegate && m_isDefaultAnnotationItemDelegate) {
2665 if (m_annotationBorderOn && !m_hoveredAnnotationGroupIdentifier.isEmpty()) {
2666 m_hoveredAnnotationGroupIdentifier.clear();
2667 hideAnnotationTooltip();
2671 if (!m_isDefaultAnnotationItemDelegate) {
2677 m_annotationItemDelegate =
new KateAnnotationItemDelegate(
this);
2678 m_isDefaultAnnotationItemDelegate =
true;
2681 if (m_isDefaultAnnotationItemDelegate) {
2682 delete m_annotationItemDelegate;
2683 m_isDefaultAnnotationItemDelegate =
false;
2686 m_annotationItemDelegate = delegate;
2693 if (m_annotationBorderOn) {
2698void KateIconBorder::handleDestroyedAnnotationItemDelegate()
2700 setAnnotationItemDelegate(
nullptr);
2703void KateIconBorder::delayedUpdateOfSizeWithRepaint()
2715 styleOption->
view = m_view;
2716 styleOption->
decorationSize = QSize(m_iconAreaWidth, m_iconAreaWidth);
2724 const QString &annotationGroupIdentifier)
const
2727 const uint h = m_view->renderer()->lineHeight();
2728 const uint z = (
y / h);
2730 KateAnnotationGroupPositionState annotationGroupPositionState(m_viewInternal, model, annotationGroupIdentifier, z,
true);
2731 annotationGroupPositionState.nextLine(*styleOption, z, realLine);
2734QRect KateIconBorder::annotationLineRectInView(
int line)
const
2737 if (m_iconBorderOn) {
2738 x += m_iconAreaWidth + 2;
2740 const int y = m_view->m_viewInternal->lineToY(line);
2742 return QRect(
x,
y, m_annotationAreaWidth, m_view->renderer()->lineHeight());
2745void KateIconBorder::updateAnnotationLine(
int line)
2749 KTextEditor::AnnotationModel *model = m_view->annotationModel() ? m_view->annotationModel() : m_doc->annotationModel();
2752 KTextEditor::StyleOptionAnnotationItem styleOption;
2753 initStyleOption(&styleOption);
2754 width = m_annotationItemDelegate->sizeHint(styleOption, model, line).width();
2757 if (
width > m_annotationAreaWidth) {
2758 m_annotationAreaWidth =
width;
2759 m_updatePositionToArea =
true;
2765void KateIconBorder::showAnnotationMenu(
int line,
const QPoint &pos)
2768 QAction a(
i18n(
"Disable Annotation Bar"), &menu);
2771 Q_EMIT m_view->annotationContextMenuAboutToShow(m_view, &menu, line);
2773 m_view->setAnnotationBorderVisible(
false);
2777void KateIconBorder::hideAnnotationTooltip()
2779 m_annotationItemDelegate->hideTooltip(m_view);
2782void KateIconBorder::updateAnnotationBorderWidth()
2784 calcAnnotationBorderWidth();
2786 m_updatePositionToArea =
true;
2791void KateIconBorder::calcAnnotationBorderWidth()
2794 m_annotationAreaWidth = 6;
2795 KTextEditor::AnnotationModel *model = m_view->annotationModel() ? m_view->annotationModel() : m_doc->annotationModel();
2798 KTextEditor::StyleOptionAnnotationItem styleOption;
2799 initStyleOption(&styleOption);
2801 const int lineCount = m_view->doc()->lines();
2802 if (lineCount > 0) {
2803 const int checkedLineCount = m_hasUniformAnnotationItemSizes ? 1 : lineCount;
2804 for (
int i = 0; i < checkedLineCount; ++i) {
2805 const int curwidth = m_annotationItemDelegate->sizeHint(styleOption, model, i).width();
2806 if (curwidth > m_annotationAreaWidth) {
2807 m_annotationAreaWidth = curwidth;
2823 updateAnnotationBorderWidth();
2826void KateIconBorder::displayRangeChanged()
2829 removeAnnotationHovering();
2837#define MIB_DEFAULT 2
2844void KateViewEncodingAction::init()
2846 QList<KSelectAction *>
actions;
2852 actions.reserve(encodingsByScript.size());
2853 for (
const QStringList &encodingsForScript : encodingsByScript) {
2856 for (i = 1; i < encodingsForScript.size(); ++i) {
2857 tmp->
addAction(encodingsForScript.at(i));
2860 subActionTriggered(
action);
2871void KateViewEncodingAction::subActionTriggered(
QAction *action)
2873 if (currentSubAction ==
action) {
2876 currentSubAction =
action;
2881 KTextEditor::ViewPrivate *_view,
2888 , m_saveAsMode(saveAsMode)
2892 connect(menu(), &
QMenu::aboutToShow,
this, &KateViewEncodingAction::slotAboutToShow);
2896void KateViewEncodingAction::slotAboutToShow()
2898 setCurrentCodec(doc->config()->encoding());
2901void KateViewEncodingAction::setEncoding(
const QString &e)
2905 doc->documentSaveAsWithEncoding(e);
2910 doc->userSetEncodingForNextReload();
2911 doc->setEncoding(e);
2915bool KateViewEncodingAction::setCurrentCodec(
const QString &codec)
2923 for (j = 0; j <
actions().
at(i)->menu()->actions().size(); ++j) {
2932 currentSubAction =
actions().
at(i)->menu()->actions().at(j);
2933 currentSubAction->setChecked(
true);
2935 actions().
at(i)->menu()->actions().at(j)->setChecked(
false);
2949KateViewBarWidget::KateViewBarWidget(
bool addCloseButton,
QWidget *parent)
2951 , m_viewBar(nullptr)
2959 m_centralWidget =
new QWidget(
this);
2961 setFocusProxy(m_centralWidget);
2964 if (addCloseButton) {
2966 m_closeButton->setAutoRaise(
true);
2974KateViewBar::KateViewBar(
bool external,
QWidget *parent, KTextEditor::ViewPrivate *view)
2976 , m_external(external)
2978 , m_permanentBarWidget(nullptr)
2983 m_layout->addWidget(m_stack);
2984 m_layout->setContentsMargins(0, 0, 0, 0);
2990void KateViewBar::addBarWidget(KateViewBarWidget *newBarWidget)
2993 if (hasBarWidget(newBarWidget)) {
2998 newBarWidget->
hide();
2999 m_stack->addWidget(newBarWidget);
3000 newBarWidget->setAssociatedViewBar(
this);
3001 connect(newBarWidget, &KateViewBarWidget::hideMe,
this, &KateViewBar::hideCurrentBarWidget);
3004void KateViewBar::removeBarWidget(KateViewBarWidget *barWidget)
3007 if (!hasBarWidget(barWidget)) {
3011 m_stack->removeWidget(barWidget);
3012 barWidget->setAssociatedViewBar(
nullptr);
3014 disconnect(barWidget,
nullptr,
this,
nullptr);
3017void KateViewBar::addPermanentBarWidget(KateViewBarWidget *barWidget)
3019 Q_ASSERT(barWidget);
3020 Q_ASSERT(!m_permanentBarWidget);
3022 m_layout->addWidget(barWidget);
3023 m_permanentBarWidget = barWidget;
3024 m_permanentBarWidget->
show();
3026 setViewBarVisible(
true);
3029void KateViewBar::removePermanentBarWidget(KateViewBarWidget *barWidget)
3031 Q_ASSERT(m_permanentBarWidget == barWidget);
3032 Q_UNUSED(barWidget);
3034 m_permanentBarWidget->hide();
3035 m_layout->removeWidget(m_permanentBarWidget);
3036 m_permanentBarWidget =
nullptr;
3038 if (!barWidgetVisible()) {
3039 setViewBarVisible(
false);
3043void KateViewBar::showBarWidget(KateViewBarWidget *barWidget)
3045 Q_ASSERT(barWidget !=
nullptr);
3048 hideCurrentBarWidget();
3052 m_stack->addWidget(barWidget);
3053 m_stack->setCurrentWidget(barWidget);
3057 setViewBarVisible(
true);
3060bool KateViewBar::hasBarWidget(KateViewBarWidget *barWidget)
const
3062 return m_stack->indexOf(barWidget) != -1;
3065void KateViewBar::hideCurrentBarWidget()
3069 m_stack->removeWidget(current);
3075 if (!m_permanentBarWidget) {
3076 setViewBarVisible(
false);
3082void KateViewBar::setViewBarVisible(
bool visible)
3086 m_view->mainWindow()->showViewBar(m_view);
3088 m_view->mainWindow()->hideViewBar(m_view);
3095bool KateViewBar::barWidgetVisible()
const
3101void KateViewBar::keyPressEvent(
QKeyEvent *event)
3104 hideCurrentBarWidget();
3110void KateViewBar::hideEvent(
QHideEvent *event)
3120void KateViewSchemaAction::init()
3129void KateViewSchemaAction::updateMenu(KTextEditor::ViewPrivate *view)
3134void KateViewSchemaAction::slotAboutToShow()
3136 KTextEditor::ViewPrivate *view = m_view;
3138 const auto themes = KateHlManager::self()->sortedThemes();
3141 m_group =
new QActionGroup(
menu());
3142 m_group->setExclusive(
true);
3145 for (
int z = 0; z < themes.count(); z++) {
3146 QString hlName = themes[z].translatedName();
3148 if (!names.contains(hlName)) {
3161 QString
id = view->rendererConfig()->schema();
3163 for (
QAction *a : menuActions) {
3168void KateViewSchemaAction::setSchema()
3177 KTextEditor::ViewPrivate *view = m_view;
3180 view->rendererConfig()->setSchema(mode);
3185#include "moc_kateviewhelpers.cpp"
Q_INVOKABLE QAction * action(const QString &name) const
QList< QStringList > encodingsByScript() const
static KCharsets * charsets()
KCompletion * completionObject(bool handleSignals=true)
bool event(QEvent *) override
void setCompletionObject(KCompletion *, bool handle=true) override
virtual void setText(const QString &)
void returnKeyPressed(const QString &text)
void keyPressEvent(QKeyEvent *) override
QAction * addAction(const QIcon &icon, const QString &text)
KSelectAction(const QIcon &icon, const QString &text, QObject *parent)
QList< QAction * > actions() const
void setToolBarMode(ToolBarMode mode)
void textTriggered(const QString &text)
QAction * action(const QString &text, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void actionTriggered(QAction *action)
A delegate for rendering line annotation information and handling events.
void sizeHintChanged(KTextEditor::AnnotationModel *model, int line)
This signal must be emitted when the sizeHint() for model and line changed.
An model for providing line annotation information.
virtual QVariant data(int line, Qt::ItemDataRole role) const =0
data() is used to retrieve the information needed to present the annotation information from the anno...
void reset()
The model should emit the signal reset() when the text of almost all lines changes.
void lineChanged(int line)
The model should emit the signal lineChanged() when a line has to be updated.
QExplicitlySharedDataPointer< Attribute > Ptr
Shared data pointer for Attribute.
virtual bool supportsRange(const QString &cmd)
Find out if a given command can act on a range.
virtual bool help(KTextEditor::View *view, const QString &cmd, QString &msg)=0
Shows help for the given view and cmd string.
virtual bool exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range=KTextEditor::Range::invalid())=0
Execute the command for the given view and cmd string.
constexpr int line() const noexcept
Retrieve the line on which this cursor is situated.
Backend of KTextEditor::Document related public KTextEditor interfaces.
void textChanged(KTextEditor::Document *document)
The document emits this signal whenever its text changes.
void marksChanged(KTextEditor::Document *document)
The document emits this signal whenever a mark mask changed.
MarkTypes
Predefined mark types.
uint type
The mark types in the line, combined with logical OR.
int line
The line that contains the mark.
MessagePosition
Message position used to place the message either above or below of the KTextEditor::View.
@ TopInView
show message as view overlay in the top right corner.
@ CenterInView
show message as view overlay in the center of the view.
@ BottomInView
show message as view overlay in the bottom right corner.
@ ExpandRight
Expand to encapsulate new characters to the right of the range.
constexpr Cursor start() const noexcept
Get the start position of this range.
constexpr bool isEmpty() const noexcept
Returns true if this range contains no characters, ie.
static constexpr Range invalid() noexcept
Returns an invalid range.
constexpr bool isValid() const noexcept
Validity check.
constexpr bool contains(Range range) const noexcept
Check whether the this range wholly encompasses range.
constexpr bool overlapsLine(int line) const noexcept
Check whether the range overlaps at least part of line.
The style option set for an annotation item, as painted by AbstractAnnotationItemDelegate.
QSize decorationSize
Recommended size for icons or other symbols that will be rendered by the delegate.
@ GroupBegin
Real line is first of consecutive lines from same group.
@ GroupEnd
Real line is last of consecutive lines from same group.
@ InGroup
Real line belongs to a group.
AnnotationItemGroupPositions annotationItemGroupingPosition
Relative position of the real line in the row of consecutive displayed lines which belong to the same...
QFontMetricsF contentFontMetrics
The metrics of the font used for rendering the text document.
int wrappedLineCount
Number of wrapped lines for the given real line.
KTextEditor::View * view
The view where the annotation is shown.
int wrappedLine
Index of the displayed line in the wrapped lines for the given real line.
int visibleWrappedLineInGroup
Index of the displayed line in the displayed lines for the same group.
void displayRangeChanged(KTextEditor::View *view)
This signal is emitted whenever the displayed range changes.
void focusOut(KTextEditor::View *view)
This signal is emitted whenever the view loses the focus.
void selectionChanged(KTextEditor::View *view)
This signal is emitted whenever the view's selection changes.
bool setValue(const int key, const QVariant &value)
Set a config value.
void foldingRangesChanged()
If the folding state of existing ranges changes or ranges are added/removed, this signal is emitted.
@ Folded
Range is folded away.
const QString & text() const
Accessor to the text contained in this line.
const QList< Attribute > & attributesList() const
Accessor to attributes.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
KGUIADDONS_EXPORT QColor darken(const QColor &, qreal amount=0.5, qreal chromaGain=1.0)
KGUIADDONS_EXPORT qreal luma(const QColor &)
KGUIADDONS_EXPORT QColor shade(const QColor &, qreal lumaAmount, qreal chromaAmount=0.0)
KGUIADDONS_EXPORT qreal hue(const QColor &)
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
void init(KXmlGuiWindow *window, KGameDifficulty *difficulty=nullptr)
void invokeHelp(const QString &anchor=QString(), const QString &appname=QString())
bool canConvert(const QVariant &value)
QString name(StandardAction id)
KGuiItem forward(BidiMode useBidi=IgnoreRTL)
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
bool isSliderDown() const const
void setSliderPosition(int)
void valueChanged(int value)
QVariant data() const const
bool isSeparator() const const
void setActionGroup(QActionGroup *group)
void setData(const QVariant &data)
const QColor & color() const const
bool isLetterOrNumber(char32_t ucs4)
bool isNull() const const
void getHsl(int *h, int *s, int *l, int *a) const const
QColor lighter(int factor) const const
int lightness() const const
void setHsl(int h, int s, int l, int a)
void setHsv(int h, int s, int v, int a)
bool sendEvent(QObject *receiver, QEvent *event)
qreal height() const const
qreal horizontalAdvance(QChar ch) const const
Qt::KeyboardModifiers keyboardModifiers()
const_iterator constBegin() const const
const_iterator constEnd() const const
bool hasNext() const const
const Key & key() const const
const T & value() const const
QIcon fromTheme(const QString &name)
bool isNull() const const
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const const
Qt::KeyboardModifiers modifiers() const const
QString text() const const
bool setAlignment(QLayout *l, Qt::Alignment alignment)
void setContentsMargins(const QMargins &margins)
virtual void setGeometry(const QRect &r) override
QLayoutItem(Qt::Alignment alignment)
virtual void setGeometry(const QRect &r)=0
virtual QSize sizeHint() const const=0
virtual void focusInEvent(QFocusEvent *e) override
void setSelection(int start, int length)
const_reference at(qsizetype i) const const
qsizetype count() const const
bool isEmpty() const const
qsizetype size() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void destroyed(QObject *obj)
bool disconnect(const QMetaObject::Connection &connection)
virtual bool event(QEvent *e)
T qobject_cast(QObject *object)
QObject * sender() const const
bool begin(QPaintDevice *device)
void drawConvexPolygon(const QPoint *points, int pointCount)
void drawLine(const QLine &line)
void drawPixmap(const QPoint &point, const QPixmap &pixmap)
void drawPoints(const QPoint *points, int pointCount)
void drawRect(const QRect &rectangle)
void fillRect(const QRect &rectangle, QGradient::Preset preset)
const QPen & pen() const const
void setBrush(Qt::BrushStyle style)
void setPen(Qt::PenStyle style)
void setRenderHint(RenderHint hint, bool on)
const QRect & rect() const const
QBrush brush() const const
void setColor(const QColor &color)
void setJoinStyle(Qt::PenJoinStyle style)
void setWidthF(qreal width)
QPoint toPoint() const const
void adjust(int dx1, int dy1, int dx2, int dy2)
QRect adjusted(int dx1, int dy1, int dx2, int dy2) const const
QPoint center() const const
bool contains(const QPoint &point, bool proper) const const
void setHeight(int height)
UseUnicodePropertiesOption
QPointF globalPosition() const const
QPointF position() const const
const QChar at(qsizetype position) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype length() const const
QString number(double n, char format, int precision)
qsizetype size() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString join(QChar separator) const const
SH_ItemView_ActivateItemOnSingleClick
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const const=0
virtual int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const const=0
virtual QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const const=0
void initFrom(const QWidget *widget)
QTextStream & left(QTextStream &stream)
bool canConvert() const const
bool isValid() const const
int toInt(bool *ok) const const
QString toString() const const
qsizetype size() const const
void showText(const QPoint &pos, const QString &text, QWidget *w)