Kate
kateviewhelpers.cpp
Go to the documentation of this file.
134 connect(m_view, SIGNAL(selectionChanged(KTextEditor::View*)), &m_updateTimer, SLOT(start()), Qt::UniqueConnection);
135 connect(m_doc, SIGNAL(textChanged(KTextEditor::Document*)), &m_updateTimer, SLOT(start()), Qt::UniqueConnection);
136 connect(m_view, SIGNAL(delayedUpdateOfView()), &m_updateTimer, SLOT(start()), Qt::UniqueConnection);
138 connect(&(m_view->textFolding()), SIGNAL(foldingRangesChanged()), &m_updateTimer, SLOT(start()), Qt::UniqueConnection);
208 QToolTip::showText(m_toolTipPos, i18nc("from line - to line", "<center>%1<br/>—<br/>%2</center>", fromLine, lastLine), this);
256 QToolTip::showText(m_toolTipPos, i18nc("from line - to line", "<center>%1<br/>—<br/>%2</center>", fromLine, lastLine), this);
274 const QColor KateScrollBar::charColor(const QVector<Kate::TextLineData::Attribute> &attributes, int &attributeIndex,
308 if ((attributeIndex < attributes.size()) && (x < attributes[attributeIndex].offset + attributes[attributeIndex].length)) {
309 color = m_view->renderer()->attribute(attributes[attributeIndex].attributeValue)->foreground().color();
359 //kDebug(13040) << "pixmap" << pixmapLineCount << pixmapLineWidth << "docLines" << m_view->textFolding().visibleLines() << "height" << m_grooveHeight;
364 backgroundColor = m_doc->defaultStyle(KTextEditor::HighlightInterface::dsNormal)->background().color();
365 defaultTextColor = m_doc->defaultStyle(KTextEditor::HighlightInterface::dsNormal)->foreground().color();
406 QList< QTextLayout::FormatRange > decorations = m_view->renderer()->decorationsForLine(kateline, realLineNumber);
429 painter.setPen(charColor(attributes, attributeIndex, decorations, defaultTextColor, x, lineText[x]));
500 QRect grooveRect = style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SC_ScrollBarGroove, this);
502 if (style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SC_ScrollBarSubLine, this).height() == 0) {
507 if (style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SC_ScrollBarAddLine, this).height() == 0) {
513 QRect sliderRect = style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SC_ScrollBarSlider, this);
522 int yoffset = 1; // top-aligned in stead of center-aligned (grooveRect.height() - docHeight) / 2;
523 QRect docRect(QPoint(grooveRect.left()+docXMargin, yoffset+grooveRect.top()), QSize(grooveRect.width()-2*docXMargin, docHeight));
538 // TODO KDE5: If HighlightInterface is a View interface, use HighlightInterface::defaultStyle() again.
540 backgroundColor = m_doc->defaultStyle(KTextEditor::HighlightInterface::dsNormal)->background().color();
541 foregroundColor = m_doc->defaultStyle(KTextEditor::HighlightInterface::dsNormal)->foreground().color();
580 if ((docHeight+2*docXMargin >= grooveRect.height()) && (sliderRect.height() > visibleRect.height()+2)) {
622 QRect pixmapRect(QPoint(s_pixelMargin, 0), QSize(m_pixmap.width() - s_pixelMargin, m_pixmap.height()));
623 QRect docPixmapRect(QPoint(s_pixelMargin, docRect.top()), QSize(docRect.width()-s_pixelMargin, docRect.height()));
674 QRect rect = style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SC_ScrollBarSlider, this);
728 QToolTip::showText(m_toolTipPos, i18nc("from line - to line", "<center>%1<br/>—<br/>%2</center>", fromLine, lastLine), this);
749 QRect grooveRect = style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SC_ScrollBarGroove, this);
768 for (QHash<int, KTextEditor::Mark*>::const_iterator i = marks.constBegin(); i != marks.constEnd(); ++i)
774 KateRendererConfig::global()->lineMarkerColor((KTextEditor::MarkInterface::MarkTypes)mark->type));
837 // inserts the given string in the command line edit and (if selected = true) selects it so the user
871 // make sure the timer is stopped when the user switches views. if not, focus will be given to the
886 QString beg = "<qt background=\"white\"><div><table width=\"100%\"><tr><td bgcolor=\"brown\"><font color=\"white\"><b>Help: <big>";
977 // Parse any leading range expression, and strip it (and maybe do some other transforms on the command).
979 KTextEditor::Range range = CommandRangeExpressionParser::parseRangeExpression(cmd, m_view, leadingRangeExpression, cmd);
1000 // the following commands changes the focus themselves, so bar should be hidden before execution.
1001 if (QRegExp("buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e").exactMatch(cmd.split(" ").at(0))) {
1007 if ( ( !ce && range.isValid() && p ) || ( range.isValid() && ce && !ce->supportsRange(cmd) ) ) {
1065 if (!QRegExp("buffer|b|new|vnew|bp|bprev|bn|bnext|bf|bfirst|bl|blast|edit|e").exactMatch(cmd.split(" ").at(0))) {
1131 //kDebug(13025)<<"keypress in commandline: We have a command! "<<m_command<<". text is '"<<text()<<"'";
1425 if (m_cachedLNWidth != width || m_oldBackgroundColor != m_view->renderer()->config()->iconBarColor()) {
1430 if ((m_arrow.size() != newSize || m_oldBackgroundColor != m_view->renderer()->config()->iconBarColor()) && !newSize.isEmpty()) {
1464 static void paintTriangle (QPainter &painter, QColor c, int xOffset, int yOffset, int width, int height, bool open)
1492 QPointF points[3] = { middle+QPointF(-halfSize, -halfSizeP), middle+QPointF(halfSize, -halfSizeP), middle+QPointF(0, halfSizeP) };
1497 QPointF points[3] = { middle+QPointF(-halfSizeP, -halfSize), middle+QPointF(-halfSizeP, halfSize), middle+QPointF(halfSizeP, 0) };
1517 if ( m_lineNumbersOn || (m_view->dynWordWrap() && m_dynWrapIndicatorsOn) ) // avoid calculating unless needed ;-)
1520 if ( lnWidth != m_cachedLNWidth || m_oldBackgroundColor != m_view->renderer()->config()->iconBarColor() )
1627 // Draw a border around all adjacent entries that have the same text as the currently hovered one
1647 && m_viewInternal->cache()->viewLine(z).viewLine() == m_viewInternal->cache()->viewLineCount(realLine)-1)
1660 if( text.isValid() && text.canConvert<QString>() && (m_viewInternal->cache()->viewLine(z).startCol() == 0) )
1718 m_viewInternal->cache()->viewLine(z).viewLine() == m_viewInternal->cache()->viewLineCount(realLine)-1)
1729 QVector<QPair<qint64, Kate::TextFolding::FoldingRangeFlags> > startingRanges = m_view->textFolding().foldingRangesStartingOnLine (realLine);
1741 paintTriangle (p, m_view->renderer()->config()->foldingColor(), lnX, y, iconPaneWidth, h, false);
1745 paintTriangle (p, m_view->renderer()->config()->foldingColor(), lnX, y, iconPaneWidth, h, true);
1811 if ( positionToArea( e->pos() ) != IconBorder && positionToArea( e->pos() ) != AnnotationBorder )
1989 QVector<QPair<qint64, Kate::TextFolding::FoldingRangeFlags> > startingRanges = m_view->textFolding().foldingRangesStartingOnLine (cursorOnLine);
1998 actionDone = (anyFolded ? m_view->textFolding().unfoldRange (startingRanges[i].first) : m_view->textFolding().foldRange (startingRanges[i].first)) || actionDone;
2003 KTextEditor::Range foldingRange = m_view->doc()->buffer().computeFoldingRangeForStartLine (cursorOnLine);
2191 void KateIconBorder::annotationModelChanged( KTextEditor::AnnotationModel * oldmodel, KTextEditor::AnnotationModel * newmodel )
2272 KateViewEncodingAction::KateViewEncodingAction(KateDocument *_doc, KateView *_view, const QString& text, QObject *parent)
2358 if (codec==KGlobal::charsets()->codecForName(actions().at(i)->menu()->actions().at(j)->text()))
2424 KateViewBar::KateViewBar (bool external,KTextEditor::ViewBarContainer::Position pos,QWidget *parent, KateView *view)
2548 KTextEditor::ViewBarContainer *viewBarContainer=qobject_cast<KTextEditor::ViewBarContainer*>( KateGlobal::self()->container() );
void annotationActivated(KTextEditor::View *view, int line)
Definition: kateviewhelpers.h:178
QTextCodec * codecForName(const QString &name) const
uint type
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
QColor darken(const QColor &, qreal amount=0.5, qreal chromaGain=1.0)
virtual bool exec(KTextEditor::View *view, const QString &cmd, QString &msg)=0
void addBarWidget(KateViewBarWidget *newBarWidget)
Adds a widget to this viewbar.
Definition: kateviewhelpers.cpp:2437
void hideRequested()
virtual KTextEditor::MovingRange * newMovingRange(const KTextEditor::Range &range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors=KTextEditor::MovingRange::DoNotExpand, KTextEditor::MovingRange::EmptyBehavior emptyBehavior=KTextEditor::MovingRange::AllowEmpty)
Create a new moving range for this document.
Definition: katedocument.cpp:4742
KateViewEncodingAction(KateDocument *_doc, KateView *_view, const QString &text, QObject *parent)
Definition: kateviewhelpers.cpp:2272
virtual bool help(KTextEditor::View *view, const QString &cmd, QString &msg)=0
void ensureHighlighted(int line, int lookAhead=64)
Update highlighting of given line line, if needed.
Definition: katebuffer.cpp:284
virtual void mouseDoubleClickEvent(QMouseEvent *)
Definition: kateviewinternal.cpp:2586
bool exactMatch(const QString &candidate, const QString &wildcard, int candidatePosFromRight, int wildcardPosFromRight, bool caseSensitive=true)
Definition: katewildcardmatcher.cpp:29
virtual bool isValid() const
bool lessThanAction(KSelectAction *a, KSelectAction *b)
Definition: kateviewhelpers.cpp:2229
void setAnnotationBorderOn(bool enable)
Definition: kateviewhelpers.cpp:1301
void slotReturnPressed(const QString &cmd)
Parse the text as a command.
Definition: kateviewhelpers.cpp:964
KTextEditor::Range computeFoldingRangeForStartLine(int startLine)
For a given line, compute the folding range that starts there to be used to fold e.g.
Definition: katebuffer.cpp:522
QScriptValue i18nc(QScriptContext *context, QScriptEngine *engine)
i18nc("context", "text", arguments [optional])
Definition: katescripthelpers.cpp:210
static bool singleClick()
bool handleMarkClick(int line)
Returns true if the click on the mark should not be further processed.
Definition: katedocument.cpp:1762
int timeout
void setText(const QString &text, bool selected=true)
Definition: kateviewhelpers.cpp:839
virtual void setCompletionObject(KCompletion *, bool hsig=true)
Definition: kateviewhelpers.h:178
KateViewBar(bool external, KTextEditor::ViewBarContainer::Position pos, QWidget *parent, KateView *view)
Definition: kateviewhelpers.cpp:2424
int visibleLineToLine(int visibleLine) const
Convert a visible line number to a line number in the text buffer.
Definition: katetextfolding.cpp:422
KTextEditor::Attribute::Ptr attribute(uint pos) const
This takes an in index, and returns all the attributes for it.
Definition: katerenderer.cpp:79
virtual void processText(KTextEditor::View *view, const QString &text)=0
void removePermanentBarWidget(KateViewBarWidget *barWidget)
Removes permanent bar widget from viewbar.
Definition: kateviewhelpers.cpp:2477
virtual void mouseReleaseEvent(QMouseEvent *)
Definition: kateviewinternal.cpp:2681
const char * name(StandardAction id)
virtual KTextEditor::Attribute::Ptr defaultStyle(const KTextEditor::HighlightInterface::DefaultStyle ds) const
Definition: katedocument.cpp:5354
virtual KTextEditor::AnnotationModel * annotationModel() const
Definition: katedocument.cpp:4800
KatePasteMenu(const QString &text, KateView *view)
Definition: kateviewhelpers.cpp:2580
int mibForName(const QString &codecName, bool *ok=0) const
Definition: kateviewhelpers.cpp:2298
KateCmdLineEdit(KateCommandLineBar *bar, KateView *view)
Definition: kateviewhelpers.cpp:852
void userSetEncodingForNextReload()
User did set encoding for next reload => enforce it!
Definition: katedocument.h:960
int line
KTextEditor::AnnotationModel * annotationModel() const
Definition: kateview.cpp:3006
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
Kate::TextLine plainKateTextLine(uint i)
Definition: katedocument.cpp:4713
KUrl url
static void invokeHelp(const QString &anchor=QString(), const QString &appname=QString(), const QByteArray &startup_id=QByteArray())
KateViInputModeManager * getViInputModeManager()
Definition: kateview.cpp:1567
virtual void clear()
virtual void keyPressEvent(QKeyEvent *)
KSharedConfigPtr config()
static KTextEditor::Range parseRangeExpression(const QString &command, KateView *view, QString &destRangeExpression, QString &destTransformedCommand)
Attempt to parse any leading range expression (e.g.
Definition: katevicommandrangeexpressionparser.cpp:68
bool unfoldRange(qint64 id, bool remove=false)
Unfold the given range.
Definition: katetextfolding.cpp:191
const QColor & lineNumberColor() const
Definition: kateconfig.cpp:2433
virtual void styleChange(QStyle &oldStyle)
Definition: kateviewhelpers.cpp:704
KateTextLayout yToKateTextLayout(int y) const
Definition: kateviewinternal.cpp:306
KateViewBarWidget(bool addCloseButton, QWidget *parent=0)
Definition: kateviewhelpers.cpp:2396
virtual const KTextEditor::Range & selectionRange() const
Definition: kateview.cpp:2760
const QColor & modifiedLineColor() const
Definition: kateconfig.cpp:2496
qreal luma(const QColor &)
Definition: kateviewhelpers.h:288
virtual void resizeEvent(QResizeEvent *)
Definition: kateviewhelpers.cpp:696
virtual void keyPressEvent(QKeyEvent *event)
Definition: kateviewhelpers.cpp:2561
void updateAnnotationLine(int line)
Definition: kateviewhelpers.cpp:2143
void setIconBorderOn(bool enable)
Definition: kateviewhelpers.cpp:1289
void setFoldingMarkersOn(bool enable)
Definition: kateviewhelpers.cpp:1352
bool overlapsLine(int line) const
QVector< QPair< qint64, FoldingRangeFlags > > foldingRangesStartingOnLine(int line) const
Queries which folding ranges start at the given line and returns the id + flags for all of them...
Definition: katetextfolding.cpp:476
void removeBarWidget(KateViewBarWidget *barWidget)
Removes a widget from this viewbar.
Definition: kateviewhelpers.cpp:2452
static void paintTriangle(QPainter &painter, QColor c, int xOffset, int yOffset, int width, int height, bool open)
Definition: kateviewhelpers.cpp:1464
virtual void mousePressEvent(QMouseEvent *)
Definition: kateviewinternal.cpp:2462
virtual bool exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range)=0
int viewLine() const
Return the index of this visual line inside the document line (KateLineLayout).
Definition: katetextlayout.cpp:109
virtual void hideViewBarForView(View *view, enum Position position)=0
virtual void sliderChange(SliderChange change)
Definition: kateviewhelpers.cpp:711
void setDynWrapIndicators(int state)
Definition: kateviewhelpers.cpp:1339
virtual void mouseMoveEvent(QMouseEvent *)
Definition: kateviewinternal.cpp:2752
virtual bool supportsRange(const QString &cmd)=0
virtual QVariant data(int line, Qt::ItemDataRole role) const =0
Definition: kateviewinternal.h:57
static Range invalid()
virtual KCompletion * completionObject(KTextEditor::View *view, const QString &cmdname)=0
void hideMe()
static void beep(const QString &reason=QString(), QWidget *widget=0L)
KCharsets * charsets()
virtual void mousePressEvent(QMouseEvent *e)
Definition: kateviewhelpers.cpp:188
QString encodingForName(const QString &descriptiveName) const
KateScrollBar(Qt::Orientation orientation, class KateViewInternal *parent)
Definition: kateviewhelpers.cpp:107
bool hasBarWidget(KateViewBarWidget *barWidget) const
Definition: kateviewhelpers.cpp:2522
bool setCurrentCodec(QTextCodec *codec)
Definition: kateviewhelpers.cpp:2342
virtual void showViewBarForView(View *view, enum Position position)=0
QColor shade(const QColor &, qreal lumaAmount, qreal chromaAmount=0.0)
virtual QPixmap markPixmap(MarkInterface::MarkTypes) const
Definition: katedocument.cpp:1816
KMenu * menu()
KateTextLayout & viewLine(int viewLine)
Returns the layout of the corresponding line in the view.
Definition: katelayoutcache.cpp:358
bool handleMarkContextMenu(int line, QPoint position)
Returns true if the context-menu event should not further be processed.
Definition: katedocument.cpp:1774
void annotationModelChanged(KTextEditor::AnnotationModel *oldmodel, KTextEditor::AnnotationModel *newmodel)
Definition: kateviewhelpers.cpp:2191
Definition: kateview.h:78
void setLineNumbersOn(bool enable)
Definition: kateviewhelpers.cpp:1326
void annotationContextMenuAboutToShow(KTextEditor::View *view, QMenu *menu, int line)
int lineToVisibleLine(int line) const
Convert a text buffer line to a visible line number.
Definition: katetextfolding.cpp:366
QString currentCodecName() const
Definition: kateviewhelpers.cpp:2373
void addPermanentBarWidget(KateViewBarWidget *barWidget)
Adds widget that will be always shown in the viewbar.
Definition: kateviewhelpers.cpp:2462
Definition: katedocument.h:74
void requestMarkTooltip(int line, QPoint position)
Definition: katedocument.cpp:1752
KAction * forward(const QObject *recvr, const char *slot, QObject *parent)
virtual void mouseMoveEvent(QMouseEvent *e)
Definition: kateviewhelpers.cpp:237
bool overlapsLine(int line) const
Definition: kateviewhelpers.h:408
KGuiItem ok()
QTextCodec * codecForMib(int mib) const
Definition: kateviewhelpers.cpp:2326
void triggered(QTextCodec *codec)
Specific (proper) codec was selected.
KateCommandLineBar(KateView *view, QWidget *parent=0)
Definition: kateviewhelpers.cpp:810
virtual void focusInEvent(QFocusEvent *ev)
void updateAnnotationBorderWidth()
Definition: kateviewhelpers.cpp:2170
int currentCodecMib() const
Definition: kateviewhelpers.cpp:2383
KTextEditor::Command * queryCommand(const QString &cmd) const
Definition: katecmd.cpp:78
const QColor & separatorColor() const
Definition: kateconfig.cpp:2454
virtual QString makeCompletion(const QString &string)
virtual const MovingCursor & start() const =0
This class represents one visible line of text; with dynamic wrapping, many KateTextLayouts can be ne...
Definition: katetextlayout.h:38
virtual int line() const =0
virtual bool setEncoding(const QString &e)
Definition: katedocument.cpp:3953
BorderArea positionToArea(const QPoint &) const
Definition: kateviewhelpers.cpp:1771
~KateViewEncodingAction()
Definition: kateviewhelpers.cpp:2281
void showBarWidget(KateViewBarWidget *barWidget)
Shows barWidget that was previously added with addBarWidget.
Definition: kateviewhelpers.cpp:2501
void setAnnotationBorderVisible(bool visible)
Definition: kateview.cpp:3011
QTextCodec * currentCodec() const
Definition: kateviewhelpers.cpp:2337
virtual void removeMark(int line, uint markType)
Definition: katedocument.cpp:1714
KGuiItem stop()
Definition: kateviewhelpers.h:426
virtual bool wantsToProcessText(const QString &cmdname)=0
const QColor & savedLineColor() const
Definition: kateconfig.cpp:2517
QSharedPointer< TextLineData > TextLine
The normal world only accesses the text lines with shared pointers.
Definition: katetextline.h:443
virtual void mouseReleaseEvent(QMouseEvent *e)
Definition: kateviewhelpers.cpp:213
virtual bool event(QEvent *)
const QColor & backgroundColor() const
Definition: kateconfig.cpp:2178
KAction * selectAll(const QObject *recvr, const char *slot, QObject *parent)
virtual void setMarkDescription(MarkInterface::MarkTypes, const QString &)
Definition: katedocument.cpp:1811
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
virtual const QHash< int, KTextEditor::Mark * > & marks()
Definition: katedocument.cpp:1747
qint64 newFoldingRange(const KTextEditor::Range &range, FoldingRangeFlags flags=FoldingRangeFlags())
Create a new folding range.
Definition: katetextfolding.cpp:99
bool contains(const Range &range) const
virtual const MovingCursor & end() const =0
void annotationBorderVisibilityChanged(View *view, bool visible)
KateIconBorder(KateViewInternal *internalView, QWidget *parent)
Definition: kateviewhelpers.cpp:1251
Definition: kateconfig.h:381
const QFontMetricsF & fontMetrics() const
Definition: kateconfig.cpp:2135
KGuiItem reset()
QList< QTextLayout::FormatRange > decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly=false, KateRenderRange *completionHighlight=0L, bool completionSelected=false) const
The ultimate decoration creation function.
Definition: katerenderer.cpp:340
Definition: kateviewhelpers.h:244
void returnPressed(const QString &)
int viewCacheLineCount() const
Definition: katelayoutcache.cpp:364
virtual void setText(const QString &)
const KShortcut & end()
void sliderMMBMoved(int value)
bool hasPermanentWidget(KateViewBarWidget *barWidget) const
Definition: kateviewhelpers.cpp:2496
virtual void setMarkPixmap(MarkInterface::MarkTypes, const QPixmap &)
Definition: katedocument.cpp:1806
Definition: kateviewhelpers.h:178
virtual QString markDescription(MarkInterface::MarkTypes) const
Definition: katedocument.cpp:1831
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.