1 /* This file is part of the KDE libraries
2 Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
3 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
4 Copyright (C) 2001-2010 Joseph Wenninger <jowenn@kde.org>
5 Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef kate_view_h
23#define kate_view_h
24
25#include <ktexteditor/view.h>
26#include <ktexteditor/texthintinterface.h>
27#include <ktexteditor/markinterface.h>
28#include <ktexteditor/codecompletioninterface.h>
29#include <ktexteditor/sessionconfiginterface.h>
30#include <ktexteditor/templateinterface.h>
31#include <ktexteditor/templateinterface2.h>
32#include <ktexteditor/configinterface.h>
33#include <ktexteditor/annotationinterface.h>
34
35#include <QtCore/QPointer>
36#include <QModelIndex>
37#include <QtGui/QMenu>
38
39#include <kdebug.h>
40
41#include "kateviinputmodemanager.h"
42#include "katetextrange.h"
43#include "katetextfolding.h"
44#include "katerenderer.h"
45
46namespace KTextEditor
47{
48 class AnnotationModel;
49 class Message;
50}
51
52class KateDocument;
53class KateBookmarks;
54class KateCommandLineBar;
55class KateViewConfig;
56class KateRenderer;
57class KateSpellCheckDialog;
58class KateCompletionWidget;
59class KateViewInternal;
60class KateSearchBar;
61class KateViEmulatedCommandBar;
62class KateViewBar;
63class KateGotoBar;
64class KateDictionaryBar;
65class KateSpellingMenu;
66class KateMessageWidget;
67
68class KToggleAction;
69class KAction;
70class KSelectAction;
71
72class QVBoxLayout;
73
74//
75// Kate KTextEditor::View class ;)
76//
77class KATEPART_TESTS_EXPORT KateView : public KTextEditor::View,
78 public KTextEditor::TextHintInterface,
79 public KTextEditor::SessionConfigInterface,
80 public KTextEditor::TemplateInterface2,
81 public KTextEditor::CodeCompletionInterface,
82 public KTextEditor::ConfigInterface,
83 public KTextEditor::AnnotationViewInterface,
84 public KTextEditor::CoordinatesToCursorInterface
85{
86 Q_OBJECT
87 Q_INTERFACES(KTextEditor::TextHintInterface)
88 Q_INTERFACES(KTextEditor::SessionConfigInterface)
89 Q_INTERFACES(KTextEditor::TemplateInterface)
90 Q_INTERFACES(KTextEditor::TemplateInterface2)
91 Q_INTERFACES(KTextEditor::ConfigInterface)
92 Q_INTERFACES(KTextEditor::CodeCompletionInterface)
93 Q_INTERFACES(KTextEditor::AnnotationViewInterface)
94 Q_INTERFACES(KTextEditor::CoordinatesToCursorInterface)
95
96 friend class KateViewInternal;
97 friend class KateIconBorder;
98 friend class KateViModeBase;
99
100 public:
101 KateView( KateDocument* doc, QWidget* parent );
102 ~KateView ();
103
104 KTextEditor::Document *document () const;
105
106 QString viewMode () const;
107
108 //
109 // KTextEditor::ClipboardInterface
110 //
111 public Q_SLOTS:
112 void paste(const QString *textToPaste = 0);
113 void cut();
114 void copy() const;
115
116 private Q_SLOTS:
117 /**
118 * internal use, apply word wrap
119 */
120 void applyWordWrap ();
121
122 //
123 // KTextEditor::PopupMenuInterface
124 //
125 public:
126 void setContextMenu( QMenu* menu );
127 QMenu* contextMenu() const;
128 QMenu* defaultContextMenu(QMenu* menu = 0L) const;
129
130 private Q_SLOTS:
131 void aboutToShowContextMenu();
132 void aboutToHideContextMenu();
133
134 private:
135 QPointer<QMenu> m_contextMenu;
136
137 //
138 // KTextEditor::ViewCursorInterface
139 //
140 public:
141 /**
142 * Set the caret's style.
143 * The caret can be a box or a line; see the documentation
144 * of KateRenderer::caretStyles for other options.
145 * @param style the caret style
146 * @param repaint whether to update the caret instantly.
147 * This also resets the caret's timer.
148 */
149 void setCaretStyle( KateRenderer::caretStyles style, bool repaint = false );
150
151 bool setCursorPosition (KTextEditor::Cursor position);
152
153 KTextEditor::Cursor cursorPosition () const;
154
155 KTextEditor::Cursor cursorPositionVirtual () const;
156
157 QPoint cursorToCoordinate(const KTextEditor::Cursor& cursor) const;
158
159 KTextEditor::Cursor coordinatesToCursor(const QPoint& coord) const;
160
161 QPoint cursorPositionCoordinates() const;
162
163 bool setCursorPositionVisual( const KTextEditor::Cursor& position );
164
165 /**
166 * Return the virtual cursor column, each tab is expanded into the
167 * document's tabWidth characters. If word wrap is off, the cursor may be
168 * behind the line's length.
169 */
170 int virtualCursorColumn() const;
171
172 virtual bool mouseTrackingEnabled() const;
173 virtual bool setMouseTrackingEnabled(bool enable);
174
175 private:
176 void notifyMousePositionChanged(const KTextEditor::Cursor& newPosition);
177
178 // Internal
179 public:
180 bool setCursorPositionInternal( const KTextEditor::Cursor& position, uint tabwidth = 1, bool calledExternally = false );
181
182 //
183 // KTextEditor::ConfigInterface
184 //
185 public:
186 QStringList configKeys() const;
187 QVariant configValue(const QString &key);
188 void setConfigValue(const QString &key, const QVariant &value);
189
190 Q_SIGNALS:
191 void configChanged();
192
193 public:
194 /**
195 * Try to fold starting at the given line.
196 * This will both try to fold existing folding ranges of this line and to query the highlighting what to fold.
197 * @param startLine start line to fold at
198 */
199 void foldLine (int startLine);
200
201 /**
202 * Try to unfold all foldings starting at the given line.
203 * @param startLine start line to unfold at
204 */
205 void unfoldLine (int startLine);
206
207 //
208 // KTextEditor::CodeCompletionInterface2
209 //
210 public:
211 virtual bool isCompletionActive() const;
212 virtual void startCompletion(const KTextEditor::Range& word, KTextEditor::CodeCompletionModel* model);
213 virtual void abortCompletion();
214 virtual void forceCompletion();
215 virtual void registerCompletionModel(KTextEditor::CodeCompletionModel* model);
216 virtual void unregisterCompletionModel(KTextEditor::CodeCompletionModel* model);
217 virtual bool isAutomaticInvocationEnabled() const;
218 virtual void setAutomaticInvocationEnabled(bool enabled = true);
219
220 Q_SIGNALS:
221 void completionExecuted(KTextEditor::View* view, const KTextEditor::Cursor& position, KTextEditor::CodeCompletionModel* model, const QModelIndex&);
222 void completionAborted(KTextEditor::View* view);
223
224 public Q_SLOTS:
225 void userInvokedCompletion();
226
227 public:
228 KateCompletionWidget* completionWidget() const;
229 mutable KateCompletionWidget* m_completionWidget;
230 void sendCompletionExecuted(const KTextEditor::Cursor& position, KTextEditor::CodeCompletionModel* model, const QModelIndex& index);
231 void sendCompletionAborted();
232
233 //
234 // KTextEditor::TextHintInterface
235 //
236 public:
237 void enableTextHints(int timeout);
238 void disableTextHints();
239
240 Q_SIGNALS:
241 void needTextHint(const KTextEditor::Cursor& position, QString &text);
242
243 public:
244 bool dynWordWrap() const { return m_hasWrap; }
245
246 //
247 // KTextEditor::SelectionInterface stuff
248 //
249 public Q_SLOTS:
250 virtual bool setSelection ( const KTextEditor::Range &selection );
251
252 // unhide method...
253 bool setSelection (const KTextEditor::Cursor &c, int i, bool b)
254 { return KTextEditor::View::setSelection (c, i, b); }
255
256 virtual bool removeSelection () { return clearSelection(); }
257
258 virtual bool removeSelectionText () { return removeSelectedText(); }
259
260 virtual bool setBlockSelection (bool on);
261 bool toggleBlockSelection ();
262
263 bool clearSelection ();
264 bool clearSelection (bool redraw, bool finishedChangingSelection = true);
265
266 bool removeSelectedText ();
267
268 bool selectAll();
269
270 public:
271 virtual bool selection() const;
272 virtual QString selectionText() const;
273 virtual bool blockSelection() const;
274 virtual const KTextEditor::Range &selectionRange() const;
275
276 static void blockFix(KTextEditor::Range& range);
277
278 private:
279 mutable KTextEditor::Range m_holdSelectionRangeForAPI;
280
281 //
282 // Arbitrary Syntax HL + Action extensions
283 //
284 public:
285 // Action association extension
286 void deactivateEditActions();
287 void activateEditActions();
288
289 //
290 // internal helper stuff, for katerenderer and so on
291 //
292 public:
293 // should cursor be wrapped ? take config + blockselection state in account
294 bool wrapCursor () const;
295
296 // some internal functions to get selection state of a line/col
297 bool cursorSelected(const KTextEditor::Cursor& cursor);
298 bool lineSelected (int line);
299 bool lineEndSelected (const KTextEditor::Cursor& lineEndPos);
300 bool lineHasSelected (int line);
301 bool lineIsSelection (int line);
302
303 void ensureCursorColumnValid();
304
305 void tagSelection (const KTextEditor::Range &oldSelection);
306
307 void selectWord( const KTextEditor::Cursor& cursor );
308 void selectLine( const KTextEditor::Cursor& cursor );
309
310
311 //BEGIN EDIT STUFF
312 public:
313 void editStart ();
314 void editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom);
315
316 void editSetCursor (const KTextEditor::Cursor &cursor);
317 //END
318
319 //BEGIN TAG & CLEAR
320 public:
321 bool tagLine (const KTextEditor::Cursor& virtualCursor);
322
323 bool tagRange (const KTextEditor::Range& range, bool realLines = false);
324 bool tagLines (int start, int end, bool realLines = false );
325 bool tagLines (KTextEditor::Cursor start, KTextEditor::Cursor end, bool realCursors = false);
326 bool tagLines (KTextEditor::Range range, bool realRange = false);
327
328 void tagAll ();
329
330 void clear ();
331
332 void repaintText (bool paintOnlyDirty = false);
333
334 void updateView (bool changed = false);
335 //END
336
337 //
338 // KTextEditor::AnnotationView
339 //
340 public:
341 void setAnnotationModel( KTextEditor::AnnotationModel* model );
342 KTextEditor::AnnotationModel* annotationModel() const;
343 void setAnnotationBorderVisible( bool visible);
344 bool isAnnotationBorderVisible() const;
345
346 Q_SIGNALS:
347 void annotationContextMenuAboutToShow( KTextEditor::View* view, QMenu* menu, int line );
348 void annotationActivated( KTextEditor::View* view, int line );
349 void annotationBorderVisibilityChanged( View* view, bool visible );
350
351 void navigateLeft();
352 void navigateRight();
353 void navigateUp();
354 void navigateDown();
355 void navigateAccept();
356 void navigateBack();
357
358 private:
359 KTextEditor::AnnotationModel* m_annotationModel;
360
361 //
362 // KTextEditor::View
363 //
364 public:
365 void emitNavigateLeft() {
366 emit navigateLeft();
367 }
368 void emitNavigateRight() {
369 emit navigateRight();
370 }
371 void emitNavigateUp() {
372 emit navigateUp();
373 }
374 void emitNavigateDown() {
375 emit navigateDown();
376 }
377 void emitNavigateAccept() {
378 emit navigateAccept();
379 }
380 void emitNavigateBack() {
381 emit navigateBack();
382 }
383 /**
384 Return values for "save" related commands.
385 */
386 bool isOverwriteMode() const;
387 EditMode viewEditMode() const;
388 QString currentTextLine();
389
390 /**
391 * The current search pattern.
392 * This is set by the last search.
393 * @return the search pattern or the empty string if not set
394 */
395 QString searchPattern() const;
396
397 /**
398 * The current replacement string.
399 * This is set by the last search and replace.
400 * @return the replacment string or the empty string if not set
401 */
402 QString replacementPattern() const;
403
404 /**
405 * Set the current search pattern.
406 * @param searchPattern the search pattern
407 */
408 void setSearchPattern(const QString &searchPattern);
409
410 /**
411 * Set the current replacement pattern.
412 * @param replacementPattern the replacement pattern
413 */
414 void setReplacementPattern(const QString &replacementPattern);
415
416 public Q_SLOTS:
417 void indent();
418 void unIndent();
419 void cleanIndent();
420 void align();
421 void comment();
422 void uncomment();
423 void toggleComment();
424 void killLine();
425 void createSnippet ();
426 void showSnippetsDialog ();
427
428 /**
429 Uppercases selected text, or an alphabetic character next to the cursor.
430 */
431 void uppercase();
432 /**
433 Lowercases selected text, or an alphabetic character next to the cursor.
434 */
435 void lowercase();
436 /**
437 Capitalizes the selection (makes each word start with an uppercase) or
438 the word under the cursor.
439 */
440 void capitalize();
441 /**
442 Joins lines touched by the selection
443 */
444 void joinLines();
445
446 // Note - the following functions simply forward to KateViewInternal
447 void keyReturn();
448 void smartNewline();
449 void backspace();
450 void deleteWordLeft();
451 void keyDelete();
452 void deleteWordRight();
453 void transpose();
454 void cursorLeft();
455 void shiftCursorLeft();
456 void cursorRight();
457 void shiftCursorRight();
458 void wordLeft();
459 void shiftWordLeft();
460 void wordRight();
461 void shiftWordRight();
462 void home();
463 void shiftHome();
464 void end();
465 void shiftEnd();
466 void up();
467 void shiftUp();
468 void down();
469 void shiftDown();
470 void scrollUp();
471 void scrollDown();
472 void topOfView();
473 void shiftTopOfView();
474 void bottomOfView();
475 void shiftBottomOfView();
476 void pageUp();
477 void shiftPageUp();
478 void pageDown();
479 void shiftPageDown();
480 void top();
481 void shiftTop();
482 void bottom();
483 void shiftBottom();
484 void toMatchingBracket();
485 void shiftToMatchingBracket();
486 void toPrevModifiedLine();
487 void toNextModifiedLine();
488 void insertTab();
489
490 void gotoLine();
491
492 // config file / session management functions
493 public:
494 void readSessionConfig(const KConfigGroup&);
495 void writeSessionConfig(KConfigGroup&);
496
497 public Q_SLOTS:
498 void setEol( int eol );
499 void setAddBom( bool enabled);
500 void find();
501 void findSelectedForwards();
502 void findSelectedBackwards();
503 void replace();
504 void findNext();
505 void findPrevious();
506
507 void setFoldingMarkersOn( bool enable ); // Not in KTextEditor::View, but should be
508 void setIconBorder( bool enable );
509 void setLineNumbersOn( bool enable );
510 void setScrollBarMarks( bool enable );
511 void setScrollBarMiniMap( bool enable );
512 void setScrollBarMiniMapAll( bool enable );
513 void setScrollBarMiniMapWidth( int width );
514 void toggleFoldingMarkers();
515 void toggleIconBorder();
516 void toggleLineNumbersOn();
517 void toggleScrollBarMarks();
518 void toggleScrollBarMiniMap();
519 void toggleScrollBarMiniMapAll();
520 void toggleDynWordWrap ();
521 void toggleViInputMode ();
522
523
524 void showViModeEmulatedCommandBar();
525
526 void setDynWrapIndicators(int mode);
527
528 public:
529 int getEol() const;
530
531 public:
532 KateRenderer *renderer ();
533
534 bool iconBorder();
535 bool lineNumbersOn();
536 bool scrollBarMarks();
537 bool scrollBarMiniMap();
538 bool scrollBarMiniMapAll();
539 int dynWrapIndicators();
540 bool foldingMarkersOn();
541
542 private Q_SLOTS:
543 /**
544 * used to update actions after selection changed
545 */
546 void slotSelectionChanged ();
547
548 public:
549 /**
550 * accessor to katedocument pointer
551 * @return pointer to document
552 */
553 KateDocument* doc() { return m_doc; }
554 const KateDocument* doc() const { return m_doc; }
555
556 public Q_SLOTS:
557 void slotUpdateUndo();
558 void toggleInsert();
559 void reloadFile();
560 void toggleWWMarker();
561 void toggleWriteLock();
562 void switchToCmdLine ();
563 void slotReadWriteChanged ();
564 void slotClipboardHistoryChanged ();
565
566 Q_SIGNALS:
567 void dropEventPass(QDropEvent*);
568
569 public:
570 /**
571 * Folding handler for this view.
572 * @return folding handler
573 */
574 Kate::TextFolding &textFolding ()
575 {
576 return m_textFolding;
577 }
578
579 public:
580 void slotTextInserted ( KTextEditor::View *view, const KTextEditor::Cursor &position, const QString &text);
581
582 protected:
583 void contextMenuEvent( QContextMenuEvent* );
584
585 private Q_SLOTS:
586 void slotGotFocus();
587 void slotLostFocus();
588 void slotDropEventPass( QDropEvent* ev );
589 void slotSaveCanceled( const QString& error );
590 void slotConfigDialog ();
591
592 public Q_SLOTS: // TODO: turn into good interface, see kte5/foldinginterface.h
593 void slotFoldToplevelNodes();
594 void slotCollapseLocal();
595 void slotCollapseLevel();
596 void slotExpandLevel();
597 void slotExpandLocal();
598
599 private:
600 void setupConnections();
601 void setupActions();
602 void setupEditActions();
603 void setupCodeFolding();
604
605 QList<QAction*> m_editActions;
606 KAction* m_editUndo;
607 KAction* m_editRedo;
608 KAction* m_pasteMenu;
609 KToggleAction* m_toggleFoldingMarkers;
610 KToggleAction* m_toggleIconBar;
611 KToggleAction* m_toggleLineNumbers;
612 KToggleAction* m_toggleScrollBarMarks;
613 KToggleAction* m_toggleScrollBarMiniMap;
614 KToggleAction* m_toggleScrollBarMiniMapAll;
615 KToggleAction* m_toggleDynWrap;
616 KSelectAction* m_setDynWrapIndicators;
617 KToggleAction* m_toggleWWMarker;
618 KAction* m_switchCmdLine;
619 KToggleAction* m_viInputModeAction;
620
621 KSelectAction* m_setEndOfLine;
622 KToggleAction* m_addBom;
623
624 QAction *m_cut;
625 QAction *m_copy;
626 QAction *m_paste;
627 QAction *m_selectAll;
628 QAction *m_deSelect;
629
630 KToggleAction *m_toggleBlockSelection;
631 KToggleAction *m_toggleInsert;
632 KToggleAction *m_toggleWriteLock;
633
634 bool m_hasWrap;
635
636 KateDocument *const m_doc;
637 Kate::TextFolding m_textFolding;
638 KateViewConfig *const m_config;
639 KateRenderer *const m_renderer;
640 KateViewInternal *const m_viewInternal;
641 KateSpellCheckDialog *m_spell;
642 KateBookmarks *const m_bookmarks;
643
644 QVBoxLayout *m_vBox;
645
646 private Q_SLOTS:
647 void slotHlChanged();
648
649 /**
650 * Configuration
651 */
652 public:
653 inline KateViewConfig *config () { return m_config; }
654
655 void updateConfig ();
656
657 void updateDocumentConfig();
658
659 void updateRendererConfig();
660
661 private Q_SLOTS:
662 void updateFoldingConfig ();
663
664 private:
665 bool m_startingUp;
666 bool m_updatingDocumentConfig;
667
668 // stores the current selection
669 Kate::TextRange m_selection;
670
671 // do we select normal or blockwise ?
672 bool blockSelect;
673
674 //
675 // TemplateInterface + TemplateInterface2
676 //
677 public:
678 virtual bool insertTemplateTextImplementation ( const KTextEditor::Cursor&, const QString &templateString, const QMap<QString,QString> &initialValues);
679 virtual bool insertTemplateTextImplementation ( const KTextEditor::Cursor&, const QString &templateString, const QMap<QString,QString> &initialValues, KTextEditor::TemplateScript* templateScript);
680 /**
681 * Accessors to the bars...
682 */
683 public:
684 KateViewBar *topViewBar() const;
685 KateViewBar *bottomViewBar() const;
686 KateCommandLineBar *cmdLineBar ();
687 KateDictionaryBar *dictionaryBar();
688 KateViEmulatedCommandBar *viModeEmulatedCommandBar();
689
690 private:
691 KateSearchBar *searchBar (bool initHintAsPower = false);
692 bool hasSearchBar () const { return m_searchBar != 0; }
693 KateGotoBar *gotoBar ();
694
695 /**
696 * viewbar + its widgets
697 * they are created on demand...
698 */
699 private:
700 // created in constructor of the view
701 KateViewBar *m_bottomViewBar;
702 KateViewBar *m_topViewBar;
703 // created on demand..., only access them through the above accessors....
704 KateCommandLineBar *m_cmdLine;
705 KateSearchBar *m_searchBar;
706 KateViEmulatedCommandBar *m_viModeEmulatedCommandBar;
707 KateGotoBar *m_gotoBar;
708 KateDictionaryBar *m_dictionaryBar;
709
710 // vi Mode
711 public:
712 /**
713 * @return boolean indicating whether vi mode is active or not
714 */
715 bool viInputMode() const;
716
717 /**
718 * @return the current vi mode
719 */
720 ViMode getCurrentViMode() const;
721
722 /**
723 * @return a pointer to the KateViInputModeManager belonging to the view
724 */
725 KateViInputModeManager* getViInputModeManager();
726
727 /**
728 * Replace ViInputModeManager by new one.
729 * @return a pointer to the new KateViInputModeManager.
730 */
731 KateViInputModeManager* resetViInputModeManager();
732
733 /**
734 * @return boolean indicating whether vi mode will override actions or not
735 */
736 bool viInputModeStealKeys() const;
737
738 /**
739 * @return boolean indicating whether relative line numbers should
740 * be used or not.
741 */
742 bool viRelativeLineNumbers() const;
743
744 /**
745 * Update vi mode statusbar according to the current mode
746 */
747 void updateViModeBarMode();
748
749 /**
750 * Update vi mode statusbar with the (partial) vi command being typed
751 */
752 void updateViModeBarCmd();
753
754 public:
755 KTextEditor::Range visibleRange();
756
757 Q_SIGNALS:
758 void displayRangeChanged(KateView *view);
759
760 protected:
761 KToggleAction* m_toggleOnTheFlySpellCheck;
762 KateSpellingMenu *m_spellingMenu;
763
764 protected Q_SLOTS:
765 void toggleOnTheFlySpellCheck(bool b);
766
767 public Q_SLOTS:
768 void changeDictionary();
769 void reflectOnTheFlySpellCheckStatus(bool enabled);
770
771 public:
772 KateSpellingMenu* spellingMenu();
773 private:
774 bool m_userContextMenuSet;
775
776 private Q_SLOTS:
777 /**
778 * save folding state before document reload
779 */
780 void saveFoldingState ();
781
782 /**
783 * restore folding state after document reload
784 */
785 void applyFoldingState ();
786
787 private:
788 /**
789 * saved folding state
790 */
791 QVariantList m_savedFoldingState;
792
793public:
794 /**
795 * Attribute of a range changed or range with attribute changed in given line range.
796 * @param startLine start line of change
797 * @param endLine end line of change
798 * @param rangeWithAttribute attribute changed or is active, this will perhaps lead to repaints
799 */
800 void notifyAboutRangeChange (int startLine, int endLine, bool rangeWithAttribute);
801
802 private Q_SLOTS:
803 /**
804 * Delayed update for view after text ranges changed
805 */
806 void slotDelayedUpdateOfView ();
807
808 Q_SIGNALS:
809 /**
810 * Delayed update for view after text ranges changed
811 */
812 void delayedUpdateOfView ();
813
814 public:
815 /**
816 * set of ranges which had the mouse inside last time, used for rendering
817 * @return set of ranges which had the mouse inside last time checked
818 */
819 const QSet<Kate::TextRange *> *rangesMouseIn () const { return &m_rangesMouseIn; }
820
821 /**
822 * set of ranges which had the caret inside last time, used for rendering
823 * @return set of ranges which had the caret inside last time checked
824 */
825 const QSet<Kate::TextRange *> *rangesCaretIn () const { return &m_rangesCaretIn; }
826
827 /**
828 * check if ranges changed for mouse in and caret in
829 * @param activationType type of activation to check
830 */
831 void updateRangesIn (KTextEditor::Attribute::ActivationType activationType);
832
833 //
834 // helpers for delayed view update after ranges changes
835 //
836 private:
837 /**
838 * update already inited?
839 */
840 bool m_delayedUpdateTriggered;
841
842 /**
843 * minimal line to update
844 */
845 int m_lineToUpdateMin;
846
847 /**
848 * maximal line to update
849 */
850 int m_lineToUpdateMax;
851
852 /**
853 * set of ranges which had the mouse inside last time
854 */
855 QSet<Kate::TextRange *> m_rangesMouseIn;
856
857 /**
858 * set of ranges which had the caret inside last time
859 */
860 QSet<Kate::TextRange *> m_rangesCaretIn;
861
862 //
863 // forward impl for KTextEditor::MessageInterface
864 //
865 public:
866 /**
867 * Used by Document::postMessage().
868 */
869 void postMessage(KTextEditor::Message* message, QList<QSharedPointer<QAction> > actions);
870
871 private:
872 /** Message widget showing KTextEditor::Messages above the View. */
873 KateMessageWidget* m_topMessageWidget;
874 /** Message widget showing KTextEditor::Messages below the View. */
875 KateMessageWidget* m_bottomMessageWidget;
876 /** Message widget showing KTextEditor::Messages as view overlay in top right corner. */
877 KateMessageWidget* m_floatTopMessageWidget;
878 /** Message widget showing KTextEditor::Messages as view overlay in bottom left corner. */
879 KateMessageWidget* m_floatBottomMessageWidget;
880 /** Layout for floating notifications */
881 QVBoxLayout* m_notificationLayout;
882
883 // for unit test 'tests/messagetest.cpp'
884 public:
885 KateMessageWidget* messageWidget() { return m_floatTopMessageWidget; }
886};
887
888/**
889 * metatype register
890 */
891Q_DECLARE_METATYPE(KTextEditor::Cursor)
892Q_DECLARE_METATYPE(KTextEditor::Range)
893
894#endif
895
896// kate: space-indent on; indent-width 2; replace-tabs on;
897